diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java index 775438768..12009e65b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -669,12 +669,12 @@ public class ABC { List abcList; boolean pcode; String informStr; - String path; + ClassPath path; AtomicInteger index; int count; boolean paralel; - public ExportPackTask(AtomicInteger index, int count, String path, ScriptPack pack, String directory, List abcList, boolean pcode, String informStr, boolean paralel) { + public ExportPackTask(AtomicInteger index, int count, ClassPath path, ScriptPack pack, String directory, List abcList, boolean pcode, String informStr, boolean paralel) { this.pack = pack; this.directory = directory; this.abcList = abcList; @@ -705,8 +705,8 @@ public class ABC { List> futureResults = new ArrayList<>(); AtomicInteger cnt = new AtomicInteger(1); for (int i = 0; i < script_info.length; i++) { - HashMap packs = script_info[i].getPacks(this, i); - for (String path : packs.keySet()) { + HashMap packs = script_info[i].getPacks(this, i); + for (ClassPath path : packs.keySet()) { Future future = executor.submit(new ExportPackTask(cnt, script_info.length, path, packs.get(path), directory, abcList, pcode, abcStr, paralel)); futureResults.add(future); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ClassPath.java b/trunk/src/com/jpexs/decompiler/flash/abc/ClassPath.java new file mode 100644 index 000000000..9c109e9a9 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ClassPath.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2013 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc; + +/** + * + * @author JPEXS + */ +public class ClassPath { + + public String packageStr; + public String className; + + public ClassPath(String packageStr, String className) { + this.packageStr = packageStr; + this.className = className; + } + + @Override + public String toString() { + return (packageStr == null || packageStr.equals("")) ? className : packageStr + "." + className; + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java index 54dd7129d..0e2310535 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.abc.gui; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.ClassPath; import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.abc.gui.tablemodels.*; import com.jpexs.decompiler.flash.gui.Main; @@ -80,7 +81,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener { searchIgnoreCase = ignoreCase; searchRegexp = regexp; ClassesListTreeModel clModel = (ClassesListTreeModel) classTree.getModel(); - HashMap allpacks = clModel.getList(); + HashMap allpacks = clModel.getList(); found = new ArrayList<>(); Pattern pat = null; if (regexp) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTree.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTree.java index eb307bd32..f9efb835d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTree.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTree.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.abc.gui; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.ClassPath; import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.abc.types.ScriptInfo; import com.jpexs.decompiler.flash.abc.types.traits.Trait; @@ -37,7 +38,7 @@ import javax.swing.tree.TreeSelectionModel; public class ClassesListTree extends JTree implements TreeSelectionListener { private List abcList; - public HashMap treeList; + public HashMap treeList; private ABCPanel abcPanel; public void selectClass(int classIndex) { @@ -95,14 +96,14 @@ public class ClassesListTree extends JTree implements TreeSelectionListener { return selectedScripts; } - public HashMap getTreeList(List list) { - HashMap ret = new HashMap<>(); + public HashMap getTreeList(List list) { + HashMap ret = new HashMap<>(); for (ABCContainerTag tag : list) { ABC abc = tag.getABC(); for (int i = 0; i < abc.script_info.length; i++) { ScriptInfo script = abc.script_info[i]; - HashMap packs = script.getPacks(abc, i); - for (String path : packs.keySet()) { + HashMap packs = script.getPacks(abc, i); + for (ClassPath path : packs.keySet()) { ret.put(path, packs.get(path)); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTreeModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTreeModel.java index 91052bc32..e41e9fd27 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTreeModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTreeModel.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.abc.gui; +import com.jpexs.decompiler.flash.abc.ClassPath; import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitClass; @@ -75,28 +76,28 @@ class ClassIndexVisitor implements TreeVisitor { public class ClassesListTreeModel implements TreeModel { private Tree classTree = new Tree(); - private HashMap list; + private HashMap list; - public HashMap getList() { + public HashMap getList() { return list; } - public ClassesListTreeModel(HashMap list) { + public ClassesListTreeModel(HashMap list) { this(list, null); } - public ClassesListTreeModel(HashMap list, String filter) { - for (String path : list.keySet()) { + public ClassesListTreeModel(HashMap list, String filter) { + for (ClassPath path : list.keySet()) { if (filter != null) { if (!filter.equals("")) { - if (!path.contains(filter)) { + if (!path.toString().contains(filter)) { continue; } } } - String nsName = path.contains(".") ? path.substring(path.lastIndexOf(".") + 1) : path; - String packageName = path.contains(".") ? path.substring(0, path.lastIndexOf(".")) : ""; - classTree.add(nsName, packageName, list.get(path)); + //String nsName = path.contains(".") ? path.substring(path.lastIndexOf(".") + 1) : path; + //String packageName = path.contains(".") ? path.substring(0, path.lastIndexOf(".")) : ""; + classTree.add(path.className, path.packageStr, list.get(path)); } this.list = list; 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 03a10bd46..a2a269a09 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.abc.types; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.ClassPath; import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.Traits; @@ -31,8 +32,8 @@ public class ScriptInfo { public int init_index; //MethodInfo public Traits traits; - public HashMap getPacks(ABC abc, int scriptIndex) { - HashMap ret = new HashMap<>(); + public HashMap getPacks(ABC abc, int scriptIndex) { + HashMap ret = new HashMap<>(); List otherTraits = new ArrayList<>(); for (int j = 0; j < traits.traits.length; j++) { @@ -52,7 +53,6 @@ public class ScriptInfo { || (ns.kind == Namespace.KIND_PACKAGE)) { String packageName = ns.getName(abc.constants); String objectName = name.getName(abc.constants, new ArrayList()); - String path = packageName.equals("") ? objectName : packageName + "." + objectName; List traitIndices = new ArrayList<>(); traitIndices.add(j); @@ -60,7 +60,7 @@ public class ScriptInfo { traitIndices.addAll(otherTraits); } otherTraits = new ArrayList<>(); - ret.put(path, new ScriptPack(abc, scriptIndex, traitIndices)); + ret.put(new ClassPath(packageName, objectName), new ScriptPack(abc, scriptIndex, traitIndices)); } } return ret; @@ -84,7 +84,7 @@ public class ScriptInfo { } public void export(ABC abc, List abcList, String directory, boolean pcode, int scriptIndex, boolean paralel) throws IOException { - HashMap packs = getPacks(abc, scriptIndex); + HashMap packs = getPacks(abc, scriptIndex); for (ScriptPack pack : packs.values()) { pack.export(directory, abcList, pcode, paralel); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index d2ae1d2c8..305d343f2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -177,32 +177,33 @@ public class Main { } public static SWF parseSWF(String file) throws Exception { - FileInputStream fis = new FileInputStream(file); - InputStream bis = new BufferedInputStream(fis); - SWF locswf = new SWF(bis, new PercentListener() { + SWF locswf; + try (FileInputStream fis = new FileInputStream(file)) { + InputStream bis = new BufferedInputStream(fis); + locswf = new SWF(bis, new PercentListener() { @Override public void percent(int p) { startWork("Reading SWF", p); } }, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE)); - locswf.addEventListener(new EventListener() { - @Override - public void handleEvent(String event, Object data) { - if (event.equals("export")) { - startWork((String) data); + locswf.addEventListener(new EventListener() { + @Override + public void handleEvent(String event, Object data) { + if (event.equals("export")) { + startWork((String) data); + } + if (event.equals("getVariables")) { + startWork("Getting variables..." + (String) data); + } + if (event.equals("deobfuscate")) { + startWork("Deobfuscating..." + (String) data); + } + if (event.equals("rename")) { + startWork("Renaming..." + (String) data); + } } - if (event.equals("getVariables")) { - startWork("Getting variables..." + (String) data); - } - if (event.equals("deobfuscate")) { - startWork("Deobfuscating..." + (String) data); - } - if (event.equals("rename")) { - startWork("Renaming..." + (String) data); - } - } - }); - fis.close(); + }); + } return locswf; }