高分求助!急急急,内存搜索,得出的偏移量是错的!!!
Public Function searchBaseAddr(ByVal ProcessId As Long, ByVal lBeginAddr As Long) As Long
Dim sBuffer As String * 33600
Dim hProcess As Long
Dim addr As Long
Dim sLen As Long
Dim readLen As Long
Dim tLen As Long
Dim baseAddr As Long
'lBeginAddr from &H4FFA700
sLen = 33600
searchBaseAddr = 0
hProcess = OpenProcess(PROCESS_READ_WRITE_QUERY, 0, ProcessId)
If hProcess = 0 Then Exit Function
For addr = 0 To 500
baseAddr = lBeginAddr + addr * sLen
ReadProcessMemory hProcess, ByVal baseAddr, ByVal sBuffer, sLen, readLen
If readLen > 0 Then
tLen = InStr(sBuffer, MyString)
If tLen > 0 Then '找到了
searchBaseAddr = baseAddr + tLen - 1
Exit For
End If
If addr Mod 5 = 0 Then DoEvents
Next addr
CloseHandle hProcess
End Function
上面的这个function能够找到我要的字符串(通过调试输出,可以确定)。但是得出的偏移量是错的,与我在winhex中找到的偏移量不对,用VB读取此偏移量的字符证实有错。
上面的代码问题在哪?
请高手们帮忙看看!
分不够再加!