Here is an example that gets the user's Gold (static) and Current HP (dynamic) in AutoIt3:
Code:
;Get the Process ID of Conquer.exe
$pid=ProcessExists("Conquer.exe")
;Check if Conquer.exe is Running
If $pid Then
;Open the Process for memory Handling
$mem=MemOpen($pid)
;Check if Memory Access Established and No Errors Present
If Not @error Then
;Get the Amount of Gold
$gold=MemRead($mem, 0x004FF1E0, "int")
;Get the Base Pointer Address for Char HP
$hpa=MemRead($mem, 0x004FF1B8, "int")
;Get the Char HP
$hp=MemRead($mem, $hpa + 24, "int")
;Close the Memory Access and Process Handle
MemClose($mem)
;Display the Gold Amount and Char HP
MsgBox(0,"CO2 Gold and HP","Gold: " & $gold & @CRLF & "HP:" & $hp)
EndIf
EndIf
#region Memory Access Functions (Reusable)
;Open Process for Memory Access
Func MemOpen( $i_Pid, $i_Access = 0x1F0FFF, $i_Inherit = 0 )
Local $av_Return[2] = [DllOpen('kernel32.dll')]
Local $ai_Handle = DllCall($av_Return[0], 'int', 'OpenProcess', 'int', $i_Access, 'int', $i_Inherit, 'int', $i_Pid)
If @error Then
DllClose($av_Return[0])
SetError(1)
Return 0
EndIf
$av_Return[1] = $ai_Handle[0]
Return $av_Return
EndFunc
;Close Process Handle Returned by MemOpen
Func MemClose( $ah_Mem )
Local $av_Ret = DllCall($ah_Mem[0], 'int', 'CloseHandle', 'int', $ah_Mem[1])
DllClose($ah_Mem[0])
Return $av_Ret[0]
EndFunc
;Read a Process Handle Returned by MemOpen at a Certain Address and Return Type
Func MemRead( $ah_Mem, $i_Address, $s_Type = '' )
If $s_Type = '' Then
Local $v_Return = ''
Local $v_Struct = DllStructCreate('byte[1]')
Local $v_Ret
While 1
DllCall($ah_Mem[0], 'int', 'ReadProcessMemory', 'int', $ah_Mem[1], 'int', $i_Address, 'ptr', DllStructGetPtr($v_Struct), 'int', 1, 'int', 0)
$v_Ret = DllStructGetData($v_Struct, 1)
If $v_Ret = 0 Then ExitLoop
$v_Return &= Chr($v_Ret)
$i_Address += 1
WEnd
Else
Local $v_Struct = DllStructCreate($s_Type)
DllCall($ah_Mem[0], 'int', 'ReadProcessMemory', 'int', $ah_Mem[1], 'int', $i_Address, 'ptr', DllStructGetPtr($v_Struct), 'int', _SizeOf($s_Type), 'int', 0)
Local $v_Return = DllStructGetData($v_Struct, 1, 1)
EndIf
Return $v_Return
EndFunc
;Gets the Size of a DLL Structure
Func _SizeOf( $s_Type )
Local $v_Struct = DllStructCreate($s_Type), $i_Size = DllStructGetSize($v_Struct)
If @error Then
SetError(1)
Return 0
EndIf
$v_Struct = 0
Return $i_Size
EndFunc
#endregion