From bb27d692ff280fee1adb70de04262a24b1e5c858 Mon Sep 17 00:00:00 2001 From: Samuel Date: Tue, 4 Feb 2020 13:09:04 +0100 Subject: [PATCH] Add a -gdb option that dumps relevant sections in a gdb-friendly way $ xbe bin/default.xbe -gdb XBE Dumper 0.5-BETA Release 0x00011000 -s .rdata 0x00071000 -s .data 0x0007B000 --- main.c | 12 +++++++----- xbedump.c | 13 +++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 86a929c..3528f31 100644 --- a/main.c +++ b/main.c @@ -33,6 +33,7 @@ void usage(){ " -dc Dumps the Certificate\n" " -ds Dumps the Sections\n" " -dl Dumps the Library Sections\n\n" + " -gdb Dumps sections adresses, for use with gdb\n\n" " -vh Verifies the .xbe Header \n" " -wb Writes back the update to file out.xbe \n\n" @@ -82,11 +83,12 @@ int main (int argc, const char * argv[]) for (counter=2;counterSections - (int)header->BaseAddress); for (i = 0; i < header->NumSections; i++, sechdr++) { + if (option_flag & 0x00000100) { + char *name = ((char *)xbe)+(int)sechdr->SectionName-(int)header->BaseAddress; + if (!strcmp(name,".text")) { + printf("0x%08X ", sechdr->VirtualAddress); + }else if (!strcmp(name,".bss") || !strcmp(name,".data") || !strcmp(name,".rdata")) { + printf("-s %s 0x%08X ", name, sechdr->VirtualAddress); + } + if (i == header->NumSections-1) { + printf("\n"); + } + } + + if (option_flag & 0x00000004) { printf("\nSection Header %i\n~~~~~~~~~~~~~~~~~\n", i);