[求助]关于ReadProcessMemory函数的,,问题。。。请进
目的:从内存中读出一个整数型数值。问题:在单步跟踪的时候,该函数的第二个参数,总是一个地址。也读不出来任何数据,
代码如下:
Sub SearchMem(Hwndle As Long, bSearch As Long)
Const PAGE_READWRITE = 4, MEM_COMMIT = &H1000
Dim r As Long, mbi As MEMORY_BASIC_INFORMATION
Dim lpAddress As Long: lpAddress = &H400000 '以 400000 作为起点
Dim nCount As Long
nCount = 0
r = VirtualQuery(lpAddress, mbi, Len(mbi)) '这里只能用VirtulQuery(),而用VirtualQueryEx()返回零
'将7F000000作为搜索结束地址
Do While (r And (lpAddress < &H7F000000))
'只搜索可读取的已提交的内存区域
If (mbi.Protect And PAGE_READWRITE) And (mbi.State = MEM_COMMIT) Then
Dim lpBuffer(40) As Byte
Dim lenth_NUMBER As Integer
ReadProcessMemory Hwndle, mbi.BaseAddress, lpBuffer(0), mbi.RegionSize, lenth_NUMBER
List1.AddItem (mbi.BaseAddress) '将查询地址输出
List2.AddItem (lpBuffer) '将查询到的值输出
' If lpBuffer = bSearch Then '判断。与要查找的值是否相同
' Text1.Text = lpBuffer
' Text1.Text = Text1.Text & " " & mbi.BaseAddress
' nCount = nCount + 1
' End If
'
' If lpBuffer = bSearch Then '判断。与要查找的值是否相同
' Text2.Text = lpBuffer
' Text2.Text = Text2.Text & " " & mbi.BaseAddress
' nCount = nCount + 1
' End If
End If
lpAddress = lpAddress + mbi.RegionSize
r = VirtualQuery(lpAddress, mbi, Len(mbi))
Loop
If nCount = 0 Then
MsgBox "搜索不到任何结果", vbExclamation
Else
MsgBox "此次共搜索到 " & nCount & " 个结果", vbInformation
End If
End Sub
帮我看下为什么??谢谢。。。