Thank you, that was exactly what i was searching for.
Here is a simple Auto Heal in Python I did using your contribution =)
Utility
Code:
import ctypes
kernel32 = ctypes.windll.kernel32
def FindDMAAddy(hProc, base, offsets, arch=64):
size=8
if (arch == 32): size = 4
adress = ctypes.c_uint64(base)
for offset in offsets:
kernel32.ReadProcessMemory(hProc, adress, ctypes.byref(adress), size, 0)
adress = ctypes.c_uint64(adress.value + offset)
return(adress.value)
Autoheal
Code:
import time
import win32api, win32gui
import win32con
from pymem import Pymem
import utility
###Autopot by coys####
# Addresses by KronosQC, ty
#"PathOfExile.exe"+03886DB0
#38 18 40 20 208 2c - MaxHP
#38 18 40 20 208 30 - CurHP
#38 18 40 20 208 7c - MaxMP
#38 18 40 20 208 80 - CurMP
process_name = "PathOfExile.exe"
pointer = 0x03886DB0
offsets_CurHP = [0x38, 0x18, 0x40, 0x20, 0x208, 0x30]
offsets_MaxHP = [0x38, 0x18, 0x40, 0x20, 0x208, 0x2c]
offsets_CurMP = [0x38, 0x18, 0x40, 0x20, 0x208, 0x80]
offsets_MaxMP = [0x38, 0x18, 0x40, 0x20, 0x208, 0x7c]
# Heals %
heal_hp = 70
heal_mp = 40
#Handle+Base
try:
pm = Pymem(process_name)
print(f"Conectado ao processo: {process_name}")
hProc = pm.process_handle
base_pointer = pm.base_address + pointer
except Exception as e:
print(f"Erro ao conectar ao processo: {e}")
exit()
janela_jogo = win32gui.FindWindow(None, "Path of Exile 2")
if not janela_jogo:
print("Janela do jogo não encontrada.")
exit()
#healbot
while True:
try:
maxhp_address = utility.FindDMAAddy(hProc, base_pointer, offsets_MaxHP, 64)
curhp_address = utility.FindDMAAddy(hProc, base_pointer, offsets_CurHP, 64)
maxmana_address = utility.FindDMAAddy(hProc, base_pointer, offsets_MaxMP, 64)
curmana_address = utility.FindDMAAddy(hProc, base_pointer, offsets_CurMP, 64)
current_hp = pm.read_int(curhp_address)
max_hp = pm.read_int(maxhp_address)
current_mp = pm.read_int(curmana_address)
max_mp = pm.read_int(maxmana_address)
hp_percent = (current_hp / max_hp) * 100 if max_hp != 0 else 0
mp_percent = (current_mp / max_mp) * 100 if max_mp != 0 else 0
if hp_percent <= heal_hp:
time.sleep(0.2)
win32api.PostMessage(janela_jogo, win32con.WM_KEYDOWN, ord('1'), 0)
win32api.PostMessage(janela_jogo, win32con.WM_KEYUP, ord('1'), 0)
if mp_percent <= heal_mp:
time.sleep(0.2)
win32api.PostMessage(janela_jogo, win32con.WM_KEYDOWN, ord('2'), 0)
win32api.PostMessage(janela_jogo, win32con.WM_KEYUP, ord('2'), 0)
except Exception as e:
print(f"Erro ao acessar memória: {e}")
time.sleep(0.5)
I apreaciate any tips in how to improve and how to do better =)
Edit*
Amazing post too Xab3r that was very helpful