Originally Posted by
szulak
How is this going?
Currently it's almost done. I just haven't gotten round to doing the final steps. Here's what I have so far:
Control.py:
Code:
import ctypes
import win32ui
import win32process
import win32api
import win32con
class Control:
def __init__(self, hwnd, handle):
self.hwnd = hwnd
self.handle = handle
def SendKey(self, key):
for k in key:
print(str(k))
if k == "\n":
win32api.SendMessage(self.hwnd, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0)
win32api.SendMessage(self.hwnd, win32con.WM_KEYUP, win32con.VK_RETURN, 0)
else:
win32api.SendMessage(self.hwnd, win32con.WM_CHAR, ord(k), 0)
Healer.py
Code:
from threading import Thread
import time, random
import control
class Healer:
def __init__(self, rules, ctrl, mem):
Thread.__init__(self)
self.rules = rules
self.ctrl = ctrl
self.isStopped = False
self.mem = mem
def run(self):
self.isStopped = False
for i in self.rules:
print("HealRule")
while (~self.isStopped):
delay = random.uniform(0.7, 1.3)
print("tick " + str(delay))
self.ctrl.SendKey("Hello, world!")
time.sleep(delay)
main.py
Code:
import memory, healer, time, control
# Heal Rules:
# Format: minhp, maxhp, minmp, maxmp, spell
HealRules = [
{ 2000, 3000, 40, 0, "Exura Ico" }#,
#{ 1000, 2000, 100, 0, "Exura Gran Ico" }
]
mem = memory.Memory()
ctrl = control.Control(mem.HWND, mem.PROCESS.handle)
heal = healer.Healer(HealRules, ctrl, mem)
print("Name from BattleList: " + mem.ReadString(5943964))
print("CID from BattleList: " + str(mem.ReadInt(5943960)))
heal.run()
memory.py
Code:
import ctypes, win32ui, win32process ,win32api
class Memory:
def __init__(self):
# Read and write process memory methods from kernel32
self.rPM = ctypes.windll.kernel32.ReadProcessMemory
self.wPM = ctypes.windll.kernel32.WriteProcessMemory
# PROCESS_ALL_ACCESS is a flag typically set in kernel32, for simplicity we shall define it here
PROCESS_ALL_ACCESS = 0x1F0FFF
# Acquire a HWND for Tibia
self.HWND = win32ui.FindWindow("TibiaClient",None).GetSafeHwnd()
print("HWND : " + str(self.HWND))
# Acquire the ProcessID using our HWND
self.PID = win32process.GetWindowThreadProcessId(self.HWND)[1]
print("PID : " + str(self.PID))
# Acquire a Process object to work with
self.PROCESS = win32api.OpenProcess(PROCESS_ALL_ACCESS,0,self.PID)
print("HANDLE : " + str(self.PROCESS.handle))
# Enumerate Process MOdules to find the base address of Tibia
self.BASEADDRESSLIST = win32process.EnumProcessModules(self.PROCESS.handle)
# Take the first (C# "Default") base address from the list
self.BASEADDRESS = self.BASEADDRESSLIST[0]
print("BASEADDRESS : " + str(self.BASEADDRESS))
#ALL GLOBALS DEFINED
def ReadInt(self, Address):
data = 4294967295
self.rPM(self.PROCESS.handle,Address+self.BASEADDRESS,data,32,0)
return data
def ReadString(self, Address):
data = b"wah"
buff = ctypes.create_string_buffer(data, 32)
self.rPM(self.PROCESS.handle,Address+self.BASEADDRESS,buff,32,0)
val = ctypes.string_at(buff).decode("utf-8")
return val