Should PHIDP_PREPARSED_DATA be a SafeHandle? #1675
Unanswered
SSL-Julian
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm working on migrating to use CsWin32 instead of our own native interop definitions to ensure the interop is correct but I'm not sure how to proceed with Hid Preparsed data.
CsWin32 has created this definition for HidD_GetPreparsedData:
internal static unsafe winmdroot.Foundation.BOOLEAN HidD_GetPreparsedData(SafeHandle HidDeviceObject, out winmdroot.Devices.HumanInterfaceDevice.PHIDP_PREPARSED_DATA PreparsedData)The PHIDP_PREPARSED_DATA is a struct that only contains a nint property, and is only passed to other HidD_* functions, but is allocated by the HidD_GetPreparsedData and must be freed with HidD_FreePreparsedData when no longer required.
Recently we discovered a memory leak in our software where the preparsed data was not being freed in some cases and changed our interop definitions to use a custom PreParsedDataSafeHandle, but I'm not sure how to proceed with CsWin32 when the definition it returns a struct containing a single nint. Should I bundle the PHIDP_PREPARSED_DATA in a custom SafeHandle, or should CsWin32 be providing a definition that returns a SafeHandle?
many thanks.
Beta Was this translation helpful? Give feedback.
All reactions