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

Windows: Avoid GetModuleHandle(NULL) #2300

Closed
AronParker opened this issue May 23, 2022 · 0 comments · Fixed by #2301
Closed

Windows: Avoid GetModuleHandle(NULL) #2300

AronParker opened this issue May 23, 2022 · 0 comments · Fixed by #2301

Comments

@AronParker
Copy link
Contributor

The library makes extensive use of GetModuleHandle(NULL) to obtain the instance handle. This is discouraged, as it does not work for targets that are not executables, such as DLLs.

A possible solution for this would be to use the __ImageBase linker pseudovariable, which is intended for static libraries as described here.

This trick has also been used in the Windows Implementation Library for C++ which has extensive usage:

https://github.com/microsoft/wil/blob/master/include/wil/win32_helpers.h#L513-L514

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant