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

FreeLibrarySafeHandle.Null uses the wrong pointer value #72

Closed
dotMorten opened this issue Jan 28, 2021 · 1 comment · Fixed by #73
Closed

FreeLibrarySafeHandle.Null uses the wrong pointer value #72

dotMorten opened this issue Jan 28, 2021 · 1 comment · Fixed by #73
Assignees
Labels
bug Something isn't working

Comments

@dotMorten
Copy link

I'm trying to call the method LoadIcon. The first parameter is documented to be null if you want a system resource.
However if I call it with the following:

var handle = PInvoke.LoadIcon(FreeLibrarySafeHandle.Null, resource_name);

I'll get an access violation exception, because it sets the pointer to -1 which becomes 0xffffffff.
The workaround is to set it to the correct pointer value for a null:

var handle = PInvoke.LoadIcon(new FreeLibrarySafeHandle(IntPtr.Zero), resource_name);

It seems to me the Null should be using 0 instead of -1.

@AArnott AArnott added the bug Something isn't working label Jan 29, 2021
@AArnott AArnott self-assigned this Jan 29, 2021
AArnott added a commit that referenced this issue Jan 29, 2021
@AArnott AArnott closed this as completed Jan 29, 2021
@dotMorten
Copy link
Author

@AArnott Thanks!

That confirms my suspicion that the same problem was appearing with CloseHandleSafeHandle and DestroyMenuSafeHandle, since you fixed it on their common baseclass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants