|
<p>'<br/>Private Function 查找城市地址(hProcess As Long, bSearch() As Byte) As Long</p><p>Const PAGE_READWRITE = 4<br/>Const MEM_COMMIT = &H1000<br/>Dim i As Long, j As Long<br/>Dim r As Long, mbi As MEMORY_BASIC_INFORMATION<br/>Dim lpAddress As Long<br/>Dim ubs As Long<br/>Dim add_city As Long<br/>Dim flg_27 As Long<br/>Dim nCount As Long</p><p> ubs = UBound(bSearch)<br/> lpAddress = &H3F00000<br/> nCount = 0<br/> r = VirtualQueryEx(hProcess, lpAddress, mbi, Len(mbi))<br/> Do While (r And (lpAddress < &H7FFFFFFF))<br/> DoEvents '[防止死机]<br/> If (mbi.Protect And PAGE_READWRITE) And (mbi.State = MEM_COMMIT) Then<br/> Dim lpBuffer() As Byte<br/> ReDim lpBuffer(mbi.RegionSize - 1)<br/> ReadProcessMemory hProcess, mbi.BaseAddress, lpBuffer(0), mbi.RegionSize, 0<br/> For i = 0 To mbi.RegionSize - 1 - ubs<br/> DoEvents '[防止死机]<br/> For j = 0 To ubs<br/> If bSearch(j) <> lpBuffer(i + j) Then<br/> GoTo 10<br/> End If<br/> Next<br/> add_city = i + lpAddress<br/> ReadProcessMemory hProcess, add_city - 28, ByVal VarPtr(flg_27), 2, 0<br/> If flg_27 = 39 Then<br/> nCount = nCount + 1<br/> 查找城市地址 = add_city<br/> Exit For<br/> End If<br/>10:<br/> Next<br/> End If<br/> If nCount > 0 Then<br/> Exit Do<br/> End If<br/> lpAddress = lpAddress + mbi.RegionSize<br/> r = VirtualQueryEx(hProcess, lpAddress, mbi, Len(mbi))<br/> Loop<br/> CloseHandle hProcess<br/> 'If nCount = 0 Then<br/> 'Text1.Text = "有城市没有找到"<br/> 'End If</p><p><br/>End Function</p> |
|