記憶體代碼讀取
我在form1堻]了一個timer1和一個Lebal1,想從記憶體媗爸角色名字 “天正下雨”,寫了以下代碼,但是我的Lebal1堳o出現不了角色名。哪位大蝦幫小弟看看是什麼地方出了錯誤。不勝感謝哈!!!!!!人物基址是&H6447A0,沒有偏移量
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 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 dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32.dll" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByRef lpBuffer As Any, ByVal nSize As Long, ByRef lpNumberOfBytesWritten As Long) As Long
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
'----------------聲明變數--------------------
Dim hwd As Long
Dim pid As Long
Dim hProcess As Long
Private Sub Timer1_Timer()
Dim base As Long
Dim hmp As Long
Dim minhp As Long
Dim name(21) As Byte
base = &H6447A0
hProcess = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If hProcess Then
Call ReadProcessMemory(hProcess, ByVal base, name(0), 32, 0&)
CloseHandle hProcess
End If
name = StrConv(name, vbUnicode)
Label1.Caption = name
End Sub |