#174860 - Dirbaio - Mon Jul 26, 2010 4:13 pm
So, basically I want to replace libc's malloc and free functions with mine.
(I'm using latest devkitpro and libnds)
I've had no success no far.
Googling around i got these two solutions, which i tried without success:
"Malloc hooks": They don't seem to exist in DevkitARM...
Redefining malloc/free and making them link before the lib ones: Works for my code, but other parts of libc (printf-related) call weird functions called _malloc_r or _free_r which i guess are part of the internal logic for malloc and free... I'm not catching those calls, so it doesnt work...
BTW, you're probably asking why in the world I want that. I want it for two different things:
- For debugging: I have weird memory corruption issues :(
- For ROM Hacking (in particular NSMB Hacking): I've set up some linker scripts that allow me to write some asm/c/c++ code and insert it into the game. I need malloc/free to call the actuall malloc/free from the game, or i can't use dynamic memory, libc, libfat and lots of cool things i'd like to use...
What would you suggest? Ive read blogs of people that have mentioned that they have done it, so it must be possible ...
Thanks in advance!
(I'm using latest devkitpro and libnds)
I've had no success no far.
Googling around i got these two solutions, which i tried without success:
"Malloc hooks": They don't seem to exist in DevkitARM...
Redefining malloc/free and making them link before the lib ones: Works for my code, but other parts of libc (printf-related) call weird functions called _malloc_r or _free_r which i guess are part of the internal logic for malloc and free... I'm not catching those calls, so it doesnt work...
BTW, you're probably asking why in the world I want that. I want it for two different things:
- For debugging: I have weird memory corruption issues :(
- For ROM Hacking (in particular NSMB Hacking): I've set up some linker scripts that allow me to write some asm/c/c++ code and insert it into the game. I need malloc/free to call the actuall malloc/free from the game, or i can't use dynamic memory, libc, libfat and lots of cool things i'd like to use...
What would you suggest? Ive read blogs of people that have mentioned that they have done it, so it must be possible ...
Thanks in advance!