Skip to content

Instantly share code, notes, and snippets.

@GitaiQAQ
Created March 2, 2016 12:53
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save GitaiQAQ/f07aee1cf240010f09de to your computer and use it in GitHub Desktop.
Save GitaiQAQ/f07aee1cf240010f09de to your computer and use it in GitHub Desktop.
a xposed module for QQbot
  private void a1405(final XC_LoadPackage.LoadPackageParam lpparam) throws ClassNotFoundException,NoSuchFieldException,IllegalAccessException{
      String className = "com.tencent.mobileqq.activity.ChatActivity";
      String methodName = "a";

      Class<?> message = lpparam.classLoader.loadClass("com.tencent.mobileqq.app.message.QQMessageFacade$Message");

      XposedBridge.log("Hooking a(QQMessageFacade$Message qQMessageFacade$Message)[1405]");

      XposedHelpers.findAndHookMethod(className, lpparam.classLoader, methodName,
              message,
              new XC_MethodHook() {
          @Override
          protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
              Application app = AndroidAppHelper.currentApplication();
              Context context = (Context)param.thisObject;

              Message message = new Message(param.args[0]);

              XposedBridge.log(message.toString().replace(",", "\n"));

              /*if (!sessionInfos.containsKey(message.getFrienduin())){
                  return;
              }*/

              Class<?> QQAppInterface = lpparam.classLoader.loadClass("com.tencent.mobileqq.app.QQAppInterface");
              Class<?> SessionInfo = lpparam.classLoader.loadClass("com.tencent.mobileqq.activity.aio.SessionInfo");

              Object qQAppInterface = XposedHelpers.getObjectField(context, "mRuntime");
              Object sessionInfo = null;

              Field[] fields = context.getClass().getDeclaredFields();
              for (int i = 0; i < fields.length; i++) {
                  if (fields[i].getType().equals(SessionInfo)){
                      sessionInfo = fields[i].get(context);
                  }
              }

              Class<?> ChatActivityFacade = lpparam.classLoader.loadClass("com.tencent.mobileqq.activity.ChatActivityFacade");
              XposedHelpers.callStaticMethod(ChatActivityFacade, "a",
                      new Class<?>[]{QQAppInterface, Context.class, SessionInfo, String.class, ArrayList.class},
                      qQAppInterface, context, sessionInfo, message.getNickName() + ":" + message.getMessageText(), null);
          }
      });
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment