diff --git a/examples/DeobfuscatorSample.java b/examples/DeobfuscatorSample.java index d64f4ce16..59383893d 100644 --- a/examples/DeobfuscatorSample.java +++ b/examples/DeobfuscatorSample.java @@ -2,9 +2,12 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.action.ActionList; import com.jpexs.decompiler.flash.helpers.SWFDecompilerListener; import com.jpexs.decompiler.flash.tags.base.ASMSource; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.List; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -22,6 +25,11 @@ public class DeobfuscatorSample implements SWFDecompilerListener { System.out.println("actionListParsed"); } + @Override + public void actionTreeCreated(List tree, SWF swf) { + System.out.println("actionTreeCreated"); + } + @Override public void swfParsed(SWF swf) { System.out.println("swfParsed"); @@ -44,4 +52,9 @@ public class DeobfuscatorSample implements SWFDecompilerListener { public void methodBodyParsed(MethodBody body, SWF swf) { System.out.println("methodBodyParsed"); } + + @Override + public void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException { + System.out.println("avm2CodeRemoveTraps"); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java index 54503cc62..4bcec972b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java @@ -58,6 +58,10 @@ public class IdentifiersDeobfuscation { private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("^[" + VALID_FIRST_CHARACTERS + "][" + VALID_NEXT_CHARACTERS + "]*$"); + private static final Pattern VALID_NAME_PATTERN_DOT = Pattern.compile("^[a-zA-Z_\\$][a-zA-Z0-9_.\\$]*$"); + + private static final Pattern IDENTIFIER_PATTERN_DOT = Pattern.compile("^[" + VALID_FIRST_CHARACTERS + "][" + VALID_NEXT_CHARACTERS + ".]*$"); + public static final String FOO_CHARACTERS = "bcdfghjklmnpqrstvwz"; public static final String FOO_JOIN_CHARACTERS = "aeiouy"; @@ -228,6 +232,28 @@ public class IdentifiersDeobfuscation { return null; } + public static boolean isValidNameWithDot(boolean as3, String s, String... exceptions) { + for (String e : exceptions) { + if (e.equals(s)) { + return true; + } + } + + if (isReservedWord(s, as3)) { + return false; + } + + // simple fast test + if (VALID_NAME_PATTERN_DOT.matcher(s).matches()) { + return true; + } + // unicode test + if (IDENTIFIER_PATTERN_DOT.matcher(s).matches()) { + return true; + } + return false; + } + public static boolean isValidName(boolean as3, String s, String... exceptions) { for (String e : exceptions) { if (e.equals(s)) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/AVM2LocalData.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/AVM2LocalData.java index 9ee961304..8cb509418 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/AVM2LocalData.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/AVM2LocalData.java @@ -20,8 +20,10 @@ import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.types.ABCException; +import com.jpexs.decompiler.flash.abc.types.InstanceInfo; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.flash.abc.types.ScriptInfo; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.ScopeStack; @@ -44,10 +46,6 @@ public class AVM2LocalData extends BaseLocalData { public ScopeStack scopeStack; - public AVM2ConstantPool constants; - - public List methodInfo; - public MethodBody methodBody; public ABC abc; @@ -83,8 +81,6 @@ public class AVM2LocalData extends BaseLocalData { classIndex = localData.classIndex; localRegs = localData.localRegs; scopeStack = localData.scopeStack; - constants = localData.constants; - methodInfo = localData.methodInfo; methodBody = localData.methodBody; abc = localData.abc; localRegNames = localData.localRegNames; @@ -99,4 +95,20 @@ public class AVM2LocalData extends BaseLocalData { refs = localData.refs; code = localData.code; } + + public AVM2ConstantPool getConstants() { + return abc.constants; + } + + public List getMethodInfo() { + return abc.method_info; + } + + public List getInstanceInfo() { + return abc.instance_info; + } + + public List getScriptInfo() { + return abc.script_info; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java index d8387c175..bf805bcc6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java @@ -68,6 +68,7 @@ public class ScriptPack extends AS3ClassTreeItem { private final ClassPath path; public boolean isSimple = false; + public boolean scriptInitializerIsEmpty = false; @Override @@ -162,7 +163,7 @@ public class ScriptPack extends AS3ClassTreeItem { } writer.mark(); - abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/.scriptinitializer", exportMode, true, script_init, scriptIndex, -1, abc, null, abc.constants, abc.method_info, new ScopeStack(), GraphTextWriter.TRAIT_SCRIPT_INITIALIZER, writer, new ArrayList(), ts, true); + abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/.scriptinitializer", exportMode, true, script_init, scriptIndex, -1, abc, null, new ScopeStack(), GraphTextWriter.TRAIT_SCRIPT_INITIALIZER, writer, new ArrayList(), ts, true); scriptInitializerIsEmpty = !writer.getMark(); } @@ -190,7 +191,7 @@ public class ScriptPack extends AS3ClassTreeItem { writer.startMethod(script_init); if (!scriptInitializerIsEmpty) { writer.startBlock(); - abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/.scriptinitializer", exportMode, abc, null, abc.constants, abc.method_info, writer, new ArrayList()); + abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/.scriptinitializer", exportMode, abc, null, writer, new ArrayList<>()); writer.endBlock(); } else { writer.append(" "); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 9cf1d9ede..98d06f7dc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -275,6 +275,7 @@ import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; +import com.jpexs.decompiler.flash.helpers.SWFDecompilerPlugin; import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import com.jpexs.decompiler.graph.Block; import com.jpexs.decompiler.graph.DottedChain; @@ -1463,7 +1464,7 @@ public class AVM2Code implements Cloneable { return pos2adr(fixIPAfterDebugLine(adr2pos(addr, true))); } - public ConvertOutput toSourceOutput(String path, GraphPart part, boolean processJumps, boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ABC abc, AVM2ConstantPool constants, List method_info, MethodBody body, int start, int end, HashMap localRegNames, List fullyQualifiedNames, boolean[] visited, HashMap localRegAssigmentIps, HashMap> refs) throws ConvertException, InterruptedException { + public ConvertOutput toSourceOutput(String path, GraphPart part, boolean processJumps, boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ABC abc, MethodBody body, int start, int end, HashMap localRegNames, List fullyQualifiedNames, boolean[] visited, HashMap localRegAssigmentIps, HashMap> refs) throws ConvertException, InterruptedException { calcKilledStats(body); boolean debugMode = DEBUG_MODE; if (debugMode) { @@ -1570,12 +1571,12 @@ public class AVM2Code implements Cloneable { AVM2Instruction insAfter = code.get(ip + 1); if ((insAfter.definition instanceof GetLocalTypeIns) && (((GetLocalTypeIns) insAfter.definition).getRegisterId(insAfter) == ((SetLocalTypeIns) ins.definition).getRegisterId(ins))) { GraphTargetItem before = stack.peek(); - ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this); + ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, ins, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this); stack.push(before); ip += 2; continue iploop; } else { - ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this); + ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, ins, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this); ip++; continue iploop; } @@ -1584,7 +1585,7 @@ public class AVM2Code implements Cloneable { do { AVM2Instruction insAfter = ip + 1 < code.size() ? code.get(ip + 1) : null; if (insAfter == null) { - ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this); + ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, ins, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this); ip++; break; } @@ -1618,7 +1619,7 @@ public class AVM2Code implements Cloneable { if (((GetLocalTypeIns) code.get(t).definition).getRegisterId(code.get(t)) == reg) { if (code.get(t + 1).definition instanceof KillIns) { if (code.get(t + 1).operands[0] == reg) { - ConvertOutput assignment = toSourceOutput(path, part, processJumps, isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip + 2, t - 1, localRegNames, fullyQualifiedNames, visited, localRegAssigmentIps, refs); + ConvertOutput assignment = toSourceOutput(path, part, processJumps, isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, abc, body, ip + 2, t - 1, localRegNames, fullyQualifiedNames, visited, localRegAssigmentIps, refs); if (!assignment.output.isEmpty()) { GraphTargetItem tar = assignment.output.remove(assignment.output.size() - 1); tar.firstPart = part; @@ -1652,21 +1653,21 @@ public class AVM2Code implements Cloneable { } stack.push(vx); } else { - ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this); + ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, ins, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this); } ip++; break; //} } else { - ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this); + ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, ins, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this); ip++; break; //throw new ConvertException("Unknown pattern after DUP:" + insComparsion.toString()); } } while (ins.definition instanceof DupIns); } else if ((ins.definition instanceof ReturnValueIns) || (ins.definition instanceof ReturnVoidIns) || (ins.definition instanceof ThrowIns)) { - ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this); + ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, ins, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this); //ip = end + 1; break; } else if (ins.definition instanceof NewFunctionIns) { @@ -1688,7 +1689,7 @@ public class AVM2Code implements Cloneable { if (code.get(ip + plus + 2).definition instanceof SwapIns) { if (code.get(ip + plus + 4).definition instanceof PopScopeIns) { if (code.get(ip + plus + 3).definition instanceof SetPropertyIns) { - functionName = abc.constants.getMultiname(code.get(ip + plus + 3).operands[0]).getName(constants, fullyQualifiedNames, true); + functionName = abc.constants.getMultiname(code.get(ip + plus + 3).operands[0]).getName(abc.constants, fullyQualifiedNames, true); scopeStack.pop();// with output.remove(output.size() - 1); // with ip = ip + plus + 4; // +1 below @@ -1702,13 +1703,13 @@ public class AVM2Code implements Cloneable { } } // What to do when hasDup is false? - ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this); + ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, ins, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this); NewFunctionAVM2Item nft = (NewFunctionAVM2Item) stack.peek(); nft.functionName = functionName; ip++; } else { try { - ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this); + ins.definition.translate(isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, ins, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this); } catch (RuntimeException re) { /*String last=""; int len=5; @@ -1879,7 +1880,7 @@ public class AVM2Code implements Cloneable { }*/ } - public List toGraphTargetItems(String path, int methodIndex, boolean isStatic, int scriptIndex, int classIndex, ABC abc, AVM2ConstantPool constants, List method_info, MethodBody body, HashMap localRegNames, ScopeStack scopeStack, int initializerType, List fullyQualifiedNames, List initTraits, int staticOperation, HashMap localRegAssigmentIps, HashMap> refs) throws InterruptedException { + public List toGraphTargetItems(String path, int methodIndex, boolean isStatic, int scriptIndex, int classIndex, ABC abc, MethodBody body, HashMap localRegNames, ScopeStack scopeStack, int initializerType, List fullyQualifiedNames, List initTraits, int staticOperation, HashMap localRegAssigmentIps, HashMap> refs) throws InterruptedException { initToSource(); List list; HashMap localRegs = new HashMap<>(); @@ -2217,8 +2218,6 @@ public class AVM2Code implements Cloneable { ret.classIndex = localData.classIndex; ret.localRegs = new HashMap<>(localData.localRegs); ret.scopeStack = (ScopeStack) (localData.scopeStack).clone(); - ret.constants = localData.constants; - ret.methodInfo = localData.methodInfo; ret.methodBody = localData.methodBody; ret.abc = localData.abc; ret.localRegNames = localData.localRegNames; @@ -2235,15 +2234,13 @@ public class AVM2Code implements Cloneable { return ret; } - private int removeTrapsOld(AVM2ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, ABC abc, int scriptIndex, int classIndex, boolean isStatic, String path) throws InterruptedException { + private int removeTrapsOld(Trait trait, int methodInfo, MethodBody body, ABC abc, int scriptIndex, int classIndex, boolean isStatic, String path) throws InterruptedException { removeDeadCode(body); AVM2LocalData localData = new AVM2LocalData(); localData.isStatic = isStatic; localData.classIndex = classIndex; localData.localRegs = new HashMap<>(); localData.scopeStack = new ScopeStack(); - localData.constants = abc.constants; - localData.methodInfo = abc.method_info; localData.methodBody = body; localData.abc = abc; localData.localRegNames = body.getLocalRegNames(abc); @@ -2253,25 +2250,26 @@ public class AVM2Code implements Cloneable { localData.refs = refs; localData.code = this; int ret = 0; - ret += removeTrapsOld(constants, trait, info, body, localData, new AVM2GraphSource(this, false, -1, -1, new HashMap<>(), new ScopeStack(), abc, body, new HashMap<>(), new ArrayList<>(), new HashMap<>(), refs), 0, path, refs); + ret += removeTrapsOld(trait, methodInfo, body, localData, new AVM2GraphSource(this, false, -1, -1, new HashMap<>(), new ScopeStack(), abc, body, new HashMap<>(), new ArrayList<>(), new HashMap<>(), refs), 0, path, refs); removeIgnored(body); removeDeadCode(body); return ret; } - public int removeTraps(AVM2ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, ABC abc, int scriptIndex, int classIndex, boolean isStatic, String path) throws InterruptedException { + public int removeTraps(Trait trait, int methodInfo, MethodBody body, ABC abc, int scriptIndex, int classIndex, boolean isStatic, String path) throws InterruptedException { if (Configuration.deobfuscationOldMode.get()) { - return removeTrapsOld(constants, trait, info, body, abc, scriptIndex, classIndex, isStatic, path); + return removeTrapsOld(trait, methodInfo, body, abc, scriptIndex, classIndex, isStatic, path); } else { + SWFDecompilerPlugin.fireAvm2CodeRemoveTraps(path, classIndex, isStatic, scriptIndex, abc, trait, methodInfo, body); try (Statistics s = new Statistics("AVM2DeobfuscatorSimple")) { - new AVM2DeobfuscatorSimple().deobfuscate(path, classIndex, isStatic, scriptIndex, abc, constants, trait, info, body); + new AVM2DeobfuscatorSimple().avm2CodeRemoveTraps(path, classIndex, isStatic, scriptIndex, abc, trait, methodInfo, body); } try (Statistics s = new Statistics("AVM2DeobfuscatorRegisters")) { - new AVM2DeobfuscatorRegisters().deobfuscate(path, classIndex, isStatic, scriptIndex, abc, constants, trait, info, body); + new AVM2DeobfuscatorRegisters().avm2CodeRemoveTraps(path, classIndex, isStatic, scriptIndex, abc, trait, methodInfo, body); } try (Statistics s = new Statistics("AVM2DeobfuscatorJumps")) { - new AVM2DeobfuscatorJumps().deobfuscate(path, classIndex, isStatic, scriptIndex, abc, constants, trait, info, body); + new AVM2DeobfuscatorJumps().avm2CodeRemoveTraps(path, classIndex, isStatic, scriptIndex, abc, trait, methodInfo, body); } return 1; } @@ -3310,7 +3308,7 @@ public class AVM2Code implements Cloneable { return ret; } - public static int removeTrapsOld(AVM2ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, AVM2LocalData localData, AVM2GraphSource code, int addr, String path, HashMap> refs) throws InterruptedException { + public static int removeTrapsOld(Trait trait, int methodInfo, MethodBody body, AVM2LocalData localData, AVM2GraphSource code, int addr, String path, HashMap> refs) throws InterruptedException { HashMap decisions = new HashMap<>(); removeTrapsOld(refs, false, false, localData, new TranslateStack(path), new ArrayList<>(), code, code.adr2pos(addr), new HashMap<>(), new HashMap<>(), decisions, path, 0); int cnt = 0; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorJumps.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorJumps.java index 465563423..a8567db80 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorJumps.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorJumps.java @@ -19,12 +19,10 @@ package com.jpexs.decompiler.flash.abc.avm2.deobfuscation; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns; import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.action.ActionList; import java.util.List; @@ -47,7 +45,7 @@ public class AVM2DeobfuscatorJumps extends AVM2DeobfuscatorSimple { } @Override - public void deobfuscate(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body) throws InterruptedException { + public void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException { //body.getCode().markMappedOffsets(); //removeUnreachableInstructions(body.getCode(), cpool, trait, minfo, body); @@ -81,7 +79,7 @@ public class AVM2DeobfuscatorJumps extends AVM2DeobfuscatorSimple { } } } - removeUnreachableInstructions(body.getCode(), cpool, trait, minfo, body); + removeUnreachableInstructions(body.getCode(), body); } while (found); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegisters.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegisters.java index ea41b1f28..1c0784137 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegisters.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegisters.java @@ -92,11 +92,11 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple { } @Override - public void deobfuscate(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body) throws InterruptedException { + public void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException { //System.err.println("regdeo:" + path); MethodBody originalBody = body; - removeUnreachableInstructions(body.getCode(), cpool, trait, minfo, body); + removeUnreachableInstructions(body.getCode(), body); Set ignoredRegs = new HashSet<>(); int localReservedCount = body.getLocalReservedCount(); @@ -141,7 +141,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple { AVM2Instruction assignment = assignmentRef.getVal(); InstructionDefinition def = assignment.definition; if ((def instanceof SetLocalTypeIns) || (def instanceof GetLocalTypeIns /*First usage -> value undefined*/)) { - super.removeObfuscationIfs(classIndex, isStatic, scriptIndex, abc, cpool, trait, minfo, body, Arrays.asList(assignment)); + super.removeObfuscationIfs(classIndex, isStatic, scriptIndex, abc, body, Arrays.asList(assignment)); } if (def instanceof GetLocalTypeIns) { @@ -154,7 +154,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple { originalBody.exceptions = body.exceptions; originalBody.setCode(body.getCode()); - removeUnreachableInstructions(body.getCode(), cpool, trait, minfo, body); + removeUnreachableInstructions(body.getCode(), body); //System.err.println("/deo"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorSimple.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorSimple.java index 61a4baaa8..0c9b1beb9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorSimple.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorSimple.java @@ -77,7 +77,6 @@ import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.StringAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.UndefinedAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.action.ActionList; import com.jpexs.decompiler.flash.ecma.EcmaScript; @@ -170,7 +169,7 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener { } } - protected boolean removeObfuscationIfs(int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body, List inlineIns) throws InterruptedException { + protected boolean removeObfuscationIfs(int classIndex, boolean isStatic, int scriptIndex, ABC abc, MethodBody body, List inlineIns) throws InterruptedException { AVM2Code code = body.getCode(); if (code.code.isEmpty()) { return false; @@ -206,7 +205,7 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener { return false; } - protected void removeUnreachableInstructions(AVM2Code code, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body) throws InterruptedException { + protected void removeUnreachableInstructions(AVM2Code code, MethodBody body) throws InterruptedException { code.removeDeadCode(body); } @@ -236,8 +235,6 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener { localData.localRegs = new HashMap<>(body.max_regs); localData.localRegAssignmentIps = new HashMap<>(); localData.scopeStack = new ScopeStack(true); - localData.constants = cpool; - localData.methodInfo = abc.method_info; localData.methodBody = body; localData.abc = abc; localData.localRegNames = new HashMap<>(); @@ -472,10 +469,11 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener { } - public void deobfuscate(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body) throws InterruptedException { + @Override + public void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException { AVM2Code code = body.getCode(); - removeUnreachableInstructions(code, cpool, trait, minfo, body); - removeObfuscationIfs(classIndex, isStatic, scriptIndex, abc, cpool, trait, minfo, body, new ArrayList<>()); + removeUnreachableInstructions(code, body); + removeObfuscationIfs(classIndex, isStatic, scriptIndex, abc, body, new ArrayList<>()); removeZeroJumps(code, body); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java index 1471172fe..23b54aa9f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java @@ -122,8 +122,6 @@ public class AVM2Graph extends Graph { localData.classIndex = classIndex; localData.localRegs = localRegs; localData.scopeStack = scopeStack; - localData.constants = abc.constants; - localData.methodInfo = abc.method_info; localData.methodBody = body; localData.abc = abc; localData.localRegNames = localRegNames; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2GraphSource.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2GraphSource.java index 4ccb7dcde..51e560d50 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2GraphSource.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2GraphSource.java @@ -102,7 +102,7 @@ public class AVM2GraphSource extends GraphSource { public List translatePart(GraphPart part, BaseLocalData localData, TranslateStack stack, int start, int end, int staticOperation, String path) throws InterruptedException { List ret = new ArrayList<>(); ScopeStack newstack = ((AVM2LocalData) localData).scopeStack; - ConvertOutput co = code.toSourceOutput(path, part, false, isStatic, scriptIndex, classIndex, localRegs, stack, newstack, abc, abc.constants, abc.method_info, body, start, end, localRegNames, fullyQualifiedNames, new boolean[size()], localRegAssigmentIps, refs); + ConvertOutput co = code.toSourceOutput(path, part, false, isStatic, scriptIndex, classIndex, localRegs, stack, newstack, abc, body, start, end, localRegNames, fullyQualifiedNames, new boolean[size()], localRegAssigmentIps, refs); ret.addAll(co.output); return ret; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java index 6bbd614c9..2a70069ff 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java @@ -29,7 +29,6 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocalTypeIn import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -92,15 +91,13 @@ public abstract class InstructionDefinition implements Serializable { public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) throws InterruptedException { } - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2Instruction ins, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { AVM2LocalData localData = new AVM2LocalData(); localData.isStatic = isStatic; localData.scriptIndex = scriptIndex; localData.classIndex = classIndex; localData.localRegs = localRegs; localData.scopeStack = scopeStack; - localData.constants = constants; - localData.methodInfo = method_info; localData.methodBody = body; localData.abc = abc; localData.localRegNames = localRegNames; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java index 8a794d88c..06715d1b8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java @@ -89,13 +89,13 @@ public class ConstructIns extends InstructionDefinition { FullMultinameAVM2Item fptXmlMult = (FullMultinameAVM2Item) fpt.propertyName; FullMultinameAVM2Item gptXmlMult = (FullMultinameAVM2Item) gpt.propertyName; - isXML = fptXmlMult.isXML(localData.constants, localData.localRegNames, localData.fullyQualifiedNames) - && gptXmlMult.isXML(localData.constants, localData.localRegNames, localData.fullyQualifiedNames); + isXML = fptXmlMult.isXML(localData.getConstants(), localData.localRegNames, localData.fullyQualifiedNames) + && gptXmlMult.isXML(localData.getConstants(), localData.localRegNames, localData.fullyQualifiedNames); } } if (obj instanceof GetLexAVM2Item) { GetLexAVM2Item glt = (GetLexAVM2Item) obj; - isXML = glt.propertyName.getName(localData.constants, localData.fullyQualifiedNames, true).equals("XML"); + isXML = glt.propertyName.getName(localData.getConstants(), localData.fullyQualifiedNames, true).equals("XML"); } if (isXML) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructPropIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructPropIns.java index 75d9717b2..1b2755cc1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructPropIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructPropIns.java @@ -60,10 +60,10 @@ public class ConstructPropIns extends InstructionDefinition { for (int a = 0; a < argCount; a++) { args.add(0, stack.pop()); } - FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.constants, multinameIndex, ins); + FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.getConstants(), multinameIndex, ins); GraphTargetItem obj = stack.pop(); - if (multiname.isXML(localData.constants, localData.localRegNames, localData.fullyQualifiedNames)) { + if (multiname.isXML(localData.getConstants(), localData.localRegNames, localData.fullyQualifiedNames)) { if (args.size() == 1) { GraphTargetItem arg = args.get(0); List xmlLines = new ArrayList<>(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java index abf1bfc16..94771c0b2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java @@ -39,10 +39,10 @@ public class NewClassIns extends InstructionDefinition { public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) throws InterruptedException { int clsIndex = ins.operands[0]; HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); - stack.pop().toString(writer, LocalData.create(localData.constants, localData.localRegNames, localData.fullyQualifiedNames)); + stack.pop().toString(writer, LocalData.create(localData.getConstants(), localData.localRegNames, localData.fullyQualifiedNames)); String baseType = writer.toString(); ABC abc = localData.abc; - stack.push(new UnparsedAVM2Item(ins, "new " + abc.constants.getMultiname(abc.instance_info.get(clsIndex).name_index).getName(localData.constants, localData.fullyQualifiedNames, false) + ".class extends " + baseType)); + stack.push(new UnparsedAVM2Item(ins, "new " + abc.constants.getMultiname(abc.instance_info.get(clsIndex).name_index).getName(localData.getConstants(), localData.fullyQualifiedNames, false) + ".class extends " + baseType)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java index 7a62cbd3d..0d54cdf28 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java @@ -35,7 +35,7 @@ public class NewFunctionIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int methodIndex = ins.operands[0]; - NewFunctionAVM2Item function = new NewFunctionAVM2Item(ins, "", path, localData.isStatic, localData.scriptIndex, localData.classIndex, localData.abc, localData.fullyQualifiedNames, localData.constants, localData.methodInfo, methodIndex); + NewFunctionAVM2Item function = new NewFunctionAVM2Item(ins, "", path, localData.isStatic, localData.scriptIndex, localData.classIndex, localData.abc, localData.fullyQualifiedNames, methodIndex); stack.push(function); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallMethodIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallMethodIns.java index 53e59c135..8aedaf2c5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallMethodIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallMethodIns.java @@ -57,7 +57,7 @@ public class CallMethodIns extends InstructionDefinition { args.add(0, stack.pop()); } GraphTargetItem receiver = stack.pop(); - String methodName = localData.methodInfo.get(methodIndex).getName(localData.constants); + String methodName = localData.getMethodInfo().get(methodIndex).getName(localData.getConstants()); stack.push(new CallMethodAVM2Item(ins, receiver, methodName, args)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java index bf7a6fd05..a8926241a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java @@ -42,7 +42,7 @@ public class CallPropLexIns extends CallPropertyIns { args.add(0, stack.pop()); } - FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.constants, multinameIndex, ins); + FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.getConstants(), multinameIndex, ins); GraphTargetItem receiver = stack.pop(); stack.push(new CallPropertyAVM2Item(ins, false, receiver, multiname, args)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java index b9a99b200..3e0ce2e49 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java @@ -61,7 +61,7 @@ public class CallPropVoidIns extends InstructionDefinition { for (int a = 0; a < argCount; a++) { args.add(0, stack.pop()); } - FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.constants, multinameIndex, ins); + FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.getConstants(), multinameIndex, ins); GraphTargetItem receiver = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java index 8b4790d0e..8e36c4641 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java @@ -60,7 +60,7 @@ public class CallPropertyIns extends InstructionDefinition { args.add(0, stack.pop()); } - FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.constants, multinameIndex, ins); + FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.getConstants(), multinameIndex, ins); GraphTargetItem receiver = stack.pop(); stack.push(new CallPropertyAVM2Item(ins, false, receiver, multiname, args)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallStaticIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallStaticIns.java index 07eabc768..1e64c093c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallStaticIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallStaticIns.java @@ -57,7 +57,7 @@ public class CallStaticIns extends InstructionDefinition { args.add(0, stack.pop()); } GraphTargetItem receiver = stack.pop(); - String methodName = localData.methodInfo.get(methodIndex).getName(localData.constants); + String methodName = localData.getMethodInfo().get(methodIndex).getName(localData.getConstants()); stack.push(new CallStaticAVM2Item(ins, receiver, methodName, args)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperIns.java index eb278239a..cecce19fb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperIns.java @@ -59,7 +59,7 @@ public class CallSuperIns extends InstructionDefinition { for (int a = 0; a < argCount; a++) { args.add(0, stack.pop()); } - FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.constants, multinameIndex, ins); + FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.getConstants(), multinameIndex, ins); GraphTargetItem receiver = stack.pop(); stack.push(new CallSuperAVM2Item(ins, false, receiver, multiname, args)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperVoidIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperVoidIns.java index 9ca45940c..c04d79b62 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperVoidIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperVoidIns.java @@ -59,7 +59,7 @@ public class CallSuperVoidIns extends InstructionDefinition { for (int a = 0; a < argCount; a++) { args.add(0, stack.pop()); } - FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.constants, multinameIndex, ins); + FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.getConstants(), multinameIndex, ins); GraphTargetItem receiver = stack.pop(); output.add(new CallSuperAVM2Item(ins, true, receiver, multiname, args)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java index 340eff857..bfe0af14c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java @@ -41,14 +41,14 @@ public abstract class GetLocalTypeIns extends InstructionDefinition { int regId = getRegisterId(ins); if (regId == 0) { - if ((localData.classIndex >= localData.abc.instance_info.size()) || localData.classIndex < 0) { + if ((localData.classIndex >= localData.getInstanceInfo().size()) || localData.classIndex < 0) { stack.push(new ScriptAVM2Item(localData.scriptIndex)); return; } if (localData.isStatic) { - stack.push(new ClassAVM2Item(localData.abc.instance_info.get(localData.classIndex).getName(localData.constants))); + stack.push(new ClassAVM2Item(localData.getInstanceInfo().get(localData.classIndex).getName(localData.getConstants()))); } else { - stack.push(new ThisAVM2Item(ins, localData.abc.instance_info.get(localData.classIndex).getName(localData.constants))); + stack.push(new ThisAVM2Item(ins, localData.getInstanceInfo().get(localData.classIndex).getName(localData.getConstants()))); } return; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java index f932cfa89..2d06501de 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java @@ -48,7 +48,7 @@ public class DeletePropertyIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int multinameIndex = ins.operands[0]; - FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.constants, multinameIndex, ins); + FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.getConstants(), multinameIndex, ins); GraphTargetItem obj = stack.pop(); //stack.add(new BooleanAVM2Item(ins, Boolean.TRUE));//property successfully deleted stack.add(new DeletePropertyAVM2Item(ins, obj, multiname)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindDefIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindDefIns.java index cbf328efd..c8fca6d18 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindDefIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindDefIns.java @@ -36,7 +36,7 @@ public class FindDefIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int multinameIndex = ins.operands[0]; - Multiname multiname = localData.constants.getMultiname(multinameIndex); + Multiname multiname = localData.getConstants().getMultiname(multinameIndex); stack.push(new FindDefAVM2Item(ins, multiname)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyIns.java index b2d7894d2..f22c236d1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyIns.java @@ -47,7 +47,7 @@ public class FindPropertyIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int multinameIndex = ins.operands[0]; - FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.constants, multinameIndex, ins); + FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.getConstants(), multinameIndex, ins); stack.push(new FindPropertyAVM2Item(ins, multiname)); //resolve right object } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyStrictIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyStrictIns.java index da23b0272..b7408ad06 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyStrictIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyStrictIns.java @@ -46,7 +46,7 @@ public class FindPropertyStrictIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int multinameIndex = ins.operands[0]; - FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.constants, multinameIndex, ins); + FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.getConstants(), multinameIndex, ins); stack.push(new FindPropertyAVM2Item(ins, multiname)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java index 4a45b10d4..95de7ae5e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java @@ -47,7 +47,7 @@ public class GetDescendantsIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int multinameIndex = ins.operands[0]; - FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.constants, multinameIndex, ins); + FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.getConstants(), multinameIndex, ins); GraphTargetItem obj = stack.pop(); stack.push(new GetDescendantsAVM2Item(ins, obj, multiname)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java index 44bf509d0..c14db1e9d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java @@ -45,7 +45,7 @@ public class GetGlobalScopeIns extends InstructionDefinition { if (localData.classIndex == -1) { stack.push(new ScriptAVM2Item(localData.scriptIndex)); } else { - stack.push(new ClassAVM2Item(localData.abc.instance_info.get(localData.classIndex).getName(localData.constants))); + stack.push(new ClassAVM2Item(localData.getInstanceInfo().get(localData.classIndex).getName(localData.getConstants()))); } return; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java index eacd1e343..3d82b67a4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java @@ -43,7 +43,7 @@ public class GetGlobalSlotIns extends InstructionDefinition { GraphTargetItem obj = localData.scopeStack.get(0); //scope Multiname slotname = null; if (obj instanceof ExceptionAVM2Item) { - slotname = localData.constants.getMultiname(((ExceptionAVM2Item) obj).exception.name_index); + slotname = localData.getConstants().getMultiname(((ExceptionAVM2Item) obj).exception.name_index); } else { MethodBody body = localData.methodBody; List traits = body.traits.traits; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java index 84c5b432d..78c458191 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java @@ -36,7 +36,7 @@ public class GetLexIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int multinameIndex = ins.operands[0]; - Multiname multiname = localData.constants.getMultiname(multinameIndex); + Multiname multiname = localData.getConstants().getMultiname(multinameIndex); stack.push(new GetLexAVM2Item(ins, multiname)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java index 94c4fa688..b39ec822c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java @@ -36,7 +36,7 @@ public class GetPropertyIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int multinameIndex = ins.operands[0]; - FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.constants, multinameIndex, ins); + FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.getConstants(), multinameIndex, ins); GraphTargetItem obj = stack.pop(); stack.push(new GetPropertyAVM2Item(ins, obj, multiname)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java index 7b93cf4f9..e7a6c8dad 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java @@ -48,13 +48,13 @@ public class GetSlotIns extends InstructionDefinition { obj = obj.getThroughRegister(); Multiname slotname = null; if (obj instanceof ExceptionAVM2Item) { - slotname = localData.constants.getMultiname(((ExceptionAVM2Item) obj).exception.name_index); + slotname = localData.getConstants().getMultiname(((ExceptionAVM2Item) obj).exception.name_index); } else if (obj instanceof ClassAVM2Item) { slotname = ((ClassAVM2Item) obj).className; } else if (obj instanceof ThisAVM2Item) { slotname = ((ThisAVM2Item) obj).className; } else if (obj instanceof ScriptAVM2Item) { - List traits = localData.abc.script_info.get(((ScriptAVM2Item) obj).scriptIndex).traits.traits; + List traits = localData.getScriptInfo().get(((ScriptAVM2Item) obj).scriptIndex).traits.traits; for (int t = 0; t < traits.size(); t++) { Trait tr = traits.get(t); if (tr instanceof TraitWithSlot) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSuperIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSuperIns.java index dfc1e9196..29009b344 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSuperIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSuperIns.java @@ -36,7 +36,7 @@ public class GetSuperIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int multinameIndex = ins.operands[0]; - FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.constants, multinameIndex, ins); + FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.getConstants(), multinameIndex, ins); GraphTargetItem obj = stack.pop(); stack.push(new GetSuperAVM2Item(ins, obj, multiname)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java index 4f5968758..5b3f70364 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java @@ -38,7 +38,7 @@ public class InitPropertyIns extends InstructionDefinition { int multinameIndex = ins.operands[0]; GraphTargetItem val = stack.pop(); - FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.constants, multinameIndex, ins); + FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.getConstants(), multinameIndex, ins); GraphTargetItem obj = stack.pop(); output.add(new InitPropertyAVM2Item(ins, obj, multiname, val)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java index edf57c402..cff2a7911 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java @@ -55,7 +55,7 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int multinameIndex = ins.operands[0]; GraphTargetItem value = stack.pop(); - FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.constants, multinameIndex, ins); + FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.getConstants(), multinameIndex, ins); GraphTargetItem obj = stack.pop(); if (value.getThroughDuplicate().getThroughRegister().getThroughDuplicate() instanceof IncrementAVM2Item) { GraphTargetItem inside = ((IncrementAVM2Item) value.getThroughDuplicate().getThroughRegister().getThroughDuplicate()).value.getThroughRegister().getNotCoerced().getThroughDuplicate(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java index 9ea6f5c22..57e806d54 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java @@ -68,13 +68,13 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns { } if (obj instanceof ExceptionAVM2Item) { - slotname = localData.constants.getMultiname(((ExceptionAVM2Item) obj).exception.name_index); + slotname = localData.getConstants().getMultiname(((ExceptionAVM2Item) obj).exception.name_index); } else if (obj instanceof ClassAVM2Item) { slotname = ((ClassAVM2Item) obj).className; } else if (obj instanceof ThisAVM2Item) { slotname = ((ThisAVM2Item) obj).className; } else if (obj instanceof ScriptAVM2Item) { - List traits = localData.abc.script_info.get(((ScriptAVM2Item) obj).scriptIndex).traits.traits; + List traits = localData.getScriptInfo().get(((ScriptAVM2Item) obj).scriptIndex).traits.traits; for (int t = 0; t < traits.size(); t++) { Trait tr = traits.get(t); if (tr instanceof TraitWithSlot) { @@ -100,7 +100,7 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns { if (slotname != null) { if (value instanceof LocalRegAVM2Item) { LocalRegAVM2Item lr = (LocalRegAVM2Item) value; - String slotNameStr = slotname.getName(localData.constants, localData.fullyQualifiedNames, true); + String slotNameStr = slotname.getName(localData.getConstants(), localData.fullyQualifiedNames, true); if (localData.localRegNames.containsKey(lr.regIndex)) { if (localData.localRegNames.get(lr.regIndex).equals(slotNameStr)) { return; //Register with same name to slot diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java index 0542a97f1..67351f1cd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java @@ -47,7 +47,7 @@ public class SetSuperIns extends InstructionDefinition implements SetTypeIns { int multinameIndex = ins.operands[0]; GraphTargetItem value = stack.pop(); - FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.constants, multinameIndex, ins); + FullMultinameAVM2Item multiname = resolveMultiname(stack, localData.getConstants(), multinameIndex, ins); GraphTargetItem obj = stack.pop(); output.add(new SetSuperAVM2Item(ins, value, obj, multiname)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushDoubleIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushDoubleIns.java index 93585e13c..6e24f999b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushDoubleIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushDoubleIns.java @@ -41,7 +41,7 @@ public class PushDoubleIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new FloatValueAVM2Item(ins, localData.constants.getDouble(ins.operands[0]))); + stack.push(new FloatValueAVM2Item(ins, localData.getConstants().getDouble(ins.operands[0]))); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushIntIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushIntIns.java index 2aa88d9ef..952535807 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushIntIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushIntIns.java @@ -41,7 +41,7 @@ public class PushIntIns extends InstructionDefinition implements PushIntegerType @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new IntegerValueAVM2Item(ins, localData.constants.getInt(ins.operands[0]))); + stack.push(new IntegerValueAVM2Item(ins, localData.getConstants().getInt(ins.operands[0]))); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushStringIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushStringIns.java index 8198009a0..30b5a1182 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushStringIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushStringIns.java @@ -41,7 +41,7 @@ public class PushStringIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new StringAVM2Item(ins, localData.constants.getString(ins.operands[0]))); + stack.push(new StringAVM2Item(ins, localData.getConstants().getString(ins.operands[0]))); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUIntIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUIntIns.java index ab29e4f5b..60f47e816 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUIntIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUIntIns.java @@ -41,7 +41,7 @@ public class PushUIntIns extends InstructionDefinition implements PushIntegerTyp @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new IntegerValueAVM2Item(ins, localData.constants.getUInt(ins.operands[0]))); + stack.push(new IntegerValueAVM2Item(ins, localData.getConstants().getUInt(ins.operands[0]))); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java index 7c709987b..76e62f5dd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java @@ -45,7 +45,7 @@ public class CoerceAIns extends InstructionDefinition implements CoerceOrConvert @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new CoerceAVM2Item(ins, stack.pop(), getTargetType(localData.constants, ins))); + stack.push(new CoerceAVM2Item(ins, stack.pop(), getTargetType(localData.getConstants(), ins))); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java index 8644f66d3..f4f31ad6e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java @@ -44,7 +44,7 @@ public class CoerceIns extends InstructionDefinition implements CoerceOrConvertT @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int multinameIndex = ins.operands[0]; - stack.push(new CoerceAVM2Item(ins, stack.pop(), PropertyAVM2Item.multinameToType(multinameIndex, localData.constants))); + stack.push(new CoerceAVM2Item(ins, stack.pop(), PropertyAVM2Item.multinameToType(multinameIndex, localData.getConstants()))); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java index b618db54b..e81b5317c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java @@ -43,7 +43,7 @@ public class CoerceSIns extends InstructionDefinition implements CoerceOrConvert @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new CoerceAVM2Item(ins, stack.pop(), getTargetType(localData.constants, ins))); + stack.push(new CoerceAVM2Item(ins, stack.pop(), getTargetType(localData.getConstants(), ins))); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java index 17020c152..5d8eb4558 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java @@ -53,7 +53,7 @@ public class ConvertBIns extends InstructionDefinition implements CoerceOrConver @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(localData.constants, ins))); + stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(localData.getConstants(), ins))); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java index de9c82b71..21fbdf339 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java @@ -61,7 +61,7 @@ public class ConvertDIns extends InstructionDefinition implements CoerceOrConver @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(localData.constants, ins))); + stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(localData.getConstants(), ins))); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java index e00fb181b..f44e144a9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java @@ -59,7 +59,7 @@ public class ConvertIIns extends InstructionDefinition implements CoerceOrConver @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(localData.constants, ins))); + stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(localData.getConstants(), ins))); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java index 59af7bd08..5fbbca17c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java @@ -42,7 +42,7 @@ public class ConvertOIns extends InstructionDefinition implements CoerceOrConver @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(localData.constants, ins))); + stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(localData.getConstants(), ins))); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java index 1d3ad0f46..1973c5af5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java @@ -43,7 +43,7 @@ public class ConvertSIns extends InstructionDefinition implements CoerceOrConver @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(localData.constants, ins))); + stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(localData.getConstants(), ins))); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java index a49e74bf9..787f1849c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java @@ -42,7 +42,7 @@ public class ConvertUIns extends InstructionDefinition implements CoerceOrConver @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(localData.constants, ins))); + stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(localData.getConstants(), ins))); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSIns.java index 3dd3e91ab..0c8c08d69 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSIns.java @@ -45,6 +45,6 @@ public class DXNSIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { //FIXME!!! - search namespace - output.add(new DefaultXMLNamespace(ins, new StringAVM2Item(ins, localData.constants.getString(ins.operands[0])))); + output.add(new DefaultXMLNamespace(ins, new StringAVM2Item(ins, localData.getConstants().getString(ins.operands[0])))); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java index 3a8cd6edd..8eea6d766 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java @@ -17,10 +17,8 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; @@ -48,13 +46,9 @@ public class NewFunctionAVM2Item extends AVM2Item { public List fullyQualifiedNames; - public AVM2ConstantPool constants; - - public List methodInfo; - public int methodIndex; - public NewFunctionAVM2Item(AVM2Instruction instruction, String functionName, String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, List fullyQualifiedNames, AVM2ConstantPool constants, List methodInfo, int methodIndex) { + public NewFunctionAVM2Item(AVM2Instruction instruction, String functionName, String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, List fullyQualifiedNames, int methodIndex) { super(instruction, PRECEDENCE_PRIMARY); this.functionName = functionName; this.path = path; @@ -63,8 +57,6 @@ public class NewFunctionAVM2Item extends AVM2Item { this.classIndex = classIndex; this.abc = abc; this.fullyQualifiedNames = fullyQualifiedNames; - this.constants = constants; - this.methodInfo = methodInfo; this.methodIndex = methodIndex; } @@ -75,20 +67,20 @@ public class NewFunctionAVM2Item extends AVM2Item { writer.startMethod(methodIndex); writer.append((!functionName.isEmpty() ? " " + functionName : "")); writer.appendNoHilight("("); - methodInfo.get(methodIndex).getParamStr(writer, constants, body, abc, fullyQualifiedNames); + abc.method_info.get(methodIndex).getParamStr(writer, abc.constants, body, abc, fullyQualifiedNames); writer.appendNoHilight("):"); if (Configuration.showMethodBodyId.get()) { writer.appendNoHilight("// method body id: "); writer.appendNoHilight(abc.findBodyIndex(methodIndex)); writer.newLine(); } - methodInfo.get(methodIndex).getReturnTypeStr(writer, constants, fullyQualifiedNames); + abc.method_info.get(methodIndex).getReturnTypeStr(writer, abc.constants, fullyQualifiedNames); writer.startBlock(); if (body != null) { if (writer instanceof NulWriter) { - body.convert(path + "/inner", ScriptExportMode.AS, isStatic, methodIndex, scriptIndex, classIndex, abc, null, constants, methodInfo, new ScopeStack(), 0, (NulWriter) writer, fullyQualifiedNames, null, false); + body.convert(path + "/inner", ScriptExportMode.AS, isStatic, methodIndex, scriptIndex, classIndex, abc, null, new ScopeStack(), 0, (NulWriter) writer, fullyQualifiedNames, null, false); } else { - body.toString(path + "/inner", ScriptExportMode.AS, abc, null, constants, methodInfo, writer, fullyQualifiedNames); + body.toString(path + "/inner", ScriptExportMode.AS, abc, null, writer, fullyQualifiedNames); } } writer.endBlock(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index 753850321..5ede361ab 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -178,18 +178,18 @@ public final class MethodBody implements Cloneable { getCode().restoreControlFlow(constants, trait, info, this); } - public int removeTraps(AVM2ConstantPool constants, ABC abc, Trait trait, int scriptIndex, int classIndex, boolean isStatic, String path) throws InterruptedException { + public int removeTraps(ABC abc, Trait trait, int scriptIndex, int classIndex, boolean isStatic, String path) throws InterruptedException { - return getCode().removeTraps(constants, trait, abc.method_info.get(method_info), this, abc, scriptIndex, classIndex, isStatic, path); + return getCode().removeTraps(trait, method_info, this, abc, scriptIndex, classIndex, isStatic, path); } public void deobfuscate(DeobfuscationLevel level, Trait trait, int scriptIndex, int classIndex, boolean isStatic, String path) throws InterruptedException { if (level == DeobfuscationLevel.LEVEL_REMOVE_DEAD_CODE) { removeDeadCode(abc.constants, trait, abc.method_info.get(method_info)); } else if (level == DeobfuscationLevel.LEVEL_REMOVE_TRAPS) { - removeTraps(abc.constants, abc, trait, scriptIndex, classIndex, isStatic, path); + removeTraps(abc, trait, scriptIndex, classIndex, isStatic, path); } else if (level == DeobfuscationLevel.LEVEL_RESTORE_CONTROL_FLOW) { - removeTraps(abc.constants, abc, trait, scriptIndex, classIndex, isStatic, path); + removeTraps(abc, trait, scriptIndex, classIndex, isStatic, path); restoreControlFlow(abc.constants, trait, abc.method_info.get(method_info)); } } @@ -276,12 +276,12 @@ public final class MethodBody implements Cloneable { return ret; } - public void convert(final String path, ScriptExportMode exportMode, final boolean isStatic, final int methodIndex, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final AVM2ConstantPool constants, final List method_info, final ScopeStack scopeStack, final int initializerType, final NulWriter writer, final List fullyQualifiedNames, final List initTraits, boolean firstLevel) throws InterruptedException { + public void convert(final String path, ScriptExportMode exportMode, final boolean isStatic, final int methodIndex, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ScopeStack scopeStack, final int initializerType, final NulWriter writer, final List fullyQualifiedNames, final List initTraits, boolean firstLevel) throws InterruptedException { if (debugMode) { System.err.println("Decompiling " + path); } if (exportMode != ScriptExportMode.AS) { - getCode().toASMSource(constants, trait, method_info.get(this.method_info), this, exportMode, writer); + getCode().toASMSource(abc.constants, trait, abc.method_info.get(this.method_info), this, exportMode, writer); } else { if ((DEBUG_FIXED != null && !path.endsWith(DEBUG_FIXED)) || (!Configuration.decompile.get())) { writer.appendNoHilight(Helper.getDecompilationSkippedComment()).newLine(); @@ -294,14 +294,14 @@ public final class MethodBody implements Cloneable { @Override public Void call() throws InterruptedException { try (Statistics s1 = new Statistics("MethodBody.convert")) { - MethodBody converted = convertMethodBody(path, isStatic, scriptIndex, classIndex, abc, trait, constants, method_info, scopeStack, initializerType != GraphTextWriter.TRAIT_INSTANCE_INITIALIZER, fullyQualifiedNames, initTraits); + MethodBody converted = convertMethodBody(path, isStatic, scriptIndex, classIndex, abc, trait, scopeStack, initializerType != GraphTextWriter.TRAIT_INSTANCE_INITIALIZER, fullyQualifiedNames, initTraits); HashMap localRegNames = getLocalRegNames(abc); List convertedItems1; try (Statistics s = new Statistics("AVM2Code.toGraphTargetItems")) { - convertedItems1 = converted.getCode().toGraphTargetItems(path, methodIndex, isStatic, scriptIndex, classIndex, abc, constants, method_info, converted, localRegNames, scopeStack, initializerType, fullyQualifiedNames, initTraits, Graph.SOP_USE_STATIC, new HashMap<>(), converted.getCode().visitCode(converted)); + convertedItems1 = converted.getCode().toGraphTargetItems(path, methodIndex, isStatic, scriptIndex, classIndex, abc, converted, localRegNames, scopeStack, initializerType, fullyQualifiedNames, initTraits, Graph.SOP_USE_STATIC, new HashMap<>(), converted.getCode().visitCode(converted)); } try (Statistics s = new Statistics("Graph.graphToString")) { - Graph.graphToString(convertedItems1, writer, LocalData.create(constants, localRegNames, fullyQualifiedNames)); + Graph.graphToString(convertedItems1, writer, LocalData.create(abc.constants, localRegNames, fullyQualifiedNames)); } convertedItems = convertedItems1; } @@ -330,9 +330,9 @@ public final class MethodBody implements Cloneable { } } - public GraphTextWriter toString(final String path, ScriptExportMode exportMode, final ABC abc, final Trait trait, final AVM2ConstantPool constants, final List method_info, final GraphTextWriter writer, final List fullyQualifiedNames) throws InterruptedException { + public GraphTextWriter toString(final String path, ScriptExportMode exportMode, final ABC abc, final Trait trait, final GraphTextWriter writer, final List fullyQualifiedNames) throws InterruptedException { if (exportMode != ScriptExportMode.AS) { - getCode().toASMSource(constants, trait, method_info.get(this.method_info), this, exportMode, writer); + getCode().toASMSource(abc.constants, trait, abc.method_info.get(this.method_info), this, exportMode, writer); } else { if ((DEBUG_FIXED != null && !path.endsWith(DEBUG_FIXED)) || (!Configuration.decompile.get())) { //writer.startMethod(this.method_info); @@ -351,7 +351,7 @@ public final class MethodBody implements Cloneable { writer.appendNoHilight(abc.findBodyIndex(this.method_info)); writer.newLine(); } - Graph.graphToString(convertedItems, writer, LocalData.create(constants, localRegNames, fullyQualifiedNames)); + Graph.graphToString(convertedItems, writer, LocalData.create(abc.constants, localRegNames, fullyQualifiedNames)); //writer.endMethod(); } else if (convertException instanceof TimeoutException) { // exception was logged in convert method @@ -365,7 +365,7 @@ public final class MethodBody implements Cloneable { return writer; } - public MethodBody convertMethodBody(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, Trait trait, AVM2ConstantPool constants, List method_info, ScopeStack scopeStack, boolean isStaticInitializer, List fullyQualifiedNames, List initTraits) throws InterruptedException { + public MethodBody convertMethodBody(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, Trait trait, ScopeStack scopeStack, boolean isStaticInitializer, List fullyQualifiedNames, List initTraits) throws InterruptedException { MethodBody body = clone(); AVM2Code code = body.getCode(); code.markMappedOffsets(); @@ -373,7 +373,7 @@ public final class MethodBody implements Cloneable { if (Configuration.autoDeobfuscate.get()) { try { - code.removeTraps(constants, trait, method_info.get(this.method_info), body, abc, scriptIndex, classIndex, isStatic, path); + code.removeTraps(trait, method_info, body, abc, scriptIndex, classIndex, isStatic, path); } catch (ThreadDeath | InterruptedException ex) { throw ex; } catch (Throwable ex) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index 6172ed20e..ec69db450 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -470,7 +470,7 @@ public class TraitClass extends Trait implements TraitWithSlot { writer.startMethod(classInfo.cinit_index); if (!classInitializerIsEmpty) { writer.startBlock(); - abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/" + instanceInfoName + ".staticinitializer", exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames); + abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/" + instanceInfoName + ".staticinitializer", exportMode, abc, this, writer, fullyQualifiedNames); writer.endBlock(); } else { //Note: There must be trait/method highlight even if the initializer is empty to TraitList in GUI to work correctly @@ -518,7 +518,7 @@ public class TraitClass extends Trait implements TraitWithSlot { abc.method_info.get(instanceInfo.iinit_index).getParamStr(writer, abc.constants, body, abc, fullyQualifiedNames); writer.appendNoHilight(")").startBlock(); if (body != null) { - body.toString(path +/*packageName +*/ "/" + instanceInfoName + ".initializer", exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames); + body.toString(path +/*packageName +*/ "/" + instanceInfoName + ".initializer", exportMode, abc, this, writer, fullyQualifiedNames); } writer.endBlock().newLine(); @@ -553,7 +553,7 @@ public class TraitClass extends Trait implements TraitWithSlot { writer.mark(); List ts = new ArrayList<>(); ts.add(classInfo.static_traits); - abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/" + instanceInfoName + ".staticinitializer", exportMode, true, classInfo.cinit_index, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new ScopeStack(), GraphTextWriter.TRAIT_CLASS_INITIALIZER, writer, fullyQualifiedNames, ts, true); + abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/" + instanceInfoName + ".staticinitializer", exportMode, true, classInfo.cinit_index, scriptIndex, class_info, abc, this, new ScopeStack(), GraphTextWriter.TRAIT_CLASS_INITIALIZER, writer, fullyQualifiedNames, ts, true); classInitializerIsEmpty = !writer.getMark(); } @@ -563,7 +563,7 @@ public class TraitClass extends Trait implements TraitWithSlot { if (bodyIndex != -1) { List ts = new ArrayList<>(); ts.add(instanceInfo.instance_traits); - abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/" + instanceInfoName + ".initializer", exportMode, false, instanceInfo.iinit_index, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new ScopeStack(), GraphTextWriter.TRAIT_INSTANCE_INITIALIZER, writer, fullyQualifiedNames, ts, true); + abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/" + instanceInfoName + ".initializer", exportMode, false, instanceInfo.iinit_index, scriptIndex, class_info, abc, this, new ScopeStack(), GraphTextWriter.TRAIT_INSTANCE_INITIALIZER, writer, fullyQualifiedNames, ts, true); } } @@ -585,11 +585,11 @@ public class TraitClass extends Trait implements TraitWithSlot { int iInitializer = abc.findBodyIndex(instanceInfo.iinit_index); int ret = 0; if (iInitializer != -1) { - ret += abc.bodies.get(iInitializer).removeTraps(abc.constants, abc, this, scriptIndex, class_info, false, path); + ret += abc.bodies.get(iInitializer).removeTraps(abc, this, scriptIndex, class_info, false, path); } int sInitializer = abc.findBodyIndex(classInfo.cinit_index); if (sInitializer != -1) { - ret += abc.bodies.get(sInitializer).removeTraps(abc.constants, abc, this, scriptIndex, class_info, true, path); + ret += abc.bodies.get(sInitializer).removeTraps(abc, this, scriptIndex, class_info, true, path); } ret += instanceInfo.instance_traits.removeTraps(scriptIndex, class_info, false, abc, path); ret += classInfo.static_traits.removeTraps(scriptIndex, class_info, true, abc, path); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java index 473eaf595..cb39d78df 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java @@ -80,7 +80,7 @@ public class TraitFunction extends Trait implements TraitWithSlot { writer.appendNoHilight(" {").newLine(); int bodyIndex = abc.findBodyIndex(method_info); if (bodyIndex != -1) { - abc.bodies.get(bodyIndex).toString(path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false), exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames); + abc.bodies.get(bodyIndex).toString(path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false), exportMode, abc, this, writer, fullyQualifiedNames); } writer.newLine(); writer.appendNoHilight("}"); @@ -97,7 +97,7 @@ public class TraitFunction extends Trait implements TraitWithSlot { if (!abc.instance_info.get(classIndex).isInterface()) { int bodyIndex = abc.findBodyIndex(method_info); if (bodyIndex != -1) { - abc.bodies.get(bodyIndex).convert(path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false), exportMode, isStatic, method_info, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new ScopeStack(), 0, writer, fullyQualifiedNames, null, true); + abc.bodies.get(bodyIndex).convert(path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false), exportMode, isStatic, method_info, scriptIndex, classIndex, abc, this, new ScopeStack(), 0, writer, fullyQualifiedNames, null, true); } } writer.endMethod(); @@ -107,7 +107,7 @@ public class TraitFunction extends Trait implements TraitWithSlot { public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc, String path) throws InterruptedException { int bodyIndex = abc.findBodyIndex(method_info); if (bodyIndex != -1) { - return abc.bodies.get(bodyIndex).removeTraps(abc.constants, abc, this, scriptIndex, classIndex, isStatic, path); + return abc.bodies.get(bodyIndex).removeTraps(abc, this, scriptIndex, classIndex, isStatic, path); } return 0; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java index 2c10edf5f..d049adee7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java @@ -81,7 +81,7 @@ public class TraitMethodGetterSetter extends Trait { int bodyIndex = abc.findBodyIndex(method_info); if (!(classIndex != -1 && abc.instance_info.get(classIndex).isInterface() || bodyIndex == -1)) { if (bodyIndex != -1) { - abc.bodies.get(bodyIndex).convert(path, exportMode, isStatic, method_info, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new ScopeStack(), 0, writer, fullyQualifiedNames, null, true); + abc.bodies.get(bodyIndex).convert(path, exportMode, isStatic, method_info, scriptIndex, classIndex, abc, this, new ScopeStack(), 0, writer, fullyQualifiedNames, null, true); } } writer.endMethod(); @@ -99,7 +99,7 @@ public class TraitMethodGetterSetter extends Trait { } else { writer.startBlock(); if (bodyIndex != -1) { - abc.bodies.get(bodyIndex).toString(path, exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames); + abc.bodies.get(bodyIndex).toString(path, exportMode, abc, this, writer, fullyQualifiedNames); } writer.endBlock(); } @@ -112,7 +112,7 @@ public class TraitMethodGetterSetter extends Trait { public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc, String path) throws InterruptedException { int bodyIndex = abc.findBodyIndex(method_info); if (bodyIndex != -1) { - return abc.bodies.get(bodyIndex).removeTraps(abc.constants, abc, this, scriptIndex, classIndex, isStatic, path); + return abc.bodies.get(bodyIndex).removeTraps(abc, this, scriptIndex, classIndex, isStatic, path); } return 0; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java index 3aed4233f..8a60834cb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.DisassemblyListener; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.deobfuscation.ActionDeobfuscatorSimpleFast; import com.jpexs.decompiler.flash.action.model.ActionItem; import com.jpexs.decompiler.flash.action.model.ConstantPool; import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; @@ -64,6 +65,7 @@ import com.jpexs.decompiler.flash.helpers.CodeFormatting; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; +import com.jpexs.decompiler.flash.helpers.SWFDecompilerPlugin; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.graph.Graph; @@ -817,13 +819,20 @@ public abstract class Action implements GraphSourceItem { List tree = null; Throwable convertException = null; int timeout = Configuration.decompilationTimeoutSingleMethod.get(); - final int version = asm == null ? SWF.DEFAULT_VERSION : asm.getSwf().version; + final SWF swf = asm == null ? null : asm.getSwf(); + final int version = swf == null ? SWF.DEFAULT_VERSION : swf.version; try { tree = CancellableWorker.call(new Callable>() { @Override public List call() throws Exception { int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC; List tree = actionsToTree(new HashMap<>(), new HashMap<>(), new HashMap<>(), actions, version, staticOperation, path); + SWFDecompilerPlugin.fireActionTreeCreated(tree, swf); + int deobfuscationMode = Configuration.autoDeobfuscate.get() ? (Configuration.deobfuscationOldMode.get() ? 0 : 1) : -1; + if (deobfuscationMode == 1) { + new ActionDeobfuscatorSimpleFast().actionTreeCreated(tree, swf); + } + Graph.graphToString(tree, new NulWriter(), new LocalData()); return tree; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimple.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimple.java index 9dd661c77..126b10c37 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimple.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimple.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.deobfuscation; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionList; import com.jpexs.decompiler.flash.action.ActionLocalData; @@ -419,6 +420,10 @@ public class ActionDeobfuscatorSimple implements SWFDecompilerListener { public void methodBodyParsed(MethodBody body, SWF swf) { } + @Override + public void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException { + } + class ExecutionResult { public int idx = -1; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimpleFast.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimpleFast.java index f6af32e43..52e38c36b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimpleFast.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimpleFast.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.deobfuscation; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionList; import com.jpexs.decompiler.flash.action.ActionListReader; @@ -652,6 +653,10 @@ public class ActionDeobfuscatorSimpleFast implements SWFDecompilerListener { public void methodBodyParsed(MethodBody body, SWF swf) { } + @Override + public void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException { + } + class ExecutionResult { public ActionItem item = null; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java index f8b787cf8..48d4c4203 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java @@ -176,8 +176,8 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue { if (value instanceof RegisterNumber) { return writer.append(((RegisterNumber) value).translate()); } - return writer.append(value.toString()); - //return writer.append(EcmaScript.toString(value, true)); // todo, use this line + //return writer.append(value.toString()); + return writer.append(EcmaScript.toString(value, true)); // todo, use this line } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java index fe70e95e6..e143ae5af 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java @@ -64,7 +64,7 @@ public class GetVariableActionItem extends ActionItem { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { - if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!IdentifiersDeobfuscation.isValidName(false, ((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) { + if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!IdentifiersDeobfuscation.isValidNameWithDot(false, ((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) { return IdentifiersDeobfuscation.appendObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData), writer); } else if ((!(name instanceof DirectValueActionItem)) || (!((DirectValueActionItem) name).isString())) { writer.append("eval("); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java index 967306273..e92c8da89 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java @@ -85,7 +85,7 @@ public class ActionIf extends Action { @Override public String getASMSource(ActionList container, Set knownAddreses, ScriptExportMode exportMode) { - long address = getAddress() + getTotalActionLength() + offset; + long address = getTargetAddress(); String ofsStr = Helper.formatAddress(address); return "If loc" + ofsStr + (!jumpUsed ? " ;compileTimeIgnore" : (!ignoreUsed ? " ;compileTimeJump" : "")); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java index 72c84bfa3..8c7888ead 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java @@ -85,7 +85,7 @@ public class ActionJump extends Action { @Override public String getASMSource(ActionList container, Set knownAddreses, ScriptExportMode exportMode) { - long address = getAddress() + getTotalActionLength() + offset; + long address = getTargetAddress(); String ofsStr = Helper.formatAddress(address); return "Jump loc" + ofsStr; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/SWFDecompilerListener.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/SWFDecompilerListener.java index 26acc8e22..faa28a599 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/SWFDecompilerListener.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/SWFDecompilerListener.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.helpers; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.action.ActionList; import com.jpexs.decompiler.graph.GraphTargetItem; import java.util.List; @@ -40,4 +41,7 @@ public interface SWFDecompilerListener { void abcParsed(ABC abc, SWF swf); void methodBodyParsed(MethodBody body, SWF swf); + + // this method is only called when deobfuscation is enabled and new deobfuscation mode is selected + void avm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/SWFDecompilerPlugin.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/SWFDecompilerPlugin.java index a6d71bf90..6f7b4bea4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/SWFDecompilerPlugin.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/SWFDecompilerPlugin.java @@ -19,8 +19,11 @@ package com.jpexs.decompiler.flash.helpers; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.action.ActionList; +import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.helpers.Helper; +import com.jpexs.helpers.Path; import com.jpexs.helpers.plugin.CharSequenceJavaFileObject; import com.jpexs.helpers.plugin.ClassFileManager; import java.util.ArrayList; @@ -43,6 +46,18 @@ public class SWFDecompilerPlugin { private static final List listeners = new ArrayList<>(); public static void loadPlugin(String path) { + if (".class".equals(Path.getExtension(path))) { + loadPluginCompiled(path); + } else { + loadPluginSource(path); + } + } + + private static void loadPluginCompiled(String path) { + + } + + private static void loadPluginSource(String path) { // Here we specify the source code of the class to be compiled String src = Helper.readTextFile(path); @@ -90,6 +105,8 @@ public class SWFDecompilerPlugin { result = newResult; data = newResult; } + } catch (ThreadDeath ex) { + throw ex; } catch (Throwable e) { logger.log(Level.SEVERE, "Failed to call plugin method proxyFileCatched.", e); } @@ -101,6 +118,8 @@ public class SWFDecompilerPlugin { for (SWFDecompilerListener listener : listeners) { try { listener.swfParsed(swf); + } catch (ThreadDeath ex) { + throw ex; } catch (Throwable e) { logger.log(Level.SEVERE, "Failed to call plugin method swfParsed.", e); } @@ -108,10 +127,12 @@ public class SWFDecompilerPlugin { return !listeners.isEmpty(); } - public static boolean fireActionListParsed(ActionList actions, SWF swf) { + public static boolean fireActionListParsed(ActionList actions, SWF swf) throws InterruptedException { for (SWFDecompilerListener listener : listeners) { try { listener.actionListParsed(actions, swf); + } catch (ThreadDeath | InterruptedException ex) { + throw ex; } catch (Throwable e) { logger.log(Level.SEVERE, "Failed to call plugin method actionListParsed.", e); } @@ -119,10 +140,25 @@ public class SWFDecompilerPlugin { return !listeners.isEmpty(); } + public static boolean fireActionTreeCreated(List tree, SWF swf) throws InterruptedException { + for (SWFDecompilerListener listener : listeners) { + try { + listener.actionTreeCreated(tree, swf); + } catch (ThreadDeath | InterruptedException ex) { + throw ex; + } catch (Throwable e) { + logger.log(Level.SEVERE, "Failed to call plugin method actionTreeCreated.", e); + } + } + return !listeners.isEmpty(); + } + public static boolean fireAbcParsed(ABC abc, SWF swf) { for (SWFDecompilerListener listener : listeners) { try { listener.abcParsed(abc, swf); + } catch (ThreadDeath ex) { + throw ex; } catch (Throwable e) { logger.log(Level.SEVERE, "Failed to call plugin method abcParsed.", e); } @@ -134,10 +170,25 @@ public class SWFDecompilerPlugin { for (SWFDecompilerListener listener : listeners) { try { listener.methodBodyParsed(body, swf); + } catch (ThreadDeath ex) { + throw ex; } catch (Throwable e) { logger.log(Level.SEVERE, "Failed to call plugin method methodBodyParsed.", e); } } return !listeners.isEmpty(); } + + public static boolean fireAvm2CodeRemoveTraps(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, Trait trait, int methodInfo, MethodBody body) throws InterruptedException { + for (SWFDecompilerListener listener : listeners) { + try { + listener.avm2CodeRemoveTraps(path, classIndex, isStatic, scriptIndex, abc, trait, methodInfo, body); + } catch (ThreadDeath | InterruptedException ex) { + throw ex; + } catch (Throwable e) { + logger.log(Level.SEVERE, "Failed to call plugin method abcParsed.", e); + } + } + return !listeners.isEmpty(); + } } diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DeobfuscatorTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DeobfuscatorTest.java index e3340291d..9afadaf82 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DeobfuscatorTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DeobfuscatorTest.java @@ -84,7 +84,7 @@ public class ActionScript3DeobfuscatorTest extends ActionStript2TestBase { MethodBody b = new MethodBody(abc); AVM2Code code = ASM3Parser.parse(new StringReader(str), abc.constants, null, b, new MethodInfo()); b.setCode(code); - new AVM2DeobfuscatorJumps().deobfuscate("test", 0, true, 0, abc, abc.constants, null, new MethodInfo(), b); + new AVM2DeobfuscatorJumps().avm2CodeRemoveTraps("test", 0, true, 0, abc, null, 0, b); HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false); code.toASMSource(abc.constants, null, new MethodInfo(), new MethodBody(abc), ScriptExportMode.PCODE, writer); String ret = writer.toString(); diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java index df2232c21..bde472366 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java @@ -79,9 +79,9 @@ public class ActionScript3Test extends ActionScriptTestBase { try { List ts = new ArrayList<>(); ts.add(abc.instance_info.get(clsIndex).instance_traits); - abc.bodies.get(bodyIndex).convert(methodName, ScriptExportMode.AS, isStatic, -1/*FIX?*/, -1/*FIX?*/, clsIndex, abc, null, abc.constants, abc.method_info, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), ts, true); + abc.bodies.get(bodyIndex).convert(methodName, ScriptExportMode.AS, isStatic, -1/*FIX?*/, -1/*FIX?*/, clsIndex, abc, null, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), ts, true); writer = new HighlightedTextWriter(new CodeFormatting(), false); - abc.bodies.get(bodyIndex).toString(methodName, ScriptExportMode.AS, abc, null, abc.constants, abc.method_info, writer, new ArrayList<>()); + abc.bodies.get(bodyIndex).toString(methodName, ScriptExportMode.AS, abc, null, writer, new ArrayList<>()); } catch (InterruptedException ex) { fail(); } diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS3Generator.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS3Generator.java index 6a89e294d..0ae14f5b3 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS3Generator.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS3Generator.java @@ -70,8 +70,8 @@ public class AS3Generator { MethodBody b = abc.findBody(((TraitMethodGetterSetter) t).method_info); List ts = new ArrayList<>(); ts.add(abc.instance_info.get(classId).instance_traits); - b.convert("", ScriptExportMode.AS, false, -1/*FIX?*/, -1/*FIX?*/, classId, abc, null, abc.constants, abc.method_info, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), ts, true); - b.toString("", ScriptExportMode.AS, abc, null, abc.constants, abc.method_info, src, new ArrayList<>()); + b.convert("", ScriptExportMode.AS, false, -1/*FIX?*/, -1/*FIX?*/, classId, abc, null, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), ts, true); + b.toString("", ScriptExportMode.AS, abc, null, src, new ArrayList<>()); String[] srcs = src.toString().split("[\r\n]+"); for (int i = 0; i < srcs.length; i++) { String ss = srcs[i]; diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index da5d6108a..46d87a7cb 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -444,7 +444,10 @@ public class TagTreeContextMenu extends JPopupMenu { Timelined timelined = isDefineSprite ? (DefineSpriteTag) firstItem : swf; t.setTimelined(timelined); if (isDefineSprite) { - ((DefineSpriteTag) firstItem).subTags.add(t); + DefineSpriteTag sprite = (DefineSpriteTag) firstItem; + timelined.resetTimeline(); + sprite.subTags.add(t); + sprite.frameCount = timelined.getTimeline().getFrameCount(); } else { int index; if (firstItem instanceof Tag) { @@ -470,8 +473,10 @@ public class TagTreeContextMenu extends JPopupMenu { } else { swf.tags.add(t); } + + timelined.resetTimeline(); } - timelined.resetTimeline(); + swf.updateCharacters(); mainPanel.refreshTree(swf); } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException ex) {