mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-25 09:46:02 +00:00
Issue #148 Better tree handling on obfuscated names
This commit is contained in:
@@ -669,12 +669,12 @@ public class ABC {
|
||||
List<ABCContainerTag> 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<ABCContainerTag> abcList, boolean pcode, String informStr, boolean paralel) {
|
||||
public ExportPackTask(AtomicInteger index, int count, ClassPath path, ScriptPack pack, String directory, List<ABCContainerTag> abcList, boolean pcode, String informStr, boolean paralel) {
|
||||
this.pack = pack;
|
||||
this.directory = directory;
|
||||
this.abcList = abcList;
|
||||
@@ -705,8 +705,8 @@ public class ABC {
|
||||
List<Future<File>> futureResults = new ArrayList<>();
|
||||
AtomicInteger cnt = new AtomicInteger(1);
|
||||
for (int i = 0; i < script_info.length; i++) {
|
||||
HashMap<String, ScriptPack> packs = script_info[i].getPacks(this, i);
|
||||
for (String path : packs.keySet()) {
|
||||
HashMap<ClassPath, ScriptPack> packs = script_info[i].getPacks(this, i);
|
||||
for (ClassPath path : packs.keySet()) {
|
||||
Future<File> future = executor.submit(new ExportPackTask(cnt, script_info.length, path, packs.get(path), directory, abcList, pcode, abcStr, paralel));
|
||||
futureResults.add(future);
|
||||
}
|
||||
|
||||
37
trunk/src/com/jpexs/decompiler/flash/abc/ClassPath.java
Normal file
37
trunk/src/com/jpexs/decompiler/flash/abc/ClassPath.java
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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<String, ScriptPack> allpacks = clModel.getList();
|
||||
HashMap<ClassPath, ScriptPack> allpacks = clModel.getList();
|
||||
found = new ArrayList<>();
|
||||
Pattern pat = null;
|
||||
if (regexp) {
|
||||
|
||||
@@ -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<ABCContainerTag> abcList;
|
||||
public HashMap<String, ScriptPack> treeList;
|
||||
public HashMap<ClassPath, ScriptPack> treeList;
|
||||
private ABCPanel abcPanel;
|
||||
|
||||
public void selectClass(int classIndex) {
|
||||
@@ -95,14 +96,14 @@ public class ClassesListTree extends JTree implements TreeSelectionListener {
|
||||
return selectedScripts;
|
||||
}
|
||||
|
||||
public HashMap<String, ScriptPack> getTreeList(List<ABCContainerTag> list) {
|
||||
HashMap<String, ScriptPack> ret = new HashMap<>();
|
||||
public HashMap<ClassPath, ScriptPack> getTreeList(List<ABCContainerTag> list) {
|
||||
HashMap<ClassPath, ScriptPack> 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<String, ScriptPack> packs = script.getPacks(abc, i);
|
||||
for (String path : packs.keySet()) {
|
||||
HashMap<ClassPath, ScriptPack> packs = script.getPacks(abc, i);
|
||||
for (ClassPath path : packs.keySet()) {
|
||||
ret.put(path, packs.get(path));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String, ScriptPack> list;
|
||||
private HashMap<ClassPath, ScriptPack> list;
|
||||
|
||||
public HashMap<String, ScriptPack> getList() {
|
||||
public HashMap<ClassPath, ScriptPack> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public ClassesListTreeModel(HashMap<String, ScriptPack> list) {
|
||||
public ClassesListTreeModel(HashMap<ClassPath, ScriptPack> list) {
|
||||
this(list, null);
|
||||
}
|
||||
|
||||
public ClassesListTreeModel(HashMap<String, ScriptPack> list, String filter) {
|
||||
for (String path : list.keySet()) {
|
||||
public ClassesListTreeModel(HashMap<ClassPath, ScriptPack> 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;
|
||||
|
||||
|
||||
@@ -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<String, ScriptPack> getPacks(ABC abc, int scriptIndex) {
|
||||
HashMap<String, ScriptPack> ret = new HashMap<>();
|
||||
public HashMap<ClassPath, ScriptPack> getPacks(ABC abc, int scriptIndex) {
|
||||
HashMap<ClassPath, ScriptPack> ret = new HashMap<>();
|
||||
|
||||
List<Integer> 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>());
|
||||
String path = packageName.equals("") ? objectName : packageName + "." + objectName;
|
||||
List<Integer> 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<ABCContainerTag> abcList, String directory, boolean pcode, int scriptIndex, boolean paralel) throws IOException {
|
||||
HashMap<String, ScriptPack> packs = getPacks(abc, scriptIndex);
|
||||
HashMap<ClassPath, ScriptPack> packs = getPacks(abc, scriptIndex);
|
||||
for (ScriptPack pack : packs.values()) {
|
||||
pack.export(directory, abcList, pcode, paralel);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user