Skip to content

Commit 1788842

Browse files
committed
Refactor TextData class discovery and usage
Dynamically locate the `TextData` class in `Unobfuscator` instead of relying on a hardcoded "com.whatsapp.TextData" string. Update the `TextStatusComposer` to simplify argument retrieval based on this change. Signed-off-by: Dev4Mod <[email protected]>
1 parent e40ce6c commit 1788842

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

app/src/main/java/com/wmods/wppenhacer/xposed/core/devkit/Unobfuscator.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1654,9 +1654,16 @@ public synchronized static Class loadListChannelItemClass(ClassLoader classLoade
16541654

16551655
public synchronized static Method[] loadTextStatusData(ClassLoader classLoader) throws Exception {
16561656
return UnobfuscatorCache.getInstance().getMethods(classLoader, () -> {
1657+
Class<?> textData;
1658+
var textDataList = dexkit.findClass(FindClass.create().matcher(ClassMatcher.create().addUsingString("TextData;")));
1659+
if (textDataList.isEmpty()) {
1660+
textData = findFirstClassUsingName(classLoader, StringMatchType.EndsWith, "TextData");
1661+
} else {
1662+
textData = textDataList.get(0).getInstance(classLoader);
1663+
}
16571664
var methods = dexkit.findMethod(
16581665
FindMethod.create().matcher(
1659-
MethodMatcher.create().addParamType("com.whatsapp.TextData")
1666+
MethodMatcher.create().addParamType(textData)
16601667
)
16611668
);
16621669
if (methods.isEmpty())

app/src/main/java/com/wmods/wppenhacer/xposed/features/others/TextStatusComposer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,11 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
7777
var methodsTextStatus = Unobfuscator.loadTextStatusData(classLoader);
7878

7979
for (var method : methodsTextStatus) {
80-
Class<?> textDataClass = classLoader.loadClass("com.whatsapp.TextData");
8180
logDebug("setColorTextComposer", Unobfuscator.getMethodDescriptor(method));
8281
XposedBridge.hookMethod(method, new XC_MethodHook() {
8382
@Override
8483
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
85-
var textData = ReflectionUtils.getArg(param.args, textDataClass, 0);
84+
var textData = param.args[0];
8685
if (textData == null) return;
8786
if (colorData.textColor != -1)
8887
XposedHelpers.setObjectField(textData, "textColor", colorData.textColor);

0 commit comments

Comments
 (0)