From 32db14b3290fcfcc06cd0f6c46c148e284066842 Mon Sep 17 00:00:00 2001 From: Katie Durden Date: Tue, 4 Apr 2023 22:22:36 -0700 Subject: [PATCH] add /libraries/windows to the dll search path before loading Tolk. This enables nvdaControllerClient64.dll to be loaded in place. --- stardew-access/ScreenReader/NativeMethods.cs | 8 ++++++++ stardew-access/ScreenReader/ScreenReaderWindows.cs | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 stardew-access/ScreenReader/NativeMethods.cs diff --git a/stardew-access/ScreenReader/NativeMethods.cs b/stardew-access/ScreenReader/NativeMethods.cs new file mode 100644 index 0000000..9e5b26a --- /dev/null +++ b/stardew-access/ScreenReader/NativeMethods.cs @@ -0,0 +1,8 @@ +using System; +using System.Runtime.InteropServices; + +public static class NativeMethods +{ + [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] + public static extern bool SetDllDirectory(string lpPathName); +} diff --git a/stardew-access/ScreenReader/ScreenReaderWindows.cs b/stardew-access/ScreenReader/ScreenReaderWindows.cs index d9b2dbc..ee9ed5e 100644 --- a/stardew-access/ScreenReader/ScreenReaderWindows.cs +++ b/stardew-access/ScreenReader/ScreenReaderWindows.cs @@ -1,4 +1,5 @@ using DavyKager; +using System.IO; namespace stardew_access.ScreenReader { @@ -15,6 +16,13 @@ namespace stardew_access.ScreenReader public void InitializeScreenReader() { + if (MainClass.ModHelper is not null) + { + // Set the path to load Tolk.dll from + string dllDirectory = Path.Combine(MainClass.ModHelper.DirectoryPath, "libraries", "windows");; + // Call SetDllDirectory to change the DLL search path + NativeMethods.SetDllDirectory(dllDirectory); + } MainClass.InfoLog("Initializing Tolk..."); Tolk.TrySAPI(true); Tolk.Load();