Results 1 to 7 of 7
Thread: Basic Info On Hooks
12-29-2010, 01:49 PM #1
Basic Info On Hooks
For Those who want to learn on mips you'll be dealing with hooks
this isn't anything technical or deep in so don't worry.
So What Is This?
A hook is a Jump most times jal and j but think about j at beginner stage(as its a basic info thread)
There are tons of them in your game for functions
Why Do we need this?
We Need this to call functions as said earlier and when writing a subroutine in ps2dis
which most times are written in a nop cave (A nop cave is a big area in the game of nop- no operation)So without these when writing or subroutines in nop caves which aren't used how would the commands take place?Thats why we got hooks to call our functions and to call our sub.
How Do I find these?
Use your cheat device search 03e00008 hex value (jr ra) and once you start searching hold whatever button you use to cancel the searching by this time you'll have thousands of results copy the address to decoder and change the value to something else like nop and if it freezes its a hook
How To Use Hooks to Call Our Subroutine
Easiest Part next to finding them,All you do go in ps2dis to a nop cave In this case we're using j.. so your sub starts at 0x00000e90
in ps2dis j $08800e90..now dont click ok look where data is you'll see 0a2-----
and thats your jump hex so at the start at your sub you would put
0xYour Hook Here 0xYour Jump hex from ps2dis here
And that's it
Im not good at guides so sorry if its hard to understand
This was a beginner base guide,well I made it as simple asI could so I hope you understood.
12-29-2010, 05:15 PM #2
- Join Date
- Mar 2010
"think about j at beginner stage" J and Jal commands are basic, there are two different commands for a reason. A jump is mainly used as a pointer to other memory. A J can also be used to "call a function then return to where the last function should of returned" because J doesn't change the value in $ra. Jal is used to call functions. Why? Because when you use a Jal command it will take the address after the jal's delay slot and put it in the register $ra so it will know where to link back to. This is good for a quick, good "go to function then come back" method, allowing us to do something in the game smoothly.
More information that I will point out:
Hooks must be in "active RAM". Active RAM is basically just RAM that is (or will) be read when in game. For example a line that is in the see walks function (which is always being used in game) will be in active ram. Another example is a line in the shooting function, if we use a line in the shooting function then we will call our function once we shoot because the shooting function is called when we shoot (duh).
What do most hooks do?
Most hooks are at the end of functions, at the point "go back to where you came from" which I slightly talked about above: ""call a function then return to where the last function should of returned"". So we change the return part to "go to "here"" and "here" would be the location of your own function/routine. If we do use a hook this way (at the end of the function) and you do not want to do something specifically (you will need to know a lot to be able to) then a J command is what you are looking for to use. As I said above a J command doesn't change the value in $ra (only jal (jump and LINK) so it knows where to LINK back to) so $ra still holds the value where the function should return (where the function should return <<< by that I mean the function that you edited at the end, to call your function). So the J goes to your function/routine, runs that code, then jumps to what ever value is in $ra, which will return to where we should be, and then we will be executing the rest of the code in the game like normal.
All in all hooks are saying: "Before you go to $ra, go to my function, then go to $ra" so you are just slipping your own code in the game to be executed.
When would you use Jal? Well if you have read this so far you know that Jal is used to "link" back to a address, for a "go to here then come back" effect. You would need to do this to be able to use a Jal for a hook. So you might want to check the function to see when and where and if you want to do this. Most the time that people use Jal's they are changing a function call (which is a jal in the game normally) to call there function. The original Jal is never used and therefor never calls the function that it normally calls. So this way you can do something like "don't jump to that function, jump to my function instead". Again, you will need to know when to do this, and if you don't know how to check if you need to do this, just use a J lol.
We can also use Jr as the same as J, or Jalr as the same as Jal. But those are usually used in functions that load dynamic memory. Why are they used? Well if you have a DMA address you will need to load it right? Well yeah, so the function does some loading and calculating, and then puts the DMA address into a register, Jr or Jalr (jump to register, and jump and link to register) can then be used to jump to the DMA address that is in the register. Typically we will use J or Jal because we are not dealing with dynamic memory, because we know where our function is (hopefully you do to o_o)
So, nice tutorial, but I suggest learning more/all of the stuff about something before making a tutorial on it ;)
12-29-2010, 06:44 PM #3Tipped OuTGuest
Really Leet? You don't need all that info just to find and use a freaking hook. If you even read his tutorial, he says multiple times that the guide is not meant to be detailed, technical, or deep; just a quick FYI for the begginers. This is what I hate about OHG Coders, they're always being over techinical for no reason. You know MIPS, we get it.
12-30-2010, 04:47 AM #4
- Join Date
- Mar 2010
12-30-2010, 05:12 AM #5Tipped OuTGuest
Yes, to you or to me it's not techincal or deep, just like division wouldn't be to an algebra teacher, while this guide is intended for 2nd graders. Either way it's uneeded information for a simplistic guide, and you took it a step furthur by insulting weed about knowing something, before making a guide about it.
I'm not an idiot, none of us here are. It's clear what you're implying. So how about you just make your own guide?
12-30-2010, 05:36 AM #6
Last edited by WeEd; 12-30-2010 at 05:37 AM.
12-30-2010, 05:53 AM #7
- Join Date
- Mar 2010
I wasn't implying that weed was in idiot, I was sharing more information. I guess the last line could of been taken as rude, I didn't mean to be rude though.
All I was trying to do was add in more info to help out his guide.