Skip to content

Commit

Permalink
Replace XInput library with updated one (#278)
Browse files Browse the repository at this point in the history
* Replace XInput library with updated one

This code adds better compatibility with newer controllers and different controller types

Also adds ASLR to the loaded library

* Formatting
  • Loading branch information
emma-miler authored Sep 24, 2022
1 parent 122f84f commit c3b6151
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions NorthstarDLL/hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,29 @@ void CallAllPendingDLLLoadCallbacks()

HMODULE LoadLibraryExAHook(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
{
HMODULE moduleAddress = LoadLibraryExAOriginal(lpLibFileName, hFile, dwFlags);

if (moduleAddress)
if (!strncmp(lpLibFileName, "XInput1_3.dll", 14))
{
CallLoadLibraryACallbacks(lpLibFileName, moduleAddress);
HMODULE moduleAddress = LoadLibraryExAOriginal("XInput9_1_0.dll", hFile, dwFlags);
if (moduleAddress)
{
CallLoadLibraryACallbacks(lpLibFileName, moduleAddress);
}
else
{
MessageBoxA(0, "Could not find XInput9_1_0.dll", "Northstar", MB_ICONERROR);
exit(-1);
}
return moduleAddress;
}
else
{
HMODULE moduleAddress = LoadLibraryExAOriginal(lpLibFileName, hFile, dwFlags);
if (moduleAddress)
{
CallLoadLibraryACallbacks(lpLibFileName, moduleAddress);
}
return moduleAddress;
}

return moduleAddress;
}

HMODULE LoadLibraryAHook(LPCSTR lpLibFileName)
Expand Down

0 comments on commit c3b6151

Please sign in to comment.