Last active
March 12, 2018 21:17
-
-
Save NSExceptional/f0ee69846eca8617609afc590aba58b0 to your computer and use it in GitHub Desktop.
Demonstrates how to hook methods with MSHookFunction.
This file contains hidden or 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
// Typical tweak | |
%hook UIView | |
- (UIColor *)backgroundColor { | |
return [UIColor blackColor]; | |
} | |
%end | |
// Hook using MSHookFunction | |
// return type method name arguments ... | |
MSHook(UIColor *, backgroundColor, id self, SEL _cmd) { | |
return [UIColor blackColor]; | |
} | |
%ctor { | |
void *backgroundColorImp = (void *)class_getMethodImplementation([UIView class], @selector(backgroundColor)); | |
MSHookFunction(backgroundColorImp, MSHake(backgroundColorImp)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment