Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
refactor with dexkit 2
Browse files Browse the repository at this point in the history
  • Loading branch information
GuhDoy committed Sep 16, 2023
1 parent 2050309 commit e6bb3d5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ dependencies {
implementation "androidx.room:room-ktx:$roomVersion"
ksp "androidx.room:room-compiler:$roomVersion"

implementation 'io.reactivex.rxjava3:rxjava:3.1.2'
implementation 'org.luckypray:DexKit:2.0.0-rc'
implementation 'io.reactivex.rxjava3:rxjava:3.1.7'
implementation 'org.luckypray:dexkit:2.0.0-rc2'
// https://stackoverflow.com/questions/61195038/excluding-dependency-from-implementation-files
implementation files('apktool_2.7.0.jar')
implementation 'com.squareup.okhttp3:okhttp:4.11.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

import android.content.Context;

import org.luckypray.dexkit.DexKitBridge;
import org.luckypray.dexkit.query.FindMethod;
import org.luckypray.dexkit.query.MethodDataList;
import org.luckypray.dexkit.query.matchers.MethodMatcher;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -19,11 +24,6 @@
import gm.tieba.tabswitch.XposedContext;
import gm.tieba.tabswitch.dao.AcRules;
import gm.tieba.tabswitch.dao.Preferences;
import io.luckypray.dexkit.DexKitBridge;
import io.luckypray.dexkit.builder.MethodCallerArgs;
import io.luckypray.dexkit.builder.MethodUsingNumberArgs;
import io.luckypray.dexkit.builder.MethodUsingStringArgs;
import io.luckypray.dexkit.descriptor.member.DexMethodDescriptor;
import io.reactivex.rxjava3.subjects.PublishSubject;

public class Deobfuscation extends XposedContext {
Expand Down Expand Up @@ -126,29 +126,32 @@ public void dexkit(final PublishSubject<Float> progress) {
Objects.requireNonNull(bridge);

forEachProgressed(progress, matchers, matcher -> {
Collection<DexMethodDescriptor> ret = null;
MethodDataList ret = null;
if (matcher instanceof final StringMatcher stringMatcher) {
ret = bridge.findMethodUsingString(
new MethodUsingStringArgs.Builder()
.usingString(stringMatcher.getStr())
.build()
ret = bridge.findMethod(
FindMethod.create().matcher(
MethodMatcher.create().usingStrings(stringMatcher.getStr())
)
);
} else if (matcher instanceof final ResMatcher resMatcher) {
ret = bridge.findMethodUsingNumber(
new MethodUsingNumberArgs.Builder()
.usingNumber(resMatcher.getId())
.build()
ret = bridge.findMethod(
FindMethod.create().matcher(
MethodMatcher.create().usingNumbers(resMatcher.getId())
)
);
} else if (matcher instanceof final SmaliMatcher smaliMatcher) {
ret = bridge.findMethodCaller(
new MethodCallerArgs.Builder()
.methodDescriptor(smaliMatcher.toString())
.build()
).keySet();
ret = bridge.findMethod(
FindMethod.create().matcher(
MethodMatcher.create().addInvoke(
MethodMatcher.create().descriptor(smaliMatcher.toString())
)
)
);
}
if (ret != null) {
for (final var d : ret) {
AcRules.putRule(matcher.toString(), d.getDeclaringClassName(), d.getName());
for (final var methodData : ret) {
AcRules.putRule(
matcher.toString(), methodData.getClassName(), methodData.getName());
}
}
});
Expand Down

0 comments on commit e6bb3d5

Please sign in to comment.