尝试使用下面的代码使用kernel32函数SecureZeroMemory
失败,并以System.EntryPointNotFoundException
-即使here, on PInvoke和here, on SO都有据可查。在目标.NET Framework 4.7.2上运行完全正常的Windows 10 Pro。
/// <summary>
/// A kernel32 function that destroys all values in a block of memory
/// </summary>
/// <param name="destination">The pointer to the start of the block to be zeroed</param>
/// <param name="length">The number of bytes to zero</param>
/// <returns></returns>
[DllImport("kernel32.dll", CharSet = CharSet.Auto, EntryPoint = "RtlSecureZeroMemory")]
public static extern void SecureZeroMemory(IntPtr destination, IntPtr length);
答案 0 :(得分:1)
已记录此功能,但是您所包含的任何链接都不是该文档。要了解发生了什么,您应该先阅读以下实际文档:https://msdn.microsoft.com/en-us/library/windows/desktop/aa366877(v=vs.85).aspx
它说:
此函数定义为 RtlSecureZeroMemory 函数(请参阅WinBase.h)。 RtlSecureZeroMemory 的实现是内联提供的,可以在任何版本的Windows上使用(请参阅WinNT.h。)
“提供的内联”是指该函数在头文件中定义,而不由任何系统DLL导出。这意味着它不能被p / invoke调用。