Jump to content
  • 0

Hooking Code...


Jason777
 Share

Question

So after awhile of studying source code by a few hackers (spinout, frauber, ZZT, Hectamatatortron), I made a practice hack in C (originally C++ but I wasn't so sure g++ could be made to target MIPS...) and now I come to the issue of creating a hook. I don't quite understand what a hook is other that the fact that it "hooks" into the memory to execute the code. How would I create one for printing text in the most efficient way possible? Thanks for any help.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

A hook is the method used to execute your code - cutting in somewhere in the normal execution of instructions as intended by the original program. In most cases, it is best to do your hook where it is most convenient - for example, if you want to do a hack that needs the address of every spawned actor, you could put a hack at the end of the actor spawn function (as it returns the address of the actor it spawns), by replacing the jr $ra with jal <address of your code>. It is best to hook in or right after a function call, to avoid messing with registers in use.

 

For example, this hook is at the end of one of the custom functions discussed here (specifically, when bb is 0). Now, if you go into RAM and look at what the end of that function looks like unmodified, you will see that I replaced a function call - however, in the function that I replaced it with, I finish that function by calling the function that I originally replaced.

 

I hope somewhat answered your question.

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.