Skip to content

Commit

Permalink
Add support to WhatsApp 2.24.10.74~75
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev4Mod committed May 17, 2024
1 parent 1f234a8 commit 51af4bd
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -827,22 +827,38 @@ public static Method loadAntiRevokeMessageMethod(ClassLoader loader) throws Exce
});
}

// public static Field loadMessageKeyField(ClassLoader loader) throws Exception {
// return UnobfuscatorCache.getInstance().getField(loader, () -> {
// Class<?> classExtendJid = loadAntiRevokeChatJidField(loader).getType();
// ClassDataList classes = dexkit.findClass(
// new FindClass().matcher(
// new ClassMatcher().
// addUsingString("remote_jid=")
// .addField(new FieldMatcher().type(classExtendJid))
// )
// );
// if (classes.isEmpty()) throw new Exception("AntiRevokeMessageKey class not found");
// Class<?> messageKey = classes.get(0).getInstance(loader);
// var classMessage = loadThreadMessageClass(loader);
// var field = Arrays.stream(classMessage.getFields()).filter(f -> f.getType() == messageKey && Modifier.isFinal(f.getModifiers())).findFirst().orElse(null);
// if (field == null) throw new Exception("AntiRevokeMessageKey field not found");
// return field;
// });
// }

public static Field loadMessageKeyField(ClassLoader loader) throws Exception {
return UnobfuscatorCache.getInstance().getField(loader, () -> {
Class<?> classExtendJid = loadAntiRevokeChatJidField(loader).getType();
ClassDataList classes = dexkit.findClass(
new FindClass().matcher(
new ClassMatcher().
addUsingString("remote_jid=")
.addField(new FieldMatcher().type(classExtendJid))
)
);
if (classes.isEmpty()) throw new Exception("AntiRevokeMessageKey class not found");
Class<?> messageKey = classes.get(0).getInstance(loader);
var GroupJid = XposedHelpers.findClass("com.whatsapp.jid.GroupJid", loader).getField("Companion");
var keyMessageList = dexkit.findClass(new FindClass().matcher(new ClassMatcher().addUsingString("Key").addUsingString("remote_jid=").addUsingString("from_me").addMethod(new MethodMatcher().addUsingField(DexSignUtil.getFieldDescriptor(GroupJid)))));
if (keyMessageList.isEmpty()) {
keyMessageList = dexkit.findClass(new FindClass().matcher(new ClassMatcher().addUsingString("Key").addUsingString("from_me").addMethod(new MethodMatcher().addUsingField(DexSignUtil.getFieldDescriptor(GroupJid)))));
}
if (keyMessageList.isEmpty()) throw new Exception("MessageKey class not found");
Class<?> keyMessageClass = keyMessageList.get(0).getInstance(loader);
var classMessage = loadThreadMessageClass(loader);
var field = Arrays.stream(classMessage.getFields()).filter(f -> f.getType() == messageKey && Modifier.isFinal(f.getModifiers())).findFirst().orElse(null);
if (field == null) throw new Exception("AntiRevokeMessageKey field not found");
return field;
var fields = ReflectionUtils.getFieldsByExtendType(classMessage, keyMessageClass);
if (fields.isEmpty()) throw new Exception("MessageKey field not found");
return fields.get(fields.size() - 1);
});
}

Expand Down Expand Up @@ -1104,7 +1120,12 @@ public static Method loadChatLimitDelete2Method(ClassLoader loader) throws Excep
public static Method loadNewMessageMethod(ClassLoader loader) throws Exception {
return UnobfuscatorCache.getInstance().getMethod(loader, () -> {
var clazzMessage = loadThreadMessageClass(loader);
var methodData = dexkit.findMethod(new FindMethod().searchInClass(List.of(Objects.requireNonNull(dexkit.getClassData(clazzMessage)))).matcher(new MethodMatcher().addUsingString("\n").returnType(String.class)));
var clazzData = Objects.requireNonNull(dexkit.getClassData(clazzMessage));
var methodData = clazzData.findMethod(new FindMethod().matcher(new MethodMatcher().addUsingString("\n").returnType(String.class)));
if (methodData.isEmpty()) {
var field = clazzMessage.getDeclaredField("A02");
methodData = clazzData.findMethod(new FindMethod().matcher(new MethodMatcher().addUsingField(DexSignUtil.getFieldDescriptor(field)).returnType(String.class)));
}
if (methodData.isEmpty()) throw new RuntimeException("NewMessage method not found");
return methodData.get(0).getMethodInstance(loader);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Typeface;
import android.util.Pair;
import android.view.Gravity;
import android.view.Menu;
Expand Down Expand Up @@ -60,6 +61,7 @@ public void doHook() throws Exception {
// param.setResult(date);
// }
// });

var novoTema = prefs.getBoolean("novotema", false);
var menuWIcons = prefs.getBoolean("menuwicon", false);
var newSettings = prefs.getBoolean("novaconfig", false);
Expand Down Expand Up @@ -102,6 +104,8 @@ public void doHook() throws Exception {
propsInteger.put(3877, channels ? igstatus ? 2 : 0 : 2);
propsInteger.put(6728, videotime ? 60 : 30);



var methodPropsBoolean = Unobfuscator.loadPropsBooleanMethod(loader);
logDebug(Unobfuscator.getMethodDescriptor(methodPropsBoolean));

Expand All @@ -120,6 +124,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (Unobfuscator.isCalledFromClass(dataUsageActivityClass))
return;
break;
// Fix bug in work manager
case 3877:
if (!Unobfuscator.isCalledFromClass(workManagerClass))
return;
Expand Down Expand Up @@ -202,7 +207,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
var argResult = IntStream.range(0, param.args.length).mapToObj(i -> new Pair<>(i, param.args[i])).filter(p -> p.second instanceof List).findFirst().orElse(null);
if (argResult != null) {
var newList = new ArrayList<Object>((List)argResult.second);
var newList = new ArrayList<Object>((List) argResult.second);
newList.removeIf(item -> {
var name = XposedHelpers.getObjectField(item, "A01");
return name == null || name == "CONTACTS_FILTER" || name == "GROUP_FILTER";
Expand Down Expand Up @@ -319,29 +324,29 @@ private static void InsertDNDOption(Menu menu, Activity home) {
}

@SuppressLint({"DiscouragedApi", "UseCompatLoadingForDrawables", "ApplySharedPref"})
private static void InsertFreezeLastSeenOption(Menu menu, Activity home) {
final boolean freezelastseen = WppCore.getPrivBoolean("freezelastseen", false);
MenuItem item = menu.add(0, 0, 0, "Freeze Last Seen");
item.setIcon(freezelastseen ? ResId.drawable.eye_disabled : ResId.drawable.eye_enabled);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
item.setOnMenuItemClickListener(menuItem -> {
if (!freezelastseen) {
new AlertDialogWpp(home)
.setTitle(home.getString(ResId.string.freezelastseen_title))
.setMessage(home.getString(ResId.string.freezelastseen_message))
.setPositiveButton(home.getString(ResId.string.activate), (dialog, which) -> {
WppCore.setPrivBoolean("freezelastseen", true);
Utils.doRestart(home);
})
.setNegativeButton(home.getString(ResId.string.cancel), (dialog, which) -> dialog.dismiss())
.create().show();
private static void InsertFreezeLastSeenOption(Menu menu, Activity home) {
final boolean freezelastseen = WppCore.getPrivBoolean("freezelastseen", false);
MenuItem item = menu.add(0, 0, 0, "Freeze Last Seen");
item.setIcon(freezelastseen ? ResId.drawable.eye_disabled : ResId.drawable.eye_enabled);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
item.setOnMenuItemClickListener(menuItem -> {
if (!freezelastseen) {
new AlertDialogWpp(home)
.setTitle(home.getString(ResId.string.freezelastseen_title))
.setMessage(home.getString(ResId.string.freezelastseen_message))
.setPositiveButton(home.getString(ResId.string.activate), (dialog, which) -> {
WppCore.setPrivBoolean("freezelastseen", true);
Utils.doRestart(home);
})
.setNegativeButton(home.getString(ResId.string.cancel), (dialog, which) -> dialog.dismiss())
.create().show();
return true;
}
WppCore.setPrivBoolean("freezelastseen", false);
Utils.doRestart(home);
return true;
}
WppCore.setPrivBoolean("freezelastseen", false);
Utils.doRestart(home);
return true;
});
}
});
}

@NonNull
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.wmods.wppenhacer.xposed.utils;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -44,4 +46,7 @@ public static boolean isOverridden(Method method) {
}


public static List<Field> getFieldsByExtendType(Class<?> cls, Class<?> type) {
return Arrays.stream(cls.getFields()).filter(f -> type.isAssignableFrom(f.getType())).collect(Collectors.toList());
}
}
2 changes: 2 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
<item>2.24.9.77</item>
<item>2.24.9.78</item>
<item>2.24.9.79</item>
<item>2.24.10.74</item>
<item>2.24.10.75</item>
</string-array>

<string-array name="supported_versions_business">
Expand Down

0 comments on commit 51af4bd

Please sign in to comment.