I tried to hex-edit a code into a game's ELF, so that I wouldn't need to use a cheat device anymore, but can't get it to work.
The code is a simple constant write to a RAM address. Here's what it looks like, ready to be used with a cheat device that accepts raw codes.
F0100008 0026F787
2043AAB4 00000000
So I read a few things about MIPS assembly, and how to hook my own functions into the game. I have to thank GameMasterZer0 and bungholio for their tutorials on the subject, and Gtlcpimp for his excellent Code Designer tool. Without all these people, I wouldn't have gotten anywhere. I'm new to all this stuff and I'm struggling to make it work.
Anyway, here's what I did so far:
-extracted the elf, opened it up in ps2dis, invoked the analyzer and imported labels from label mates
-looked for room to place my own function (rows of nop)
-found the scesifsendcmd label and the "jr ra" at the end of the function
-used Code Designer to write a jump to the "empty space" and injected it to replace the "jr ra"
-wrote my own function that should store the zeros into the RAM and injected it at the empty space
-copied the modified ELF file onto my USB stick and plugged it in my softmodded PS2
-loaded the ELF file with ESR's "launch app" option by locating and executing it through ulaunch on the stick (the game DVD is ESR patched)
Here's the code of my hook in Code Designer.
I choose "file inject" at this address: 0015d5e4 (003d8a40 - fff00).
Here's the code of my function in Code Designer (it's supposed to write this data: 00000000 at this address: 0043AAB4).
I choose "file inject" at this address: 002d8b40 (003d8a40 - fff00).
Here are screenshots from ps2dis, before and after injecting the hook (I only added the label "hook").


Here's a screenshot from ps2dis after injecting the function (I only added the label "mod").

I must've screwed up somewhere, because the game loads and plays like it hasn't been modified at all. I hope someone can help me.
The code is a simple constant write to a RAM address. Here's what it looks like, ready to be used with a cheat device that accepts raw codes.
F0100008 0026F787
2043AAB4 00000000
So I read a few things about MIPS assembly, and how to hook my own functions into the game. I have to thank GameMasterZer0 and bungholio for their tutorials on the subject, and Gtlcpimp for his excellent Code Designer tool. Without all these people, I wouldn't have gotten anywhere. I'm new to all this stuff and I'm struggling to make it work.
Anyway, here's what I did so far:
-extracted the elf, opened it up in ps2dis, invoked the analyzer and imported labels from label mates
-looked for room to place my own function (rows of nop)
-found the scesifsendcmd label and the "jr ra" at the end of the function
-used Code Designer to write a jump to the "empty space" and injected it to replace the "jr ra"
-wrote my own function that should store the zeros into the RAM and injected it at the empty space
-copied the modified ELF file onto my USB stick and plugged it in my softmodded PS2
-loaded the ELF file with ESR's "launch app" option by locating and executing it through ulaunch on the stick (the game DVD is ESR patched)
Here's the code of my hook in Code Designer.
Code:
// Hook address $0025d4e4 j $003d8a40
Here's the code of my function in Code Designer (it's supposed to write this data: 00000000 at this address: 0043AAB4).
Code:
// Mod address $003d8a40 lui t0, $0x0000 li t0, $0x0000 lui t1, $0x0043 nop sw t0,$AAB4(t1) nop jr ra
Here are screenshots from ps2dis, before and after injecting the hook (I only added the label "hook").


Here's a screenshot from ps2dis after injecting the function (I only added the label "mod").

I must've screwed up somewhere, because the game loads and plays like it hasn't been modified at all. I hope someone can help me.

Comment