3131import org .luckypray .dexkit .result .UsingFieldData ;
3232import org .luckypray .dexkit .util .DexSignUtil ;
3333
34- import java .io .File ;
3534import java .lang .reflect .Constructor ;
3635import java .lang .reflect .Field ;
3736import java .lang .reflect .Method ;
@@ -517,11 +516,14 @@ public synchronized static Method loadStatusActivePage(ClassLoader classLoader)
517516 });
518517 }
519518
520- public synchronized static Class <?> loadStatusDownloadMediaClass (ClassLoader classLoader ) throws Exception {
519+
520+ public synchronized static Class <?> loadMenuManagerClass (ClassLoader classLoader ) throws Exception {
521521 return UnobfuscatorCache .getInstance ().getClass (classLoader , () -> {
522- var clazz = findFirstClassUsingStrings (classLoader , StringMatchType .Contains , "static.whatsapp.net/downloadable?category=PSA" );
523- if (clazz == null ) throw new Exception ("StatusDownloadMedia class not found" );
524- return clazz ;
522+ var methods = findAllMethodUsingStrings (classLoader , StringMatchType .Contains , "MenuPopupHelper cannot be used without an anchor" );
523+ for (var method : methods ) {
524+ if (method .getReturnType () == void .class ) return method .getDeclaringClass ();
525+ }
526+ throw new Exception ("MenuManager class not found" );
525527 });
526528 }
527529
@@ -534,43 +536,6 @@ public synchronized static Method loadMenuStatusMethod(ClassLoader loader) throw
534536 });
535537 }
536538
537- public synchronized static Field loadStatusDownloadFileField (ClassLoader classLoader ) throws Exception {
538- return UnobfuscatorCache .getInstance ().getField (classLoader , () -> {
539- var clazz = loadStatusDownloadMediaClass (classLoader );
540- for (Field clazzField : clazz .getFields ()) {
541- var clazz2 = clazzField .getType ();
542- var field = ReflectionUtils .getFieldByType (clazz2 , File .class );
543- if (field != null ) return field ;
544- }
545-
546- throw new Exception ("StatusDownloadFile field not found" );
547- });
548- }
549-
550- public synchronized static Class <?> loadStatusDownloadSubMenuClass (ClassLoader classLoader ) throws Exception {
551- return UnobfuscatorCache .getInstance ().getClass (classLoader , () -> {
552- var classes = dexkit .findClass (
553- new FindClass ().matcher (
554- new ClassMatcher ().addMethod (
555- new MethodMatcher ()
556- .addUsingString ("MenuPopupHelper" , StringMatchType .Contains )
557- .returnType (void .class )
558- )
559- )
560- );
561- if (classes .isEmpty ()) throw new Exception ("StatusDownloadSubMenu method not found" );
562- return classes .get (0 ).getInstance (classLoader );
563- });
564- }
565-
566- public synchronized static Class <?> loadStatusDownloadMenuClass (ClassLoader classLoader ) throws Exception {
567- return UnobfuscatorCache .getInstance ().getClass (classLoader , () -> {
568- var clazz = findFirstClassUsingStrings (classLoader , StringMatchType .Contains , "android:menu:expandedactionview" );
569- if (clazz == null ) throw new Exception ("StatusDownloadMenu class not found" );
570- return clazz ;
571- });
572- }
573-
574539 // TODO: Classes and methods to ViewOnce
575540
576541 public synchronized static Method [] loadViewOnceMethod (ClassLoader classLoader ) throws Exception {
@@ -631,53 +596,6 @@ public synchronized static Method loadViewOnceDownloadMenuMethod(ClassLoader cla
631596 });
632597 }
633598
634- public synchronized static Field loadViewOnceDownloadMenuField (ClassLoader classLoader ) throws Exception {
635- return UnobfuscatorCache .getInstance ().getField (classLoader , () -> {
636- var method = loadViewOnceDownloadMenuMethod (classLoader );
637- var clazz = XposedHelpers .findClass ("com.whatsapp.mediaview.MediaViewFragment" , classLoader );
638- var methodData = dexkit .getMethodData (method );
639- var fields = methodData .getUsingFields ();
640- for (UsingFieldData field : fields ) {
641- Field field1 = field .getField ().getFieldInstance (classLoader );
642- if (field1 .getType () == int .class && field1 .getDeclaringClass () == clazz ) {
643- return field1 ;
644- }
645- }
646- throw new Exception ("ViewOnceDownloadMenu field not found" );
647- });
648- }
649-
650- public synchronized static Field loadViewOnceDownloadMenuField2 (ClassLoader classLoader ) throws Exception {
651- return UnobfuscatorCache .getInstance ().getField (classLoader , () -> {
652- var methodData = dexkit .findMethod (new FindMethod ().matcher (new MethodMatcher ().addUsingString ("photo_progress_fragment" ))).get (0 );
653- var clazz = methodData .getMethodInstance (classLoader ).getDeclaringClass ();
654- var fields = methodData .getUsingFields ();
655- for (UsingFieldData field : fields ) {
656- Field field1 = field .getField ().getFieldInstance (classLoader );
657- if (field1 .getType () == int .class && field1 .getDeclaringClass () == clazz ) {
658- return field1 ;
659- }
660- }
661- throw new Exception ("ViewOnceDownloadMenu field 2 not found" );
662- });
663- }
664-
665- /**
666- * @noinspection SimplifyOptionalCallChains
667- */
668- public synchronized static Method loadViewOnceDownloadMenuCallMethod (ClassLoader loader ) throws Exception {
669- return UnobfuscatorCache .getInstance ().getMethod (loader , () -> {
670- var clazz = XposedHelpers .findClass ("com.whatsapp.mediaview.MediaViewFragment" , loader );
671- var method = Arrays .stream (clazz .getDeclaredMethods ()).filter (m ->
672- ((m .getParameterCount () == 2 && Objects .equals (m .getParameterTypes ()[1 ], int .class ) && Objects .equals (m .getParameterTypes ()[0 ], clazz ))
673- || (m .getParameterCount () == 1 && Objects .equals (m .getParameterTypes ()[0 ], int .class ))) &&
674- Modifier .isPublic (m .getModifiers ()) && Object .class .isAssignableFrom (m .getReturnType ())
675- ).findFirst ();
676- if (!method .isPresent ())
677- throw new Exception ("ViewOnceDownloadMenuCall method not found" );
678- return method .get ();
679- });
680- }
681599
682600 // TODO: Methods and Classes for Change Colors
683601
@@ -1778,4 +1696,14 @@ public static synchronized Class loadCachedMessageStore(ClassLoader loader) thro
17781696 return cacheMsClass ;
17791697 });
17801698 }
1699+
1700+ public static synchronized Class loadAbstractMediaMessageClass (ClassLoader loader ) throws Exception {
1701+ return UnobfuscatorCache .getInstance ().getClass (loader , () -> {
1702+ var fMessageClass = findFirstClassUsingStrings (loader , StringMatchType .Contains , "static.whatsapp.net/downloadable?category=PSA" );
1703+ if (fMessageClass == null )
1704+ throw new RuntimeException ("AbstractMediaMessage class not found" );
1705+ return fMessageClass ;
1706+ });
1707+ }
1708+
17811709}
0 commit comments