This commit is contained in:
Sunnyyoung
2022-02-01 19:35:43 +08:00
parent 3f3ec79543
commit d3e6823f86
4 changed files with 5 additions and 57 deletions
+5 -5
View File
@@ -7,7 +7,6 @@
//
#import "WeChatTweak.h"
#import "NSString+WeChatTweak.h"
#import "NSBundle+WeChatTweak.h"
@implementation NSObject (AntiRevoke)
@@ -28,11 +27,12 @@ static void __attribute__((constructor)) tweak(void) {
return [self tweak_FFToNameFavChatZZ:message sessionMsgList:sessionMsgList];
}
// Decode message
NSString *session = [message.msgContent tweak_subStringFrom:@"<session>" to:@"</session>"];
NSUInteger newMessageID = [message.msgContent tweak_subStringFrom:@"<newmsgid>" to:@"</newmsgid>"].longLongValue;
NSString *replaceMessage = [message.msgContent tweak_subStringFrom:@"<replacemsg><![CDATA[" to:@"]]></replacemsg>"];
NSDictionary *dictionary = [NSDictionary dictionaryWithXMLString:message.msgContent];
NSString *session = dictionary[@"revokemsg"][@"session"];
NSString *newMessageID = dictionary[@"revokemsg"][@"newmsgid"];
NSString *replaceMessage = dictionary[@"revokemsg"][@"replacemsg"];
// Get message data
MessageData *messageData = ((id (*)(id, SEL, id, unsigned long long))objc_msgSend)(self, GetMsgDataSelector, session, newMessageID);
MessageData *messageData = ((id (*)(id, SEL, id, unsigned long long))objc_msgSend)(self, GetMsgDataSelector, session, newMessageID.longLongValue);
if (messageData.isSendFromSelf) {
// Fallback to origin method
[self tweak_FFToNameFavChatZZ:message sessionMsgList:sessionMsgList];
@@ -1,15 +0,0 @@
//
// NSString+WeChatTweak.h
// WeChatTweak
//
// Created by Sunnyyoung on 2017/8/12.
// Copyright © 2017年 Sunnyyoung. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface NSString (WeChatTweak)
- (NSString *)tweak_subStringFrom:(NSString *)beginString to:(NSString *)endString;
@end
@@ -1,29 +0,0 @@
//
// NSString+WeChatTweak.m
// WeChatTweak
//
// Created by Sunnyyoung on 2017/8/12.
// Copyright © 2017年 Sunnyyoung. All rights reserved.
//
#import "NSString+WeChatTweak.h"
@implementation NSString (WeChatTweak)
- (NSString *)tweak_subStringFrom:(NSString *)beginString to:(NSString *)endString {
NSRange begin = [self rangeOfString:beginString];
if (begin.location == NSNotFound) {
return nil;
}
NSRange end = [self rangeOfString:endString];
if (end.location == NSNotFound) {
return nil;
}
NSRange range = NSMakeRange(begin.location + begin.length, end.location - begin.location - begin.length);
if (range.location == NSNotFound) {
return nil;
}
return [self substringWithRange:range];
}
@end