-
-
Notifications
You must be signed in to change notification settings - Fork 226
Kernel32.GetModuleHandle should return IntPtr instead of SafeHandle #563
Comments
Maybe it should retun a SafeHandle with ownsHandle=false. |
@zgabi That would be great if .NET offered a way to do that. AFAIK it does not. |
@AArnott : you mean that the .net marshalling can't reate SafeHandle with ownsHandle=false? in this case a private method shoudl created (with a differnt name or in an internal class):
Or create a request to MS to allow to return a SafeHandle with ownsHandle=false with an attribute :) |
Yes, that's my meaning. Yes, a wrapper method can help resolve this problem. You could do this in your own code as well. |
Hi, I just stumbled over the same bug and found this issue and that it is already fixed via IntPtr return. Is there some release available with this fix included that I could use?
and this still returns the safe handle and I've looked for a prerelease version, but didn't find any. Is there something more that needs to be done, before it can be released that I am missing? Thanks for the great project! Take care, |
Sure. Watch for 0.7.104 to release to nuget shortly. |
Thank you! |
The GetModuleHandle function returns a handle to a mapped module without incrementing its reference count. However, if this handle is passed to the FreeLibrary function, the reference count of the mapped module will be decremented. Therefore, do not pass a handle returned by GetModuleHandle to the FreeLibrary function. Doing so can cause a DLL module to be unmapped prematurely.
The text was updated successfully, but these errors were encountered: