refactor: move plugins-api module into jadx-core
This commit is contained in:
@@ -3,8 +3,6 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(':jadx-plugins:jadx-plugins-api'))
|
||||
|
||||
implementation 'com.google.code.gson:gson:2.10.1'
|
||||
|
||||
// TODO: move resources decoding to separate plugin module
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.api.core.nodes.IJadxDecompiler;
|
||||
import jadx.api.impl.plugins.SimplePluginContext;
|
||||
import jadx.api.metadata.ICodeAnnotation;
|
||||
import jadx.api.metadata.ICodeNodeRef;
|
||||
@@ -84,7 +83,7 @@ import jadx.core.xmlgen.ResourcesSaver;
|
||||
* </code>
|
||||
* </pre>
|
||||
*/
|
||||
public final class JadxDecompiler implements IJadxDecompiler, Closeable {
|
||||
public final class JadxDecompiler implements Closeable {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JadxDecompiler.class);
|
||||
|
||||
private final JadxArgs args;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package jadx.api.core.nodes;
|
||||
package jadx.api.data;
|
||||
|
||||
public interface IRenameNode {
|
||||
|
||||
@@ -2,6 +2,7 @@ package jadx.api.impl.plugins;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import jadx.api.JadxArgs;
|
||||
import jadx.api.JadxDecompiler;
|
||||
import jadx.api.plugins.JadxPluginContext;
|
||||
import jadx.api.plugins.gui.JadxGuiContext;
|
||||
@@ -18,6 +19,11 @@ public class SimplePluginContext implements JadxPluginContext {
|
||||
this.passContext = new SimplePassContext(decompiler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JadxArgs getArgs() {
|
||||
return decompiler.getArgs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JadxDecompiler getDecompiler() {
|
||||
return decompiler;
|
||||
|
||||
+5
-2
@@ -2,13 +2,16 @@ package jadx.api.plugins;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import jadx.api.core.nodes.IJadxDecompiler;
|
||||
import jadx.api.JadxArgs;
|
||||
import jadx.api.JadxDecompiler;
|
||||
import jadx.api.plugins.gui.JadxGuiContext;
|
||||
import jadx.api.plugins.pass.JadxPassContext;
|
||||
|
||||
public interface JadxPluginContext {
|
||||
|
||||
IJadxDecompiler getDecompiler();
|
||||
JadxArgs getArgs();
|
||||
|
||||
JadxDecompiler getDecompiler();
|
||||
|
||||
JadxPassContext getPassContext();
|
||||
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
package jadx.api.plugins.pass.types;
|
||||
|
||||
import jadx.api.core.nodes.IJadxDecompiler;
|
||||
import jadx.api.JadxDecompiler;
|
||||
import jadx.api.plugins.pass.JadxPass;
|
||||
|
||||
public interface JadxAfterLoadPass extends JadxPass {
|
||||
JadxPassType TYPE = new JadxPassType(JadxAfterLoadPass.class);
|
||||
|
||||
void init(IJadxDecompiler decompiler);
|
||||
void init(JadxDecompiler decompiler);
|
||||
|
||||
@Override
|
||||
default JadxPassType getPassType() {
|
||||
+6
-6
@@ -1,26 +1,26 @@
|
||||
package jadx.api.plugins.pass.types;
|
||||
|
||||
import jadx.api.core.nodes.IClassNode;
|
||||
import jadx.api.core.nodes.IMethodNode;
|
||||
import jadx.api.core.nodes.IRootNode;
|
||||
import jadx.api.plugins.pass.JadxPass;
|
||||
import jadx.core.dex.nodes.ClassNode;
|
||||
import jadx.core.dex.nodes.MethodNode;
|
||||
import jadx.core.dex.nodes.RootNode;
|
||||
|
||||
public interface JadxDecompilePass extends JadxPass {
|
||||
JadxPassType TYPE = new JadxPassType(JadxDecompilePass.class);
|
||||
|
||||
void init(IRootNode root);
|
||||
void init(RootNode root);
|
||||
|
||||
/**
|
||||
* Visit class
|
||||
*
|
||||
* @return false for disable child methods and inner classes traversal
|
||||
*/
|
||||
boolean visit(IClassNode cls);
|
||||
boolean visit(ClassNode cls);
|
||||
|
||||
/**
|
||||
* Visit method
|
||||
*/
|
||||
void visit(IMethodNode mth);
|
||||
void visit(MethodNode mth);
|
||||
|
||||
@Override
|
||||
default JadxPassType getPassType() {
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
package jadx.api.plugins.pass.types;
|
||||
|
||||
import jadx.api.core.nodes.IRootNode;
|
||||
import jadx.api.plugins.pass.JadxPass;
|
||||
import jadx.core.dex.nodes.RootNode;
|
||||
|
||||
public interface JadxPreparePass extends JadxPass {
|
||||
JadxPassType TYPE = new JadxPassType(JadxPreparePass.class);
|
||||
|
||||
void init(IRootNode root);
|
||||
void init(RootNode root);
|
||||
|
||||
@Override
|
||||
default JadxPassType getPassType() {
|
||||
@@ -20,7 +20,6 @@ import jadx.api.ICodeInfo;
|
||||
import jadx.api.ICodeWriter;
|
||||
import jadx.api.JadxArgs;
|
||||
import jadx.api.JavaClass;
|
||||
import jadx.api.core.nodes.IClassNode;
|
||||
import jadx.api.impl.SimpleCodeInfo;
|
||||
import jadx.api.plugins.input.data.IClassData;
|
||||
import jadx.api.plugins.input.data.IFieldData;
|
||||
@@ -55,7 +54,7 @@ import static jadx.core.dex.nodes.ProcessState.LOADED;
|
||||
import static jadx.core.dex.nodes.ProcessState.NOT_LOADED;
|
||||
|
||||
public class ClassNode extends NotificationAttrNode
|
||||
implements IClassNode, ILoadable, ICodeNode, IPackageUpdate, Comparable<ClassNode> {
|
||||
implements ILoadable, ICodeNode, IPackageUpdate, Comparable<ClassNode> {
|
||||
private final RootNode root;
|
||||
private final IClassData clsData;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package jadx.core.dex.nodes;
|
||||
|
||||
import jadx.api.core.nodes.IRenameNode;
|
||||
import jadx.api.data.IRenameNode;
|
||||
|
||||
public interface IDexNode extends IRenameNode {
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import jadx.api.ICodeInfo;
|
||||
import jadx.api.JavaMethod;
|
||||
import jadx.api.core.nodes.IMethodNode;
|
||||
import jadx.api.metadata.ICodeNodeRef;
|
||||
import jadx.api.metadata.annotations.NodeDeclareRef;
|
||||
import jadx.api.metadata.annotations.VarNode;
|
||||
@@ -44,8 +43,7 @@ import jadx.core.utils.exceptions.JadxRuntimeException;
|
||||
|
||||
import static jadx.core.utils.Utils.lockList;
|
||||
|
||||
public class MethodNode extends NotificationAttrNode implements IMethodNode,
|
||||
IMethodDetails, ILoadable, ICodeNode, Comparable<MethodNode> {
|
||||
public class MethodNode extends NotificationAttrNode implements IMethodDetails, ILoadable, ICodeNode, Comparable<MethodNode> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MethodNode.class);
|
||||
|
||||
private final MethodInfo mthInfo;
|
||||
|
||||
@@ -20,7 +20,6 @@ import jadx.api.JadxDecompiler;
|
||||
import jadx.api.ResourceFile;
|
||||
import jadx.api.ResourceType;
|
||||
import jadx.api.ResourcesLoader;
|
||||
import jadx.api.core.nodes.IRootNode;
|
||||
import jadx.api.data.ICodeData;
|
||||
import jadx.api.impl.passes.DecompilePassWrapper;
|
||||
import jadx.api.impl.passes.PreparePassWrapper;
|
||||
@@ -60,7 +59,7 @@ import jadx.core.xmlgen.ResourceStorage;
|
||||
import jadx.core.xmlgen.entry.ResourceEntry;
|
||||
import jadx.core.xmlgen.entry.ValuesParser;
|
||||
|
||||
public class RootNode implements IRootNode {
|
||||
public class RootNode {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RootNode.class);
|
||||
|
||||
private final JadxArgs args;
|
||||
|
||||
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":jadx-plugins:jadx-plugins-api"))
|
||||
api(project(":jadx-core"))
|
||||
|
||||
// TODO: finish own smali printer
|
||||
implementation 'org.smali:baksmali:2.5.2'
|
||||
|
||||
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":jadx-plugins:jadx-plugins-api"))
|
||||
api(project(":jadx-core"))
|
||||
|
||||
implementation(project(":jadx-plugins:jadx-dex-input"))
|
||||
implementation('com.jakewharton.android.repackaged:dalvik-dx:11.0.0_r3')
|
||||
|
||||
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":jadx-plugins:jadx-plugins-api"))
|
||||
api(project(":jadx-core"))
|
||||
|
||||
// show bytecode disassemble
|
||||
implementation 'io.github.skylot:raung-disasm:0.0.3'
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
plugins {
|
||||
id 'jadx-library'
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package jadx.api.core.nodes;
|
||||
|
||||
public interface IClassNode {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package jadx.api.core.nodes;
|
||||
|
||||
public interface IJadxDecompiler {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package jadx.api.core.nodes;
|
||||
|
||||
public interface IMethodNode {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package jadx.api.core.nodes;
|
||||
|
||||
public interface IRootNode {
|
||||
}
|
||||
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":jadx-plugins:jadx-plugins-api"))
|
||||
api(project(":jadx-core"))
|
||||
|
||||
implementation(project(":jadx-plugins:jadx-java-input"))
|
||||
|
||||
|
||||
+3
-8
@@ -9,9 +9,6 @@ import net.fabricmc.mappingio.tree.MappingTree.ClassMapping;
|
||||
import net.fabricmc.mappingio.tree.MappingTree.MethodArgMapping;
|
||||
import net.fabricmc.mappingio.tree.MappingTree.MethodMapping;
|
||||
|
||||
import jadx.api.core.nodes.IClassNode;
|
||||
import jadx.api.core.nodes.IMethodNode;
|
||||
import jadx.api.core.nodes.IRootNode;
|
||||
import jadx.api.plugins.pass.JadxPassInfo;
|
||||
import jadx.api.plugins.pass.impl.OrderedJadxPassInfo;
|
||||
import jadx.api.plugins.pass.types.JadxDecompilePass;
|
||||
@@ -38,15 +35,13 @@ public class CodeMappingsVisitor implements JadxDecompilePass {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(IRootNode iroot) {
|
||||
RootNode root = (RootNode) iroot;
|
||||
public void init(RootNode root) {
|
||||
updateMappingsMap();
|
||||
root.registerCodeDataUpdateListener(codeData -> updateMappingsMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(IClassNode icls) {
|
||||
ClassNode cls = (ClassNode) icls;
|
||||
public boolean visit(ClassNode cls) {
|
||||
ClassMapping classMapping = getMapping(cls);
|
||||
if (classMapping != null) {
|
||||
applyRenames(cls, classMapping);
|
||||
@@ -56,7 +51,7 @@ public class CodeMappingsVisitor implements JadxDecompilePass {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(IMethodNode mth) {
|
||||
public void visit(MethodNode mth) {
|
||||
}
|
||||
|
||||
private static void applyRenames(ClassNode cls, ClassMapping classMapping) {
|
||||
|
||||
+1
-3
@@ -5,7 +5,6 @@ import net.fabricmc.mappingio.tree.MappingTree.ClassMapping;
|
||||
import net.fabricmc.mappingio.tree.MappingTree.FieldMapping;
|
||||
import net.fabricmc.mappingio.tree.MappingTree.MethodMapping;
|
||||
|
||||
import jadx.api.core.nodes.IRootNode;
|
||||
import jadx.api.plugins.pass.JadxPassInfo;
|
||||
import jadx.api.plugins.pass.impl.OrderedJadxPassInfo;
|
||||
import jadx.api.plugins.pass.types.JadxPreparePass;
|
||||
@@ -34,8 +33,7 @@ public class MappingsVisitor implements JadxPreparePass {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(IRootNode iroot) {
|
||||
RootNode root = (RootNode) iroot;
|
||||
public void init(RootNode root) {
|
||||
process(root);
|
||||
root.registerCodeDataUpdateListener(codeData -> process(root));
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":jadx-plugins:jadx-script:jadx-script-runtime"))
|
||||
|
||||
implementation("org.jetbrains.kotlin:kotlin-scripting-common")
|
||||
implementation("org.jetbrains.kotlin:kotlin-scripting-jvm")
|
||||
implementation("org.jetbrains.kotlin:kotlin-scripting-jvm-host")
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package jadx.plugins.script.passes
|
||||
|
||||
import jadx.api.core.nodes.IJadxDecompiler
|
||||
import jadx.api.JadxDecompiler
|
||||
import jadx.api.plugins.pass.impl.SimpleJadxPassInfo
|
||||
import jadx.api.plugins.pass.types.JadxAfterLoadPass
|
||||
import jadx.plugins.script.runner.ScriptStates
|
||||
@@ -12,7 +12,7 @@ class JadxScriptAfterLoadPass(private val scriptStates: ScriptStates) : JadxAfte
|
||||
|
||||
override fun getInfo() = SimpleJadxPassInfo("JadxScriptAfterLoad", "Execute scripts 'afterLoad' block")
|
||||
|
||||
override fun init(decompiler: IJadxDecompiler) {
|
||||
override fun init(decompiler: JadxDecompiler) {
|
||||
for (script in scriptStates.getScripts()) {
|
||||
if (script.error) {
|
||||
continue
|
||||
|
||||
@@ -5,6 +5,8 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":jadx-core"))
|
||||
|
||||
implementation("org.jetbrains.kotlin:kotlin-scripting-common")
|
||||
implementation("org.jetbrains.kotlin:kotlin-scripting-jvm")
|
||||
|
||||
@@ -15,9 +17,6 @@ dependencies {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
|
||||
implementation("io.github.microutils:kotlin-logging-jvm:3.0.2")
|
||||
|
||||
api(project(":jadx-plugins:jadx-plugins-api"))
|
||||
api(project(":jadx-core")) // TODO: workaround
|
||||
|
||||
runtimeOnly(project(":jadx-plugins:jadx-dex-input"))
|
||||
runtimeOnly(project(":jadx-plugins:jadx-smali-input"))
|
||||
runtimeOnly(project(":jadx-plugins:jadx-java-convert"))
|
||||
|
||||
+4
-5
@@ -1,6 +1,5 @@
|
||||
package jadx.plugins.script.runtime.data
|
||||
|
||||
import jadx.api.core.nodes.IMethodNode
|
||||
import jadx.core.dex.nodes.MethodNode
|
||||
import jadx.core.dex.visitors.DotGraphVisitor
|
||||
import jadx.core.utils.DebugUtils
|
||||
@@ -9,11 +8,11 @@ import java.io.File
|
||||
|
||||
class Debug(private val jadx: JadxScriptInstance) {
|
||||
|
||||
fun printMethodRegions(mth: IMethodNode, printInsns: Boolean = false) {
|
||||
DebugUtils.printRegions(mth as MethodNode, printInsns)
|
||||
fun printMethodRegions(mth: MethodNode, printInsns: Boolean = false) {
|
||||
DebugUtils.printRegions(mth, printInsns)
|
||||
}
|
||||
|
||||
fun saveCFG(mth: IMethodNode, file: File = File("dump-mth-raw")) {
|
||||
DotGraphVisitor.dumpRaw().save(file, mth as MethodNode)
|
||||
fun saveCFG(mth: MethodNode, file: File = File("dump-mth-raw")) {
|
||||
DotGraphVisitor.dumpRaw().save(file, mth)
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user