WiiRd forum

Wii & Gamecube Hacking => Wii Game hacking help => Topic started by: Deathwolf on August 01, 2010, 10:35:02 PM

Title: D2 pointer codetype
Post by: Deathwolf on August 01, 2010, 10:35:02 PM
how to use a ASM D2 pointer?
atm I have no pointers but I will write one with 04 codetype.
example on this code:

04123456 80012A14

my asm instruction:
lis r14,0x0000
ori r14,r14,0x0000
stw r14,40(r4)
lwz r5,40(r4)


assembly:
C2012A14 00000003
3DC00000 61CE0000
91C40028 80A40028
60000000 00000000

so I should write:
04123456 80012A14
D2123456 00000003
3DC00000 61CE0000
91C40028 80A40028
60000000 00000000

is it right?
thanks...




Title: Re: D2 pointer codetype
Post by: wiiztec on August 01, 2010, 10:57:56 PM
You need an address range check
Title: Re: D2 pointer codetype
Post by: Deathwolf on August 01, 2010, 11:00:36 PM
DE000000 80008180?
please explain
Title: Re: D2 pointer codetype
Post by: wiiztec on August 01, 2010, 11:14:55 PM
Yes if your pointer is expected to fall into that range, you would need that between the 48 and D2
Title: Re: D2 pointer codetype
Post by: Deathwolf on August 01, 2010, 11:17:26 PM
so I can't write only D2?

how should I write it now?

04123456 80012A14

D2XXXXXX 00000003
3DC00000 61CE0000
91C40028 80A40028
60000000 00000000
Title: Re: D2 pointer codetype
Post by: wiiztec on August 01, 2010, 11:44:03 PM
You can but it will be the same as C2 since both the ba & po default to 80000000
Title: Re: D2 pointer codetype
Post by: Deathwolf on August 01, 2010, 11:52:24 PM
oh okay but is my code right?

04123456 80012A14
D2123456 00000003
3DC00000 61CE0000
91C40028 80A40028
60000000 00000000
Title: Re: D2 pointer codetype
Post by: wiiztec on August 02, 2010, 12:20:13 AM
No if you intend to use a pointer then you need an address range check if you don't then it's the same as a normal C2 code & I have no idea what your 04 line is for
Title: Re: D2 pointer codetype
Post by: Deathwolf on August 02, 2010, 12:27:29 AM
I said that I have atm no pointer but I want to use D2.
so I write one.

04123456 80012A14 <-- my new pointer

it points to my hook address.

04123456 80012A14
D2123456 00000003
3DC00000 61CE0000
91C40028 80A40028
60000000 00000000

but how to include now a range check?
I know it's the same like C2.
Title: Re: D2 pointer codetype
Post by: wiiztec on August 02, 2010, 03:15:56 AM
If the po is known and invarible then an address range check is not needed

and that code would write your ASM to 80123456 which isn't valid btw since it starts in the middle of a word
Title: Re: D2 pointer codetype
Post by: Deathwolf on August 02, 2010, 12:21:07 PM
the code should take me to 80012A14.
that's my problem. I don't know how to write.
isn't D2 codetype reading the pointer value at the address?

04123456 80012A14 <-- write pointer (80012A14) to a free address (80123456)

D2123456 00000003 <-- D2 read the pointer value (80012A14) at the address (80123456)
3DC00000 61CE0000
91C40028 80A40028
60000000 00000000
Title: Re: D2 pointer codetype
Post by: wiiztec on August 02, 2010, 12:52:10 PM
No D2 applies an offset to the pointer, the only thing that loads a value at an address into the pointer is 48
Title: Re: D2 pointer codetype
Post by: Deathwolf on August 02, 2010, 12:54:27 PM
so that is it?

D2012A14 00000003
3DC00000 61CE0000
91C40028 80A40028
60000000 00000000
Title: Re: D2 pointer codetype
Post by: hetoan2 on August 02, 2010, 01:34:05 PM
my asm instruction:
lis r14,0x0000
ori r14,r14,0x0000 <- not needed
stw r14,40(r4)
lwz r5,40(r4)

your code should be:

D2012A14 00000003
3DC00000 91C40028
80A40028 60000000
Title: Re: D2 pointer codetype
Post by: Deathwolf on August 02, 2010, 01:36:07 PM
oh okay, thank you guys :)
Title: Re: D2 pointer codetype
Post by: wiiztec on August 02, 2010, 02:51:58 PM
Actually it needs to end with a single 00000000 so it would be

D2012A14 00000003
3DC00000 91C40028
80A40028 00000000
Title: Re: D2 pointer codetype
Post by: Deathwolf on August 02, 2010, 02:53:59 PM
yep, 4 instructions needs to end with 60000000