#RequireAdmin
#include<NomadMemory.au3>
Global Const $Basepointer_Player_Pattern = "\x83\xC2\xFC\x89\x15\x00\x00\x00\x00"
Global Const $Basepointer_Player_Mask = "xxxxx????"
Global Const $Basepointer_Player_Offset = 0x06
Global Const $Player_offset = 0x28
Global Const $HP_Cur_Offset = 0x84
Global $HPID =_MemoryOpen(ProcessExists("maestia.exe"))
Global $Basepointer_Player=_MemoryScanEx($HPID,$Basepointer_Player_Pattern,$Basepointer_Player_Mask)
$Basepointer_Player = _MemoryRead($Basepointer_Player + $Basepointer_Player_Offset,$HPID,'dword')
$Basepointer_Player = _MemoryRead($Basepointer_Player,$HPID,'dword')
$Basepointer_Player = _MemoryRead($Basepointer_Player+$Player_offset,$HPID,'dword')
MsgBox(0,"",StringFormat("Current HP: %i", _MemoryRead($Basepointer_Player+$HP_Cur_Offset,$HPID,'dword'))
Func _MemoryScanEx($ah_Handle, $pattern, $mask , $after = False, $iv_addrStart = 0x00400000, $iv_addrEnd = 0x00FFFFFF, $step = 51200)
If Not IsArray($ah_Handle) Then
SetError(1)
Return -1
EndIf
$pattern = StringRegExpReplace($pattern, "[^0123456789ABCDEFabcdef.]", "")
If StringLen($pattern) = 0 Then
SetError(2)
Return -2
EndIf
If Stringlen($pattern)/2 <> Stringlen($mask) Then
SetError(4)
Return -4
EndIf
Local $formatedpattern=""
Local $BufferPattern
Local $BufferMask
for $i = 0 to stringlen($mask)-1
$BufferPattern = StringLeft($pattern,2)
$pattern = StringRight($pattern,StringLen($pattern)-2)
$BufferMask = StringLeft($mask,1)
$mask = StringRight($mask,StringLen($mask)-1)
if $BufferMask = "?" then $BufferPattern = ".."
$formatedpattern = $formatedpattern&$BufferPattern
Next
$pattern = $formatedpattern
For $addr = $iv_addrStart To $iv_addrEnd Step $step - (StringLen($pattern) / 2)
StringRegExp(_MemoryRead($addr, $ah_Handle, "byte[" & $step & "]"), $pattern, 1, 2)
If Not @error Then
If $after Then
Return StringFormat("0x%.8X", $addr + ((@extended - 2) / 2))
Else
Return StringFormat("0x%.8X", $addr + ((@extended - StringLen($pattern) - 2) / 2))
EndIf
EndIf
Next
Return -3
EndFunc ;==>_MemoryScanEx