Created
March 5, 2014 15:36
-
-
Save samdmarshall/9369619 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define DYLD_INTERPOSE(_replacement,_replacee) \ | |
__attribute__((used)) static struct{ const void* replacement; const void* replacee; } _interpose_##_replacee \ | |
__attribute__ ((section ("__DATA,__interpose"))) = { (const void*)(unsigned long)&_replacement, (const void*)(unsigned long)&_replacee }; | |
DYLD_INTERPOSE(my_function_replacement, original_function); | |
int original_function() { | |
return 5; | |
} | |
int my_function_replacement() { | |
int result = original_function(); | |
printf("%i\n",result); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment