Skip to content

Commit

Permalink
Add the ALTERED_LIBRARY_SEARCH_PATH constant to winKernel and use it …
Browse files Browse the repository at this point in the history
…in NVDAHelper and nvda_slave when loading NvDAHelperRemote.
  • Loading branch information
michaelDCurran committed Sep 25, 2020
1 parent 90c8fce commit 7e76868
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions source/NVDAHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,14 @@ def initialize():
if config.isAppX:
log.info("Remote injection disabled due to running as a Windows Store Application")
return
#Load nvdaHelperRemote.dll but with an altered search path so it can pick up other dlls in lib
# Load nvdaHelperRemote.dll
h = windll.kernel32.LoadLibraryExW(
os.path.join(versionedLibPath, "nvdaHelperRemote.dll"),
0,
0x8
# Using an altered search path is necessary here
# As NVDAHelperRemote needs to locate dependent dlls in the same directory
# such as minhook.dll.
winKernel.LOAD_WITH_ALTERED_SEARCH_PATH
)
if not h:
log.critical("Error loading nvdaHelperRemote.dll: %s" % WinError())
Expand Down
6 changes: 5 additions & 1 deletion source/nvda_slave.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Performs miscellaneous tasks which need to be performed in a separate process.
import sys
import os
import globalVars
import winKernel


# Initialise comtypes.client.gen_dir and the comtypes.gen search path
Expand Down Expand Up @@ -95,7 +96,10 @@ def main():
h = ctypes.windll.kernel32.LoadLibraryExW(
os.path.join(globalVars.appDir, "lib", versionInfo.version, "nvdaHelperRemote.dll"),
0,
0x8
# Using an altered search path is necessary here
# As NVDAHelperRemote needs to locate dependent dlls in the same directory
# such as minhook.dll.
winKernel.LOAD_WITH_ALTERED_SEARCH_PATH
)
remoteLib=ctypes.WinDLL("nvdaHelperRemote",handle=h)
ret = remoteLib.nvdaControllerInternal_installAddonPackageFromPath(addonPath)
Expand Down
3 changes: 3 additions & 0 deletions source/winKernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
WAIT_FAILED = 0xffffffff
# Image file machine constants
IMAGE_FILE_MACHINE_UNKNOWN = 0
# LoadLibraryEx constants
LOAD_WITH_ALTERED_SEARCH_PATH = 0x8


def GetStdHandle(handleID):
h=kernel32.GetStdHandle(handleID)
Expand Down

0 comments on commit 7e76868

Please sign in to comment.