diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java index aedaca1fa..4c7b58ee2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -72,8 +72,8 @@ public class ABC { public int removeTraps() { int rem = 0; - for (MethodBody body : bodies) { - rem += body.removeTraps(constants, this); + for (int s = 0; s < script_info.length; s++) { + rem += script_info[s].removeTraps(s, this); } return rem; } @@ -465,6 +465,16 @@ public class ABC { return ret.toString(); } + public boolean isStaticTraitId(int classIndex, int traitId) { + if (traitId < class_info[classIndex].static_traits.traits.length) { + return true; + } else if (traitId < class_info[classIndex].static_traits.traits.length + instance_info[classIndex].instance_traits.traits.length) { + return false; + } else { + return true; //Can be class or instance initializer + } + } + public Trait findTraitByTraitId(int classIndex, int traitId) { if (traitId < class_info[classIndex].static_traits.traits.length) { return class_info[classIndex].static_traits.traits[traitId]; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 0b51a662b..9450ef01a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -1687,171 +1687,11 @@ public class AVM2Code implements Serializable { code.add(pos, instruction); } - public int removeTraps(ConstantPool constants, MethodBody body, ABC abc) { - + public int removeTraps(ConstantPool constants, MethodBody body, ABC abc, int scriptIndex, int classIndex, boolean isStatic) { removeDeadCode(constants, body); - /* boolean isSecure = true; - try { - if (code.size() > 4) { - AVM2Instruction first = code.get(0); - AVM2Instruction second = code.get(1); - boolean firstValue = false; - boolean secondValue = false; - if (first.definition instanceof PushFalseIns) { - firstValue = false; - } else if (first.definition instanceof PushTrueIns) { - firstValue = true; - } else { - isSecure = false; - } - if (isSecure) { - if (second.definition instanceof PushFalseIns) { - secondValue = false; - } else if (second.definition instanceof PushTrueIns) { - secondValue = true; - } else { - isSecure = false; - } - if (isSecure) { - int pos = 2; - AVM2Instruction third = code.get(pos); - if (third.definition instanceof SwapIns) { - pos++; - boolean dup = firstValue; - firstValue = secondValue; - secondValue = dup; - third.ignored = true; - } - while (third.definition instanceof JumpIns) { - pos = adr2pos(pos2adr(pos) + third.getBytes().length + third.operands[0]); - third = code.get(pos); - } - AVM2Instruction firstSet = code.get(pos); - while (firstSet.definition instanceof JumpIns) { - pos = adr2pos(pos2adr(pos) + firstSet.getBytes().length + firstSet.operands[0]); - firstSet = code.get(pos); - } - pos++; - AVM2Instruction secondSet = code.get(pos); - while (secondSet.definition instanceof JumpIns) { - pos = adr2pos(pos2adr(pos) + secondSet.getBytes().length + secondSet.operands[0]); - secondSet = code.get(pos); - } - int trueIndex = -1; - int falseIndex = -1; - if (firstSet.definition instanceof SetLocalTypeIns) { - if (secondValue == true) { - trueIndex = ((SetLocalTypeIns) firstSet.definition).getRegisterId(firstSet); - } - if (secondValue == false) { - falseIndex = ((SetLocalTypeIns) firstSet.definition).getRegisterId(firstSet); - } - } else { - isSecure = false; - } - if (isSecure) { - if (secondSet.definition instanceof SetLocalTypeIns) { - if (firstValue == true) { - trueIndex = ((SetLocalTypeIns) secondSet.definition).getRegisterId(secondSet); - } - if (firstValue == false) { - falseIndex = ((SetLocalTypeIns) secondSet.definition).getRegisterId(secondSet); - } - secondSet.ignored = true; - firstSet.ignored = true; - first.ignored = true; - second.ignored = true; - boolean found; - do { - found = false; - for (int ip = 0; ip < code.size(); ip++) { - if (code.get(ip).ignored) { - continue; - } - if (code.get(ip).definition instanceof GetLocalTypeIns) { - int regIndex = ((GetLocalTypeIns) code.get(ip).definition).getRegisterId(code.get(ip)); - if ((regIndex == trueIndex) || (regIndex == falseIndex)) { - found = true; - Stack myStack = new Stack(); - do { - AVM2Instruction ins = code.get(ip); - if (ins.definition instanceof GetLocalTypeIns) { - regIndex = ((GetLocalTypeIns) ins.definition).getRegisterId(ins); - if (regIndex == trueIndex) { - myStack.push(true); - } - if (regIndex == falseIndex) { - myStack.push(false); - } - ip++; - ins.ignored = true; - } else if (ins.definition instanceof DupIns) { - Boolean b = myStack.pop(); - myStack.push(b); - myStack.push(b); - ins.ignored = true; - ip++; - } else if (ins.definition instanceof PopIns) { - myStack.pop(); - ins.ignored = true; - ip++; - } else if (ins.definition instanceof IfTrueIns) { - boolean val = myStack.pop(); - if (val) { - code.get(ip).definition = new JumpIns(); - ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); - } else { - code.get(ip).ignored = true; - ip++; - } - } else if (ins.definition instanceof IfFalseIns) { - boolean val = myStack.pop(); - if (!val) { - code.get(ip).definition = new JumpIns(); - ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); - } else { - code.get(ip).ignored = true; - ip++; - } - } else if (ins.definition instanceof JumpIns) { - ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); - } else { - ip++; - } - - } while (myStack.size() > 0 && ip < code.size()); - - break; - } - - } - } - } while (found); - removeIgnored(constants, body); - removeDeadCode(constants, body); - } else { - //isSecure = false; - } - } - - } - } - } - } catch (ConvertException cex) { - } - int ret = isSecure ? 1 : 0; - ret += visitCodeTrap(body, new int[code.size()]);*/ - - //definition.translate((Boolean) localData.get(0), (Integer) localData.get(1), - //(HashMap) localData.get(2), stack, - //(Stack) localData.get(3), (ConstantPool) localData.get(4), this, - //(MethodInfo[]) localData.get(5), output, - //(MethodBody) localData.get(6), (ABC) localData.get(7), - //(HashMap) localData.get(8), (List) localData.get(8)); - List localData = new ArrayList(); - localData.add((Boolean) false); //isStatic - localData.add((Integer) (-1)); //classIndex + localData.add((Boolean) isStatic); //isStatic + localData.add((Integer) (classIndex)); //classIndex localData.add(new HashMap()); localData.add(new Stack()); localData.add(abc.constants); @@ -1863,7 +1703,7 @@ public class AVM2Code implements Serializable { localData.add(new ArrayList()); localData.add(new ArrayList()); localData.add(new ArrayList()); - localData.add((Integer) (-1)); + localData.add((Integer) (scriptIndex)); int ret = 0; ret += removeTraps(localData, new AVM2GraphSource(this, false, -1, -1, new HashMap(), new Stack(), abc, body, new HashMap(), new ArrayList()), 0); removeIgnored(constants, body); @@ -2593,6 +2433,6 @@ public class AVM2Code implements Serializable { HashMap decisions = new HashMap(); removeTraps(false, false, localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), 0, new HashMap(), new HashMap>(), decisions); localData.set(2, new HashMap()); - return removeTraps(true, true, localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), 0, new HashMap(), new HashMap>(), decisions); + return removeTraps(true, false, localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), 0, new HashMap(), new HashMap>(), decisions); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java index e2649aa81..d423887ac 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java @@ -244,9 +244,9 @@ public class AVM2Instruction implements Serializable, GraphSourceItem { @Override public void translate(List localData, Stack stack, List output) { - definition.translate((Boolean) localData.get(0), + definition.translate((Boolean) localData.get(0), (Integer) localData.get(13), - (Integer) localData.get(1), + (Integer) localData.get(1), (HashMap) localData.get(2), stack, (Stack) localData.get(3), diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java index acd190ba1..230ae8bb2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java @@ -38,11 +38,21 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL private List classHighlights = new ArrayList(); private Highlighting currentMethodHighlight; private ABC abc; - private int scriptIndex=-1; + private int scriptIndex = -1; public int lastTraitIndex = 0; private boolean ignoreCarret = false; private boolean reset = false; private ABCPanel abcPanel; + private int classIndex = -1; + private boolean isStatic = false; + + public int getScriptIndex() { + return scriptIndex; + } + + public boolean getIsStatic() { + return isStatic; + } public void setNoTrait() { abcPanel.detailPanel.showCard(DetailPanel.UNSUPPORTED_TRAIT_CARD, null); @@ -72,7 +82,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL this.classIndex = classIndex; } - private boolean displayMethod(int pos, int methodIndex, String name, Trait trait) { + private boolean displayMethod(int pos, int methodIndex, String name, Trait trait, boolean isStatic) { if (abc == null) { return false; } @@ -86,6 +96,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL abcPanel.detailPanel.methodTraitPanel.methodBodyParamsPanel.loadFromBody(abc.bodies[bi]); abcPanel.detailPanel.methodTraitPanel.methodInfoPanel.load(abc.bodies[bi].method_info, abc); abcPanel.detailPanel.setEditMode(false); + this.isStatic = isStatic; } boolean success = false; for (Highlighting h : highlights) { @@ -103,7 +114,6 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL abcPanel.navigator.setClassIndex(classIndex, scriptIndex); } } - private int classIndex = -1; public void resetEditing() { reset = true; @@ -147,6 +157,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL lastTraitIndex = (int) th.offset; if (abc != null) { t = abc.findTraitByTraitId(classIndex, lastTraitIndex); + isStatic = abc.isStaticTraitId(classIndex, lastTraitIndex); if (t != null) { name += ":" + t.getName(abc).getName(abc.constants, new ArrayList()); } @@ -154,7 +165,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } } - displayMethod(pos, (int) tm.offset, name, t); + displayMethod(pos, (int) tm.offset, name, t, isStatic); currentMethodHighlight = tm; @@ -184,12 +195,13 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL if (abc != null) { name = abc.instance_info[classIndex].getName(abc.constants).getNameWithNamespace(abc.constants); t = abc.findTraitByTraitId(classIndex, lastTraitIndex); + isStatic = abc.isStaticTraitId(classIndex, lastTraitIndex); if (t != null) { name += ":" + t.getName(abc).getName(abc.constants, new ArrayList()); } } - displayMethod(pos, abc.findMethodIdByTraitId(classIndex, (int) th.offset), name, t); + displayMethod(pos, abc.findMethodIdByTraitId(classIndex, (int) th.offset), name, t, isStatic); return; } } @@ -315,7 +327,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL if (bufferedClasses.containsKey(scriptIndex)) { bufferedClasses.remove(scriptIndex); } - if((scriptIndex!=-1)&&(abc!=null)){ + if ((scriptIndex != -1) && (abc != null)) { setScript(scriptIndex, abc, abcList); } setNoTrait(); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index 096351539..d36461fe0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -31,6 +31,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Stack; +import java.util.logging.Level; +import java.util.logging.Logger; public class MethodBody implements Cloneable, Serializable { @@ -70,8 +72,8 @@ public class MethodBody implements Cloneable, Serializable { code.restoreControlFlow(constants, this); } - public int removeTraps(ConstantPool constants, ABC abc) { - return code.removeTraps(constants, this, abc); + public int removeTraps(ConstantPool constants, ABC abc, int scriptIndex, int classIndex, boolean isStatic) { + return code.removeTraps(constants, this, abc, scriptIndex, classIndex, isStatic); } public HashMap getLocalRegNames(ABC abc) { @@ -117,7 +119,11 @@ public class MethodBody implements Cloneable, Serializable { deobfuscated = b.code; deobfuscated.markMappedOffsets(); if ((Boolean) Configuration.getConfig("autoDeobfuscate", true)) { - deobfuscated.removeTraps(constants, b, abc); + try { + deobfuscated.removeTraps(constants, b, abc, scriptIndex, classIndex, isStatic); + } catch (Exception ex) { + Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Error during remove traps", ex); + } } //deobfuscated.restoreControlFlow(constants, b); try { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java index 7c5feeb76..cb9196b1a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java @@ -32,6 +32,10 @@ public class ScriptInfo { public int init_index; //MethodInfo public Traits traits; + public int removeTraps(int scriptIndex, ABC abc) { + return traits.removeTraps(scriptIndex, -1, true, abc); + } + @Override public String toString() { return "method_index=" + init_index + "\r\n" + traits.toString(); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java index 70fa31074..22aa6db68 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java @@ -138,4 +138,6 @@ public abstract class Trait implements Serializable { return abc.constants.constant_multiname[name_index]; } } + + public abstract int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index fe779241a..4952afbdd 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -301,6 +301,7 @@ public class TraitClass extends Trait { @Override public String convert(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List fullyQualifiedNames) { + if (!highlight) { Highlighting.doHighlight = false; } @@ -314,7 +315,9 @@ public class TraitClass extends Trait { } String packageName = abc.instance_info[class_info].getName(abc.constants).getNamespace(abc.constants).getName(abc.constants); - + if (debugMode) { + System.err.println("Decompiling " + packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames)); + } List namesInThisPackage = new ArrayList(); for (ABCContainerTag tag : abcTags) { for (ScriptInfo si : tag.getABC().script_info) { @@ -462,4 +465,20 @@ public class TraitClass extends Trait { public Multiname getName(ABC abc) { return abc.constants.constant_multiname[abc.instance_info[class_info].name_index]; } + + @Override + public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc) { + int iInitializer = abc.findBodyIndex(abc.instance_info[class_info].iinit_index); + int ret = 0; + if (iInitializer != -1) { + ret += abc.bodies[iInitializer].removeTraps(abc.constants, abc, scriptIndex, class_info, false); + } + int sInitializer = abc.findBodyIndex(abc.class_info[class_info].cinit_index); + if (sInitializer != -1) { + ret += abc.bodies[sInitializer].removeTraps(abc.constants, abc, scriptIndex, class_info, true); + } + ret += abc.instance_info[class_info].instance_traits.removeTraps(scriptIndex, class_info, false, abc); + ret += abc.class_info[class_info].static_traits.removeTraps(scriptIndex, class_info, true, abc); + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java index ed3288b86..530f3f11c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java @@ -55,4 +55,13 @@ public class TraitFunction extends Trait { return ABC.IDENT_STRING + ABC.IDENT_STRING + header + (abc.instance_info[classIndex].isInterface() ? ";" : " {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}"); } + + @Override + public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc) { + int bodyIndex = abc.findBodyIndex(method_info); + if (bodyIndex != -1) { + return abc.bodies[bodyIndex].removeTraps(abc.constants, abc, scriptIndex, classIndex, isStatic); + } + return 0; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java index fb3572bd8..bfd08f571 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java @@ -66,4 +66,13 @@ public class TraitMethodGetterSetter extends Trait { } return ABC.IDENT_STRING + ABC.IDENT_STRING + header + ((classIndex != -1 && abc.instance_info[classIndex].isInterface()) ? ";" : " {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}"); } + + @Override + public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc) { + int bodyIndex = abc.findBodyIndex(method_info); + if (bodyIndex != -1) { + return abc.bodies[bodyIndex].removeTraps(abc.constants, abc, scriptIndex, classIndex, isStatic); + } + return 0; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java index 554506e0a..72d7c4c2d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java @@ -170,4 +170,10 @@ public class TraitSlotConst extends Trait { public boolean isVar() { return kindType == TRAIT_SLOT; } + + @Override + public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc) { + //do nothing + return 0; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java index 5505fe567..f1e6338fc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java @@ -26,6 +26,14 @@ public class Traits implements Serializable { public Trait traits[] = new Trait[0]; + public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc) { + int ret = 0; + for (Trait t : traits) { + ret += t.removeTraps(scriptIndex, classIndex, isStatic, abc); + } + return ret; + } + @Override public String toString() { String s = ""; diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java b/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java index 5da33809f..3a9165703 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.abc.avm2.treemodel.CommentTreeItem; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.helpers.Highlighting; import java.util.ArrayList; +import java.util.EmptyStackException; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -557,9 +558,20 @@ public class Graph { if ((ti = checkLoop(next, stopPart, loops)) != null) { ret.add(ti); } else { - printGraph(localData, stack, allParts, parent, next, reversed ? sp1 : sp0, loops, forFinalCommands); - GraphTargetItem second = stack.pop(); GraphTargetItem first = stack.pop(); + GraphTargetItem second = null; + if (first.isCompileTime() && (reversed == first.toBoolean())) { + second = new TrueItem(null); + } else { + printGraph(localData, stack, allParts, parent, next, reversed ? sp1 : sp0, loops, forFinalCommands); + try { + second = stack.pop(); + } catch (EmptyStackException ese) { + ese.printStackTrace(); + System.err.println(part.toString()); + System.out.println("" + first.isCompileTime() + first.toBoolean()); + } + } if (!reversed) { AndItem a = new AndItem(null, first, second); stack.push(a); @@ -605,9 +617,16 @@ public class Graph { if ((ti = checkLoop(next, stopPart, loops)) != null) { ret.add(ti); } else { - printGraph(localData, stack, allParts, parent, next, reversed ? sp1 : sp0, loops, forFinalCommands); - GraphTargetItem second = stack.pop(); GraphTargetItem first = stack.pop(); + GraphTargetItem second = null; + if (first.isCompileTime() && (reversed == !first.toBoolean())) { + second = new TrueItem(null); + } else { + printGraph(localData, stack, allParts, parent, next, reversed ? sp1 : sp0, loops, forFinalCommands); + second = stack.pop(); + } + + if (reversed) { AndItem a = new AndItem(null, first, second); stack.push(a); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index fefd2b740..cc2c788d1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -1161,7 +1161,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi it.setImage(data); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "message", ex); - JOptionPane.showMessageDialog(null, "Invalid image.","Error",JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(null, "Invalid image.", "Error", JOptionPane.ERROR_MESSAGE); } reload(true); } @@ -1483,7 +1483,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi } else { int bi = abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex(); if (bi != -1) { - cnt += abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc); + cnt += abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc, abcPanel.decompiledTextArea.getScriptIndex(), abcPanel.decompiledTextArea.getClassIndex(), abcPanel.decompiledTextArea.getIsStatic()); } abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abcPanel.abc); } @@ -1531,25 +1531,25 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi new SwingWorker() { @Override protected Object doInBackground() throws Exception { - try{ - int cnt = 0; + try { + int cnt = 0; - if (abcPanel != null) { - HashMap namesMap = new HashMap(); - for (ABCContainerTag tag : abcPanel.list) { - cnt += tag.getABC().deobfuscateIdentifiers(namesMap); + if (abcPanel != null) { + HashMap namesMap = new HashMap(); + for (ABCContainerTag tag : abcPanel.list) { + cnt += tag.getABC().deobfuscateIdentifiers(namesMap); + } + } else { + cnt = swf.deobfuscateAS2Identifiers(); } - } else { - cnt = swf.deobfuscateAS2Identifiers(); - } - Main.stopWork(); - JOptionPane.showMessageDialog(null, "Identifiers renamed: " + cnt); - if (abcPanel != null) { - abcPanel.reload(); - } - doFilter(); - reload(true); - }catch(Exception ex){ + Main.stopWork(); + JOptionPane.showMessageDialog(null, "Identifiers renamed: " + cnt); + if (abcPanel != null) { + abcPanel.reload(); + } + doFilter(); + reload(true); + } catch (Exception ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "message", ex); } return true; @@ -1587,9 +1587,9 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_DEAD_CODE) { abcPanel.abc.bodies[bi].removeDeadCode(abcPanel.abc.constants); } else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_TRAPS) { - abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc); + abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc, abcPanel.decompiledTextArea.getScriptIndex(), abcPanel.decompiledTextArea.getClassIndex(), abcPanel.decompiledTextArea.getIsStatic()); } else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_RESTORE_CONTROL_FLOW) { - abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc); + abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc, abcPanel.decompiledTextArea.getScriptIndex(), abcPanel.decompiledTextArea.getClassIndex(), abcPanel.decompiledTextArea.getIsStatic()); abcPanel.abc.bodies[bi].restoreControlFlow(abcPanel.abc.constants); } }