diff --git a/Makefile b/Makefile index 7dce04a..d49a672 100644 --- a/Makefile +++ b/Makefile @@ -22,11 +22,15 @@ install:: echo "Can not find the dylib file, please build first.";\ exit 1;\ fi - - @cp ${WECHATPATH}/WeChat ${WECHATPATH}/WeChat.bak; - @cp ./${DYLIBFILE} ${WECHATPATH}/${DYLIBFILE}; - @./insert_dylib @executable_path/${DYLIBFILE} ${WECHATPATH}/WeChat ${WECHATPATH}/WeChat --all-yes; - @echo "Install successed!"; + @if [ -f "${WECHATPATH}/${DYLIBFILE}" ]; then\ + cp ./${DYLIBFILE} ${WECHATPATH}/${DYLIBFILE};\ + echo "Tweak file found! Replace with new tweak file successed!";\ + else \ + cp ${WECHATPATH}/WeChat ${WECHATPATH}/WeChat.bak;\ + cp ./${DYLIBFILE} ${WECHATPATH}/${DYLIBFILE};\ + ./insert_dylib @executable_path/${DYLIBFILE} ${WECHATPATH}/WeChat ${WECHATPATH}/WeChat --all-yes;\ + echo "Install successed!";\ + fi uninstall:: @if ! [[ $EUID -eq 0 ]]; then\ diff --git a/README-Chinese.md b/README-Chinese.md index 8c4e06e..032a7b0 100644 --- a/README-Chinese.md +++ b/README-Chinese.md @@ -9,8 +9,6 @@ ## 截图 ![](Screenshot/0x01.png) -![](Screenshot/0x02.png) -![](Screenshot/0x03.png) ## 功能 @@ -19,13 +17,13 @@ - 系统通知 - 正常撤回自己发出的消息 - 客户端无限多开 - - 右键 Dock Icon 登录新的微信账号 + - 右键 dock icon 登录新的微信账号 - 命令行执行:`open -n /Applications/WeChat.app` - 重新打开应用无需手机认证 ## 使用 -- `sudo make install` 安装动态库 +- `sudo make install` 安装或者更新动态库 - `sudo make uninstall` 卸载动态库 ## 开发调试 @@ -43,6 +41,11 @@ - [JRSwizzle](https://github.com/rentzsch/jrswizzle) - [insert_dylib](https://github.com/Tyilo/insert_dylib) +## 参考 + +- [微信 macOS 客户端无限多开功能实践](https://blog.sunnyyoung.net/wei-xin-macos-ke-hu-duan-wu-xian-duo-kai-gong-neng-shi-jian/) +- [微信 macOS 客户端拦截撤回功能实践](https://blog.sunnyyoung.net/wei-xin-macos-ke-hu-duan-lan-jie-che-hui-gong-neng-shi-jian/) + ## License The [MIT License](LICENSE). diff --git a/README.md b/README.md index ee708e3..3bcacef 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,6 @@ A dynamic library tweak for WeChat macOS. ## Screenshot ![](Screenshot/0x01.png) -![](Screenshot/0x02.png) -![](Screenshot/0x03.png) ## Feature @@ -19,13 +17,13 @@ A dynamic library tweak for WeChat macOS. - System notification - Revoke message you sent - Multiple WeChat Instance - - Right click on the Dock icon to login another WeChat account + - Right click on the dock icon to login another WeChat account - Run command: `open -n /Applications/WeChat.app` - Auto login without authentication ## Usage -- `sudo make install` Inject the dylib +- `sudo make install` Install or Updrade the dylib - `sudo make uninstall` Uninstall the dylib ## Development @@ -43,6 +41,11 @@ Run `xcode-select --install` to install Command Line Tools - [JRSwizzle](https://github.com/rentzsch/jrswizzle) - [insert_dylib](https://github.com/Tyilo/insert_dylib) +## Reference + +- [微信 macOS 客户端无限多开功能实践](https://blog.sunnyyoung.net/wei-xin-macos-ke-hu-duan-wu-xian-duo-kai-gong-neng-shi-jian/) +- [微信 macOS 客户端拦截撤回功能实践](https://blog.sunnyyoung.net/wei-xin-macos-ke-hu-duan-lan-jie-che-hui-gong-neng-shi-jian/) + ## License The [MIT License](LICENSE). diff --git a/Screenshot/0x01.png b/Screenshot/0x01.png index 02d823e..e81ea49 100644 Binary files a/Screenshot/0x01.png and b/Screenshot/0x01.png differ diff --git a/Screenshot/0x02.png b/Screenshot/0x02.png deleted file mode 100644 index 552d84c..0000000 Binary files a/Screenshot/0x02.png and /dev/null differ diff --git a/Screenshot/0x03.png b/Screenshot/0x03.png deleted file mode 100644 index c650cfa..0000000 Binary files a/Screenshot/0x03.png and /dev/null differ diff --git a/WeChatTweak.dylib b/WeChatTweak.dylib index 0bac113..a612b4f 100755 Binary files a/WeChatTweak.dylib and b/WeChatTweak.dylib differ diff --git a/WeChatTweak.m b/WeChatTweak.m index a25ce5d..83e0fcf 100755 --- a/WeChatTweak.m +++ b/WeChatTweak.m @@ -82,7 +82,7 @@ static void __attribute__((constructor)) tweak(void) { // Dispatch notification dispatch_async(dispatch_get_main_queue(), ^{ - // Delete message if is revoke from myself + // Delete message if it is revoke from myself if ([localMessageData isSendFromSelf]) { [((MessageService *)self) DelMsg:session msgList:@[localMessageData] isDelAll:NO isManual:YES]; [((MessageService *)self) AddRevokePromptMsg:session msgData: promptMessageData]; @@ -108,7 +108,7 @@ static void __attribute__((constructor)) tweak(void) { } - (void)openNewWeChatInstace:(id)sender { - NSString *applicationPath = [[objc_getClass("NSBundle") mainBundle] bundlePath]; + NSString *applicationPath = [[NSBundle mainBundle] bundlePath]; NSTask *task = [[objc_getClass("NSTask") alloc] init]; task.launchPath = @"/usr/bin/open"; task.arguments = @[@"-n", applicationPath]; @@ -119,19 +119,16 @@ static void __attribute__((constructor)) tweak(void) { - (void)tweak_applicationDidFinishLaunching:(NSNotification *)notification { [self tweak_applicationDidFinishLaunching:notification]; - NSBundle *bundle = [objc_getClass("NSBundle") mainBundle]; - NSString *bundleIdentifier = [bundle bundleIdentifier]; + NSString *bundleIdentifier = [[objc_getClass("NSBundle") mainBundle] bundleIdentifier]; NSArray *instances = [objc_getClass("NSRunningApplication") runningApplicationsWithBundleIdentifier:bundleIdentifier]; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wobjc-method-access" + // Detect multiple instance conflict if (instances.count == 1) { - id serviceCenter = [objc_getClass("MMServiceCenter") defaultCenter]; - id accountService = [serviceCenter getService:objc_getClass("AccountService")]; + AccountService *accountService = [[objc_getClass("MMServiceCenter") defaultCenter] getService:objc_getClass("AccountService")]; if ([accountService canAutoAuth]) { [accountService AutoAuth]; } } -#pragma clang diagnostic pop + } - (NSApplicationTerminateReply)tweak_applicationShouldTerminate:(NSApplication *)sender { diff --git a/WeChatTweakHeaders.h b/WeChatTweakHeaders.h index ef987db..d08512c 100644 --- a/WeChatTweakHeaders.h +++ b/WeChatTweakHeaders.h @@ -42,3 +42,10 @@ - (void)notifyAddMsgOnMainThread:(id)arg1 msgData:(id)arg2; @end + +@interface AccountService: NSObject + +- (BOOL)canAutoAuth; +- (void)AutoAuth; + +@end \ No newline at end of file