␉long flags;␊ |
␉long time;␊ |
␉struct dirstuff* moduleDir = opendir("/Extra/modules/");␊ |
␉while(readdir(moduleDir, (const char**)&name, &flags, &time) >= 0)␊ |
␉while (readdir(moduleDir, (const char**)&name, &flags, &time) >= 0)␊ |
␉{␊ |
␉␉if(strcmp(&name[strlen(name) - sizeof("dylib")], ".dylib") == 0)␊ |
␉␉if (strcmp(&name[strlen(name) - sizeof("dylib")], ".dylib") == 0)␊ |
␉␉{␊ |
␉␉␉char* tmp = malloc(strlen(name) + 1);␊ |
␉␉␉strcpy(tmp, name);␊ |
␊ |
␉␉␉if(!load_module(tmp))␊ |
␉␉␉if (!load_module(tmp))␊ |
␉␉␉{␊ |
␉␉␉␉// failed to load␊ |
␉␉␉␉// free(tmp);␊ |
|
␉␉{␊ |
␉␉␉DBG("Ignoring %s\n", name);␊ |
␉␉}␊ |
␊ |
␉}␊ |
closedir(moduleDir);␊ |
}␊ |
␊ |
␊ |
|
␉␉return 1;␊ |
␉}␊ |
␉␊ |
␉sprintf(modString, MODULE_PATH "%s", module);␊ |
␉snprintf(modString, sizeof(modString), MODULE_PATH "%s", module);␊ |
␉fh = open(modString, 0);␊ |
␉if(fh < 0)␊ |
␉{␊ |
|
*/␊ |
int replace_function(const char* symbol, void* newAddress)␊ |
{␊ |
␉UInt32* jumpPointer = malloc(sizeof(UInt32*));␉ ␊ |
␉UInt32 addr = lookup_all_symbols(symbol);␊ |
␉␊ |
␉char* binary = (char*)addr;␊ |
␉if(addr != 0xFFFFFFFF)␊ |
␉{␊ |
␉␉//DBG("Replacing %s to point to 0x%x\n", symbol, newAddress);␊ |
␉␉*binary++ = 0xFF;␉// Jump␊ |
␉␉*binary++ = 0x25;␉// Long Jump␊ |
␉␉*((UInt32*)binary) = (UInt32)jumpPointer;␊ |
␉␉␊ |
␉␉*jumpPointer = (UInt32)newAddress;␊ |
␉␉return 1;␊ |
//DBG("Replacing %s to point to 0x%x\n", symbol, newAddress);␊ |
UInt32* jumpPointer = malloc(sizeof(UInt32*));␉ ␊ |
char* binary = (char*)addr;␊ |
*binary++ = 0xFF;␉// Jump␊ |
*binary++ = 0x25;␉// Long Jump␊ |
*((UInt32*)binary) = (UInt32)jumpPointer;␊ |
*jumpPointer = (UInt32)newAddress;␊ |
return 1;␊ |
␉}␊ |
␉return 0;␊ |
}␊ |