0

With CydiaSubstrate we could easily hook the methods as below, but I want to know how can I uninstall the hooking and revert the implementation to original one? Thank you!

static IMP original_UIView_setFrame_;
void replaced_UIView_setFrame_(UIView* self, SEL _cmd, CGRect frame) {  // Note the implicit self and _cmd parameters are needed explicitly here.
  CGRect originalFrame = self.frame;
  NSLog("Changing frame of %p from %@ to %@", self, NSStringFromCGRect(originalFrame), NSStringFromCGRect(frame));
  original_UIView_setFrame_(self, _cmd, frame);    // Remember to pass self and _cmd.
}
...
MSHookMessageEx([UIView class], @selector(setFrame:), (IMP)replaced_UIView_setFrame_, (IMP *)&original_UIView_setFrame_);
Suge
  • 2,808
  • 3
  • 48
  • 79

1 Answers1

1

You just need to exchange the implementations again, i.e. just call the following a second time:

MSHookMessageEx([UIView class], @selector(setFrame:), (IMP)replaced_UIView_setFrame_, (IMP *)&original_UIView_setFrame_);

When you exchange the implementations you are swapping them around, so by swapping them again you get back to the originals.

hypercrypt
  • 15,389
  • 6
  • 48
  • 59
  • Oh, thank you very much, that's really simple and clear.The way is very unexpected ^^ – Suge Feb 11 '15 at 12:17