tatatat0
Smash Journeyman
- Joined
- Jan 28, 2015
- Messages
- 412
Decided to create a guide for this since I don't remember the last time I saw all this information in one place.
Okay so in each dat file, the first 0x20 bytes are the header, which stores information like the length of the file, where the pointer table is, and other good stuff. All the pointers in the dat file IGNORE this header, but the file size is the same. So in order to point to something in the dat file, you must take the offset you want to go to and minus 0x20. If you want to find out where the pointer is for a subaction, you search up the starting offset of the first subaction in it and minus 0x20. Alright, say I want to make a goto that goes to the beginning of bowser's jab1.
You can see that the offset is 0x4794. So minus 0x20 from that and you get 0x4774.
so the goto would look like 14 00 00 00 00 00 47 74
Now if we wanted to relocate bowser's jab1 somewhere, we would find out where the pointer is for the first subaction
First I'm gonna take out the default subaction which is
D0000003 08000007 44040000 0000009D 00007F40 AC020000 2C013005 03E80000 00000000 29990293 000C008F 2C811005 03E80000 00000000 29990293 000C008F 2D00F805 01F40000 00000000 29990293 000C008F 74000001 04000003 40000000 0800000E 74000000 08000015 5C000000
and then we look up 4774 casted to a double word(4 bytes) which is (00 00 47 74)
we find the pointer to be at 0x7FBC in the file. You can easily goto places in the file in HxD by pressing ctrl + G
I want about 40 extra bytes so I get that amount in a new file in HxD and copy it
then I go back and search for that amount of zeros in bowser's dat file
We get a bunch of zeros, but we also get them next to real numbers. Make sure to give yourself a padding! DON'T start adding subactions right after real numbers, you'll get wonky animations! In general a rule is that its HARD to tell which areas are safe! The safest option is to ADD extra data to your dat file.
So I'm gonna start my subaction at 0x7480 So I update the pointer we had earlier to point to 0x7460(00 00 74 60)
Now in our newfile we want to paste write(CTRL + B) our old subaction, and then highlight the remaining zeros and fill selection with CC000000 or the self damage subaction, so crazy hand can read it.
Paste write(CTRL+B) that at where your new subaction is gonna be, and save and load it into crazyhand
and WOW. You just relocated a subaction!
Resizing DAT Files:
Lets add some data to PlKp.dat for Bowser's jab1!
In order to resize a dat file without changing lots of pointers you need to update the filesize in the header and add extra bytes to the end of the file. MAKE SURE there is a (00 00 00 00) padding in between the extra data you add and the last original double word(4 bytes).
I want to add 200 bytes to the end of bowser's dat file. So I'm gonna Edit -> Insert Bytes -> 200 at the end of the file
Remember if I want crazy hand to recognize the data it can't be 00 00 00 00 so we are gonna fill selection with CC000000 again. MAKE SURE to leave the 1 double word padding! Since we already did this in the instructions above, I'm just gonna paste write the new subaction we made here(CTRL + B)
Now we should update the file size in the Header. This is LITERALLY the first byte in the file. For this file it is 2FD00. We are adding 0x200 so we want to update it to 0x2FF00.
Now we need to update its pointer at 0x7FBC to point to the new subaction. I decided to make it start at 0x2FD20 so we minus 0x20 from that and get 0x2FD00. We should then update the pointer at 0x7FBC to equal 0x2FD00 casted to a double word(4 bytes)
Now we can save the file, but we now have one extra set of steps to do.
We need to manually rebuild the iso to include the new dat file, if you already know how to do this, you are done. If you don't I'll explain it.
You're gonna want to open up your iso in GCR and right click on the root and export it somewhere like your desktop.
This will take a little bit. Close GCR when you are done.
When you are done you are gonna want to OVERWRITE the PlKp.dat file in the root folder you created with the PlKp.dat you made. The file names should be the same.
When you are done with that reopen GCR but don't open up your iso. Instead click Root -> Open and then browse to the root folder you created(make sure the folder you are selecting is called root)
Now click Root -> Save and choose a place to save your new iso. Finally the last step is to click Root -> Rebuild. When that is done you have probably succesfully added extra data to your dat file!
Okay so in each dat file, the first 0x20 bytes are the header, which stores information like the length of the file, where the pointer table is, and other good stuff. All the pointers in the dat file IGNORE this header, but the file size is the same. So in order to point to something in the dat file, you must take the offset you want to go to and minus 0x20. If you want to find out where the pointer is for a subaction, you search up the starting offset of the first subaction in it and minus 0x20. Alright, say I want to make a goto that goes to the beginning of bowser's jab1.
You can see that the offset is 0x4794. So minus 0x20 from that and you get 0x4774.
so the goto would look like 14 00 00 00 00 00 47 74
Now if we wanted to relocate bowser's jab1 somewhere, we would find out where the pointer is for the first subaction
First I'm gonna take out the default subaction which is
D0000003 08000007 44040000 0000009D 00007F40 AC020000 2C013005 03E80000 00000000 29990293 000C008F 2C811005 03E80000 00000000 29990293 000C008F 2D00F805 01F40000 00000000 29990293 000C008F 74000001 04000003 40000000 0800000E 74000000 08000015 5C000000
and then we look up 4774 casted to a double word(4 bytes) which is (00 00 47 74)
we find the pointer to be at 0x7FBC in the file. You can easily goto places in the file in HxD by pressing ctrl + G
I want about 40 extra bytes so I get that amount in a new file in HxD and copy it
then I go back and search for that amount of zeros in bowser's dat file
We get a bunch of zeros, but we also get them next to real numbers. Make sure to give yourself a padding! DON'T start adding subactions right after real numbers, you'll get wonky animations! In general a rule is that its HARD to tell which areas are safe! The safest option is to ADD extra data to your dat file.
So I'm gonna start my subaction at 0x7480 So I update the pointer we had earlier to point to 0x7460(00 00 74 60)
Now in our newfile we want to paste write(CTRL + B) our old subaction, and then highlight the remaining zeros and fill selection with CC000000 or the self damage subaction, so crazy hand can read it.
Paste write(CTRL+B) that at where your new subaction is gonna be, and save and load it into crazyhand
and WOW. You just relocated a subaction!
Resizing DAT Files:
Lets add some data to PlKp.dat for Bowser's jab1!
In order to resize a dat file without changing lots of pointers you need to update the filesize in the header and add extra bytes to the end of the file. MAKE SURE there is a (00 00 00 00) padding in between the extra data you add and the last original double word(4 bytes).
I want to add 200 bytes to the end of bowser's dat file. So I'm gonna Edit -> Insert Bytes -> 200 at the end of the file
Remember if I want crazy hand to recognize the data it can't be 00 00 00 00 so we are gonna fill selection with CC000000 again. MAKE SURE to leave the 1 double word padding! Since we already did this in the instructions above, I'm just gonna paste write the new subaction we made here(CTRL + B)
Now we should update the file size in the Header. This is LITERALLY the first byte in the file. For this file it is 2FD00. We are adding 0x200 so we want to update it to 0x2FF00.
Now we need to update its pointer at 0x7FBC to point to the new subaction. I decided to make it start at 0x2FD20 so we minus 0x20 from that and get 0x2FD00. We should then update the pointer at 0x7FBC to equal 0x2FD00 casted to a double word(4 bytes)
Now we can save the file, but we now have one extra set of steps to do.
We need to manually rebuild the iso to include the new dat file, if you already know how to do this, you are done. If you don't I'll explain it.
You're gonna want to open up your iso in GCR and right click on the root and export it somewhere like your desktop.
This will take a little bit. Close GCR when you are done.
When you are done you are gonna want to OVERWRITE the PlKp.dat file in the root folder you created with the PlKp.dat you made. The file names should be the same.
When you are done with that reopen GCR but don't open up your iso. Instead click Root -> Open and then browse to the root folder you created(make sure the folder you are selecting is called root)
Now click Root -> Save and choose a place to save your new iso. Finally the last step is to click Root -> Rebuild. When that is done you have probably succesfully added extra data to your dat file!
Last edited: