问题描述
在vb.net下用ReadProcessMemory总是读不了内存的内容。似乎是普遍存在的一个问题,不知道大家有什么好的方法,ReadProcessMemory要怎么调用和声明,或用其它的方法了读取其它进程的内存。
解决方案
ReadProcessMemory这样声明。把lpBaseAddress声明为 ByVal:
Public Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByVal lpBuffer() As Byte, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Dim ph As Integer
Dim buffer(200) As Byte
Dim bytesRead As Integer
ReadProcessMemory(ph, &H403000, buffer, buffer.Length,bytesRead)