/*␊ |
* Copyright 2009 Evan Lojewski. All rights reserved.␊ |
* Copyright 2010 Evan Lojewski. All rights reserved.␊ |
*␊ |
*/␊ |
␊ |
|
␉char* nonlazy = NULL;␊ |
␉//char* nonlazy_variables = NULL;␊ |
␊ |
␉// TODO convert all of the structs a union␊ |
␉// TODO convert all of the structs to a union␊ |
␉struct load_command *loadCommand = NULL;␊ |
␉struct dylib_command* dylibCommand = NULL;␊ |
␉struct dyld_info_command* dyldInfoCommand = NULL;␊ |
|
␉␉␉␉section = binary + binaryIndex + sizeof(struct segment_command);␊ |
␉␉␉␉while(sections)␊ |
␉␉␉␉{␊ |
␉␉␉␉␉// Look for the __symbol_stub section␊ |
␉␉␉␉␉// Look for some sections and save the addresses␊ |
␉␉␉␉␉if(strcmp(section->sectname, SECT_NON_LAZY_SYMBOL_PTR) == 0)␊ |
␉␉␉␉␉{␊ |
␉␉␉␉␉␉/*printf("\tSection non lazy pointers at 0x%X, %d symbols\n",␊ |
|
␉␉␉␉␊ |
␉␉␉case LC_LOAD_DYLIB:␊ |
␉␉␉case LC_LOAD_WEAK_DYLIB ^ LC_REQ_DYLD:␊ |
␉␉␉␉dylibCommand = binary + binaryIndex;␊ |
␉␉␉␉dylibCommand = binary + binaryIndex;␊ |
␉␉␉␉char* module = binary + binaryIndex + ((UInt32)*((UInt32*)&dylibCommand->dylib.name));␊ |
␉␉␉␉// =␉dylibCommand->dylib.current_version;␊ |
␉␉␉␉// =␉dylibCommand->dylib.compatibility_version;␊ |
|
␊ |
␉␊ |
␊ |
␉␊ |
␉// To satisfy cicular deps, the module_loaded command shoudl be run before the module init();␊ |
␉// Notify the system that it was laoded␊ |
␉module_loaded(moduleName, moduleVersion, moduleCompat);␊ |
␉␊ |
␉return module_start;␊ |
|
unsigned int lookup_all_symbols(const char* name)␊ |
{␊ |
␉unsigned int addr = 0xFFFFFFFF;␊ |
␉if(lookup_symbol)␊ |
␉if(lookup_symbol && lookup_symbol != 0xFFFFFFFF)␊ |
␉{␊ |
␉␉addr = lookup_symbol(name);␊ |
␉␉if(addr != 0xFFFFFFFF)␊ |