It strikes me that you are probably trying too hard to avoid pointers. The C# language supports them just fine, you can declare the argument as [In] uint* pchEaten
. Now you have all of the options available that you have in a native language, you can pass &local
as well as null
. Where local
should be a local variable of the calling method so that the pointer is stable and you won't have to fret about pinning.
But yes, you do have to declare the method unsafe. Of course it is not when you program it correctly :)