不知道为什么,但对某些人来说,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
发布于 2018-08-14 03:56:00
读操作进入了进程中无法访问的区域,这就是它返回false的原因。感谢Jeroen Mostert链接文档,从现在开始,我将把SetLastError设置为true。
https://stackoverflow.com/questions/51829297
复制相似问题