HavocXphere
Honorary Master
I'm trying to compile some code off MSDN its refusing to do so.
Basically the function requires a ref string while the value being used is a IntPtr. The compiler (VS Express '10) says it can't convert it.
As I understand it ref string and IntPtr are roughly the same thing, but I don't want to nuke the wrong memory location so a clean & correct conversion would be best.
Thanks
HX
Basically the function requires a ref string while the value being used is a IntPtr. The compiler (VS Express '10) says it can't convert it.
// Call this function to remove the key from memory after use for security
[System.Runtime.InteropServices.DllImport("KERNEL32.DLL", EntryPoint="RtlZeroMemory")]
public static extern bool ZeroMemory(IntPtr Destination, int Length);
[...]
GCHandle gch = GCHandle.Alloc( sSecretKey,GCHandleType.Pinned );
[...]
ZeroMemory(gch.AddrOfPinnedObject(), sSecretKey.Length * 2);
As I understand it ref string and IntPtr are roughly the same thing, but I don't want to nuke the wrong memory location so a clean & correct conversion would be best.
Thanks
HX