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 - Update LoadLibrary Error Message to include Error Code #1026

Merged
merged 1 commit into from
Apr 20, 2023

Conversation

cfis
Copy link
Contributor

@cfis cfis commented Apr 20, 2023

On Windows FormatMessageA can return a NULL message - for example when trying to load a 32bit dll from a 64 bit program (garbage.so in the test suite). Since the passed in buffer contains junk data the resulting error message is made up of garbage characters which makes it impossible to know what the problem is.

This commit updates the message so that it always returns the error code (in this case 193) plus message, which makes it possible to debug the problem.

…n trying to load a 32bit dll from a 64 bit program (garbage.so in the test suite). Since the passed in buffer contains junk data the resulting error message full of garbage characters which makes it impossible to know what the problem is.

This commit updates the message so that it at least returns the error code (in this case 193) which makes it possible to debug the problem.
@larskanis larskanis merged commit a17aeb8 into ffi:master Apr 20, 2023
@larskanis
Copy link
Member

Looks good! Thank you!

@larskanis
Copy link
Member

Oh, just noticed that FORMAT_MESSAGE_ALLOCATE_BUFFER allocates a buffer which should be freed by LocalFree(). This could be right after snprintf(). Or do I miss something?

@cfis
Copy link
Contributor Author

cfis commented Apr 20, 2023

Oh you are right! I'll push another MR.

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

Successfully merging this pull request may close these issues.

None yet

2 participants