Theos开发微信插件做自动回复,hook微信新消息函数,收到新消息时,微信闪退。

Makefile

export THEOS = /opt/theos
export THEOS_DEVICE_IP = 192.168.1.106
export ARCHS = armv7 arm64
export TARGET = iPhone:latest:8.0
include $(THEOS)/makefiles/common.mk

TWEAK_NAME = xin
xin_FILES = Tweak.xm
xin_FRAMEWORKS = UIKit

include $(THEOS_MAKE_PATH)/tweak.mk

after-install::
install.exec “killall -9 SpringBoard”

Tweak

%hook CMessageMgr

  • (void)AsyncOnAddMsg:(id)arg1 MsgWrap:(id)arg2 {
    UIAlertController *alerView = [UIAlertController alertControllerWithTitle:@“通知” message:@“HOOK” preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@“确定” style:UIAlertActionStyleCancel handler:nil];
    [alerView addAction:cancelAction];
    [self presentViewController:alerView animated:YES completion:nil];
    }
    %end

然后插件装在手机上,微信收到新消息就闪退了,我想知道我这思路对吗?请不吝赐教~~~谢谢

代码里执行下 %orig

你们这样搞 ,真的好么,张总说navie啊

这些可怜虫,唏嘘

tweak.xm 收新消息函数中,具体的hook代码我改了,现在微信收到新信息时不闪退,可以获取到arg1和arg2 这2个参数。arg1是消息类型,arg2是一直为空,不知道是什么?现在卡在这了。如果我想获取消息内容,张总能不能给点提示?

Nobody cares

1 个赞

怎么可能???
arg2就是消息啊。一直这么用都没问题的。

你竟然在这个类里,,用[self presentViewController:alerView animated:YES completion:nil];

都是大神啊,建议还是回去再学下正向的知识吧,尴尬