From 6887e51a8686ec21461d1cc510e22ed94febd4f7 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sun, 30 Aug 2015 08:37:19 +0200 Subject: [PATCH] unnecessarry try-catch removed from deobfuscarot methods 2 + small fixes --- .../com/jpexs/decompiler/flash/abc/ABC.java | 25 +- .../jpexs/decompiler/flash/abc/ClassPath.java | 3 +- .../AVM2DeobfuscatorRegisters.java | 233 +++++++------ .../deobfuscation/AVM2DeobfuscatorSimple.java | 308 +++++++++--------- .../parser/script/ActionScript3Parser.java | 1 + .../flash/abc/types/MethodBody.java | 7 +- .../flash/action/ActionListReader.java | 12 +- src/com/jpexs/decompiler/flash/gui/Main.java | 5 +- 8 files changed, 297 insertions(+), 297 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java index 0e5d67881..31ce6a1ed 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -578,6 +578,8 @@ public class ABC { SWFDecompilerPlugin.fireMethodBodyParsed(mb, swf); } + createBodyIdxFromMethodIdxMap(); + /*for(int i=0;i getBodyIdxFromMethodIdx() { - if (bodyIdxFromMethodIdx == null) { - Map map = new HashMap<>(bodies.size()); - for (int i = 0; i < bodies.size(); i++) { - MethodBody mb = bodies.get(i); - map.put(mb.method_info, i); - } - - bodyIdxFromMethodIdx = map; + public final void createBodyIdxFromMethodIdxMap() { + Map map = new HashMap<>(bodies.size()); + for (int i = 0; i < bodies.size(); i++) { + MethodBody mb = bodies.get(i); + map.put(mb.method_info, i); } + bodyIdxFromMethodIdx = map; + } + + private Map getBodyIdxFromMethodIdx() { + if (bodyIdxFromMethodIdx == null) { + createBodyIdxFromMethodIdxMap(); + } return bodyIdxFromMethodIdx; } @@ -1305,5 +1310,7 @@ public class ABC { m--; } } + + createBodyIdxFromMethodIdxMap(); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java index 1f4548e0c..537c74506 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java @@ -37,7 +37,8 @@ public class ClassPath { @Override public String toString() { - return packageStr.isEmpty() ? className : packageStr.toPrintableString(true) + "." + IdentifiersDeobfuscation.printIdentifier(true, className); + return packageStr.isEmpty() ? IdentifiersDeobfuscation.printIdentifier(true, className) + : packageStr.toPrintableString(true) + "." + IdentifiersDeobfuscation.printIdentifier(true, className); } @Override 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 9607d3c1e..6c1c11774 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 @@ -180,132 +180,129 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple { while (!toVisit.isEmpty()) { idx = toVisit.remove(0); stack = toVisitStacks.remove(0); - try { - while (true) { - if (idx > endIdx) { - break; - } - if (visited.contains(idx)) { - break; - } - visited.add(idx); - AVM2Instruction ins = code.code.get(idx); - InstructionDefinition def = ins.definition; + while (true) { + if (idx > endIdx) { + break; + } + if (visited.contains(idx)) { + break; + } + visited.add(idx); + + AVM2Instruction ins = code.code.get(idx); + InstructionDefinition def = ins.definition; //System.err.println("" + idx + ": " + ins + " stack:" + stack.size()); - // do not throw EmptyStackException, much faster - int requiredStackSize = ins.getStackPopCount(localData); - if (stack.size() < requiredStackSize) { - continue outer; + // do not throw EmptyStackException, much faster + int requiredStackSize = ins.getStackPopCount(localData); + if (stack.size() < requiredStackSize) { + continue outer; + } + + ins.translate(localData, stack, output, Graph.SOP_USE_STATIC, ""); + + //if (!(def instanceof KillIns)) + if (def instanceof SetLocalTypeIns) { + int regId = ((SetLocalTypeIns) def).getRegisterId(ins); + if (!ignored.contains(regId)) { + assignment.setVal(ins); + return regId; } - - ins.translate(localData, stack, output, Graph.SOP_USE_STATIC, ""); - - //if (!(def instanceof KillIns)) - if (def instanceof SetLocalTypeIns) { - int regId = ((SetLocalTypeIns) def).getRegisterId(ins); - if (!ignored.contains(regId)) { - assignment.setVal(ins); - return regId; - } - } else if (def instanceof GetLocalTypeIns) { - int regId = ((GetLocalTypeIns) def).getRegisterId(ins); - if (!ignored.contains(regId) && !ignoredGets.contains(regId)) { - assignment.setVal(ins); - return regId; - } - } else { - for (int p = 0; p < ins.definition.operands.length; p++) { - int op = ins.definition.operands[p]; - if (op == AVM2Code.DAT_REGISTER_INDEX) { - int regId = ins.operands[p]; - if (!ignored.contains(regId)) { - assignment.setVal(ins); - return regId; - } + } else if (def instanceof GetLocalTypeIns) { + int regId = ((GetLocalTypeIns) def).getRegisterId(ins); + if (!ignored.contains(regId) && !ignoredGets.contains(regId)) { + assignment.setVal(ins); + return regId; + } + } else { + for (int p = 0; p < ins.definition.operands.length; p++) { + int op = ins.definition.operands[p]; + if (op == AVM2Code.DAT_REGISTER_INDEX) { + int regId = ins.operands[p]; + if (!ignored.contains(regId)) { + assignment.setVal(ins); + return regId; } } } - - idx++; - - if (ins.definition instanceof JumpIns) { - - long address = ins.offset + ins.getBytesLength() + ins.operands[0]; - idx = code.adr2pos(address);//code.indexOf(code.getByAddress(address)); - if (idx == -1) { - throw new TranslateException("Jump target not found: " + address); - } - } - - if (ins.isBranch()) { - List branches = ins.getBranches(new GraphSource() { - - @Override - public int size() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public GraphSourceItem get(int pos) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public boolean isEmpty() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public List translatePart(GraphPart part, BaseLocalData localData, TranslateStack stack, int start, int end, int staticOperation, String path) throws InterruptedException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int adr2pos(long adr) { - return code.adr2pos(adr); - } - - @Override - public long pos2adr(int pos) { - return code.pos2adr(pos); - } - }); - idx = branches.get(0); - for (int n = 1; n < branches.size(); n++) { - //visitCode(visited, (TranslateStack) stack.clone(), classIndex, isStatic, body, scriptIndex, abc, code, branches.get(n), endIdx, result); - int nidx = branches.get(n); - if (visited.contains(nidx)) { - continue; - } - toVisit.add(nidx); - toVisitStacks.add((TranslateStack) stack.clone()); - } - } - /*if (ins.definition instanceof IfTypeIns) { - long address = ins.offset + ins.getBytes().length + ins.operands[0]; - int newIdx = code.adr2pos(address); - if (newIdx == -1) { - throw new TranslateException("If target not found: " + address); - } - visitCode(visited, (TranslateStack) stack.clone(), classIndex, isStatic, body, scriptIndex, abc, code, newIdx, endIdx, result); - }*/ - - if (ins.definition instanceof ReturnValueIns) { - break; - } - - if (ins.definition instanceof ThrowIns) { - break; - } - - if (ins.definition instanceof ReturnVoidIns) { - break; - } } - } catch (ThreadDeath | InterruptedException ex) { - throw ex; + + idx++; + + if (ins.definition instanceof JumpIns) { + + long address = ins.offset + ins.getBytesLength() + ins.operands[0]; + idx = code.adr2pos(address);//code.indexOf(code.getByAddress(address)); + if (idx == -1) { + throw new TranslateException("Jump target not found: " + address); + } + } + + if (ins.isBranch()) { + List branches = ins.getBranches(new GraphSource() { + + @Override + public int size() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public GraphSourceItem get(int pos) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public boolean isEmpty() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public List translatePart(GraphPart part, BaseLocalData localData, TranslateStack stack, int start, int end, int staticOperation, String path) throws InterruptedException { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public int adr2pos(long adr) { + return code.adr2pos(adr); + } + + @Override + public long pos2adr(int pos) { + return code.pos2adr(pos); + } + }); + idx = branches.get(0); + for (int n = 1; n < branches.size(); n++) { + //visitCode(visited, (TranslateStack) stack.clone(), classIndex, isStatic, body, scriptIndex, abc, code, branches.get(n), endIdx, result); + int nidx = branches.get(n); + if (visited.contains(nidx)) { + continue; + } + toVisit.add(nidx); + toVisitStacks.add((TranslateStack) stack.clone()); + } + } + /*if (ins.definition instanceof IfTypeIns) { + long address = ins.offset + ins.getBytes().length + ins.operands[0]; + int newIdx = code.adr2pos(address); + if (newIdx == -1) { + throw new TranslateException("If target not found: " + address); + } + visitCode(visited, (TranslateStack) stack.clone(), classIndex, isStatic, body, scriptIndex, abc, code, newIdx, endIdx, result); + }*/ + + if (ins.definition instanceof ReturnValueIns) { + break; + } + + if (ins.definition instanceof ThrowIns) { + break; + } + + if (ins.definition instanceof ReturnVoidIns) { + break; + } } } return -1; 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 ef47a7214..ede6bf919 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 @@ -254,169 +254,165 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener { FixItemCounterTranslateStack stack = new FixItemCounterTranslateStack(""); int instructionsProcessed = 0; - try { - while (true) { - if (idx > endIdx) { - break; - } + while (true) { + if (idx > endIdx) { + break; + } - if (instructionsProcessed > executionLimit) { - break; - } + if (instructionsProcessed > executionLimit) { + break; + } - AVM2Instruction ins = code.code.get(idx); - if (ins.definition instanceof NewFunctionIns) { - if (idx + 1 < code.code.size()) { - if (code.code.get(idx + 1).definition instanceof PopIns) { - code.removeInstruction(idx + 1, body); - code.removeInstruction(idx, body); - continue; - } + AVM2Instruction ins = code.code.get(idx); + if (ins.definition instanceof NewFunctionIns) { + if (idx + 1 < code.code.size()) { + if (code.code.get(idx + 1).definition instanceof PopIns) { + code.removeInstruction(idx + 1, body); + code.removeInstruction(idx, body); + continue; } + } + } else { + // do not throw EmptyStackException, much faster + int requiredStackSize = ins.getStackPopCount(localData); + if (stack.size() < requiredStackSize) { + return; + } + + ins.translate(localData, stack, output, Graph.SOP_USE_STATIC, ""); + } + + InstructionDefinition def = ins.definition; + + if (inlineIns.contains(ins)) { + if (def instanceof SetLocalTypeIns) { + int regId = ((SetLocalTypeIns) def).getRegisterId(ins); + staticRegs.put(regId, localData.localRegs.get(regId).getNotCoerced()); + code.replaceInstruction(idx, new AVM2Instruction(0, new DeobfuscatePopIns(), null), body); + } + } + if (def instanceof GetLocalTypeIns) { + int regId = ((GetLocalTypeIns) def).getRegisterId(ins); + if (staticRegs.containsKey(regId)) { + stack.pop(); + AVM2Instruction pushins = makePush(abc.constants, staticRegs.get(regId)); + code.replaceInstruction(idx, pushins, body); + stack.push(staticRegs.get(regId)); + ins = pushins; + def = ins.definition; + } + } + + boolean ok = false; + if (def instanceof PushByteIns + || def instanceof PushShortIns + || def instanceof PushIntIns + || def instanceof PushDoubleIns + || def instanceof PushStringIns + || def instanceof PushNullIns + || def instanceof PushUndefinedIns + || def instanceof PushFalseIns + || def instanceof PushTrueIns + || def instanceof DupIns + || def instanceof SwapIns + || def instanceof AddIns + || def instanceof AddIIns + || def instanceof SubtractIns + || def instanceof SubtractIIns + || def instanceof ModuloIns + || def instanceof MultiplyIns + || def instanceof BitAndIns + || def instanceof BitXorIns + || def instanceof BitOrIns + || def instanceof LShiftIns + || def instanceof RShiftIns + || def instanceof URShiftIns + || def instanceof EqualsIns + || def instanceof NotIns + || def instanceof IfTypeIns + || def instanceof JumpIns + || def instanceof EqualsIns + || def instanceof LessEqualsIns + || def instanceof GreaterEqualsIns + || def instanceof GreaterThanIns + || def instanceof LessThanIns + || def instanceof StrictEqualsIns + || def instanceof PopIns + || def instanceof GetLocalTypeIns + || def instanceof NewFunctionIns + || def instanceof CoerceOrConvertTypeIns) { + ok = true; + } + + if (!ok) { + break; + } + + if (def instanceof GetLocalTypeIns) { + int regId = ((GetLocalTypeIns) def).getRegisterId(ins); + if (staticRegs.containsKey(regId)) { + stack.pop(); + stack.push(staticRegs.get(regId)); } else { - // do not throw EmptyStackException, much faster - int requiredStackSize = ins.getStackPopCount(localData); - if (stack.size() < requiredStackSize) { - return; - } - - ins.translate(localData, stack, output, Graph.SOP_USE_STATIC, ""); - } - - InstructionDefinition def = ins.definition; - - if (inlineIns.contains(ins)) { - if (def instanceof SetLocalTypeIns) { - int regId = ((SetLocalTypeIns) def).getRegisterId(ins); - staticRegs.put(regId, localData.localRegs.get(regId).getNotCoerced()); - code.replaceInstruction(idx, new AVM2Instruction(0, new DeobfuscatePopIns(), null), body); - } - } - if (def instanceof GetLocalTypeIns) { - int regId = ((GetLocalTypeIns) def).getRegisterId(ins); - if (staticRegs.containsKey(regId)) { - stack.pop(); - AVM2Instruction pushins = makePush(abc.constants, staticRegs.get(regId)); - code.replaceInstruction(idx, pushins, body); - stack.push(staticRegs.get(regId)); - ins = pushins; - def = ins.definition; - } - } - - boolean ok = false; - if (def instanceof PushByteIns - || def instanceof PushShortIns - || def instanceof PushIntIns - || def instanceof PushDoubleIns - || def instanceof PushStringIns - || def instanceof PushNullIns - || def instanceof PushUndefinedIns - || def instanceof PushFalseIns - || def instanceof PushTrueIns - || def instanceof DupIns - || def instanceof SwapIns - || def instanceof AddIns - || def instanceof AddIIns - || def instanceof SubtractIns - || def instanceof SubtractIIns - || def instanceof ModuloIns - || def instanceof MultiplyIns - || def instanceof BitAndIns - || def instanceof BitXorIns - || def instanceof BitOrIns - || def instanceof LShiftIns - || def instanceof RShiftIns - || def instanceof URShiftIns - || def instanceof EqualsIns - || def instanceof NotIns - || def instanceof IfTypeIns - || def instanceof JumpIns - || def instanceof EqualsIns - || def instanceof LessEqualsIns - || def instanceof GreaterEqualsIns - || def instanceof GreaterThanIns - || def instanceof LessThanIns - || def instanceof StrictEqualsIns - || def instanceof PopIns - || def instanceof GetLocalTypeIns - || def instanceof NewFunctionIns - || def instanceof CoerceOrConvertTypeIns) { - ok = true; - } - - if (!ok) { - break; - } - - if (def instanceof GetLocalTypeIns) { - int regId = ((GetLocalTypeIns) def).getRegisterId(ins); - if (staticRegs.containsKey(regId)) { - stack.pop(); - stack.push(staticRegs.get(regId)); - } else { - break; - } - } - - boolean ifed = false; - if (def instanceof JumpIns) { - long address = ins.offset + ins.getBytesLength() + ins.operands[0]; - idx = code.adr2pos(address); - - if (idx == -1) { - throw new TranslateException("Jump target not found: " + address); - } - } else if (def instanceof IfTypeIns) { - GraphTargetItem top = stack.pop(); - Object res = top.getResult(); - long address = ins.offset + ins.getBytesLength() + ins.operands[0]; - int nidx = code.adr2pos(address);//code.indexOf(code.getByAddress(address)); - AVM2Instruction tarIns = code.code.get(nidx); - - //Some IfType instructions need more than 1 operand, we must pop out all of them - int stackCount = -def.getStackDelta(ins, abc); - - if (EcmaScript.toBoolean(res)) { - //System.err.println("replacing " + ins + " on " + idx + " with jump"); - AVM2Instruction jumpIns = new AVM2Instruction(0, new JumpIns(), new int[]{0}); - //jumpIns.operands[0] = ins.operands[0] /*- ins.getBytes().length*/ + jumpIns.getBytes().length; - code.replaceInstruction(idx, jumpIns, body); - jumpIns.operands[0] = (int) (tarIns.offset - jumpIns.offset - jumpIns.getBytesLength()); - for (int s = 0; s < stackCount; s++) { - code.insertInstruction(idx, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), null), true, body); - } - - idx = code.adr2pos(jumpIns.offset + jumpIns.getBytesLength() + jumpIns.operands[0]); - } else { - //System.err.println("replacing " + ins + " on " + idx + " with pop"); - code.replaceInstruction(idx, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), null), body); - for (int s = 1 /*first is replaced*/; s < stackCount; s++) { - code.insertInstruction(idx, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), null), true, body); - } - //ins.definition = new DeobfuscatePopIns(); - idx++; - } - ifed = true; - //break; - } else { - idx++; - } - - instructionsProcessed++; - - if (stack.allItemsFixed()) { - result.idx = idx == code.code.size() ? idx - 1 : idx; - result.instructionsProcessed = instructionsProcessed; - result.stack.clear(); - result.stack.addAll(stack); - } - if (ifed) { break; } } - } catch (InterruptedException ex) { - throw ex; + + boolean ifed = false; + if (def instanceof JumpIns) { + long address = ins.offset + ins.getBytesLength() + ins.operands[0]; + idx = code.adr2pos(address); + + if (idx == -1) { + throw new TranslateException("Jump target not found: " + address); + } + } else if (def instanceof IfTypeIns) { + GraphTargetItem top = stack.pop(); + Object res = top.getResult(); + long address = ins.offset + ins.getBytesLength() + ins.operands[0]; + int nidx = code.adr2pos(address);//code.indexOf(code.getByAddress(address)); + AVM2Instruction tarIns = code.code.get(nidx); + + //Some IfType instructions need more than 1 operand, we must pop out all of them + int stackCount = -def.getStackDelta(ins, abc); + + if (EcmaScript.toBoolean(res)) { + //System.err.println("replacing " + ins + " on " + idx + " with jump"); + AVM2Instruction jumpIns = new AVM2Instruction(0, new JumpIns(), new int[]{0}); + //jumpIns.operands[0] = ins.operands[0] /*- ins.getBytes().length*/ + jumpIns.getBytes().length; + code.replaceInstruction(idx, jumpIns, body); + jumpIns.operands[0] = (int) (tarIns.offset - jumpIns.offset - jumpIns.getBytesLength()); + for (int s = 0; s < stackCount; s++) { + code.insertInstruction(idx, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), null), true, body); + } + + idx = code.adr2pos(jumpIns.offset + jumpIns.getBytesLength() + jumpIns.operands[0]); + } else { + //System.err.println("replacing " + ins + " on " + idx + " with pop"); + code.replaceInstruction(idx, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), null), body); + for (int s = 1 /*first is replaced*/; s < stackCount; s++) { + code.insertInstruction(idx, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), null), true, body); + } + //ins.definition = new DeobfuscatePopIns(); + idx++; + } + ifed = true; + //break; + } else { + idx++; + } + + instructionsProcessed++; + + if (stack.allItemsFixed()) { + result.idx = idx == code.code.size() ? idx - 1 : idx; + result.instructionsProcessed = instructionsProcessed; + result.stack.clear(); + result.stack.addAll(stack); + } + if (ifed) { + break; + } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java index c6a80a04c..9bf92896a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java @@ -2445,6 +2445,7 @@ public class ActionScript3Parser { abc.class_info = originalAbc.class_info; abc.script_info = originalAbc.script_info; abc.bodies = originalAbc.bodies; + abc.createBodyIdxFromMethodIdxMap(); } } } 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 a35dbd288..bfa466fc7 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 @@ -235,11 +235,12 @@ public final class MethodBody implements Cloneable { } public int getLocalReservedCount() { - int pos = abc.method_info.get(this.method_info).param_types.length + 1; - if (abc.method_info.get(this.method_info).flagNeed_arguments()) { + MethodInfo methodInfo = abc.method_info.get(this.method_info); + int pos = methodInfo.param_types.length + 1; + if (methodInfo.flagNeed_arguments()) { pos++; } - if (abc.method_info.get(this.method_info).flagNeed_rest()) { + if (methodInfo.flagNeed_rest()) { pos++; } return pos; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java index 04aae8173..feef57f75 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java @@ -171,7 +171,7 @@ public class ActionListReader { if (deobfuscationMode == 0) { try { - actions = deobfuscateActionList(listeners, actions, version, 0, path); + actions = deobfuscateActionListOld(listeners, actions, version, 0, path); updateActionLengths(actions, version); } catch (OutOfMemoryError | StackOverflowError | TranslateException ex) { // keep orignal (not deobfuscated) actions @@ -259,7 +259,7 @@ public class ActionListReader { * @throws IOException * @throws java.lang.InterruptedException */ - private static ActionList deobfuscateActionList(List listeners, ActionList actions, int version, int ip, String path) throws IOException, InterruptedException { + private static ActionList deobfuscateActionListOld(List listeners, ActionList actions, int version, int ip, String path) throws IOException, InterruptedException { if (actions.isEmpty()) { return actions; } @@ -292,7 +292,7 @@ public class ActionListReader { } } - deobfustaceActionListAtPosRecursive(listeners, + deobfustaceActionListAtPosRecursiveOld(listeners, new ArrayList<>(), new HashMap<>(), new ActionLocalData(), @@ -875,7 +875,7 @@ public class ActionListReader { } } - private static void deobfustaceActionListAtPosRecursive(List listeners, List output, HashMap> containers, ActionLocalData localData, TranslateStack stack, ConstantPool cpool, List actions, int ip, List ret, int startIp, int endip, String path, Map visited, boolean indeterminate, Map> decisionStates, int version, int recursionLevel, int maxRecursionLevel) throws IOException, InterruptedException { + private static void deobfustaceActionListAtPosRecursiveOld(List listeners, List output, HashMap> containers, ActionLocalData localData, TranslateStack stack, ConstantPool cpool, List actions, int ip, List ret, int startIp, int endip, String path, Map visited, boolean indeterminate, Map> decisionStates, int version, int recursionLevel, int maxRecursionLevel) throws IOException, InterruptedException { boolean debugMode = false; boolean decideBranch = false; @@ -1040,7 +1040,7 @@ public class ActionListReader { } else { localData2 = localData; } - deobfustaceActionListAtPosRecursive(listeners, output2, containers, localData2, new TranslateStack(path), cpool, actions, (int) endAddr, ret, startIp, (int) (endAddr + size), path + (cntName == null ? "" : "/" + cntName), visited, indeterminate, decisionStates, version, recursionLevel + 1, maxRecursionLevel); + deobfustaceActionListAtPosRecursiveOld(listeners, output2, containers, localData2, new TranslateStack(path), cpool, actions, (int) endAddr, ret, startIp, (int) (endAddr + size), path + (cntName == null ? "" : "/" + cntName), visited, indeterminate, decisionStates, version, recursionLevel + 1, maxRecursionLevel); output2s.add(output2); endAddr += size; } @@ -1101,7 +1101,7 @@ public class ActionListReader { TranslateStack subStack = (TranslateStack) stack.clone(); ActionLocalData subLocalData = new ActionLocalData(new HashMap<>(localData.regNames), new HashMap<>(localData.variables), new HashMap<>(localData.functions)); - deobfustaceActionListAtPosRecursive(listeners, output, containers, subLocalData, subStack, cpool, actions, ip + actionLen + aif.getJumpOffset(), ret, startIp, endip, path, visited, indeterminate, decisionStates, version, recursionLevel + 1, maxRecursionLevel); + deobfustaceActionListAtPosRecursiveOld(listeners, output, containers, subLocalData, subStack, cpool, actions, ip + actionLen + aif.getJumpOffset(), ret, startIp, endip, path, visited, indeterminate, decisionStates, version, recursionLevel + 1, maxRecursionLevel); } if (newip > -1) { diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 13cfdd22e..55736a63a 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -119,7 +119,7 @@ public class Main { private static MenuItem stopMenuItem; - private static MainFrame mainFrame; + private static volatile MainFrame mainFrame; public static final int UPDATE_SYSTEM_MAJOR = 1; @@ -724,9 +724,6 @@ public class Main { String filterDescription = null; switch (exeExportMode) { case WRAPPER: - ext = ".exe"; - filterDescription = "filter.exe"; - break; case PROJECTOR_WIN: ext = ".exe"; filterDescription = "filter.exe";