I was thinking about learning some WoW memory stuff and I would like to create a class for WoW memory reading and possibly tweaking which could be used later in other projects.
There are some already but my approach is memory tweaking from out of the wine environment in Linux, ie. without injecting or dll replacing.
I'll probably write more stuff here if I find something interesting. In the meantime this is my first chapter of my adventure in the land of WoW memory...
For reading WoW memory running through wine I use ptrace system function which is able to read/write memory of a process if you are root. I've found nice ptrace library for python.
If you are interested python-ptrace is just a ptrace wrapper or you can try to find your favourite language library or just use C/++
Just man ptrace and search for PEEK and POKE. Actually scanmem uses ptrace as well.
Base memory address seems to be always 0x00400000 as it is usually. I think that you can get the actual address by reading /proc/pid/maps where are all memory ranges of the process. ie. in shell you can get the base this way:
Code:
$ grep Wow.exe /proc/`pidof Wow.exe`/maps
00400000-00401000 r-xp 00000000 08:01 1337759 /path/to/Wow.exe
Here is a small python script just to show you how you can read the memory:
Code:
#!/usr/bin/env python
from ptrace.debugger.debugger import PtraceDebugger
from ptrace.debugger.process import PtraceProcess
from struct import unpack
from os import popen
# read Word, or ByteArray if size is provided
def read(address, size=None):
global tracer
if not size:
return tracer.readWord(address)
return tracer.readBytes(address, size)
# read unsigned int
def readInt4(address):
return unpack("I", read(address, 4))[0]
# get pid and instantiate ptrace wrapper
pid = int(popen("pidof Wow.exe", "r").read().strip())
tracer = PtraceProcess(PtraceDebugger(), pid, False)
# read 4 byte unsigned integer
data = readInt4(yourFavouriteOffset) # instead of yourFavouriteOffset provide your favourite offset, ie. 0x12345
If you need to read something else then Word, uInt or byteArray, check method unpack and the provided readInt4 function which you can copy, change number of bytes you need and change unpack's format character.
Here are unpack's format characters: 7.3. struct ? Interpret strings as packed binary data — Python v2.7.2 documentation
Also PtraceProcess has some others readSomething functions which might be worth to be checked: https://bitbucket.org/haypo/python-p...cess.py#cl-100
PS: Don't forget that you need root access to ptrace a process. Just sudo or login as root.