diff options
author | Jan <sentrycraft123@gmail.com> | 2023-11-22 02:16:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-22 02:16:22 +0100 |
commit | 90e0376ebcc3373d511adf0989f4b63be717d08a (patch) | |
tree | 75dc0b64e07a2cba5691ddd5cfeefd0bd7bd9773 /NorthstarDLL/core/hooks.cpp | |
parent | aeecd7a69be8de3afdca124ab624677bfd5582cf (diff) | |
download | NorthstarLauncher-90e0376ebcc3373d511adf0989f4b63be717d08a.tar.gz NorthstarLauncher-90e0376ebcc3373d511adf0989f4b63be717d08a.zip |
Improve replacing `xinput1_3` with `xinput9_1` (#583)
The previous logic incorrectly loaded compared the whole argument, which may be a path, to the string literal.
This fix checks if the argument ends with the string literal instead.
Diffstat (limited to 'NorthstarDLL/core/hooks.cpp')
-rw-r--r-- | NorthstarDLL/core/hooks.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/NorthstarDLL/core/hooks.cpp b/NorthstarDLL/core/hooks.cpp index da7f9f3e..26b3fe57 100644 --- a/NorthstarDLL/core/hooks.cpp +++ b/NorthstarDLL/core/hooks.cpp @@ -10,6 +10,8 @@ #include <filesystem> #include <Psapi.h> +#define XINPUT1_3_DLL "XInput1_3.dll" + AUTOHOOK_INIT() // called from the ON_DLL_LOAD macros @@ -393,8 +395,11 @@ HMODULE, WINAPI, (LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)) { HMODULE moduleAddress; + LPCSTR lpLibFileNameEnd = lpLibFileName + strlen(lpLibFileName); + LPCSTR lpLibName = lpLibFileNameEnd - strlen(XINPUT1_3_DLL); + // replace xinput dll with one that has ASLR - if (!strncmp(lpLibFileName, "XInput1_3.dll", 14)) + if (lpLibFileName <= lpLibName && !strncmp(lpLibName, XINPUT1_3_DLL, strlen(XINPUT1_3_DLL) + 1)) { moduleAddress = _LoadLibraryExA("XInput9_1_0.dll", hFile, dwFlags); |