From dda49f15018585422b1609784bfccf8643588f27 Mon Sep 17 00:00:00 2001 From: Skylot Date: Thu, 21 Jun 2018 16:50:36 +0300 Subject: [PATCH] core: fix enum reconstruction (#272) --- .../jadx/core/dex/visitors/EnumVisitor.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/jadx-core/src/main/java/jadx/core/dex/visitors/EnumVisitor.java b/jadx-core/src/main/java/jadx/core/dex/visitors/EnumVisitor.java index 962b5a73..f88f8a42 100644 --- a/jadx-core/src/main/java/jadx/core/dex/visitors/EnumVisitor.java +++ b/jadx-core/src/main/java/jadx/core/dex/visitors/EnumVisitor.java @@ -16,6 +16,7 @@ import jadx.core.dex.instructions.InsnType; import jadx.core.dex.instructions.args.ArgType; import jadx.core.dex.instructions.args.InsnArg; import jadx.core.dex.instructions.args.InsnWrapArg; +import jadx.core.dex.instructions.args.RegisterArg; import jadx.core.dex.instructions.mods.ConstructorInsn; import jadx.core.dex.nodes.BlockNode; import jadx.core.dex.nodes.ClassNode; @@ -26,6 +27,7 @@ import jadx.core.dex.nodes.MethodNode; import jadx.core.utils.ErrorsCounter; import jadx.core.utils.InsnUtils; import jadx.core.utils.exceptions.JadxException; +import org.jetbrains.annotations.Nullable; @JadxVisitor( name = "EnumVisitor", @@ -185,10 +187,18 @@ public class EnumVisitor extends AbstractVisitor { } InsnArg arg = putInsn.getArg(0); if (arg.isInsnWrap()) { - InsnNode wrapInsn = ((InsnWrapArg) arg).getWrapInsn(); - if (wrapInsn.getType() == InsnType.CONSTRUCTOR) { - return (ConstructorInsn) wrapInsn; - } + return castConstructorInsn(((InsnWrapArg) arg).getWrapInsn()); + } + if (arg.isRegister()) { + return castConstructorInsn(((RegisterArg) arg).getAssignInsn()); + } + return null; + } + + @Nullable + private ConstructorInsn castConstructorInsn(InsnNode coCandidate) { + if (coCandidate != null && coCandidate.getType() == InsnType.CONSTRUCTOR) { + return (ConstructorInsn) coCandidate; } return null; } -- GitLab