gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > GBA Dissasembly!

#12667 - Telerode - Fri Nov 21, 2003 6:28 pm

Is it possible to dissasemble or decompile .gba format rom's into C++ source code. I have only found refrences for QdisAss which seems to no longer exist. Can anyone help me out?

#12668 - tepples - Fri Nov 21, 2003 6:37 pm

It's straightforward to disassemble a ROM into assembly language, but what you get may not be easily comprehensible.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#12669 - torne - Fri Nov 21, 2003 10:07 pm

You'll have tremendous, almost insurmountable problems trying to disassemble a ROM image. All section info, most importantly, anything to indicate which chunks of data are code and which are data (and also which bits are ARM and which are Thumb) has been discarded by the process of making an image.

Even disassembling it to assembly source is nontrivial; you can get binutils to dump the actual bytes and their disassembly for you, but that doesn't tell you whether the bit you are looking at is really code, or just data, as most 32-bit values are valid ARM instructions, and almost all 16-bit values are valid Thumb instructions. Just possibly not sensible ones.

If you're trying to modify a rom to introduce a trainer or something, I suggest you use a debugger rather than trying to just disassemble it; the debugger can help you to infer the section boundaries and will show you clearly where different values are stored, if you know what to look for. =)

You have no chance whatsoever of being able to decompile a ROM to C/C++ source code, btw. It's a pretty hard task for an ELF binary with debugging information, let alone a ROM image.

#12672 - Telerode - Fri Nov 21, 2003 11:00 pm

Alright, that sounds encouraging enough. I am really looking to poke around in a couple of my favorite games to see what makes them tick, i.e. rpg interface's and battle systems. From what you are saying I am better off trying to fine pre-compiled roms somewhere, yeah right.

#12673 - tepples - Fri Nov 21, 2003 11:48 pm

torne wrote:
You'll have tremendous, almost insurmountable problems trying to disassemble a ROM image. All section info, most importantly, anything to indicate which chunks of data are code and which are data (and also which bits are ARM and which are Thumb) has been discarded by the process of making an image.

Not entirely discarded. A tracing emulator can mark any byte accessed through an instruction pull as definitely code, anything DMA'd to VRAM or the audio FIFOs or accessed by BIOS decompression as definitely data, anything loaded with 'ldrb' or 'ldrsb' as data, anything loaded and immediately arithmetized as data, anything DMA'd to IWRAM that looks like ARM instructions as probably code, and the rest as unknown. Of course, because this would greatly slow the emulation, this tracing feature would have to be performed with a special emulator build not designed for casual testing of ROMs.

Quote:
If you're trying to modify a rom to introduce a trainer or something, I suggest you use a debugger rather than trying to just disassemble it; the debugger can help you to infer the section boundaries and will show you clearly where different values are stored, if you know what to look for. =)

That's a bit like what I explain here, but perhaps more useful in the case of adding a trainer. Anyone up for a project to integrate a debugging emulator with a disassembler?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#12678 - torne - Sat Nov 22, 2003 4:28 am

No trace really gives it all back, though; having used gdb/gprof on GBA roms the coverage is pretty lame; it's absurdly hard to get to half the bytes. =)

A tool capable of automatically marking up a disassembly would be nice. Well, if you wait for, like, six months, maybe I'll write one (as a gdb client) with the engine from my high-level assembler.

#12697 - gb_feedback - Sun Nov 23, 2003 9:44 am

I'm not sure if anyone has seen this? http://www.datarescue.com/idabase/overview.htm It's not cheap though and it's still very hard work to disassemble a GBA ROM.
_________________
http://www.bookreader.co.uk/

#12701 - torne - Sun Nov 23, 2003 4:14 pm

I never got on very well with IDA. gdb and my brain work ok. =)

#12763 - Telerode - Tue Nov 25, 2003 11:13 pm

Well, I managed to procure a copy of IDA from a friend of mine, it is in the mail. Hopefully I will be able to grasp the concepts behind dissasembly.