vb 基址写法

来源:百度知道 编辑:UC知道 时间:2024/05/24 02:56:09
Private Function ncnr(lpADDress As Long) As Integer
' 声明一些需要的变量
Dim hwnd As Long ' 储存 FindWindow 函数返回的句柄
Dim pid As Long ' 储存进程标识符( Process Id )
Dim pHandle As Long ' 储存进程句柄
hwnd = FindWindow(vbNullString, "新英雄年代——兄弟版")
' 取得进程标识符
GetWindowThreadProcessId hwnd, pid
' 使用进程标识符取得进程句柄
pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
' 在内存地址中读取数据

ReadProcessMemory pHandle, lpADDress, ByVal VarPtr(ncnr), 4, 0&
' 关闭进程句柄
CloseHandle hProcess

End Function

这样写普通的内存地址能读``
但是 加偏移的基址就不行了`老是出错`不然就读不出`

应该怎么写~?

基址偏移 1C
NOWHP=ncnr(dizhi)

Private Sub Base()

Dim w_wpid As Long
Dim w_wpbh As Long
Dim w_weizi As Long
Dim w_name(65) As Byte
Dim w_name_temp As Long
Dim w_wpx As Single 'X
Dim w_wpy As Single 'Y
Dim w_wbase As Long
dim hp as long
dim mp as long
If IsRun = False Then
Exit Sub
End If
hProcess = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If hProcess Then
ReadProcessMemory hProcess, ByVal H50184, base, 4, 0
ReadProcessMemory hProcess, ByVal base + &H8, w_wbase, 4, 0
ReadProcessMemory hProcess, ByVal w_wbase + &H24, hp, 4, 0
ReadProcessMemory hProcess, ByVal w_wbase + &H18, mp, 4, 0
end if
label1.caption=cstr(hp)
End Sub
加1C后就是二级基址,不是你那样写的
你要哪个的地址,一般的红蓝就这样写
base 基址 w_wbase 人物基址
&H24 血值偏移 hp
&H18 蓝值偏移 mp