hetima / HTSymbolHook

Objective-C wrapper of mach_override

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTSymbolHook

HTSymbolHook is Objective-C wrapper of mach_override.
In addítion, It can override symbol by name (even non-exported!).

#Usage Tested on OS X 10.8.5 64bit with ARC.

Symbol name must contain underscore prefix. So use entire name by nm output. (e.g. specify @"_NSClassFromString" not @"NSClassFromString")

HTSymbolHook* hook=[HTSymbolHook symbolHookWithImageNameSuffix:@"/FrameworkName"];
[hook overrideSymbol:@"_symbol_name"
    withPtr:(void*)replace_function
    reentryIsland:(void**)&original_function];

If you check symbol index in advance,

UInt32 correctIndex=[hook indexOfSymbol:@"_symbol_name"];

Then It can be used as needle for speed.

UInt32 seekStartIndex=12345-20;
[hook overrideSymbol:@"_symbol_name"
    withPtr:(void*)replace_function
    reentryIsland:(void**)&original_function
    symbolIndexHint:seekStartIndex];

Author

http://hetima.com/
https://twitter.com/hetima

License

HTSymbolHook
MIT License. Copyright (c) 2013 hetima.

mach_override
(c) 2003-2012 Jonathan 'Wolf' Rentzsch

About

Objective-C wrapper of mach_override


Languages

Language:C 97.2%Language:Objective-C 2.4%Language:C++ 0.3%Language:Ruby 0.1%