mirror of
https://github.com/Sunnyyoung/WeChatTweak-macOS.git
synced 2025-05-23 23:06:08 +08:00
Add tweak for multiple instance
This commit is contained in:
parent
9e45c60a81
commit
0ec8de7b53
1
Makefile
1
Makefile
|
@ -5,6 +5,7 @@ build::
|
||||||
clang -dynamiclib ./WeChatTweak.m -fobjc-link-runtime -current_version 1.0 -compatibility_version 1.0 -o ./${DYLIBFILE}
|
clang -dynamiclib ./WeChatTweak.m -fobjc-link-runtime -current_version 1.0 -compatibility_version 1.0 -o ./${DYLIBFILE}
|
||||||
|
|
||||||
debug::
|
debug::
|
||||||
|
make clean
|
||||||
make build
|
make build
|
||||||
DYLD_INSERT_LIBRARIES=./${DYLIBFILE} ${WECHATPATH}/WeChat &
|
DYLD_INSERT_LIBRARIES=./${DYLIBFILE} ${WECHATPATH}/WeChat &
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -3,12 +3,12 @@
|
||||||
#import <objc/message.h>
|
#import <objc/message.h>
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
__attribute__((constructor))
|
// Tweak for no revoke message.
|
||||||
static void initializer(void) {
|
__attribute__((constructor(101))) static void noRevokeTweak(void) {
|
||||||
Class MessageServiceClass = NSClassFromString(@"MessageService");
|
Class class = NSClassFromString(@"MessageService");
|
||||||
SEL onRevokeMsgSEL = NSSelectorFromString(@"onRevokeMsg:");
|
SEL selector = NSSelectorFromString(@"onRevokeMsg:");
|
||||||
IMP onRevokeMsgIMP = imp_implementationWithBlock(^(id self, id arg) {
|
Method method = class_getInstanceMethod(class, selector);
|
||||||
NSString *message = (NSString *)arg;
|
IMP imp = imp_implementationWithBlock(^(id self, NSString *message) {
|
||||||
NSRange begin = [message rangeOfString:@"<replacemsg><![CDATA["];
|
NSRange begin = [message rangeOfString:@"<replacemsg><![CDATA["];
|
||||||
NSRange end = [message rangeOfString:@"]]></replacemsg>"];
|
NSRange end = [message rangeOfString:@"]]></replacemsg>"];
|
||||||
NSRange subRange = NSMakeRange(begin.location + begin.length,end.location - begin.location - begin.length);
|
NSRange subRange = NSMakeRange(begin.location + begin.length,end.location - begin.location - begin.length);
|
||||||
|
@ -20,6 +20,16 @@ static void initializer(void) {
|
||||||
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification];
|
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification];
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Method onRevokeMsgMethod = class_getInstanceMethod(MessageServiceClass, onRevokeMsgSEL);
|
class_replaceMethod(class, selector, imp, method_getTypeEncoding(method));
|
||||||
class_replaceMethod(MessageServiceClass, onRevokeMsgSEL, onRevokeMsgIMP, method_getTypeEncoding(onRevokeMsgMethod));
|
}
|
||||||
|
|
||||||
|
// Tweak for multiple instance.
|
||||||
|
__attribute__((constructor(102))) static void multipleInstanceTweak(void) {
|
||||||
|
Class class = object_getClass(NSClassFromString(@"CUtility"));
|
||||||
|
SEL selector = NSSelectorFromString(@"HasWechatInstance");
|
||||||
|
Method method = class_getInstanceMethod(class, selector);
|
||||||
|
IMP imp = imp_implementationWithBlock(^(id self) {
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
class_replaceMethod(class, selector, imp, method_getTypeEncoding(method));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user