Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward exports to original dinput8.dll are hardcoded to the C: drive #7

Open
techiew opened this issue Apr 16, 2022 · 0 comments
Open
Assignees

Comments

@techiew
Copy link
Owner

techiew commented Apr 16, 2022

The mod loader currently uses linker comments to forward export functions to dinput8.dll.

Linker comments are used instead of setting up the forward exports at runtime inside the mod loader thread (with LoadLibrary and GetProcAddress) because the runtime exporting introduces a race condition where dinput functions may be called before the forward exporting has finished setting up. Using linker comments sets up the forward exports at compile time and thus avoids this issue.

However this solution will not work if Windows is not installed on the C drive, although this should not be a problem for the majority of users.

In practice I don't think runtime forward exporting should be a problem, as I've observed that the first function call to dinput seems to happen about 5-10 seconds after the game has started, which should in theory give us plenty of time to set up the forward exports. But I've chosen the solution with known consequences instead of the solution with undefined consequences.

As an attempted solution, I tried making it so the exported functions forward exported themselves when they were called at runtime, this would be the best of both worlds as there would be no race condition and you could code it so it dynamically retrieved the system directory containing dinput8.dll. However I faced an issue with GetProcAddress returning the address of a function contained in a EOS (Epic Online Services) DLL instead of dinput8.dll, which I was unable to solve. I don't know why this happens, only that it happens if GetProcAddress is called after the game has been open for some seconds.

@techiew techiew added help wanted Extra attention is needed good first issue Good for newcomers labels Apr 16, 2022
@techiew techiew self-assigned this Apr 29, 2023
@techiew techiew removed help wanted Extra attention is needed good first issue Good for newcomers labels Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant