- Код: Выделить всё
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAcess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddess As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWriten As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const Process_All_Access As Long = &H1F0FFF
Private Function GetByte(Txt As String, num As Integer) As Byte
GetByte = Asc(Mid$(Txt, num, 1))
End Function
Private Function Str2Hex(ByVal Txt As String) As String
Dim i As Integer
Dim buff As String
For i = 1 To Len(Txt)
buff = Hex(GetByte(Txt, i))
If Len(buff) = 1 Then buff = "0" & buff
Str2Hex = buff & Str2Hex
Next i
End Function
Private Sub Form_Load()
Dim hWnd As Long, pid As Long, pHandle As Long, str As String * 4
Dim ReadMemory As Variant
hWnd = FindWindow(vbNullString, "Perfect World")
GetWindowThreadProcessId hWnd, pid
pHandle = OpenProcess(Process_All_Access, False, pid)
ReadProcessMemory pHandle, &H178EF5B4, str, 4, 0&
ReadMemory = Val("&H" + Str2Hex(str))
If Val(ReadMemory) < 0 Then ReadMemory = 65536 + Val(ReadMemory)
CloseHandle hProcess
Me.Show
Text1 = ReadMemory
End Sub
Адрес с деньгами читает превосходно.