Dirbaio |
Posted on 11-28-12, 07:02 pm
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10081 Posts: 2933/4458 Since: 06-08-11 |
If you want to get the value of a register, you can read r0-3 as parameters to the function.
void hook_02xxxxxx(int r0, int r1, int r2, int r3) { ... } You can't read the other regs like that because only r0..3 are used as params. If there's more than 4 params, the rest goes in the stack. To read the others, or write, you'll need to write the hook in ASM. You can call C/C++ functions from ASM. Also keep in mind that hooking destroys R14. Also hooks of type "hook" push all registers to stack so you won't be able to modify them, use a "repl" instead. |
Gericom |
Posted on 11-29-12, 02:23 pm
|
Shyguy
Karma: 160 Posts: 42/90 Since: 07-10-12 |
|
Dirbaio |
Posted on 11-29-12, 02:31 pm
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10081 Posts: 2934/4458 Since: 06-08-11 |
Yes, absolutely everywhere as long as it's ARM code (I'll add Thumb support sometime soon). When you do a hook, NSMBe replaces the instruction at the address you entered with a branch to your code.
|
Gericom |
Posted on 11-29-12, 02:54 pm (rev. 6 by Gericom on 11-29-12, 04:08 pm)
|
Shyguy
Karma: 160 Posts: 43/90 Since: 07-10-12 |
|
Dirbaio |
Posted on 11-29-12, 04:33 pm
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10081 Posts: 2935/4458 Since: 06-08-11 |
Posted by Gericom CMP R9, #217AB94 You're missing the "0x". Also, immediate values in data processing instructions are limited to 8bit. To do that you'd need to do something like: repl_02088098:
LDR R0, [R9,#0x28]
LDR R12, =0x0217AB94
CMP R9, R12
MOVEQ R0, #0 And you're missing "BX LR" at the end. I'll have a look at that error now, but afaik I'm not getting it. Are you really sure you're using a clean ROM? |
Gericom |
Posted on 11-29-12, 04:37 pm
|
Shyguy
Karma: 160 Posts: 44/90 Since: 07-10-12 |
|
Dirbaio |
Posted on 11-29-12, 04:38 pm
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10081 Posts: 2936/4458 Since: 06-08-11 |
And does the error happen with *any* code you're trying to compile and patch?
Weird. |
Gericom |
Posted on 11-29-12, 04:41 pm (rev. 1 by Gericom on 11-29-12, 04:42 pm)
|
Shyguy
Karma: 160 Posts: 45/90 Since: 07-10-12 |
|
Dirbaio |
Posted on 11-29-12, 05:26 pm (rev. 1 by Dirbaio on 11-29-12, 05:27 pm)
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10081 Posts: 2937/4458 Since: 06-08-11 |
Ok. New build is up. Fixes the error when ASM hacking MKDS.
EDIT: Now it fails when hacking NSMB. Yay. |
Gericom |
Posted on 11-29-12, 05:42 pm
|
Shyguy
Karma: 160 Posts: 46/90 Since: 07-10-12 |
|
RiksKing |
Posted on 12-06-12, 03:51 pm
|
Porcupo
Captivated by Persona 4 Karma: 605 Posts: 233/306 Since: 01-06-12 |
Uhm, sorry if this is a very dumb question, but how can you actually open/load this into NSMB Editor?
I haven't seen here how to do it... _________________________ I apologize to everyone for my horrible English. |
Dirbaio |
Posted on 12-06-12, 05:46 pm
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10081 Posts: 2945/4458 Since: 06-08-11 |
Posted by RiksKing Uhm, sorry if this is a very dumb question, but how can you actually open/load this into NSMB Editor? I haven't seen here how to do it... I just wrote tutorial How ASM hacks are setup, hope it helps! |
RiksKing |
Posted on 12-06-12, 07:04 pm
|
Porcupo
Captivated by Persona 4 Karma: 605 Posts: 234/306 Since: 01-06-12 |
Posted by Dirbaio Posted by RiksKing Uhm, sorry if this is a very dumb question, but how can you actually open/load this into NSMB Editor? I haven't seen here how to do it... I just wrote tutorial How ASM hacks are setup, hope it helps! Wow, thank you very much. I'm going to try this out ASAP _________________________ I apologize to everyone for my horrible English. |
Freeze |
Posted on 12-06-12, 08:06 pm
|
Karma: 3767 Posts: 1678/2112 Since: 06-28-11 |
Dirbaio |
Posted on 12-06-12, 08:11 pm
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10081 Posts: 2946/4458 Since: 06-08-11 |
Yeah, I know.
In fact the symbols.x file in the template is quite outdated. If you look at the one in the NSMBCR repo, that function is named "enemyActor_execute". It reads a variable from the class that is some kind of "state" and executes a virtual function from the class depending on it. That "state" variable is used for the "dying" states when stomped, hit with a fireball, etc etc. |
Gericom |
Posted on 12-08-12, 11:32 am (rev. 1 by Gericom on 12-08-12, 11:57 am)
|
Shyguy
Karma: 160 Posts: 47/90 Since: 07-10-12 |
|
Arisotura |
Posted on 12-08-12, 11:34 am
|
☭ coffee and cream
Karma: 10543 Posts: 819/2781 Since: 06-26-11 |
Posted by Gericom @ Dirbaio Can you work on the thumb code? I need it. If you can make it, I can add more tracks to mkds! Why don't you do it yourself? I thought you were a professional programmer? I also think that Dirbaio has better things to do. I can't speak for him though, so we'll see when he comes here. _________________________ Kuribo64 - zrghij |
Dirbaio |
Posted on 12-08-12, 01:55 pm
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10081 Posts: 2970/4458 Since: 06-08-11 |
Well, it isn't at the top of my priority list because there's very very few Thumb code in NSMB.
I will do it at some point though. First I should reorganize how existing hooks work Doing Thumb hooks could get tricky because of changing modes but it's doable |
Gericom |
Posted on 12-08-12, 03:20 pm
|
Shyguy
Karma: 160 Posts: 48/90 Since: 07-10-12 |
|
Dirbaio |
Posted on 12-09-12, 11:40 pm
|
Super Mario
( ͡° ͜ʖ ͡°) Karma: 10081 Posts: 2980/4458 Since: 06-08-11 |
New update for the template!
- Fixes "make clean" not removing everything. - Updated symbols.x - Added ram viewer to the debug screen! Use start/select to switch, and arrow keys to navigate! |