Chameleon

Chameleon Commit Details

Date:2012-10-28 21:15:08 (11 years 5 months ago)
Author:Evan Lojewski
Commit:2101
Parents: 2100
Message:Update kernel patcher's section handler to pass 64bit addresses.
Changes:
M/trunk/i386/boot2/modules.c
M/trunk/i386/boot2/modules.h

File differences

trunk/i386/boot2/modules.c
2323
2424
2525
26
27
26
27
2828
2929
3030
......
307307
308308
309309
310
310
311311
312312
313313
......
342342
343343
344344
345
345
346346
347347
348348
349349
350350
351351
352
353352
354353
355354
......
392391
393392
394393
395
394
396395
397
398
399
396
400397
401398
402399
......
420417
421418
422419
423
424
425
420
421
426422
427423
428424
#endif
// NOTE: Global so that modules can link with this
UInt64 textAddress = 0;
UInt64 textSection = 0;
static UInt64 textAddress = 0;
static UInt64 textSection = 0;
/** Internal symbols, however there are accessor methods **/
moduleHook_t* moduleCallbacks = NULL;
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 cmd, long long offset, long long address)
void (*section_handler)(char* section, char* segment, void* cmd, UInt64 offset, UInt64 address)
)
{
char is64 = false;
}
else if(((struct mach_header_64*)binary)->magic == MH_MAGIC_64)
{
// NOTE: modules cannot be 64bit...
// NOTE: modules cannot be 64bit. This is used to parse the kernel and kexts
is64 = true;
binaryIndex += sizeof(struct mach_header_64);
}
else
{
verbose("Invalid mach magic 0x%X\n", ((struct mach_header*)binary)->magic);
//getchar();
return NULL;
}
sectionIndex += sizeof(struct section);
if(section_handler) section_handler(sect->sectname, segCommand->segname, (long long)sect, sect->offset, sect->addr);
if(section_handler) section_handler(sect->sectname, segCommand->segname, (void*)sect, sect->offset, sect->addr);
if((strcmp("__TEXT", segCommand->segname) == 0) && (strcmp("__text", sect->sectname) == 0))
if((strcmp("__TEXT", segCommand->segname) == 0) && (strcmp("__text", sect->sectname) == 0))
{
// __TEXT,__text found, save the offset and address for when looking for the calls.
textSection = sect->offset;
sectionIndex += sizeof(struct section_64);
if(section_handler) section_handler(sect->sectname, segCommand64->segname, (long long)sect, sect->offset, sect->addr);
if(section_handler) section_handler(sect->sectname, segCommand64->segname, (void*)sect, sect->offset, sect->addr);
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.
trunk/i386/boot2/modules.h
2121
2222
2323
24
25
2624
2725
2826
......
9088
9189
9290
93
91
9492
9593
9694
#define SYMBOLS_COMPAT 0
#define VOID_SYMBOL"dyld_void_start"
extern UInt64 textAddress;
extern UInt64 textSection;
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 cmd, long long offset, long long address)
void (*section_handler)(char* section, char* segment, void* cmd, UInt64 offset, UInt64 address)
);
unsigned inthandle_symtable(UInt32 base,
struct symtab_command* symtabCommand,

Archive Download the corresponding diff file

Revision: 2101