This commit is contained in:
Sunnyyoung 2017-03-05 03:00:34 +08:00
parent 2eb9aafccb
commit 9e45c60a81
2 changed files with 4 additions and 4 deletions

Binary file not shown.

View File

@ -5,9 +5,9 @@
__attribute__((constructor)) __attribute__((constructor))
static void initializer(void) { static void initializer(void) {
Class messageServiceClass = NSClassFromString(@"MessageService"); Class MessageServiceClass = NSClassFromString(@"MessageService");
SEL onRevokeMsgSEL = NSSelectorFromString(@"onRevokeMsg:"); SEL onRevokeMsgSEL = NSSelectorFromString(@"onRevokeMsg:");
IMP hookIMP = imp_implementationWithBlock(^(id self, id arg) { IMP onRevokeMsgIMP = imp_implementationWithBlock(^(id self, id arg) {
NSString *message = (NSString *)arg; NSString *message = (NSString *)arg;
NSRange begin = [message rangeOfString:@"<replacemsg><![CDATA["]; NSRange begin = [message rangeOfString:@"<replacemsg><![CDATA["];
NSRange end = [message rangeOfString:@"]]></replacemsg>"]; NSRange end = [message rangeOfString:@"]]></replacemsg>"];
@ -20,6 +20,6 @@ static void initializer(void) {
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification]; [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification];
}); });
}); });
Method originMethod = class_getInstanceMethod(messageServiceClass, onRevokeMsgSEL); Method onRevokeMsgMethod = class_getInstanceMethod(MessageServiceClass, onRevokeMsgSEL);
IMP originImp = class_replaceMethod(messageServiceClass, onRevokeMsgSEL, hookIMP, method_getTypeEncoding(originMethod)); class_replaceMethod(MessageServiceClass, onRevokeMsgSEL, onRevokeMsgIMP, method_getTypeEncoding(onRevokeMsgMethod));
} }