Skip to content

Commit

Permalink
Merge pull request #35 from Mingyueyixi/v1.17/dev
Browse files Browse the repository at this point in the history
V1.17/dev
  • Loading branch information
Mingyueyixi authored Jun 22, 2023
2 parents 62f9743 + 1a3bafc commit fcfc3bf
Show file tree
Hide file tree
Showing 17 changed files with 455 additions and 169 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ v1.13版本开始,默认隐藏App在桌面的图标。隐藏以后,打开模
8.0.22 (2140) 2022-04-29
8.0.32 (2300) 2023-01-06
8.0.33 (2320) 2023-02-23
8.0.34 (2340) 2023-03-23
8.0.35 (2340) 2023-04-20 (PS. 不是作者写错,而是特么下载到了一个和8.0.34版本号一样的8.0.35)
8.0.35 (2360) 2023-04-20
8.0.37 (2380) 2023-05-25

**PS.**
- 仅支持上述版本,所有其他版本号以及32位版本未经测试,预计百分之九十九不可用
Expand Down Expand Up @@ -100,11 +104,18 @@ SHA1: 8069F4730CF8839BE68609EF2F4702349E23A86B
8.0.34(2340): [https://dldir1.qq.com/weixin/android/weixin8034android2340_arm64_1.apk](https://dldir1.qq.com/weixin/android/weixin8034android2340_arm64_1.apk)
SHA1: 30D0D0C25561D367A9E359A1804EA90352BEA7F5

推荐8.0.32(2300)、8.0.33(2320),因为:
8.0.35 (2360): [https://dldir1.qq.com/weixin/android/weixin8035android2360_arm64_3.apk](https://dldir1.qq.com/weixin/android/weixin8035android2360_arm64_3.apk)
SHA1: 5593FB24667D44ABD2299EF1118CD3498099B719

8.0.37(2380):[https://dldir1.qq.com/weixin/android/weixin8037android2380_arm64_1.apk](https://dldir1.qq.com/weixin/android/weixin8037android2380_arm64_1.apk)
SHA1: 410E675B0014F6DF768825F647F69D98A110D50D

- 自2.11版本以来,正在逐步放弃支持8.0.22版本微信
- 8.0.34虽然适配,但是可能存在未知的bug

推荐8.0.32(2300)、8.0.33(2320),8.0.34(2340),因为:

- 自2.11版本以来,正在逐步放弃支持8.0.22版本微信
- 8.0.35 刚适配,怕不是有点毛病,有一个版本,它的版本号和8.0.34一样
- 8.0.37 刚刚适配,不建议。

**问题4:是否支持Google Play版本?**
答:不支持。
Expand Down
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ this.afterEvaluate {

android {
namespace 'com.lu.wxmask'
compileSdk 33
compileSdk 34

defaultConfig {
applicationId "com.lu.wxmask"
minSdk 24
targetSdk 33
versionCode 17
versionName "1.16-bug"
targetSdk 34
versionCode 18
versionName "1.17-bug"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down
5 changes: 4 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
<activity
android:name=".ui.MainActivity"
android:exported="true"
android:launchMode="singleInstance">
android:excludeFromRecents="true"
android:autoRemoveFromRecents="true"
android:noHistory="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- 在Android-11及以上,不能够通过调用 pm.setComponentEnabledSetting 禁用组件的方式来实现动态显示/隐藏图标 -->
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/lu/wxmask/ClazzN.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface ClazzN {
const val BaseChattingUIFragment = "com.tencent.mm.ui.chatting.BaseChattingUIFragment"
const val LauncherUI = "com.tencent.mm.ui.LauncherUI"
const val ChattingUI = "com.tencent.mm.ui.chatting.ChattingUI"
const val MainUI = "com.tencent.mm.ui.MainUI"
const val MainUI = "com.tencent.mm.ui.conversation.MainUI"
const val ConversationListView = "com.tencent.mm.ui.conversation.ConversationListView"
const val BaseContact = "com.tencent.mm.autogen.table.BaseContact"
const val BaseConversation = "com.tencent.mm.autogen.table.BaseConversation"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/lu/wxmask/Constrant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class Constrant {
const val WX_CODE_8_0_32 = 2300
const val WX_CODE_8_0_33 = 2320
const val WX_CODE_8_0_34 = 2340
//不知道为毛8.0.35找到一个和版本号与8.0.34重复的版本
//const val WX_CODE_8_0_35 = 2340
const val WX_CODE_8_0_35 = 2360
const val WX_CODE_8_0_37 = 2380
}

}
63 changes: 59 additions & 4 deletions app/src/main/java/com/lu/wxmask/MainHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import com.lu.wxmask.plugin.WXConfigPlugin;
import com.lu.wxmask.plugin.WXMaskPlugin;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArraySet;

import de.robv.android.xposed.IXposedHookLoadPackage;
Expand All @@ -27,6 +29,7 @@
public class MainHook implements IXposedHookLoadPackage {
public static CopyOnWriteArraySet<String> uniqueMetaStore = new CopyOnWriteArraySet<>();
private boolean hasInit = false;
private List<XC_MethodHook.Unhook> initUnHookList = new ArrayList<>();

@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
Expand All @@ -52,9 +55,41 @@ public void onLog(int level, @NonNull Object[] objects) {
}
});
LogUtil.i("start main plugin for wechat");
XposedHelpers2.Config.setThrowableCallBack(throwable -> LogUtil.e("MaskPlugin error", throwable));
XposedHelpers2.Config
.setCallMethodWithProxy(true)
.setThrowableCallBack(throwable -> LogUtil.w("MaskPlugin error", throwable))
.setOnErrorReturnFallback((method, throwable) -> {
Class<?> returnType = method.getReturnType();
// 函数执行错误时,给定一个默认的返回值值。
// 没什么鸟用。xposed api就没有byte/short/int/long/这些基本类型的返回值函数
if (String.class.equals(returnType) || CharSequence.class.isAssignableFrom(returnType)) {
return "";
}
if (Integer.TYPE.equals(returnType) || Integer.class.equals(returnType)) {
return 0;
}
if (Long.TYPE.equals(returnType) || Long.class.equals(returnType)) {
return 0L;
}
if (Double.TYPE.equals(returnType) || Double.class.equals(returnType)) {
return 0d;
}
if (Float.TYPE.equals(returnType) || Float.class.equals(returnType)) {
return 0f;
}
if (Byte.TYPE.equals(returnType) || Byte.class.equals(returnType)) {
return new byte[]{};
}
if (Short.TYPE.equals(returnType) || Short.class.equals(returnType)) {
return (short)0;
}
if (BuildConfig.DEBUG) {
LogUtil.w("setOnErrorReturnFallback", throwable);
}
return null;
});

XposedHelpers2.findAndHookMethod(
XC_MethodHook.Unhook unhook = XposedHelpers2.findAndHookMethod(
Application.class.getName(),
lpparam.classLoader,
"onCreate",
Expand All @@ -65,6 +100,20 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
}
);
initUnHookList.add(unhook);

// initHookCallBack = XposedHelpers2.findAndHookMethod(
// Activity.class.getName(),
// lpparam.classLoader,
// "onCreate",
// Bundle.class,
// new XC_MethodHook() {
// @Override
// protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// initPlugin(((Activity) param.thisObject).getApplicationContext(), lpparam);
// }
// }
// );
//
//"com.tencent.mm.app.com.Application"的父类
//"tencent.tinker.loader.app.TinkerApplication"
Expand All @@ -82,7 +131,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
// }
// );
//
XposedHelpers2.findAndHookMethod(
unhook = XposedHelpers2.findAndHookMethod(
Instrumentation.class.getName(),
lpparam.classLoader,
"callApplicationOnCreate",
Expand All @@ -94,7 +143,8 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
}
);

initUnHookList.add(unhook);
//
// XposedHelpers2.findAndHookMethod(
// Activity.class.getName(),
// lpparam.classLoader,
Expand Down Expand Up @@ -127,6 +177,11 @@ private void initPlugin(Context context, XC_LoadPackage.LoadPackageParam lpparam
WXConfigPlugin.class,
WXMaskPlugin.class
).handleHooks(context, lpparam);
for (XC_MethodHook.Unhook unhook : initUnHookList) {
if (unhook != null) {
unhook.unhook();
}
}
LogUtil.i("init plugin finish");
}

Expand Down
27 changes: 19 additions & 8 deletions app/src/main/java/com/lu/wxmask/plugin/WXConfigPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,13 @@ public void doResumeHookAction(XC_MethodHook.MethodHookParam param) {
field_conRemark = XposedHelpers2.getObjectField(chatUserInfo, "field_conRemark");
// field_username = XposedHelpers2.getObjectField(chatUserInfo, "field_username");
field_nickname = XposedHelpers2.getObjectField(chatUserInfo, "field_nickname");
LogUtil.d(GsonUtil.toJson(chatUserInfo));
LogUtil.d("chatUserInfo", GsonUtil.toJson(chatUserInfo));
}

if (idIndex < 0) {
new AddMaskItemUI(activity, lst)
.setChatUserId(chatUser)
.setTagName(field_conRemark.isEmpty() ? field_nickname : field_conRemark)
.setTagName((field_conRemark == null || field_conRemark.isEmpty()) ? field_nickname : field_conRemark)
.setFreeButton("退出配置", (dialog, which) -> isOnDoingConfig = false)
.show();
} else {
Expand All @@ -214,31 +215,41 @@ private Object findChatUserObject(Object fragmentObj) {
//8.0.32: of3.b
//8.0.33: oi3.b
//8.0.34: ck3.b
//8.0.37: zq3.b
Object f = XposedHelpers2.getObjectField(fragmentObj, "f");
if (f != null) {
//com.tencent.mm.storage.y1
if (AppVersionUtil.getVersionCode() == Constrant.WX_CODE_8_0_32) {
if (AppVersionUtil.getVersionCode() <= Constrant.WX_CODE_8_0_32) {
Object v = XposedHelpers2.getObjectField(f, "e");
if (ClazzN.from(ClazzN.BaseContact).isAssignableFrom(v.getClass())) {
return v;
}
} else if (AppVersionUtil.getVersionCode() == Constrant.WX_CODE_8_0_33) {
} else if (AppVersionUtil.getVersionCode() <= Constrant.WX_CODE_8_0_33) {
Object v = XposedHelpers2.getObjectField(f, "h");
if (ClazzN.from(ClazzN.BaseContact).isAssignableFrom(v.getClass())) {
return v;
}
} else if (AppVersionUtil.getVersionCode() == Constrant.WX_CODE_8_0_34) {
} else if (AppVersionUtil.getVersionCode() <= Constrant.WX_CODE_8_0_35) {
//8.0.34开始,数据库基类改变。包:com.tencent.mm.autogen.table 已经不存在,不再校验
Object v = XposedHelpers2.getObjectField(f, "h");
return v;
} else {
}
else if (AppVersionUtil.getVersionCode() <= Constrant.WX_CODE_8_0_37) {
Object v = XposedHelpers2.getObjectField(f, "i");
return v;
}
else {
//8.0.33与8.0.34共同的父类: com.tencent.mm.contact.d
Field[] hitFields = XposedHelpers2.findFieldsByExactPredicate(f.getClass(), field -> ClazzN.from("com.tencent.mm.contact.d").isAssignableFrom(field.getType()));
if (hitFields.length > 0) {
Object result = hitFields[0].get(f);
LogUtil.w(AppVersionUtil.getSmartVersionName(), "find user info object", result);
Field field = hitFields[0];
Object result = field.get(f);
LogUtil.w(AppVersionUtil.getSmartVersionName(), "guess user info object, ", "find field: ", field.getName(), "=", result);
return result;
}
else {
LogUtil.w(AppVersionUtil.getSmartVersionName(), "guess user info object fail!");
}
}
}
} catch (Throwable e) {
Expand Down
Loading

0 comments on commit fcfc3bf

Please sign in to comment.