AU3定义内存基址的问题
本帖最后由 116154801 于 2010-5-7 05:58 编辑本贴已经解决,请查看11楼得知结果。
116154801
以下我怎么样都是读取都是0,不知道为什么,是不是我人品问题。有人能帮帮我吗?;定义内存基址
$Address = 0x00FF0F90
;定义内存偏移地址
$Off_Hp = 0x310
;获取游戏句柄
$CurProcID=WinGetProcess("步骤")
;获取内存读写句柄
$Handle = _MemoryOpen($CurProcID)
;错误处理
If $Handle=0 then
MsgBox(4096,"错误提示","打开游戏内存错误。")
Exit
EndIf
;读取内存数据
$HP = _MemoryRead("0x" & Hex($Address+$Off_Hp), $Handle)
MsgBox(0,"",$HP)
;关闭内存句柄
_MemoryClose($CurProcID)
;=================================================================================================
Func _MemoryOpen($iv_Pid, $iv_DesiredAccess = 0x1F0FFF, $if_InheritHandle = 1)
If Not ProcessExists($iv_Pid) Then
SetError(1)
Return 0
EndIf
Local $ah_Handle =
If @Error Then
SetError(2)
Return 0
EndIf
Local $av_OpenProcess = DllCall($ah_Handle, 'int', 'OpenProcess', 'int', $iv_DesiredAccess, 'int', $if_InheritHandle, 'int', $iv_Pid)
If @Error Then
DllClose($ah_Handle)
SetError(3)
Return 0
EndIf
$ah_Handle = $av_OpenProcess
Return $ah_Handle
EndFunc
;=================================================================================================
Func _MemoryRead($iv_Address, $ah_Handle, $sv_Type = 'dword')
If Not IsArray($ah_Handle) Then
SetError(1)
Return 0
EndIf
Local $v_Buffer = DllStructCreate($sv_Type)
If @Error Then
SetError(@Error + 1)
Return 0
EndIf
DllCall($ah_Handle, 'int', 'ReadProcessMemory', 'int', $ah_Handle, 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
If Not @Error Then
Local $v_Value = DllStructGetData($v_Buffer, 1)
Return $v_Value
Else
SetError(6)
Return 0
EndIf
EndFunc
;=================================================================================================
Func _MemoryClose($ah_Handle)
If Not IsArray($ah_Handle) Then
SetError(1)
Return 0
EndIf
DllCall($ah_Handle, 'int', 'CloseHandle', 'int', $ah_Handle)
If Not @Error Then
DllClose($ah_Handle)
Return 1
Else
DllClose($ah_Handle)
SetError(2)
Return 0
EndIf
EndFunc
;=================================================================================================
有人帮帮忙吗?小弟无敬感激 帮你顶一个 3Q,有说能进来帮帮忙呢? 这个东西不懂,帮顶 有人吗????? $HP = _MemoryRead("0x" & Hex($Address+$Off_Hp), $Handle)
问题应该出现在这里 $HP = _MemRead($Handle,$Address+$Off_Hp,"Byte") 回复 8# 298311657
_MemRead
我没有这个函数呢,能发出来给我们学习学习吗?谢谢你了 你这个俺基本上是帮不上啥忙的。 已经解决了,谢谢大家的支持。更谢谢 298311657大哥。下面是我解决的,我多加了一条查找基址数据,结果就是 查找到的基址数据+偏移地址=要找的真实地址了。;定义内存基址
$Address = 0x00FF0F90
;定义内存偏移地址
$Off_Hp = 0x310
;~ 01F228B0
MsgBox(0,"",Hex($Address+$Off_Hp))
;获取游戏句柄
$CurProcID=WinGetProcess("步骤")
;获取内存读写句柄
$Handle = _MemoryOpen($CurProcID)
;错误处理
If $Handle=0 then
MsgBox(4096,"错误提示","打开游戏内存错误。")
Exit
EndIf
$HP1 = _MemoryRead("0x" & Hex($Address), $Handle, "int")
;读取内存数据
$HP = _MemoryRead("0x" & Hex($HP1+$Off_Hp), $Handle, "int")
;~ $HP = _MemRead($Handle,$Address+$Off_Hp,"Byte")
MsgBox(0,"",$HP)
;关闭内存句柄
_MemoryClose($CurProcID)
;=================================================================================================
Func _MemoryOpen($iv_Pid, $iv_DesiredAccess = 0x1F0FFF, $if_InheritHandle = 1)
If Not ProcessExists($iv_Pid) Then
SetError(1)
Return 0
EndIf
Local $ah_Handle =
If @Error Then
SetError(2)
Return 0
EndIf
Local $av_OpenProcess = DllCall($ah_Handle, 'int', 'OpenProcess', 'int', $iv_DesiredAccess, 'int', $if_InheritHandle, 'int', $iv_Pid)
If @Error Then
DllClose($ah_Handle)
SetError(3)
Return 0
EndIf
$ah_Handle = $av_OpenProcess
Return $ah_Handle
EndFunc
;=================================================================================================
Func _MemoryRead($iv_Address, $ah_Handle, $sv_Type = 'dword')
If Not IsArray($ah_Handle) Then
SetError(1)
Return 0
EndIf
Local $v_Buffer = DllStructCreate($sv_Type)
If @Error Then
SetError(@Error + 1)
Return 0
EndIf
DllCall($ah_Handle, 'int', 'ReadProcessMemory', 'int', $ah_Handle, 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
If Not @Error Then
Local $v_Value = DllStructGetData($v_Buffer, 1)
Return $v_Value
Else
SetError(6)
Return 0
EndIf
EndFunc
;=================================================================================================
Func _MemoryClose($ah_Handle)
If Not IsArray($ah_Handle) Then
SetError(1)
Return 0
EndIf
DllCall($ah_Handle, 'int', 'CloseHandle', 'int', $ah_Handle)
If Not @Error Then
DllClose($ah_Handle)
Return 1
Else
DllClose($ah_Handle)
SetError(2)
Return 0
EndIf
EndFunc
;=================================================================================================
我再顶,不要让新人们错过了。 这方法我用到其他地方就可以,用在奇迹上,就读不出来,CE就可以读出来。你说奇怪不奇怪。:face (37): 如果是2 字节怎么办? 普通的还比较好读一点,如果需要注入读取,就不知道怎么搞了。
页:
[1]
2