Chameleon

Chameleon Commit Details

Date:2012-10-28 06:18:34 (6 years 8 months ago)
Author:Evan Lojewski
Commit:2099
Parents: 2098
Message:Fix macho parser to handle 64bit segment commands properly. pass section address to section_handler.
Changes:
M/trunk/i386/boot2/modules.c
M/trunk/i386/boot2/modules.h

File differences

trunk/i386/boot2/modules.c
307307
308308
309309
310
310
311311
312312
313313
......
392392
393393
394394
395
395
396396
397397
398398
......
420420
421421
422422
423
423
424424
425425
426
426
427427
428428
429429
void* parse_mach(void* binary,
int(*dylib_loader)(char*),
long long(*symbol_handler)(char*, long long, char),
void (*section_handler)(char* section, char* segment, long long offset, long long address)
void (*section_handler)(char* section, char* segment, long long cmd, long long offset, long long address)
)
{
char is64 = false;
sectionIndex += sizeof(struct section);
if(section_handler) section_handler(sect->sectname, segCommand->segname, sect->offset, sect->addr);
if(section_handler) section_handler(sect->sectname, segCommand->segname, (long long)sect, sect->offset, sect->addr);
sectionIndex += sizeof(struct section_64);
if(section_handler) section_handler(sect->sectname, segCommand->segname, sect->offset, sect->addr);
if(section_handler) section_handler(sect->sectname, segCommand64->segname, (long long)sect, sect->offset, sect->addr);
if((strcmp("__TEXT", segCommand->segname) == 0) && (strcmp("__text", sect->sectname) == 0))
if((strcmp("__TEXT", segCommand64->segname) == 0) && (strcmp("__text", sect->sectname) == 0))
{
// __TEXT,__text found, save the offset and address for when looking for the calls.
textSection = sect->offset;
trunk/i386/boot2/modules.h
9090
9191
9292
93
93
9494
9595
9696
void*parse_mach(void* binary,
int(*dylib_loader)(char*),
long long(*symbol_handler)(char*, long long, char),
void (*section_handler)(char* section, char* segment, long long offset, long long address)
void (*section_handler)(char* section, char* segment, long long cmd, long long offset, long long address)
);
unsigned inthandle_symtable(UInt32 base,
struct symtab_command* symtabCommand,

Archive Download the corresponding diff file

Revision: 2099