So I got a bit tired of the confusion brought on by C++, and with the requirement to use a specific IDE for C#. Further to that, I got sick of sitting here typing code which I'm unlikely to use in my career in the near future. Result? Bring on the Python healer.
I got to this stage this morning (but now have to leave for work). Thought it might prove useful for someone should anyone here be interested in developing using Python.
http://i.imgur.com/7A63iqo.png
Heres the code behind it:
memory.py:
main.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
Hope someone finds it useful :DCode:import memory
mem = memory.Memory()
print("Name from BattleList: " + mem.ReadString(5943964))
print("CID from BattleList: " + str(mem.ReadInt(5943960)))