不知道为什么,但是对于某些ReadProcessMemory总是返回false。总是这样导入它:
[DefaultDllImportSearchPaths(Kernel32.Path)]
[DllImport(Kernel32.Dll)]
private static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [Out] byte[] lpBuffer, int nSize, IntPtr lpNumberOfBytesRead);
这是运行ReadProcessMemory(IntPtr HandleWithAllAccess, IntPtr ProcessBaseAddress, byte[] BufferSizeOf500, int TheSize500, IntPtr.Zero);
https://preview.ibb.co/eK8189/Screenshot_890.png
Note: just so people don't start asking unrelated questions, Kernel32 is a class with the dll name and the path where to find it
答案 0 :(得分:0)
读取操作进入进程的不可访问区域,这就是为什么它返回false的原因。感谢Jeroen Mostert链接了文档,从现在开始我将SetLastError
设置为true。