Private Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Int32, ByVal lpBaseAddress As Int32, ByRef lpBuffer As Int32, ByVal nSize As` Int32, ByRef lpNumberOfBytesWritten As Int32) As Int32
Sub test()
Dim buffer(4096) As Int32
For i As Long = &H2A000000 To &H3A000000
ReadProcessMemory(hwnd, i, buffer, buffer.length, 0)
Next
End Sub
Error 1 Value of type '1-dimensional array of Integer' cannot be converted to 'Integer'.
此代码让我超过1分钟完成它。 我的老师告诉我“这就像你在团队计算机的某台计算机上进行编码,或者你将代码复制到计算机上并在其上编码,这样更快”。 显然是第二个,他告诉我,我的代码就像第一个。 有人告诉我如何加快速度? 。 非常感谢
答案 0 :(得分:0)
让您的缓冲区大小更大,以便您一次复制更多,然后迭代您的本地数据副本,这应该更快。
你必须试验看看理想大小的缓冲区是什么......我不知道它可能是什么。
试试这个API声明:
Public Declare Function ReadProcessMemory Lib "KERNEL32" Alias "ReadProcessMemory" ( _
ByVal hProcess As Int32, _
ByVal BaseAddress As Int32, _
ByVal BUFFER As Byte(), _
ByVal Size As Int32, _
Optional ByRef SizeReturned As Int32 = Nothing) As Boolean
然后你可以使用类似的东西来调用它:
Dim buffer(4096) As Byte
For i As Long = &H2A000000 To &H3A000000
ReadProcessMemory(hwnd, i, buffer, buffer.Length)
Next