--- /Users/thakis/src/mach_star/mach_override/mach_override.c 2011-04-11 09:35:25.000000000 -0700 +++ third_party/mach_override/mach_override.c 2011-04-12 16:21:19.000000000 -0700 @@ -145,36 +145,6 @@ #pragma mark - #pragma mark (Interface) - mach_error_t -mach_override( - char *originalFunctionSymbolName, - const char *originalFunctionLibraryNameHint, - const void *overrideFunctionAddress, - void **originalFunctionReentryIsland ) -{ - assert( originalFunctionSymbolName ); - assert( strlen( originalFunctionSymbolName ) ); - assert( overrideFunctionAddress ); - - // Lookup the original function's code pointer. - long *originalFunctionPtr; - if( originalFunctionLibraryNameHint ) - _dyld_lookup_and_bind_with_hint( - originalFunctionSymbolName, - originalFunctionLibraryNameHint, - (void*) &originalFunctionPtr, - NULL ); - else - _dyld_lookup_and_bind( - originalFunctionSymbolName, - (void*) &originalFunctionPtr, - NULL ); - - //printf ("In mach_override\n"); - return mach_override_ptr( originalFunctionPtr, overrideFunctionAddress, - originalFunctionReentryIsland ); -} - #if defined(__x86_64__) mach_error_t makeIslandExecutable(void *address) { mach_error_t err = err_none; @@ -563,8 +533,10 @@ { 0x2, {0xFF, 0xFF}, {0x89, 0xE5} }, // mov %esp,%ebp { 0x1, {0xFF}, {0x53} }, // push %ebx { 0x3, {0xFF, 0xFF, 0x00}, {0x83, 0xEC, 0x00} }, // sub 0x??, %esp + { 0x6, {0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00}, {0x81, 0xEC, 0x00, 0x00, 0x00, 0x00} }, // sub 0x??, %esp with 32bit immediate { 0x1, {0xFF}, {0x57} }, // push %edi { 0x1, {0xFF}, {0x56} }, // push %esi + { 0x2, {0xFF, 0xFF}, {0x31, 0xC0} }, // xor %eax, %eax { 0x0 } }; #elif defined(__x86_64__) @@ -584,7 +556,7 @@ { Boolean match = true; - int i; + size_t i; for (i=0; ilength; i++) { unsigned char mask = instruction->mask[i]; unsigned char constraint = instruction->constraint[i]; @@ -617,7 +589,7 @@ // See if instruction matches one we know AsmInstructionMatch* curInstr = possibleInstructions; do { - if (curInstructionKnown = codeMatchesInstruction(ptr, curInstr)) break; + if ((curInstructionKnown = codeMatchesInstruction(ptr, curInstr))) break; curInstr++; } while (curInstr->length > 0); @@ -665,10 +637,9 @@ #endif #if defined(__i386__) -asm( +__asm( ".text;" ".align 2, 0x90;" - ".globl _atomic_mov64;" "_atomic_mov64:;" " pushl %ebp;" " movl %esp, %ebp;" @@ -708,4 +679,4 @@ *targetAddress = value; } #endif -#endif \ No newline at end of file +#endif --- /Users/thakis/src/mach_star/mach_override/mach_override.h 2011-04-11 09:35:25.000000000 -0700 +++ third_party/mach_override/mach_override.h 2011-04-12 14:17:34.000000000 -0700 @@ -57,42 +57,6 @@ */ #define err_cannot_override (err_local|1) -/***************************************************************************//** - Dynamically overrides the function implementation referenced by - originalFunctionSymbolName with the implentation pointed to by - overrideFunctionAddress. Optionally returns a pointer to a "reentry island" - which, if jumped to, will resume the original implementation. - - @param originalFunctionSymbolName -> Required symbol name of the - function to override (with - overrideFunctionAddress). - Remember, C function name - symbols are prepended with an - underscore. - @param originalFunctionLibraryNameHint -> Optional name of the library - which contains - originalFunctionSymbolName. Can - be NULL, but this may result in - the wrong function being - overridden and/or a crash. - @param overrideFunctionAddress -> Required address to the - overriding function. - @param originalFunctionReentryIsland <- Optional pointer to pointer to - the reentry island. Can be NULL. - @result <- err_cannot_override if the - original function's - implementation begins with the - 'mfctr' instruction. - - ***************************************************************************/ - - mach_error_t -mach_override( - char *originalFunctionSymbolName, - const char *originalFunctionLibraryNameHint, - const void *overrideFunctionAddress, - void **originalFunctionReentryIsland ); - /************************************************************************************//** Dynamically overrides the function implementation referenced by originalFunctionAddress with the implentation pointed to by overrideFunctionAddress. @@ -154,4 +118,4 @@ #ifdef __cplusplus } #endif -#endif // _mach_override_ \ No newline at end of file +#endif // _mach_override_