To avoid using unsafe keywords in my project, I've opted to using the ItrPtr override of NCryptEnumKeys which is available from PInvoke.NCrypt library.
The test for NCryptEnumKeys uses the unsafe void* for the ppEnumState parameter, gets updated during the invocation and passed back in order to get the next key from the storage provider during each loop.
To avoid using
unsafe
keywords in my project, I've opted to using the ItrPtr override ofNCryptEnumKeys
which is available from PInvoke.NCrypt library.The test for
NCryptEnumKeys
uses the unsafevoid*
for theppEnumState
parameter, gets updated during the invocation and passed back in order to get the next key from the storage provider during each loop.https://github.com/AArnott/pinvoke/blob/da0071be3fca89ea12f4bf43eea1b6c7ec836f76/src/NCrypt.Tests/NCryptFacts.cs#L220-L256
The
IntPtr
variant with the following signature does not update the variable passed intoppEnumState
If i add the following to my own class, then the issue goes away: