Replies: 1 comment 1 reply
-
|
That's a good question! I have been meaning to write more documentation for some of this stuff (there's another issue tracking that) but basically cswin32 will generate a SafeHandle type for any type that has an [RAIIFree(...)] annotation on it in the win32metadata (go see https://github.com/microsoft/win32metadata readme for how to browse the metadata with ilspy). In this case I saw the MSIHANDLE had RAIIFree for MsiCloseHandle, hence if any function needs MSIHANDLE then CsWin32 will generate the safehandle. But this brings up an interesting idea: we could probably generate a SafeHandle for any function you ask for as long as it's HANDLE-like and takes one parameter. E.g. I've wanted a LocalFreeSafeHandle even though there's no metadata that would cause one to be generated yet. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
While discussing microsoft/win32metadata#2173 (comment), Jevan mentioned
MsiCloseHandleSafeHandlecasually as if it was known/visible somewhere. It was unknown to me until I added a particular method to NativeMethods.txt that happened to generate it. Up until that point, I rolled my own SafeHandle type for this.For instance, I'd like to know if there's a SafeHandle type defined already for
NetApiBufferFree()so I don't have to roll my own. The only method I'm using currently isNetGetJoinInformation()and it outs a PWSTR, so no SafeHandle has been generated.Beta Was this translation helpful? Give feedback.
All reactions