PDA

View Full Version : Research: Memory allocation system


knizz
September 14th, 2010, 05:07 AM
Game Freak removed all debug-strings from the final game except those for malloc/free. I found out that allocated blocks have this format:

0x00 / Halfword / Flag / 01 00 = used, 00 00 = unused
0x02 / Halfword / Magic-number / Always A3 A3
0x04 / Word / Idk but not a pointer, probably the size of the data
0x08 / Word / Pointer to the previous block
0x0C / Word / Pointer to the next block
0x10 / Depends / Data

knizz
October 16th, 2010, 06:30 AM
Update: I'm pretty sure that 08002B9C is "malloc", that 08002BB0 is "malloc_and_clear", and that 08002A08 is "free".

Full Metal
October 23rd, 2010, 04:15 PM
"malloc_and_clear"
so, this would be...
free(ptr);
ptr = malloc(nSize);
??

knizz
October 23rd, 2010, 10:51 PM
"malloc_and_clear"
so, this would be...
free(ptr);
ptr = malloc(nSize);
??

No. Its more like
ptr=ptr2=malloc(size);
while(size--)*ptr2++=0;
return ptr;