mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-18 15:38:10 +00:00
Parallelism can be turned off
This commit is contained in:
@@ -246,8 +246,8 @@ public class SWF {
|
||||
}
|
||||
}
|
||||
|
||||
public SWF(InputStream is) throws IOException {
|
||||
this(is, null);
|
||||
public SWF(InputStream is, boolean paralelRead) throws IOException {
|
||||
this(is, null, paralelRead);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,7 +256,7 @@ public class SWF {
|
||||
* @param is Stream to read SWF from
|
||||
* @throws IOException
|
||||
*/
|
||||
public SWF(InputStream is, PercentListener listener) throws IOException {
|
||||
public SWF(InputStream is, PercentListener listener, boolean paralelRead) throws IOException {
|
||||
byte hdr[] = new byte[3];
|
||||
is.read(hdr);
|
||||
String shdr = new String(hdr);
|
||||
@@ -303,7 +303,7 @@ public class SWF {
|
||||
int tmpFirstByetOfFrameRate = sis.readUI8();
|
||||
frameRate = sis.readUI8();
|
||||
frameCount = sis.readUI16();
|
||||
tags = sis.readTagList(0);
|
||||
tags = sis.readTagList(0, paralelRead);
|
||||
assignClassesToSymbols();
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ public class SWF {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean exportAS3Class(String className, String outdir, boolean isPcode) throws Exception {
|
||||
public boolean exportAS3Class(String className, String outdir, boolean isPcode, boolean paralel) throws Exception {
|
||||
List<ABCContainerTag> abcTags = new ArrayList<>();
|
||||
|
||||
for (Tag t : tags) {
|
||||
@@ -441,14 +441,14 @@ public class SWF {
|
||||
}
|
||||
String exStr = "Exporting " + "tag " + (i + 1) + "/" + abcTags.size() + " " + cnt + scr.getPath() + " ...";
|
||||
informListeners("export", exStr);
|
||||
scr.export(outdir, abcTags, isPcode);
|
||||
scr.export(outdir, abcTags, isPcode, paralel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean exportActionScript(String outdir, boolean isPcode) throws Exception {
|
||||
public boolean exportActionScript(String outdir, boolean isPcode, boolean paralel) throws Exception {
|
||||
boolean asV3Found = false;
|
||||
final EventListener evl = new EventListener() {
|
||||
@Override
|
||||
@@ -468,7 +468,7 @@ public class SWF {
|
||||
for (int i = 0; i < abcTags.size(); i++) {
|
||||
ABCContainerTag t = abcTags.get(i);
|
||||
t.getABC().addEventListener(evl);
|
||||
t.getABC().export(outdir, isPcode, abcTags, "tag " + (i + 1) + "/" + abcTags.size() + " ");
|
||||
t.getABC().export(outdir, isPcode, abcTags, "tag " + (i + 1) + "/" + abcTags.size() + " ", paralel);
|
||||
}
|
||||
|
||||
if (!asV3Found) {
|
||||
@@ -1308,12 +1308,12 @@ public class SWF {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void exportFla(String outfile, String swfName, String generator, String generatorVerName, String generatorVersion) {
|
||||
XFLConverter.convertSWF(this, swfName, outfile, true, generator, generatorVerName, generatorVersion);
|
||||
public void exportFla(String outfile, String swfName, String generator, String generatorVerName, String generatorVersion, boolean paralel) {
|
||||
XFLConverter.convertSWF(this, swfName, outfile, true, generator, generatorVerName, generatorVersion, paralel);
|
||||
}
|
||||
|
||||
public void exportXfl(String outfile, String swfName, String generator, String generatorVerName, String generatorVersion) {
|
||||
XFLConverter.convertSWF(this, swfName, outfile, false, generator, generatorVerName, generatorVersion);
|
||||
public void exportXfl(String outfile, String swfName, String generator, String generatorVerName, String generatorVersion, boolean paralel) {
|
||||
XFLConverter.convertSWF(this, swfName, outfile, false, generator, generatorVerName, generatorVersion, paralel);
|
||||
}
|
||||
|
||||
public static float twipToPixel(int twip) {
|
||||
|
||||
@@ -1141,16 +1141,18 @@ public class SWFInputStream extends InputStream {
|
||||
private final Tag tag;
|
||||
private final int version;
|
||||
private final int level;
|
||||
private boolean paralel;
|
||||
|
||||
public TagResolutionTask(Tag tag, int version, int level) {
|
||||
public TagResolutionTask(Tag tag, int version, int level, boolean paralel) {
|
||||
this.tag = tag;
|
||||
this.version = version;
|
||||
this.level = level;
|
||||
this.paralel = paralel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tag call() throws Exception {
|
||||
return SWFInputStream.resolveTag(tag, version, level);
|
||||
return SWFInputStream.resolveTag(tag, version, level, paralel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1161,8 +1163,13 @@ public class SWFInputStream extends InputStream {
|
||||
* @return List of tags
|
||||
* @throws IOException
|
||||
*/
|
||||
public List<Tag> readTagList(int level) throws IOException {
|
||||
ExecutorService executor = Executors.newCachedThreadPool();
|
||||
public List<Tag> readTagList(int level, boolean paralel) throws IOException {
|
||||
ExecutorService executor = null;
|
||||
if (paralel) {
|
||||
executor = Executors.newFixedThreadPool(20);
|
||||
} else {
|
||||
executor = Executors.newFixedThreadPool(1);
|
||||
}
|
||||
List<Future<Tag>> futureResults = new ArrayList<>();
|
||||
List<Tag> tags = new ArrayList<>();
|
||||
Tag tag;
|
||||
@@ -1170,7 +1177,7 @@ public class SWFInputStream extends InputStream {
|
||||
while (true) {
|
||||
long pos = getPos();
|
||||
try {
|
||||
tag = readTag(level, pos, false);
|
||||
tag = readTag(level, pos, false, paralel);
|
||||
} catch (EndOfStreamException ex) {
|
||||
tag = null;
|
||||
}
|
||||
@@ -1183,7 +1190,7 @@ public class SWFInputStream extends InputStream {
|
||||
tag.previousTag = previousTag;
|
||||
previousTag = tag;
|
||||
|
||||
Future<Tag> future = executor.submit(new TagResolutionTask(tag, version, level));
|
||||
Future<Tag> future = executor.submit(new TagResolutionTask(tag, version, level, paralel));
|
||||
futureResults.add(future);
|
||||
}
|
||||
|
||||
@@ -1198,7 +1205,7 @@ public class SWFInputStream extends InputStream {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public static Tag resolveTag(Tag tag, int version, int level) {
|
||||
public static Tag resolveTag(Tag tag, int version, int level, boolean paralel) {
|
||||
Tag ret;
|
||||
|
||||
byte data[] = tag.getData(version);
|
||||
@@ -1307,7 +1314,7 @@ public class SWFInputStream extends InputStream {
|
||||
break;
|
||||
//case 38:
|
||||
case 39:
|
||||
ret = new DefineSpriteTag(data, version, level, pos);
|
||||
ret = new DefineSpriteTag(data, version, level, pos, paralel);
|
||||
break;
|
||||
//case 40:
|
||||
case 41:
|
||||
@@ -1440,8 +1447,8 @@ public class SWFInputStream extends InputStream {
|
||||
* @return Tag or null when End tag
|
||||
* @throws IOException
|
||||
*/
|
||||
public Tag readTag(int level, long pos) throws IOException {
|
||||
return readTag(level, pos, true);
|
||||
public Tag readTag(int level, long pos, boolean paralel) throws IOException {
|
||||
return readTag(level, pos, true, paralel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1451,7 +1458,7 @@ public class SWFInputStream extends InputStream {
|
||||
* @return Tag or null when End tag
|
||||
* @throws IOException
|
||||
*/
|
||||
public Tag readTag(int level, long pos, boolean resolve) throws IOException {
|
||||
public Tag readTag(int level, long pos, boolean resolve, boolean paralel) throws IOException {
|
||||
int tagIDTagLength = readUI16();
|
||||
int tagID = (tagIDTagLength) >> 6;
|
||||
if (tagID == 0) {
|
||||
@@ -1500,7 +1507,7 @@ public class SWFInputStream extends InputStream {
|
||||
}
|
||||
}
|
||||
if (resolve) {
|
||||
return resolveTag(ret, version, level);
|
||||
return resolveTag(ret, version, level, paralel);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -563,8 +563,8 @@ public class ABC {
|
||||
}
|
||||
}
|
||||
|
||||
public void export(String directory, boolean pcode, List<ABCContainerTag> abcList) throws IOException {
|
||||
export(directory, pcode, abcList, "");
|
||||
public void export(String directory, boolean pcode, List<ABCContainerTag> abcList, boolean paralel) throws IOException {
|
||||
export(directory, pcode, abcList, "", paralel);
|
||||
}
|
||||
|
||||
private class ExportPackTask implements Runnable {
|
||||
@@ -577,8 +577,9 @@ public class ABC {
|
||||
String 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) {
|
||||
public ExportPackTask(AtomicInteger index, int count, String path, ScriptPack pack, String directory, List<ABCContainerTag> abcList, boolean pcode, String informStr, boolean paralel) {
|
||||
this.pack = pack;
|
||||
this.directory = directory;
|
||||
this.abcList = abcList;
|
||||
@@ -587,12 +588,13 @@ public class ABC {
|
||||
this.path = path;
|
||||
this.index = index;
|
||||
this.count = count;
|
||||
this.paralel = paralel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
pack.export(directory, abcList, pcode);
|
||||
pack.export(directory, abcList, pcode, paralel);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(ABC.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@@ -602,13 +604,13 @@ public class ABC {
|
||||
}
|
||||
}
|
||||
|
||||
public void export(String directory, boolean pcode, List<ABCContainerTag> abcList, String abcStr) throws IOException {
|
||||
public void export(String directory, boolean pcode, List<ABCContainerTag> abcList, String abcStr, boolean paralel) throws IOException {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(20);
|
||||
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()) {
|
||||
executor.execute(new ExportPackTask(cnt, script_info.length, path, packs.get(path), directory, abcList, pcode, abcStr));
|
||||
executor.execute(new ExportPackTask(cnt, script_info.length, path, packs.get(path), directory, abcList, pcode, abcStr, paralel));
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ScriptPack {
|
||||
return packageName + "." + scriptName;
|
||||
}
|
||||
|
||||
public void export(String directory, List<ABCContainerTag> abcList, boolean pcode) throws IOException {
|
||||
public void export(String directory, List<ABCContainerTag> abcList, boolean pcode, boolean paralel) throws IOException {
|
||||
String path = getPath();
|
||||
String scriptName = path.substring(path.lastIndexOf(".") + 1);
|
||||
String packageName = path.substring(0, path.lastIndexOf("."));
|
||||
@@ -69,9 +69,9 @@ public class ScriptPack {
|
||||
Multiname name = abc.script_info[scriptIndex].traits.traits[t].getName(abc);
|
||||
Namespace ns = name.getNamespace(abc.constants);
|
||||
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
|
||||
fos.write(abc.script_info[scriptIndex].traits.traits[t].convertPackaged("", abcList, abc, false, pcode, scriptIndex, -1, false, new ArrayList<String>()).getBytes());
|
||||
fos.write(abc.script_info[scriptIndex].traits.traits[t].convertPackaged("", abcList, abc, false, pcode, scriptIndex, -1, false, new ArrayList<String>(), paralel).getBytes());
|
||||
} else {
|
||||
fos.write(abc.script_info[scriptIndex].traits.traits[t].convert("", abcList, abc, false, pcode, scriptIndex, -1, false, new ArrayList<String>()).getBytes());
|
||||
fos.write(abc.script_info[scriptIndex].traits.traits[t].convert("", abcList, abc, false, pcode, scriptIndex, -1, false, new ArrayList<String>(), paralel).getBytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.Configuration;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
import com.jpexs.decompiler.flash.abc.types.ScriptInfo;
|
||||
@@ -293,7 +294,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
}
|
||||
if (!cache.contains(scriptLeaf)) {
|
||||
for (int scriptTraitIndex : scriptLeaf.traitIndices) {
|
||||
hilightedCodeBuf.append(script.traits.traits[scriptTraitIndex].convertPackaged("", abcList, abc, false, false, scriptIndex, -1, true, new ArrayList<String>()));
|
||||
hilightedCodeBuf.append(script.traits.traits[scriptTraitIndex].convertPackaged("", abcList, abc, false, false, scriptIndex, -1, true, new ArrayList<String>(), (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE)));
|
||||
}
|
||||
|
||||
hilightedCode = hilightedCodeBuf.toString();
|
||||
|
||||
@@ -64,9 +64,9 @@ public class TraitsListItem {
|
||||
@Override
|
||||
public String toString() {
|
||||
if ((type != Type.INITIALIZER) && isStatic) {
|
||||
return abc.class_info[classIndex].static_traits.traits[index].convertHeader("", abcTags, abc, true, false, scriptIndex, classIndex, false, new ArrayList<String>());
|
||||
return abc.class_info[classIndex].static_traits.traits[index].convertHeader("", abcTags, abc, true, false, scriptIndex, classIndex, false, new ArrayList<String>(), false);
|
||||
} else if ((type != Type.INITIALIZER) && (!isStatic)) {
|
||||
return abc.instance_info[classIndex].instance_traits.traits[index].convertHeader("", abcTags, abc, false, false, scriptIndex, classIndex, false, new ArrayList<String>());
|
||||
return abc.instance_info[classIndex].instance_traits.traits[index].convertHeader("", abcTags, abc, false, false, scriptIndex, classIndex, false, new ArrayList<String>(), false);
|
||||
} else if (!isStatic) {
|
||||
return STR_INSTANCE_INITIALIZER;
|
||||
} else {
|
||||
|
||||
@@ -79,14 +79,14 @@ public class ScriptInfo {
|
||||
return "method_index=" + init_index + "\r\n" + traits.toString(abc, fullyQualifiedNames);
|
||||
}
|
||||
|
||||
public String convert(List<ABCContainerTag> abcTags, ABC abc, boolean pcode, boolean highlighting, int scriptIndex) {
|
||||
return traits.convert("", abcTags, abc, false, pcode, true, scriptIndex, -1, highlighting, new ArrayList<String>());
|
||||
public String convert(List<ABCContainerTag> abcTags, ABC abc, boolean pcode, boolean highlighting, int scriptIndex, boolean paralel) {
|
||||
return traits.convert("", abcTags, abc, false, pcode, true, scriptIndex, -1, highlighting, new ArrayList<String>(), paralel);
|
||||
}
|
||||
|
||||
public void export(ABC abc, List<ABCContainerTag> abcList, String directory, boolean pcode, int scriptIndex) throws IOException {
|
||||
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);
|
||||
for (ScriptPack pack : packs.values()) {
|
||||
pack.export(directory, abcList, pcode);
|
||||
pack.export(directory, abcList, pcode, paralel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,16 +114,16 @@ public abstract class Trait implements Serializable {
|
||||
return abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata);
|
||||
}
|
||||
|
||||
public String convert(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
public String convert(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames, boolean paralel) {
|
||||
return abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata);
|
||||
}
|
||||
|
||||
public String convertPackaged(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcod, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
return makePackageFromIndex(abc, name_index, convert(path, abcTags, abc, isStatic, pcod, scriptIndex, classIndex, highlight, fullyQualifiedNames));
|
||||
public String convertPackaged(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcod, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames, boolean paralel) {
|
||||
return makePackageFromIndex(abc, name_index, convert(path, abcTags, abc, isStatic, pcod, scriptIndex, classIndex, highlight, fullyQualifiedNames, paralel));
|
||||
}
|
||||
|
||||
public String convertHeader(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
return convert(path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, highlight, fullyQualifiedNames).trim();
|
||||
public String convertHeader(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames, boolean paralel) {
|
||||
return convert(path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, highlight, fullyQualifiedNames, paralel).trim();
|
||||
}
|
||||
|
||||
protected String makePackageFromIndex(ABC abc, int name_index, String value) {
|
||||
@@ -153,7 +153,7 @@ public abstract class Trait implements Serializable {
|
||||
return packageName + "." + objectName;
|
||||
}
|
||||
|
||||
public void export(String directory, ABC abc, List<ABCContainerTag> abcList, boolean pcode, int scriptIndex, int classIndex, boolean isStatic) throws IOException {
|
||||
public void export(String directory, ABC abc, List<ABCContainerTag> abcList, boolean pcode, int scriptIndex, int classIndex, boolean isStatic, boolean paralel) throws IOException {
|
||||
Multiname name = getName(abc);
|
||||
Namespace ns = name.getNamespace(abc.constants);
|
||||
String packageName = ns.getName(abc.constants);
|
||||
@@ -164,7 +164,7 @@ public abstract class Trait implements Serializable {
|
||||
}
|
||||
String fileName = outDir.toString() + File.separator + objectName + ".as";
|
||||
try (FileOutputStream fos = new FileOutputStream(fileName)) {
|
||||
fos.write(convertPackaged("", abcList, abc, isStatic, pcode, scriptIndex, classIndex, false, new ArrayList<String>()).getBytes());
|
||||
fos.write(convertPackaged("", abcList, abc, isStatic, pcode, scriptIndex, classIndex, false, new ArrayList<String>(), paralel).getBytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,13 +324,13 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertHeader(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
public String convertHeader(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames, boolean paralel) {
|
||||
String classHeader = abc.instance_info[class_info].getClassHeaderStr(abc, fullyQualifiedNames);
|
||||
return classHeader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convert(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
public String convert(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames, boolean paralel) {
|
||||
|
||||
if (!highlight) {
|
||||
//Highlighting.doHighlight = false;
|
||||
@@ -501,9 +501,9 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
//}
|
||||
|
||||
//static variables,constants & methods
|
||||
outTraits.add(abc.class_info[class_info].static_traits.convert(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, true, pcode, false, scriptIndex, class_info, highlight, fullyQualifiedNames));
|
||||
outTraits.add(abc.class_info[class_info].static_traits.convert(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, true, pcode, false, scriptIndex, class_info, highlight, fullyQualifiedNames, paralel));
|
||||
|
||||
outTraits.add(abc.instance_info[class_info].instance_traits.convert(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, false, pcode, false, scriptIndex, class_info, highlight, fullyQualifiedNames));
|
||||
outTraits.add(abc.instance_info[class_info].instance_traits.convert(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, false, pcode, false, scriptIndex, class_info, highlight, fullyQualifiedNames, paralel));
|
||||
|
||||
|
||||
StringBuilder bui = new StringBuilder();
|
||||
|
||||
@@ -41,7 +41,7 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertHeader(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
public String convertHeader(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames, boolean paralel) {
|
||||
String modifier = getModifiers(abcTags, abc, isStatic) + " ";
|
||||
if (modifier.equals(" ")) {
|
||||
modifier = "";
|
||||
@@ -51,11 +51,11 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convert(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
public String convert(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames, boolean paralel) {
|
||||
if (!Configuration.DO_DECOMPILE) {
|
||||
return "";
|
||||
}
|
||||
String header = convertHeader(path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, highlight, fullyQualifiedNames);
|
||||
String header = convertHeader(path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, highlight, fullyQualifiedNames, paralel);
|
||||
String bodyStr = "";
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (bodyIndex != -1) {
|
||||
|
||||
@@ -35,7 +35,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertHeader(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
public String convertHeader(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames, boolean paralel) {
|
||||
String modifier = getModifiers(abcTags, abc, isStatic) + " ";
|
||||
if (modifier.equals(" ")) {
|
||||
modifier = "";
|
||||
@@ -53,12 +53,12 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convert(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
public String convert(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames, boolean paralel) {
|
||||
|
||||
if (debugMode) {
|
||||
System.err.println("Decompiling " + path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames));
|
||||
}
|
||||
String header = convertHeader(path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, highlight, fullyQualifiedNames);
|
||||
String header = convertHeader(path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, highlight, fullyQualifiedNames, paralel);
|
||||
|
||||
String bodyStr = "";
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
|
||||
@@ -110,7 +110,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convert(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
public String convert(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames, boolean paralel) {
|
||||
String modifier = getModifiers(abcTags, abc, isStatic) + " ";
|
||||
if (modifier.equals(" ")) {
|
||||
modifier = "";
|
||||
|
||||
@@ -79,8 +79,9 @@ public class Traits implements Serializable {
|
||||
boolean highlighting;
|
||||
List<String> fullyQualifiedNames;
|
||||
int traitIndex;
|
||||
boolean paralel;
|
||||
|
||||
public TraitConvertTask(Trait trait, boolean makePackages, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlighting, List<String> fullyQualifiedNames, int traitIndex) {
|
||||
public TraitConvertTask(Trait trait, boolean makePackages, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlighting, List<String> fullyQualifiedNames, int traitIndex, boolean paralel) {
|
||||
this.trait = trait;
|
||||
this.makePackages = makePackages;
|
||||
this.path = path;
|
||||
@@ -93,15 +94,16 @@ public class Traits implements Serializable {
|
||||
this.highlighting = highlighting;
|
||||
this.fullyQualifiedNames = fullyQualifiedNames;
|
||||
this.traitIndex = traitIndex;
|
||||
this.paralel = paralel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
String plus;
|
||||
if (makePackages) {
|
||||
plus = trait.convertPackaged(path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, highlighting, fullyQualifiedNames);
|
||||
plus = trait.convertPackaged(path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, highlighting, fullyQualifiedNames, paralel);
|
||||
} else {
|
||||
plus = trait.convert(path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, highlighting, fullyQualifiedNames);
|
||||
plus = trait.convert(path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, highlighting, fullyQualifiedNames, paralel);
|
||||
}
|
||||
if (highlighting) {
|
||||
int h = traitIndex;
|
||||
@@ -120,12 +122,12 @@ public class Traits implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public String convert(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, boolean makePackages, int scriptIndex, int classIndex, boolean highlighting, List<String> fullyQualifiedNames) {
|
||||
public String convert(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, boolean makePackages, int scriptIndex, int classIndex, boolean highlighting, List<String> fullyQualifiedNames, boolean paralel) {
|
||||
String s = "";
|
||||
ExecutorService executor = Executors.newFixedThreadPool(Trait.debugMode ? 1 : 20);
|
||||
ExecutorService executor = Executors.newFixedThreadPool(paralel ? 20 : 1);
|
||||
List<Future<String>> futureResults = new ArrayList<>();
|
||||
for (int t = 0; t < traits.length; t++) {
|
||||
Future<String> future = executor.submit(new TraitConvertTask(traits[t], makePackages, path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, highlighting, fullyQualifiedNames, t));
|
||||
Future<String> future = executor.submit(new TraitConvertTask(traits[t], makePackages, path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, highlighting, fullyQualifiedNames, t, paralel));
|
||||
futureResults.add(future);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,10 +39,10 @@ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage {
|
||||
return super.toString(abcTags, abc) + " "
|
||||
+ (parentTraitIndex > -1
|
||||
? (isStatic
|
||||
? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, false, new ArrayList<String>()))
|
||||
: (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, false, new ArrayList<String>())))
|
||||
? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, false, new ArrayList<String>(), false))
|
||||
: (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, false, new ArrayList<String>(), false)))
|
||||
: "")
|
||||
+ ((TraitSlotConst) traits.traits[traitIndex]).convertHeader("", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, false, new ArrayList<String>());
|
||||
+ ((TraitSlotConst) traits.traits[traitIndex]).convertHeader("", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, false, new ArrayList<String>(), false);
|
||||
}
|
||||
|
||||
public int getTraitIndex() {
|
||||
|
||||
@@ -48,10 +48,10 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage {
|
||||
: "instance initializer")
|
||||
: ((parentTraitIndex > -1
|
||||
? (isStatic
|
||||
? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, false, new ArrayList<String>()))
|
||||
: (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, false, new ArrayList<String>()))) + " "
|
||||
? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, false, new ArrayList<String>(), false))
|
||||
: (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, false, new ArrayList<String>(), false))) + " "
|
||||
: "")
|
||||
+ (((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader("", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, false, new ArrayList<String>()))));
|
||||
+ (((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader("", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, false, new ArrayList<String>(), false))));
|
||||
}
|
||||
|
||||
public int getTraitIndex() {
|
||||
|
||||
@@ -174,7 +174,7 @@ public class Main {
|
||||
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) {
|
||||
@@ -492,7 +492,7 @@ public class Main {
|
||||
boolean exportOK;
|
||||
try {
|
||||
printHeader();
|
||||
SWF exfile = new SWF(new FileInputStream(inFile));
|
||||
SWF exfile = new SWF(new FileInputStream(inFile), (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE));
|
||||
exfile.addEventListener(new EventListener() {
|
||||
@Override
|
||||
public void handleEvent(String event, Object data) {
|
||||
@@ -507,7 +507,7 @@ public class Main {
|
||||
System.out.println("Exporting shapes...");
|
||||
exfile.exportShapes(outDir.getAbsolutePath() + File.separator + "shapes");
|
||||
System.out.println("Exporting scripts...");
|
||||
exfile.exportActionScript(outDir.getAbsolutePath() + File.separator + "scripts", false);
|
||||
exfile.exportActionScript(outDir.getAbsolutePath() + File.separator + "scripts", false, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE));
|
||||
System.out.println("Exporting movies...");
|
||||
exfile.exportMovies(outDir.getAbsolutePath() + File.separator + "movies");
|
||||
System.out.println("Exporting sounds...");
|
||||
@@ -527,10 +527,10 @@ public class Main {
|
||||
if ((pos + 5 < args.length) && (args[pos + 4].equals("-selectas3class"))) {
|
||||
exportOK = true;
|
||||
for (int i = pos + 5; i < args.length; i++) {
|
||||
exportOK = exportOK && exfile.exportAS3Class(args[i], outDir.getAbsolutePath(), exportFormat.equals("pcode"));
|
||||
exportOK = exportOK && exfile.exportAS3Class(args[i], outDir.getAbsolutePath(), exportFormat.equals("pcode"), (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE));
|
||||
}
|
||||
} else {
|
||||
exportOK = exfile.exportActionScript(outDir.getAbsolutePath(), exportFormat.equals("pcode"));
|
||||
exportOK = exfile.exportActionScript(outDir.getAbsolutePath(), exportFormat.equals("pcode"), (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE));
|
||||
}
|
||||
} else if (exportFormat.equals("movie")) {
|
||||
exfile.exportMovies(outDir.getAbsolutePath());
|
||||
@@ -548,10 +548,10 @@ public class Main {
|
||||
exfile.exportTexts(outDir.getAbsolutePath(), false);
|
||||
exportOK = true;
|
||||
} else if (exportFormat.equals("fla")) {
|
||||
exfile.exportFla(outDir.getAbsolutePath(), inFile.getName(), applicationName, applicationVerName, version);
|
||||
exfile.exportFla(outDir.getAbsolutePath(), inFile.getName(), applicationName, applicationVerName, version, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE));
|
||||
exportOK = true;
|
||||
} else if (exportFormat.equals("xfl")) {
|
||||
exfile.exportXfl(outDir.getAbsolutePath(), inFile.getName(), applicationName, applicationVerName, version);
|
||||
exfile.exportXfl(outDir.getAbsolutePath(), inFile.getName(), applicationName, applicationVerName, version, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE));
|
||||
exportOK = true;
|
||||
} else {
|
||||
exportOK = false;
|
||||
|
||||
@@ -193,6 +193,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
private JButton imageReplaceButton;
|
||||
private JPanel imageButtonsPanel;
|
||||
private JCheckBoxMenuItem miInternalViewer;
|
||||
private JCheckBoxMenuItem miParallelSpeedUp;
|
||||
|
||||
public void setPercent(int percent) {
|
||||
progressBar.setValue(percent);
|
||||
@@ -385,6 +386,12 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
miInternalViewer.addActionListener(this);
|
||||
menuTools.add(miInternalViewer);
|
||||
|
||||
miParallelSpeedUp = new JCheckBoxMenuItem("Parallel SpeedUp");
|
||||
miParallelSpeedUp.setSelected((Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE));
|
||||
miParallelSpeedUp.setActionCommand("PARALLELSPEEDUP");
|
||||
miParallelSpeedUp.addActionListener(this);
|
||||
menuTools.add(miParallelSpeedUp);
|
||||
|
||||
menuTools.add(miProxy);
|
||||
|
||||
//menuTools.add(menuDeobfuscation);
|
||||
@@ -1176,6 +1183,19 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
if (e.getActionCommand().equals("PARALLELSPEEDUP")) {
|
||||
String confStr = "Parallelism can speed up loading and decompilation but uses more memory.\r\n";
|
||||
if (miParallelSpeedUp.isSelected()) {
|
||||
confStr += " Do you want to turn this ON?";
|
||||
} else {
|
||||
confStr += " Do you want to turn this OFF?";
|
||||
}
|
||||
if (JOptionPane.showConfirmDialog(null, confStr, "Parallelism", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
|
||||
Configuration.setConfig("paralelSpeedUp", (Boolean) miParallelSpeedUp.isSelected());
|
||||
} else {
|
||||
miParallelSpeedUp.setSelected(!miParallelSpeedUp.isSelected());
|
||||
}
|
||||
}
|
||||
if (e.getActionCommand().equals("INTERNALVIEWERSWITCH")) {
|
||||
Configuration.setConfig("internalFlashViewer", (Boolean) miInternalViewer.isSelected());
|
||||
}
|
||||
@@ -1419,9 +1439,9 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
@Override
|
||||
public void run() {
|
||||
if (compressed) {
|
||||
swf.exportFla(selfile.getAbsolutePath(), new File(Main.file).getName(), Main.applicationName, Main.applicationVerName, Main.version);
|
||||
swf.exportFla(selfile.getAbsolutePath(), new File(Main.file).getName(), Main.applicationName, Main.applicationVerName, Main.version, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE));
|
||||
} else {
|
||||
swf.exportXfl(selfile.getAbsolutePath(), new File(Main.file).getName(), Main.applicationName, Main.applicationVerName, Main.version);
|
||||
swf.exportXfl(selfile.getAbsolutePath(), new File(Main.file).getName(), Main.applicationName, Main.applicationVerName, Main.version, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE));
|
||||
}
|
||||
Main.stopWork();
|
||||
}
|
||||
@@ -1508,7 +1528,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
for (int i = 0; i < tlsList.size(); i++) {
|
||||
ScriptPack tls = tlsList.get(i);
|
||||
Main.startWork("Exporting " + (i + 1) + "/" + tlsList.size() + " " + tls.getPath() + " ...");
|
||||
tls.export(selFile, abcList, isPcode);
|
||||
tls.export(selFile, abcList, isPcode, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE));
|
||||
}
|
||||
} else {
|
||||
List<TagNode> allNodes = new ArrayList<>();
|
||||
@@ -1527,7 +1547,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
swf.exportMovies(selFile + File.separator + "movies");
|
||||
swf.exportSounds(selFile + File.separator + "sounds", isMp3OrWav, isMp3OrWav);
|
||||
swf.exportBinaryData(selFile + File.separator + "binaryData");
|
||||
swf.exportActionScript(selFile, isPcode);
|
||||
swf.exportActionScript(selFile, isPcode, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "Error during export", ex);
|
||||
|
||||
@@ -150,12 +150,12 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT
|
||||
* @param version SWF version
|
||||
* @throws IOException
|
||||
*/
|
||||
public DefineSpriteTag(byte[] data, int version, int level, long pos) throws IOException {
|
||||
public DefineSpriteTag(byte[] data, int version, int level, long pos, boolean paralel) throws IOException {
|
||||
super(39, "DefineSprite", data, pos);
|
||||
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version, pos);
|
||||
spriteId = sis.readUI16();
|
||||
frameCount = sis.readUI16();
|
||||
subTags = sis.readTagList(level + 1);
|
||||
subTags = sis.readTagList(level + 1, paralel);
|
||||
}
|
||||
static int c = 0;
|
||||
|
||||
|
||||
@@ -2445,7 +2445,7 @@ public class XFLConverter {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void convertSWF(SWF swf, String swfFileName, String outfile, boolean compressed, String generator, String generatorVerName, String generatorVersion) {
|
||||
public static void convertSWF(SWF swf, String swfFileName, String outfile, boolean compressed, String generator, String generatorVerName, String generatorVersion, boolean paralel) {
|
||||
String domDocument = "";
|
||||
String baseName = swfFileName;
|
||||
File f = new File(baseName);
|
||||
@@ -2739,7 +2739,7 @@ public class XFLConverter {
|
||||
File outF = new File(outfile);
|
||||
File outDir = outF.getParentFile();
|
||||
try {
|
||||
swf.exportActionScript(outDir.getAbsolutePath(), false);
|
||||
swf.exportActionScript(outDir.getAbsolutePath(), false, paralel);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, "Error during ActionScript3 export", ex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user