Earlier today I stumbled upon a post called Reverse Engineering for newbies that explained briefly how to find the address of certain variables in applications (ah, the good old Cheat Engine days…) and also how modifying said address should be done in C/C++.
GNU/Linux does not have the WriteProcessMemory function, but instead we’ve got ptrace! Using ptrace we are able to attach to a process and use PTRACE_POKEDATA to modify the value of an address.
We will then be able to set up a similar function to WriteProcessMemory under GNU/Linux:
bool WriteProcessMemoryNix(pid_t pid, void *addr, void *data)
// attach to process
if (ptrace(PTRACE_ATTACH, pid) != 0)
// wait for process to stop
waitpid(pid, NULL, WUNTRACED);
// modify the address
if (ptrace(PTRACE_POKEDATA, pid, addr, data) != 0)
// detach from the process
// everything went ok
To use this function, you would first need to find the memory address of the variable you want to change. I did this for the gold amount in the game Rogue Legacy using the tool scanmem.
I would then use my new WriteProcessMemoryNix() function to modify the gold address to 999 gold:
if (WriteProcessMemoryNix(1679, (void *)0x7fd01459e598, (void *)999))
std::cout << "Success!" << std::endl;
The process id (pid) of Rogue Legacy was found using the ps command.
JPhilipp over at OpenGameArt recently submitted 700 (!) sprites, with walking animation included. You can find the sprites here: http://opengameart.org/content/700-sprites
When developing games I prefer to use spritesheets with all animation frames in a single image file, rather than an image for every single animation frame.
So what to do? Use Shell!
I wrote a quick (and dirty) Shell script to combine the animation frames into a single spritesheet for each sprite. I am nowhere near an expert in Shell, but I managed to get it working, so I’m happy.
The script placed the different walking animation frames into a single spritesheet for each sprite and the result was:
You can download all the spritesheets here!
for f in *.gif
if ls combined/$short".png" &> /dev/null; then
echo "file exists"
montage -tile x1 -geometry +0+0 -background none $short*.gif combined/$short.png
convert combined/$short.png -transparent white combined/$short.png
The timing couldn’t be better. I needed a post to fill up my otherwise empty blog and PyWeek #17 has just ended.
My entry, Miner, ended up with an overall score of 3.09 out of 5 – nothing great, nor nothing bad!
I wrote the game in Python (2.7) and PyGame since that was what I felt most comfortable using for a one-week game. It’s quick, it’s easy and I feel comfortable using it.
I had originally planned spending the whole week on the game, but the nice weather made me change my plans and take a trip to Sweden instead. I did manage to finish the game (sort of) and it was great fun. Can’t wait for the next PyWeek!
You can find all the PyWeek #17 ratings here: http://pyweek.org/17/ratings/
And welcome to my blog. Feel free to have a look around.