@@ -908,7 +908,16 @@ public synchronized static Method loadSendPresenceMethod(ClassLoader loader) thr
908908 return UnobfuscatorCache .getInstance ().getMethod (loader , () -> {
909909 var methodData = dexkit .findMethod (FindMethod .create ().matcher (MethodMatcher .create ().addUsingString ("app/send-presence-subscription jid=" )));
910910 if (methodData .isEmpty ()) throw new Exception ("SendPresence method not found" );
911- var newMethod = methodData .get (0 ).getCallers ().singleOrNull (method1 -> method1 .getParamCount () == 4 );
911+ var methodCallers = methodData .get (0 ).getCallers ();
912+ if (methodCallers .isEmpty ()) {
913+ var method = methodData .get (0 );
914+ var superMethodInterfaces = method .getDeclaredClass ().getInterfaces ();
915+ if (superMethodInterfaces .isEmpty ()) throw new Exception ("SendPresence method interface list empty" );
916+ var superMethod = superMethodInterfaces .get (0 ).findMethod (FindMethod .create ().matcher (MethodMatcher .create ().name (method .getName ()))).firstOrNull ();
917+ if (superMethod == null ) throw new Exception ("SendPresence method interface method not found" );
918+ methodCallers = superMethod .getCallers ();
919+ }
920+ var newMethod = methodCallers .firstOrNull (method1 -> method1 .getParamCount () == 4 );
912921 if (newMethod == null ) throw new Exception ("SendPresence method not found 2" );
913922 return newMethod .getMethodInstance (loader );
914923 });
@@ -1658,21 +1667,53 @@ public synchronized static Method loadCopiedMessageMethod(ClassLoader classLoade
16581667 });
16591668 }
16601669
1661- public synchronized static Method loadSenderPlayed (ClassLoader classLoader ) throws Exception {
1662- return UnobfuscatorCache .getInstance ().getMethod (classLoader , () -> {
1670+ public synchronized static Class <?> loadSenderPlayedClass (ClassLoader classLoader ) throws Exception {
1671+ return UnobfuscatorCache .getInstance ().getClass (classLoader , () -> {
16631672 var clazz = findFirstClassUsingStrings (classLoader , StringMatchType .Contains , "sendmethods/sendClearDirty" );
16641673 if (clazz == null ) throw new RuntimeException ("SenderPlayed class not found" );
1674+ return clazz ;
1675+ });
1676+ }
1677+
1678+ public synchronized static Method loadSenderPlayedMethod (ClassLoader classLoader ) throws Exception {
1679+ return UnobfuscatorCache .getInstance ().getMethod (classLoader , () -> {
1680+ var clazz = loadSenderPlayedClass (classLoader );
16651681 var fmessageClass = loadFMessageClass (classLoader );
1666- var methodResult = ReflectionUtils .findMethodUsingFilter (clazz , method -> method .getParameterCount () == 1 && fmessageClass .isAssignableFrom (method .getParameterTypes ()[0 ]));
1667- if (methodResult == null ) throw new RuntimeException ("SenderPlayed method not found" );
1682+ Method methodResult = null ;
1683+ for (var method : clazz .getMethods ()) {
1684+ if (method .getParameterCount () == 1 && fmessageClass .isAssignableFrom (method .getParameterTypes ()[0 ])) {
1685+ methodResult = method ;
1686+ break ;
1687+ }
1688+ }
1689+
1690+ // 2.25.19.xx, they refactored the SenderPlayed class
1691+ if (methodResult == null ) {
1692+ var method = findFirstMethodUsingStrings (classLoader , StringMatchType .Contains , "mediaHash and fileType not both present for upload URL generation" );
1693+ if (method != null ) {
1694+ var cMethods = dexkit .getMethodData (method ).getInvokes ();
1695+ Collections .reverse (cMethods );
1696+ for (var cmethod : cMethods ) {
1697+ if (cmethod .isMethod () && cmethod .getParamCount () == 1 ) {
1698+ var cParamType = cmethod .getParamTypes ().get (0 ).getInstance (classLoader );
1699+ if (fmessageClass .isAssignableFrom (cParamType )) {
1700+ methodResult = cmethod .getMethodInstance (classLoader );
1701+ break ;
1702+ }
1703+ }
1704+ }
1705+ }
1706+ }
1707+
1708+ if (methodResult == null ) throw new RuntimeException ("SenderPlayed method not found 2" );
16681709 return methodResult ;
16691710 });
16701711 }
16711712
16721713 public synchronized static Method loadSenderPlayedBusiness (ClassLoader classLoader ) throws Exception {
16731714 return UnobfuscatorCache .getInstance ().getMethod (classLoader , () -> {
1674- var loadSenderPlayed = loadSenderPlayed (classLoader );
1675- var foundMethod = ReflectionUtils .findMethodUsingFilter (loadSenderPlayed . getDeclaringClass () , method -> method .getParameterCount () > 0 && method .getParameterTypes ()[0 ] == Set .class );
1715+ var loadSenderPlayed = loadSenderPlayedClass (classLoader );
1716+ var foundMethod = ReflectionUtils .findMethodUsingFilter (loadSenderPlayed , method -> method .getParameterCount () > 0 && method .getParameterTypes ()[0 ] == Set .class );
16761717 if (foundMethod == null )
16771718 throw new RuntimeException ("SenderPlayedBusiness method not found" );
16781719 return foundMethod ;
0 commit comments