export "pcode with hex" and "only hex" options added

This commit is contained in:
Honfika
2013-10-15 21:50:00 +02:00
parent dbd1232df2
commit 3be09601c3
50 changed files with 401 additions and 237 deletions
+15 -14
View File
@@ -93,6 +93,7 @@ import com.jpexs.decompiler.flash.types.filters.Filtering;
import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD;
import com.jpexs.decompiler.flash.types.sound.AdpcmDecoder;
import com.jpexs.decompiler.flash.xfl.XFLConverter;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
@@ -532,7 +533,7 @@ public class SWF {
return true;
}
public boolean exportAS3Class(String className, String outdir, boolean isPcode, boolean parallel) throws Exception {
public boolean exportAS3Class(String className, String outdir, ExportMode exportMode, boolean parallel) throws Exception {
List<ABCContainerTag> abcTags = new ArrayList<>();
for (Tag t : tags) {
@@ -551,7 +552,7 @@ public class SWF {
}
String exStr = "Exporting " + "tag " + (i + 1) + "/" + abcTags.size() + " " + cnt + scr.getPath() + " ...";
informListeners("export", exStr);
scr.export(outdir, abcTags, isPcode, parallel);
scr.export(outdir, abcTags, exportMode, parallel);
return true;
}
}
@@ -592,7 +593,7 @@ public class SWF {
ScriptPack pack;
String directory;
List<ABCContainerTag> abcList;
boolean pcode;
ExportMode exportMode;
ClassPath path;
AtomicInteger index;
int count;
@@ -601,11 +602,11 @@ public class SWF {
long startTime;
long stopTime;
public ExportPackTask(AbortRetryIgnoreHandler handler, AtomicInteger index, int count, ClassPath path, ScriptPack pack, String directory, List<ABCContainerTag> abcList, boolean pcode, boolean parallel) {
public ExportPackTask(AbortRetryIgnoreHandler handler, AtomicInteger index, int count, ClassPath path, ScriptPack pack, String directory, List<ABCContainerTag> abcList, ExportMode exportMode, boolean parallel) {
this.pack = pack;
this.directory = directory;
this.abcList = abcList;
this.pcode = pcode;
this.exportMode = exportMode;
this.path = path;
this.index = index;
this.count = count;
@@ -619,7 +620,7 @@ public class SWF {
@Override
public void run() throws IOException {
startTime = System.currentTimeMillis();
this.result = pack.export(directory, abcList, pcode, parallel);
this.result = pack.export(directory, abcList, exportMode, parallel);
stopTime = System.currentTimeMillis();
}
};
@@ -632,7 +633,7 @@ public class SWF {
}
}
public List<File> exportActionScript2(AbortRetryIgnoreHandler handler, String outdir, boolean isPcode, boolean parallel, EventListener evl) throws IOException {
public List<File> exportActionScript2(AbortRetryIgnoreHandler handler, String outdir, ExportMode exportMode, boolean parallel, EventListener evl) throws IOException {
List<File> ret = new ArrayList<>();
List<ContainerItem> list2 = new ArrayList<>();
list2.addAll(tags);
@@ -645,11 +646,11 @@ public class SWF {
outdir += "scripts" + File.separator;
AtomicInteger cnt = new AtomicInteger(1);
int totalCount = TagNode.getTagCountRecursive(list);
ret.addAll(TagNode.exportNodeAS(tags, handler, list, outdir, isPcode, cnt, totalCount, evl));
ret.addAll(TagNode.exportNodeAS(tags, handler, list, outdir, exportMode, cnt, totalCount, evl));
return ret;
}
public List<File> exportActionScript3(AbortRetryIgnoreHandler handler, String outdir, boolean isPcode, boolean parallel) {
public List<File> exportActionScript3(AbortRetryIgnoreHandler handler, String outdir, ExportMode exportMode, boolean parallel) {
ExecutorService executor = Executors.newFixedThreadPool(parallel ? 20 : 1);
List<Future<File>> futureResults = new ArrayList<>();
AtomicInteger cnt = new AtomicInteger(1);
@@ -661,7 +662,7 @@ public class SWF {
}
List<MyEntry<ClassPath, ScriptPack>> packs = getAS3Packs();
for (MyEntry<ClassPath, ScriptPack> item : packs) {
Future<File> future = executor.submit(new ExportPackTask(handler, cnt, packs.size(), item.key, item.value, outdir, abcTags, isPcode, parallel));
Future<File> future = executor.submit(new ExportPackTask(handler, cnt, packs.size(), item.key, item.value, outdir, abcTags, exportMode, parallel));
futureResults.add(future);
}
@@ -683,7 +684,7 @@ public class SWF {
return ret;
}
public List<File> exportActionScript(AbortRetryIgnoreHandler handler, String outdir, boolean isPcode, boolean parallel) throws Exception {
public List<File> exportActionScript(AbortRetryIgnoreHandler handler, String outdir, ExportMode exportMode, boolean parallel) throws Exception {
boolean asV3Found = false;
List<File> ret = new ArrayList<>();
final EventListener evl = new EventListener() {
@@ -701,9 +702,9 @@ public class SWF {
}
if (asV3Found) {
ret.addAll(exportActionScript3(handler, outdir, isPcode, parallel));
ret.addAll(exportActionScript3(handler, outdir, exportMode, parallel));
} else {
ret.addAll(exportActionScript2(handler, outdir, isPcode, parallel, evl));
ret.addAll(exportActionScript2(handler, outdir, exportMode, parallel, evl));
}
return ret;
}
@@ -1586,7 +1587,7 @@ public class SWF {
GraphSourceItem ins = code.get(ip);
if (debugMode) {
System.err.println("Visit " + ip + ": ofs" + Helper.formatAddress(((Action) ins).getAddress()) + ":" + ((Action) ins).getASMSource(new ArrayList<GraphSourceItem>(), new ArrayList<Long>(), new ArrayList<String>(), code.version, false) + " stack:" + Helper.stackToString(stack, LocalData.create(new ConstantPool())));
System.err.println("Visit " + ip + ": ofs" + Helper.formatAddress(((Action) ins).getAddress()) + ":" + ((Action) ins).getASMSource(new ArrayList<GraphSourceItem>(), new ArrayList<Long>(), new ArrayList<String>(), code.version, ExportMode.PCODE) + " stack:" + Helper.stackToString(stack, LocalData.create(new ConstantPool())));
}
if (ins.isExit()) {
break;
@@ -47,6 +47,7 @@ import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.flash.tags.base.Container;
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
import com.jpexs.decompiler.flash.tags.base.Exportable;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.helpers.Helper;
import java.io.File;
import java.io.FileOutputStream;
@@ -251,13 +252,13 @@ public class TagNode {
return count;
}
public static List<File> exportNodeAS(List<Tag> allTags, AbortRetryIgnoreHandler handler, List<TagNode> nodeList, String outdir, boolean isPcode) throws IOException {
public static List<File> exportNodeAS(List<Tag> allTags, AbortRetryIgnoreHandler handler, List<TagNode> nodeList, String outdir, ExportMode exportMode) throws IOException {
AtomicInteger cnt = new AtomicInteger(1);
int totalCount = TagNode.getTagCountRecursive(nodeList);
return exportNodeAS(allTags, handler, nodeList, outdir, isPcode, cnt, totalCount, null);
return exportNodeAS(allTags, handler, nodeList, outdir, exportMode, cnt, totalCount, null);
}
public static List<File> exportNodeAS(List<Tag> allTags, AbortRetryIgnoreHandler handler, List<TagNode> nodeList, String outdir, boolean isPcode, AtomicInteger index, int count, EventListener ev) throws IOException {
public static List<File> exportNodeAS(List<Tag> allTags, AbortRetryIgnoreHandler handler, List<TagNode> nodeList, String outdir, ExportMode exportMode, AtomicInteger index, int count, EventListener ev) throws IOException {
File dir = new File(outdir);
List<File> ret = new ArrayList<>();
if (!outdir.endsWith(File.separator)) {
@@ -297,9 +298,13 @@ public class TagNode {
File file = new File(f);
String res;
ASMSource asm = ((ASMSource) node.tag);
if (isPcode) {
if (exportMode == ExportMode.HEX) {
HilightedTextWriter writer = new HilightedTextWriter(false, asm.getActionSourceIndent());
asm.getASMSource(SWF.DEFAULT_VERSION, false, writer, null);
asm.getActionBytesAsHex(writer);
res = asm.getActionSourcePrefix() + writer.toString() + asm.getActionSourceSuffix();
} else if (exportMode != ExportMode.SOURCE) {
HilightedTextWriter writer = new HilightedTextWriter(false, asm.getActionSourceIndent());
asm.getASMSource(SWF.DEFAULT_VERSION, exportMode, writer, null);
res = asm.getActionSourcePrefix() + writer.toString() + asm.getActionSourceSuffix();
} else {
List<Action> as = asm.getActions(SWF.DEFAULT_VERSION);
@@ -337,7 +342,7 @@ public class TagNode {
} while (retry);
}
} else {
ret.addAll(exportNodeAS(allTags, handler, node.subItems, outdir + name, isPcode, index, count, ev));
ret.addAll(exportNodeAS(allTags, handler, node.subItems, outdir + name, exportMode, index, count, ev));
}
}
@@ -734,7 +734,7 @@ public class ABC {
}
}
/*public void export(String directory, boolean pcode, List<ABCContainerTag> abcList, boolean parallel) throws IOException {
/*public void export(String directory, ExportMode exportMode, List<ABCContainerTag> abcList, boolean parallel) throws IOException {
export(directory, pcode, abcList, "", parallel);
}*/
public List<MyEntry<ClassPath, ScriptPack>> getScriptPacks() {
@@ -744,7 +744,7 @@ public class ABC {
}
return ret;
}
/*public List<File> export(String directory, boolean pcode, List<ABCContainerTag> abcList, String abcStr, boolean parallel) throws IOException {
/*public List<File> export(String directory, ExportMode exportMode, List<ABCContainerTag> abcList, String abcStr, boolean parallel) throws IOException {
ExecutorService executor = Executors.newFixedThreadPool(20);
List<Future<File>> futureResults = new ArrayList<>();
AtomicInteger cnt = new AtomicInteger(1);
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.helpers.Helper;
import java.io.File;
@@ -103,7 +104,7 @@ public class ScriptPack {
return Helper.joinStrings(pathParts, File.separator);
}
public File export(String directory, List<ABCContainerTag> abcList, boolean pcode, boolean parallel) throws IOException {
public File export(String directory, List<ABCContainerTag> abcList, ExportMode exportMode, boolean parallel) throws IOException {
String scriptName = getPathScriptName();
String packageName = getPathPackage();
File outDir = new File(directory + File.separatorChar + makeDirPath(packageName));
@@ -122,9 +123,9 @@ public class ScriptPack {
Namespace ns = name.getNamespace(abc.constants);
HilightedTextWriter writer = new HilightedTextWriter(false);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
abc.script_info[scriptIndex].traits.traits[t].convertPackaged(null, "", abcList, abc, false, pcode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
abc.script_info[scriptIndex].traits.traits[t].convertPackaged(null, "", abcList, abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
} else {
abc.script_info[scriptIndex].traits.traits[t].convert(null, "", abcList, abc, false, pcode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
abc.script_info[scriptIndex].traits.traits[t].convert(null, "", abcList, abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
}
String s = Graph.removeNonRefenrencedLoopLabels(writer.toString());
fos.write(s.getBytes("utf-8"));
@@ -74,6 +74,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphPart;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -718,11 +719,11 @@ public class AVM2Code implements Serializable {
return writer;
}
public HilightedTextWriter toASMSource(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, boolean hex, HilightedTextWriter writer) {
return toASMSource(constants, trait, info, body, new ArrayList<Integer>(), hex, writer);
public HilightedTextWriter toASMSource(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, ExportMode exportMode, HilightedTextWriter writer) {
return toASMSource(constants, trait, info, body, new ArrayList<Integer>(), exportMode, writer);
}
public HilightedTextWriter toASMSource(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, List<Integer> outputMap, boolean hex, HilightedTextWriter writer) {
public HilightedTextWriter toASMSource(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, List<Integer> outputMap, ExportMode exportMode, HilightedTextWriter writer) {
invalidateCache();
if (trait != null) {
if (trait instanceof TraitFunction) {
@@ -899,81 +900,86 @@ public class AVM2Code implements Serializable {
int ip = 0;
int largeLimit = 20000;
boolean markOffsets = code.size() <= largeLimit;
for (AVM2Instruction ins : code) {
if (hex) {
writer.appendNoHilight("<ffdec:hex>");
writer.appendNoHilight(Helper.bytesToHexString(ins.getBytes()));
writer.appendNoHilight("</ffdec:hex>\n");
}
if (ins.labelname != null) {
writer.appendNoHilight(ins.labelname + ":");
} else if (offsets.contains(ofs)) {
writer.appendNoHilight("ofs" + Helper.formatAddress(ofs) + ":");
}
/*for (int e = 0; e < body.exceptions.length; e++) {
if (body.exceptions[e].start == ofs) {
ret.append("exceptionstart " + e + ":");
}
if (body.exceptions[e].end == ofs) {
ret.append("exceptionend " + e + ":");
}
if (body.exceptions[e].target == ofs) {
ret.append("exceptiontarget " + e + ":");
}
}*/
if (ins.replaceWith != null) {
for (Object o : ins.replaceWith) {
if (o instanceof Integer) {
AVM2Instruction ins2 = code.get((Integer) o);
if (ins2.isIgnored()) {
continue;
}
writer.append("", ins2.mappedOffset > -1 ? ins2.mappedOffset : ofs);
writer.appendNoHilight(ins2.toStringNoAddress(constants, new ArrayList<String>()) + " ;copy from " + Helper.formatAddress(pos2adr((Integer) o)));
writer.newLine();
outputMap.add((Integer) o);
} else if (o instanceof ControlFlowTag) {
ControlFlowTag cft = (ControlFlowTag) o;
if (cft.name.equals("appendjump")) {
writer.appendNoHilight("jump ofs" + Helper.formatAddress(pos2adr(cft.value))).newLine();
outputMap.add(-1);
}
if (cft.name.equals("mark")) {
writer.appendNoHilight("ofs" + Helper.formatAddress(pos2adr(cft.value)) + ":");
}
}
if (exportMode == ExportMode.HEX) {
Helper.byteArrayToHex(writer, getBytes());
} else {
for (AVM2Instruction ins : code) {
if (exportMode == ExportMode.PCODEWITHHEX) {
writer.appendNoHilight("<ffdec:hex>");
writer.appendNoHilight(Helper.bytesToHexString(ins.getBytes()));
writer.appendNoHilight("</ffdec:hex>\n");
}
} else {
if (!ins.isIgnored()) {
if (markOffsets) {
writer.append("", ins.mappedOffset > -1 ? ins.mappedOffset : ofs);
}
int fixBranch = ins.getFixBranch();
if (fixBranch > -1) {
if (ins.definition instanceof IfTypeIns) {
for (int i = 0; i < -ins.definition.getStackDelta(ins, null/*IfTypeIns do not require ABCs*/); i++) {
writer.appendNoHilight(new DeobfuscatePopIns().instructionName).newLine();
if (ins.labelname != null) {
writer.appendNoHilight(ins.labelname + ":");
} else if (offsets.contains(ofs)) {
writer.appendNoHilight("ofs" + Helper.formatAddress(ofs) + ":");
}
/*for (int e = 0; e < body.exceptions.length; e++) {
if (body.exceptions[e].start == ofs) {
ret.append("exceptionstart " + e + ":");
}
if (body.exceptions[e].end == ofs) {
ret.append("exceptionend " + e + ":");
}
if (body.exceptions[e].target == ofs) {
ret.append("exceptiontarget " + e + ":");
}
}*/
if (ins.replaceWith != null) {
for (Object o : ins.replaceWith) {
if (o instanceof Integer) {
AVM2Instruction ins2 = code.get((Integer) o);
if (ins2.isIgnored()) {
continue;
}
if (fixBranch == 0) { //jump
writer.appendNoHilight(new JumpIns().instructionName + " ofs" + Helper.formatAddress(ofs + ins.getBytes().length + ins.operands[0]));
} else {
//nojump, ignore
writer.append("", ins2.mappedOffset > -1 ? ins2.mappedOffset : ofs);
writer.appendNoHilight(ins2.toStringNoAddress(constants, new ArrayList<String>()) + " ;copy from " + Helper.formatAddress(pos2adr((Integer) o)));
writer.newLine();
outputMap.add((Integer) o);
} else if (o instanceof ControlFlowTag) {
ControlFlowTag cft = (ControlFlowTag) o;
if (cft.name.equals("appendjump")) {
writer.appendNoHilight("jump ofs" + Helper.formatAddress(pos2adr(cft.value))).newLine();
outputMap.add(-1);
}
if (cft.name.equals("mark")) {
writer.appendNoHilight("ofs" + Helper.formatAddress(pos2adr(cft.value)) + ":");
}
}
//TODO: lookupswitch ?
} else {
if (ins.changeJumpTo > -1) {
writer.appendNoHilight(ins.definition.instructionName + " ofs" + Helper.formatAddress(pos2adr(ins.changeJumpTo)));
}
} else {
if (!ins.isIgnored()) {
if (markOffsets) {
writer.append("", ins.mappedOffset > -1 ? ins.mappedOffset : ofs);
}
int fixBranch = ins.getFixBranch();
if (fixBranch > -1) {
if (ins.definition instanceof IfTypeIns) {
for (int i = 0; i < -ins.definition.getStackDelta(ins, null/*IfTypeIns do not require ABCs*/); i++) {
writer.appendNoHilight(new DeobfuscatePopIns().instructionName).newLine();
}
if (fixBranch == 0) { //jump
writer.appendNoHilight(new JumpIns().instructionName + " ofs" + Helper.formatAddress(ofs + ins.getBytes().length + ins.operands[0]));
} else {
//nojump, ignore
}
}
//TODO: lookupswitch ?
} else {
writer.appendNoHilight(ins.toStringNoAddress(constants, new ArrayList<String>()));
if (ins.changeJumpTo > -1) {
writer.appendNoHilight(ins.definition.instructionName + " ofs" + Helper.formatAddress(pos2adr(ins.changeJumpTo)));
} else {
writer.appendNoHilight(ins.toStringNoAddress(constants, new ArrayList<String>()));
}
}
writer.newLine();
outputMap.add(ip);
}
writer.newLine();
outputMap.add(ip);
}
ofs += ins.getBytes().length;
ip++;
}
ofs += ins.getBytes().length;
ip++;
}
return writer;
}
@@ -2101,7 +2107,7 @@ public class AVM2Code implements Serializable {
try {
List<Integer> outputMap = new ArrayList<>();
HilightedTextWriter writer = new HilightedTextWriter(false);
toASMSource(constants, trait, info, body, outputMap, false, writer);
toASMSource(constants, trait, info, body, outputMap, ExportMode.PCODE, writer);
String src = writer.toString();
AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(src.getBytes("UTF-8")), constants, null, body, info);
@@ -2143,7 +2149,7 @@ public class AVM2Code implements Serializable {
try {
List<Integer> outputMap = new ArrayList<>();
HilightedTextWriter writer = new HilightedTextWriter(false);
toASMSource(constants, trait, info, body, outputMap, false, writer);
toASMSource(constants, trait, info, body, outputMap, ExportMode.PCODE, writer);
String src = writer.toString();
AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(src.getBytes("UTF-8")), constants, trait, body, info);
for (int i = 0; i < acode.code.size(); i++) {
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewFunction
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
@@ -72,7 +73,7 @@ public class NewFunctionAVM2Item extends AVM2Item {
writer.indent();
if (body != null) {
try {
body.toString(path + "/inner", false, isStatic, scriptIndex, classIndex, abc, null, constants, methodInfo, new Stack<GraphTargetItem>()/*scopeStack*/, false, writer, fullyQualifiedNames, null);
body.toString(path + "/inner", ExportMode.SOURCE, isStatic, scriptIndex, classIndex, abc, null, constants, methodInfo, new Stack<GraphTargetItem>()/*scopeStack*/, false, writer, fullyQualifiedNames, null);
} catch (Exception ex) {
Logger.getLogger(NewFunctionIns.class.getName()).log(Level.SEVERE, "error during newfunction", ex);
}
@@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
@@ -109,21 +110,21 @@ public class MethodBody implements Cloneable, Serializable {
return ret;
}
public String toString(final String path, boolean pcode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final MethodInfo[] method_info, final Stack<GraphTargetItem> scopeStack, final boolean isStaticInitializer, final List<String> fullyQualifiedNames, final Traits initTraits) {
public String toString(final String path, ExportMode exportMode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final MethodInfo[] method_info, final Stack<GraphTargetItem> scopeStack, final boolean isStaticInitializer, final List<String> fullyQualifiedNames, final Traits initTraits) {
HilightedTextWriter writer = new HilightedTextWriter(false);
toString(path, pcode, isStatic, scriptIndex, classIndex, abc, trait, constants, method_info, scopeStack, isStaticInitializer, writer, fullyQualifiedNames, initTraits);
toString(path, exportMode, isStatic, scriptIndex, classIndex, abc, trait, constants, method_info, scopeStack, isStaticInitializer, writer, fullyQualifiedNames, initTraits);
String src = writer.toString();
src = Graph.removeNonRefenrencedLoopLabels(src);
return src;
}
public HilightedTextWriter toString(final String path, boolean pcode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final MethodInfo[] method_info, final Stack<GraphTargetItem> scopeStack, final boolean isStaticInitializer, final HilightedTextWriter writer, final List<String> fullyQualifiedNames, final Traits initTraits) {
public HilightedTextWriter toString(final String path, ExportMode exportMode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final MethodInfo[] method_info, final Stack<GraphTargetItem> scopeStack, final boolean isStaticInitializer, final HilightedTextWriter writer, final List<String> fullyQualifiedNames, final Traits initTraits) {
if (debugMode) {
System.err.println("Decompiling " + path);
}
if (pcode) {
if (exportMode != ExportMode.SOURCE) {
writer.indent();
code.toASMSource(constants, trait, method_info[this.method_info], this, false, writer);
code.toASMSource(constants, trait, method_info[this.method_info], this, exportMode, writer);
writer.unindent();
} else {
if (!Configuration.getConfig("decompile", true)) {
@@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
import java.util.ArrayList;
import java.util.List;
@@ -80,7 +81,7 @@ public class ScriptInfo {
return "method_index=" + init_index + "\r\n" + traits.toString(abc, fullyQualifiedNames);
}
public HilightedTextWriter convert(List<ABCContainerTag> abcTags, ABC abc, boolean pcode, HilightedTextWriter writer, int scriptIndex, boolean parallel) {
return traits.convert(null, "", abcTags, abc, false, pcode, true, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
public HilightedTextWriter convert(List<ABCContainerTag> abcTags, ABC abc, ExportMode exportMode, HilightedTextWriter writer, int scriptIndex, boolean parallel) {
return traits.convert(null, "", abcTags, abc, false, exportMode, true, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
}
}
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.helpers.Helper;
import java.io.File;
@@ -115,19 +116,19 @@ public abstract class Trait implements Serializable {
return abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata);
}
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
writer.appendNoHilight(abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata));
return writer;
}
public HilightedTextWriter convertPackaged(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcod, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
public HilightedTextWriter convertPackaged(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
Namespace ns = abc.constants.constant_multiname[name_index].getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
String nsname = ns.getName(abc.constants);
writer.appendNoHilight("package " + nsname).newLine();
writer.appendNoHilight("{").newLine();
writer.indent();
convert(parent, path, abcTags, abc, isStatic, pcod, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
convert(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
writer.newLine();
writer.unindent();
writer.appendNoHilight("}");
@@ -135,8 +136,8 @@ public abstract class Trait implements Serializable {
return writer;
}
public HilightedTextWriter convertHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
convert(parent, path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
public HilightedTextWriter convertHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
convert(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
return writer;
}
@@ -158,7 +159,7 @@ public abstract class Trait implements Serializable {
return packageName + "." + objectName;
}
public void export(Trait parent, String directory, ABC abc, List<ABCContainerTag> abcList, boolean pcode, int scriptIndex, int classIndex, boolean isStatic, boolean parallel) throws IOException {
public void export(Trait parent, String directory, ABC abc, List<ABCContainerTag> abcList, ExportMode exportMode, int scriptIndex, int classIndex, boolean isStatic, boolean parallel) throws IOException {
Multiname name = getName(abc);
Namespace ns = name.getNamespace(abc.constants);
String packageName = ns.getName(abc.constants);
@@ -174,7 +175,7 @@ public abstract class Trait implements Serializable {
String fileName = outDir.toString() + File.separator + objectName + ".as";
try (FileOutputStream fos = new FileOutputStream(fileName)) {
HilightedTextWriter writer = new HilightedTextWriter(false);
convertPackaged(parent, "", abcList, abc, isStatic, pcode, scriptIndex, classIndex, writer, new ArrayList<String>(), parallel);
convertPackaged(parent, "", abcList, abc, isStatic, exportMode, scriptIndex, classIndex, writer, new ArrayList<String>(), parallel);
String s = Graph.removeNonRefenrencedLoopLabels(writer.toString());
fos.write(s.getBytes());
}
@@ -33,6 +33,7 @@ import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
import com.jpexs.decompiler.flash.abc.types.ScriptInfo;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.ArrayList;
@@ -322,13 +323,13 @@ public class TraitClass extends Trait implements TraitWithSlot {
}
@Override
public HilightedTextWriter convertHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
public HilightedTextWriter convertHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
String classHeader = abc.instance_info[class_info].getClassHeaderStr(abc, fullyQualifiedNames);
return writer.appendNoHilight(classHeader);
}
@Override
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
writer.startClass(class_info);
String packageName = abc.instance_info[class_info].getName(abc.constants).getNamespace(abc.constants).getName(abc.constants);
@@ -426,7 +427,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
writer.startTrait(abc.class_info[class_info].static_traits.traits.length + abc.instance_info[class_info].instance_traits.traits.length + 1);
writer.appendNoHilight("{").newLine();
writer.mark();
abc.bodies[bodyIndex].toString(path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", pcode, true, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), true, writer, fullyQualifiedNames, abc.class_info[class_info].static_traits);
abc.bodies[bodyIndex].toString(path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", exportMode, true, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), true, writer, fullyQualifiedNames, abc.class_info[class_info].static_traits);
boolean empty = !writer.getMark();
writer.appendNoHilight("}").newLine();
writer.endTrait();
@@ -468,7 +469,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
}
writer.appendNoHilight(") {").newLine();
if (bodyIndex != -1) {
abc.bodies[bodyIndex].toString(path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", pcode, false, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, writer, fullyQualifiedNames, abc.instance_info[class_info].instance_traits);
abc.bodies[bodyIndex].toString(path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", exportMode, false, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, writer, fullyQualifiedNames, abc.instance_info[class_info].instance_traits);
}
writer.appendNoHilight("}").newLine();
writer.endTrait();
@@ -476,9 +477,9 @@ public class TraitClass extends Trait implements TraitWithSlot {
}
//static variables,constants & methods
abc.class_info[class_info].static_traits.convert(this, path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, true, pcode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
abc.class_info[class_info].static_traits.convert(this, path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
abc.instance_info[class_info].instance_traits.convert(this, path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, false, pcode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
abc.instance_info[class_info].instance_traits.convert(this, path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
writer.unindent();
writer.appendNoHilight("}"); // class
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.List;
@@ -41,7 +42,7 @@ public class TraitFunction extends Trait implements TraitWithSlot {
}
@Override
public HilightedTextWriter convertHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
public HilightedTextWriter convertHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
String modifier = getModifiers(abcTags, abc, isStatic) + " ";
MethodBody body = abc.findBody(method_info);
if (body == null) {
@@ -61,15 +62,15 @@ public class TraitFunction extends Trait implements TraitWithSlot {
}
@Override
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
convertHeader(parent, path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
convertHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
if (abc.instance_info[classIndex].isInterface()) {
writer.appendNoHilight(";");
} else {
writer.appendNoHilight(" {").newLine();
int bodyIndex = abc.findBodyIndex(method_info);
if (bodyIndex != -1) {
abc.bodies[bodyIndex].toString(path + "." + abc.constants.constant_multiname[name_index].getName(abc.constants, fullyQualifiedNames), pcode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, writer, fullyQualifiedNames, null);
abc.bodies[bodyIndex].toString(path + "." + abc.constants.constant_multiname[name_index].getName(abc.constants, fullyQualifiedNames), exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, writer, fullyQualifiedNames, null);
}
writer.newLine();
writer.appendNoHilight("}");
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.List;
@@ -36,7 +37,7 @@ public class TraitMethodGetterSetter extends Trait {
}
@Override
public HilightedTextWriter convertHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
public HilightedTextWriter convertHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
String modifier = getModifiers(abcTags, abc, isStatic) + " ";
if (modifier.equals(" ")) {
modifier = "";
@@ -65,15 +66,15 @@ public class TraitMethodGetterSetter extends Trait {
}
@Override
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
convertHeader(parent, path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
convertHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
int bodyIndex = abc.findBodyIndex(method_info);
if (classIndex != -1 && abc.instance_info[classIndex].isInterface() || bodyIndex == -1) {
writer.appendNoHilight(";");
} else {
writer.appendNoHilight(" {").newLine();
if (bodyIndex != -1) {
abc.bodies[bodyIndex].toString(path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames), pcode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, writer, fullyQualifiedNames, null);
abc.bodies[bodyIndex].toString(path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames), exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, writer, fullyQualifiedNames, null);
}
writer.appendNoHilight("}");
}
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.abc.types.ValueKind;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.helpers.Helper;
@@ -132,7 +133,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
}
@Override
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
String modifier = getModifiers(abcTags, abc, isStatic) + " ";
if (modifier.equals(" ")) {
modifier = "";
@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.types.traits;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
@@ -80,7 +81,7 @@ public class Traits implements Serializable {
List<ABCContainerTag> abcTags;
ABC abc;
boolean isStatic;
boolean pcode;
ExportMode exportMode;
int scriptIndex;
int classIndex;
HilightedTextWriter writer;
@@ -89,7 +90,7 @@ public class Traits implements Serializable {
boolean parallel;
Trait parent;
public TraitConvertTask(Trait trait, Trait parent, boolean makePackages, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, int traitIndex, boolean parallel) {
public TraitConvertTask(Trait trait, Trait parent, boolean makePackages, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, int traitIndex, boolean parallel) {
this.trait = trait;
this.parent = parent;
this.makePackages = makePackages;
@@ -97,7 +98,7 @@ public class Traits implements Serializable {
this.abcTags = abcTags;
this.abc = abc;
this.isStatic = isStatic;
this.pcode = pcode;
this.exportMode = exportMode;
this.scriptIndex = scriptIndex;
this.classIndex = classIndex;
this.writer = writer;
@@ -120,9 +121,9 @@ public class Traits implements Serializable {
writer.startTrait(h);
}
if (makePackages) {
trait.convertPackaged(parent, path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
trait.convertPackaged(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
} else {
trait.convert(parent, path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
trait.convert(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
}
if (trait instanceof TraitClass) {
writer.endClass();
@@ -133,7 +134,7 @@ public class Traits implements Serializable {
}
}
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, boolean makePackages, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
ExecutorService executor = null;
List<Future<String>> futureResults = null;
List<TraitConvertTask> traitConvertTasks = null;
@@ -146,7 +147,7 @@ public class Traits implements Serializable {
}
for (int t = 0; t < traits.length; t++) {
HilightedTextWriter writer2 = new HilightedTextWriter(writer.getIsHighlighted(), writer.getIndent());
TraitConvertTask task = new TraitConvertTask(traits[t], parent, makePackages, path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, writer2, fullyQualifiedNames, t, parallel);
TraitConvertTask task = new TraitConvertTask(traits[t], parent, makePackages, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer2, fullyQualifiedNames, t, parallel);
if (parallel) {
Future<String> future = executor.submit(task);
futureResults.add(future);
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
import java.util.ArrayList;
import java.util.List;
@@ -41,12 +42,12 @@ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage {
writer.appendNoHilight(super.toString(abcTags, abc) + " ");
if (parentTraitIndex > -1) {
if (isStatic) {
((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
} else {
((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
}
}
((TraitSlotConst) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
((TraitSlotConst) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
return writer.toString();
}
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
import java.util.ArrayList;
import java.util.List;
@@ -55,13 +56,13 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage {
} else {
if (parentTraitIndex > -1) {
if (isStatic){
((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
} else {
((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
}
writer.appendNoHilight(" ");
}
((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, false, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
}
return writer.toString();
}
@@ -50,6 +50,7 @@ import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2;
import com.jpexs.decompiler.flash.ecma.Null;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphSource;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -396,8 +397,8 @@ public class Action implements GraphSourceItem {
* @param path
* @return HilightedTextWriter
*/
public static HilightedTextWriter actionsToString(List<DisassemblyListener> listeners, long address, List<Action> list, List<Long> importantOffsets, int version, boolean hex, HilightedTextWriter writer, long swfPos, String path) {
return actionsToString(listeners, address, list, importantOffsets, new ArrayList<String>(), version, hex, writer, swfPos, path);
public static HilightedTextWriter actionsToString(List<DisassemblyListener> listeners, long address, List<Action> list, List<Long> importantOffsets, int version, ExportMode exportMode, HilightedTextWriter writer, long swfPos, String path) {
return actionsToString(listeners, address, list, importantOffsets, new ArrayList<String>(), version, exportMode, writer, swfPos, path);
}
/**
@@ -414,7 +415,7 @@ public class Action implements GraphSourceItem {
* @param path
* @return HilightedTextWriter
*/
private static HilightedTextWriter actionsToString(List<DisassemblyListener> listeners, long address, List<Action> list, List<Long> importantOffsets, List<String> constantPool, int version, boolean hex, HilightedTextWriter writer, long swfPos, String path) {
private static HilightedTextWriter actionsToString(List<DisassemblyListener> listeners, long address, List<Action> list, List<Long> importantOffsets, List<String> constantPool, int version, ExportMode exportMode, HilightedTextWriter writer, long swfPos, String path) {
long offset;
if (importantOffsets == null) {
//setActionsAddresses(list, 0, version);
@@ -438,7 +439,7 @@ public class Action implements GraphSourceItem {
a = (Action) s;
}
pos++;
if (hex) {
if (exportMode == ExportMode.PCODEWITHHEX) {
if (lastPush) {
writer.newLine();
lastPush = false;
@@ -495,7 +496,7 @@ public class Action implements GraphSourceItem {
lastPush = false;
}
writer.append("", offset);
writer.appendNoHilight(a.replaceWith.getASMSource(list, importantOffsets, constantPool, version, hex));
writer.appendNoHilight(a.replaceWith.getASMSource(list, importantOffsets, constantPool, version, exportMode));
writer.newLine();
} else if (a.isIgnored()) {
if (lastPush) {
@@ -519,7 +520,7 @@ public class Action implements GraphSourceItem {
writer.newLine();
lastPush = false;
}
writer.appendNoHilight(a.beforeInsert.getASMSource(list, importantOffsets, constantPool, version, hex));
writer.appendNoHilight(a.beforeInsert.getASMSource(list, importantOffsets, constantPool, version, exportMode));
writer.newLine();
}
//if (!(a instanceof ActionNop)) {
@@ -534,7 +535,7 @@ public class Action implements GraphSourceItem {
add = "";
if ((a instanceof ActionPush) && lastPush) {
writer.appendNoHilight(" ");
((ActionPush) a).paramsToStringReplaced(list, importantOffsets, constantPool, version, hex, writer);
((ActionPush) a).paramsToStringReplaced(list, importantOffsets, constantPool, version, exportMode, writer);
} else {
if (lastPush) {
writer.newLine();
@@ -565,7 +566,7 @@ public class Action implements GraphSourceItem {
}
}
} else {
a.getASMSourceReplaced(list, importantOffsets, constantPool, version, hex, writer);
a.getASMSourceReplaced(list, importantOffsets, constantPool, version, exportMode, writer);
}
writer.appendNoHilight(a.isIgnored() ? "; ignored" : "");
writer.appendNoHilight(add);
@@ -584,7 +585,7 @@ public class Action implements GraphSourceItem {
writer.newLine();
lastPush = false;
}
writer.appendNoHilight(a.afterInsert.getASMSource(list, importantOffsets, constantPool, version, hex));
writer.appendNoHilight(a.afterInsert.getASMSource(list, importantOffsets, constantPool, version, exportMode));
writer.newLine();
}
}
@@ -623,7 +624,7 @@ public class Action implements GraphSourceItem {
* @param hex Add hexadecimal
* @return String of P-code source
*/
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode) {
return toString();
}
@@ -1231,7 +1232,7 @@ public class Action implements GraphSourceItem {
String s = null;
try {
HilightedTextWriter writer = new HilightedTextWriter(false);
Action.actionsToString(new ArrayList<DisassemblyListener>(), address, ret, null, version, false, writer, swfPos, path);
Action.actionsToString(new ArrayList<DisassemblyListener>(), address, ret, null, version, ExportMode.PCODE, writer, swfPos, path);
s = writer.toString();
ret = ASMParser.parse(address, swfPos, true, s, SWF.DEFAULT_VERSION, false);
} catch (Exception ex) {
@@ -1260,8 +1261,8 @@ public class Action implements GraphSourceItem {
}
}
public HilightedTextWriter getASMSourceReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, boolean hex, HilightedTextWriter writer) {
writer.appendNoHilight(getASMSource(container, knownAddreses, constantPool, version, hex));
public HilightedTextWriter getASMSourceReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode, HilightedTextWriter writer) {
writer.appendNoHilight(getASMSource(container, knownAddreses, constantPool, version, exportMode));
return writer;
}
@@ -35,6 +35,7 @@ import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister;
import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.ecma.Null;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
@@ -678,7 +679,7 @@ public class ActionListReader {
}
if (debugMode) {
String atos = a.getASMSource(new ArrayList<GraphSourceItem>(), new ArrayList<Long>(), cpool.constants, version, false);
String atos = a.getASMSource(new ArrayList<GraphSourceItem>(), new ArrayList<Long>(), cpool.constants, version, ExportMode.PCODE);
if (a instanceof GraphSourceItemContainer) {
atos = a.toString();
}
@@ -28,6 +28,7 @@ import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.special.ActionEnd;
import com.jpexs.decompiler.flash.action.special.ActionStore;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
@@ -89,13 +90,13 @@ public class ActionWaitForFrame extends Action implements ActionStore {
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode) {
String ret = "WaitForFrame " + frame + " " + skipCount;
for (int i = 0; i < skipped.size(); i++) {
if (skipped.get(i) instanceof ActionEnd) {
break;
}
ret += "\r\n" + skipped.get(i).getASMSource(container, knownAddreses, constantPool, version, hex);
ret += "\r\n" + skipped.get(i).getASMSource(container, knownAddreses, constantPool, version, exportMode);
}
return ret;
}
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraphSource;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphSource;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.helpers.Helper;
@@ -82,7 +83,7 @@ public class ActionIf extends Action {
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode) {
String ofsStr = Helper.formatAddress(getAddress() + getBytes(version).length + offset);
return "If loc" + ofsStr + (compileTime ? " ;compileTime" : "");
}
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraphSource;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphSource;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.helpers.Helper;
@@ -81,7 +82,7 @@ public class ActionJump extends Action {
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode) {
String ofsStr = Helper.formatAddress(getAddress() + getBytes(version).length + offset);
return "Jump loc" + ofsStr;
}
@@ -28,6 +28,7 @@ import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.ecma.Null;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
@@ -227,7 +228,7 @@ public class ActionPush extends Action {
}
@Override
public HilightedTextWriter getASMSourceReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, boolean hex, HilightedTextWriter writer) {
public HilightedTextWriter getASMSourceReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode, HilightedTextWriter writer) {
if (replacement == null || replacement.size() < values.size()) {
return toString(writer);
}
@@ -238,7 +239,7 @@ public class ActionPush extends Action {
return writer;
}
public HilightedTextWriter paramsToStringReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, boolean hex, HilightedTextWriter writer) {
public HilightedTextWriter paramsToStringReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode, HilightedTextWriter writer) {
if (replacement == null || replacement.size() < values.size()) {
return paramsToString(writer);
}
@@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.special.ActionEnd;
import com.jpexs.decompiler.flash.action.special.ActionStore;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
@@ -116,13 +117,13 @@ public class ActionWaitForFrame2 extends Action implements ActionStore {
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode) {
String ret = "WaitForFrame2 " + skipCount;
for (int i = 0; i < skipped.size(); i++) {
if (skipped.get(i) instanceof ActionEnd) {
break;
}
ret += "\r\n" + skipped.get(i).getASMSource(container, knownAddreses, constantPool, version, hex);
ret += "\r\n" + skipped.get(i).getASMSource(container, knownAddreses, constantPool, version, exportMode);
}
return ret;
}
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.action.model.FunctionActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -155,7 +156,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode) {
String paramStr = "";
for (int i = 0; i < paramNames.size(); i++) {
paramStr += "\"" + Helper.escapeString(paramNames.get(i)) + "\"";
@@ -166,7 +167,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta
}
@Override
public HilightedTextWriter getASMSourceReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, boolean hex, HilightedTextWriter writer) {
public HilightedTextWriter getASMSourceReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode, HilightedTextWriter writer) {
List<String> oldParamNames = paramNames;
if (replacedParamNames != null) {
paramNames = replacedParamNames;
@@ -175,7 +176,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta
if (replacedFunctionName != null) {
functionName = replacedFunctionName;
}
String ret = getASMSource(container, knownAddreses, constantPool, version, hex);
String ret = getASMSource(container, knownAddreses, constantPool, version, exportMode);
paramNames = oldParamNames;
functionName = oldFunctionName;
writer.appendNoHilight(ret);
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.clauses.WithActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -80,7 +81,7 @@ public class ActionWith extends Action implements GraphSourceItemContainer {
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode) {
return "With {";
}
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.action.model.FunctionActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -233,7 +234,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont
}
@Override
public HilightedTextWriter getASMSourceReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, boolean hex, HilightedTextWriter writer) {
public HilightedTextWriter getASMSourceReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode, HilightedTextWriter writer) {
List<String> oldParamNames = paramNames;
if (replacedParamNames != null) {
paramNames = replacedParamNames;
@@ -242,7 +243,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont
if (replacedFunctionName != null) {
functionName = replacedFunctionName;
}
String ret = getASMSource(container, knownAddreses, constantPool, version, hex);
String ret = getASMSource(container, knownAddreses, constantPool, version, exportMode);
paramNames = oldParamNames;
functionName = oldFunctionName;
writer.appendNoHilight(ret);
@@ -251,7 +252,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode) {
String paramStr = "";
for (int i = 0; i < paramNames.size(); i++) {
paramStr += paramRegisters.get(i) + " \"" + Helper.escapeString(paramNames.get(i)) + "\"";
@@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -152,7 +153,7 @@ public class ActionTry extends Action implements GraphSourceItemContainer {
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode) {
String ret = "";
ret += "Try ";
if (catchBlockFlag) {
@@ -26,7 +26,7 @@ public class ExportDialog extends AppDialog {
{translate("images.pngjpeg")},
{translate("movies.flv")},
{translate("sounds.mp3wavflv"), translate("sounds.flv")},
{translate("actionscript.as"), translate("actionscript.pcode")}
{translate("actionscript.as"), translate("actionscript.pcode"), translate("actionscript.pcodehex"), translate("actionscript.hex")}
};
String[] optionNames = {
translate("shapes"),
@@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import static com.jpexs.decompiler.flash.gui.AppStrings.translate;
import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel;
import com.jpexs.decompiler.flash.gui.proxy.ProxyFrame;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.helpers.Cache;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.ProgressListener;
@@ -700,7 +701,7 @@ public class Main {
System.out.println(" ...opens SWF file with the decompiler GUI");
System.out.println(" 3) -proxy (-PXXX)");
System.out.println(" ...auto start proxy in the tray. Optional parameter -P specifies port for proxy. Defaults to 55555. ");
System.out.println(" 4) -export (as|pcode|image|shape|movie|sound|binaryData|text|textplain|all) outdirectory infile [-selectas3class class1 class2 ...]");
System.out.println(" 4) -export (as|pcode|pcodehex|hex|image|shape|movie|sound|binaryData|text|textplain|all|all_as|all_pcode|all_pcodehex|all_hex) outdirectory infile [-selectas3class class1 class2 ...]");
System.out.println(" ...export infile sources to outdirectory as AsctionScript code (\"as\" argument) or as PCode (\"pcode\" argument), images, shapes, movies, binaryData, text with formatting, plain text or all.");
System.out.println(" When \"as\" or \"pcode\" type specified, optional \"-selectas3class\" parameter can be passed to export only selected classes (ActionScript 3 only)");
System.out.println(" 5) -dumpSWF infile");
@@ -1044,12 +1045,17 @@ public class Main {
switch (exportFormat) {
case "all":
case "all_as":
case "all_pcode":
case "all_pcodehex":
case "all_hex":
ExportMode allExportMode = strToExportFormat(exportFormat.substring(3));
System.out.println("Exporting images...");
exfile.exportImages(handler, outDir.getAbsolutePath() + File.separator + "images");
System.out.println("Exporting shapes...");
exfile.exportShapes(handler, outDir.getAbsolutePath() + File.separator + "shapes");
System.out.println("Exporting scripts...");
exfile.exportActionScript(handler, outDir.getAbsolutePath() + File.separator + "scripts", false, Configuration.getConfig("parallelSpeedUp", true));
exfile.exportActionScript(handler, outDir.getAbsolutePath() + File.separator + "scripts", allExportMode, Configuration.getConfig("parallelSpeedUp", true));
System.out.println("Exporting movies...");
exfile.exportMovies(handler, outDir.getAbsolutePath() + File.separator + "movies");
System.out.println("Exporting sounds...");
@@ -1070,13 +1076,16 @@ public class Main {
break;
case "as":
case "pcode":
case "pcodehex":
case "hex":
ExportMode exportMode = strToExportFormat(exportFormat);
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"), Configuration.getConfig("parallelSpeedUp", true));
exportOK = exportOK && exfile.exportAS3Class(args[i], outDir.getAbsolutePath(), exportMode, Configuration.getConfig("parallelSpeedUp", true));
}
} else {
exportOK = !exfile.exportActionScript(handler, outDir.getAbsolutePath(), exportFormat.equals("pcode"), Configuration.getConfig("parallelSpeedUp", true)).isEmpty();
exportOK = !exfile.exportActionScript(handler, outDir.getAbsolutePath(), exportMode, Configuration.getConfig("parallelSpeedUp", true)).isEmpty();
}
break;
case "movie":
@@ -1175,6 +1184,18 @@ public class Main {
}
}
private static ExportMode strToExportFormat(String exportFormatStr) {
if (exportFormatStr.equals("pcode")) {
return ExportMode.PCODE;
} else if (exportFormatStr.equals("pcodehex")) {
return ExportMode.PCODEWITHHEX;
} else if (exportFormatStr.equals("hex")) {
return ExportMode.HEX;
} else {
return ExportMode.SOURCE;
}
}
private static void setConfigurations(String cfgStr) {
String[] cfgs;
if (cfgStr.contains(",")) {
@@ -97,6 +97,7 @@ import com.jpexs.decompiler.flash.types.MATRIX;
import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.RGB;
import com.jpexs.decompiler.flash.types.TEXTRECORD;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.helpers.Cache;
import com.jpexs.helpers.Helper;
import com.jpexs.process.ProcessTools;
@@ -2112,10 +2113,10 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
private SearchDialog searchDialog;
public List<File> exportSelection(AbortRetryIgnoreHandler handler, String selFile, ExportDialog export) throws IOException {
final boolean isPcode = export.getOption(ExportDialog.OPTION_ACTIONSCRIPT) == 1;
final ExportMode exportMode = ExportMode.get(export.getOption(ExportDialog.OPTION_ACTIONSCRIPT));
final boolean isMp3OrWav = export.getOption(ExportDialog.OPTION_SOUNDS) == 0;
final boolean isFormatted = export.getOption(ExportDialog.OPTION_TEXTS) == 1;
List<File> ret = new ArrayList<>();
List<Object> sel = getAllSelected(tagTree);
@@ -2175,7 +2176,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
for (int i = 0; i < tlsList.size(); i++) {
ScriptPack tls = tlsList.get(i);
Main.startWork(translate("work.exporting") + " " + (i + 1) + "/" + tlsList.size() + " " + tls.getPath() + " ...");
ret.add(tls.export(selFile, abcList, isPcode, Configuration.getConfig("parallelSpeedUp", true)));
ret.add(tls.export(selFile, abcList, exportMode, Configuration.getConfig("parallelSpeedUp", true)));
}
} else {
List<TagNode> allNodes = new ArrayList<>();
@@ -2184,7 +2185,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
allNodes.add(asn);
TagNode.setExport(allNodes, false);
TagNode.setExport(actionNodes, true);
ret.addAll(TagNode.exportNodeAS(swf.tags, handler, allNodes, selFile, isPcode));
ret.addAll(TagNode.exportNodeAS(swf.tags, handler, allNodes, selFile, exportMode));
}
}
return ret;
@@ -2718,7 +2719,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
Main.startWork(translate("work.exporting") + "...");
final String selFile = Helper.fixDialogFile(chooser.getSelectedFile()).getAbsolutePath();
Configuration.setConfig("lastExportDir", Helper.fixDialogFile(chooser.getSelectedFile()).getAbsolutePath());
final boolean isPcode = export.getOption(ExportDialog.OPTION_ACTIONSCRIPT) == 1;
final ExportMode exportMode = ExportMode.get(export.getOption(ExportDialog.OPTION_ACTIONSCRIPT));
final boolean isMp3OrWav = export.getOption(ExportDialog.OPTION_SOUNDS) == 0;
final boolean isFormatted = export.getOption(ExportDialog.OPTION_TEXTS) == 1;
final boolean onlySel = e.getActionCommand().endsWith("SEL");
@@ -2735,7 +2736,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
swf.exportMovies(errorHandler, selFile + File.separator + "movies");
swf.exportSounds(errorHandler, selFile + File.separator + "sounds", isMp3OrWav, isMp3OrWav);
swf.exportBinaryData(errorHandler, selFile + File.separator + "binaryData");
swf.exportActionScript(errorHandler, selFile, isPcode, Configuration.getConfig("parallelSpeedUp", true));
swf.exportActionScript(errorHandler, selFile, exportMode, Configuration.getConfig("parallelSpeedUp", true));
}
} catch (Exception ex) {
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "Error during export", ex);
@@ -28,6 +28,7 @@ import com.jpexs.decompiler.flash.gui.GraphFrame;
import com.jpexs.decompiler.flash.gui.View;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayInputStream;
@@ -135,7 +136,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi
return;
}
HilightedTextWriter writer = new HilightedTextWriter(true);
abc.bodies[bodyIndex].code.toASMSource(abc.constants, trait, abc.method_info[abc.bodies[bodyIndex].method_info], abc.bodies[bodyIndex], true, writer);
abc.bodies[bodyIndex].code.toASMSource(abc.constants, trait, abc.method_info[abc.bodies[bodyIndex].method_info], abc.bodies[bodyIndex], ExportMode.PCODEWITHHEX, writer);
String textWithHexTags = writer.toString();
textWithHex = Helper.hexToComments(textWithHexTags);
textNoHex = Helper.stripComments(textWithHexTags);
@@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.gui.View;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.helpers.Cache;
import java.util.ArrayList;
@@ -453,7 +454,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
if (!cache.contains(scriptLeaf)) {
HilightedTextWriter writer = new HilightedTextWriter(true);
for (int scriptTraitIndex : scriptLeaf.traitIndices) {
script.traits.traits[scriptTraitIndex].convertPackaged(null, scriptLeaf.getPath().toString(), abcList, abc, false, false, scriptIndex, -1, writer, new ArrayList<String>(), Configuration.getConfig("parallelSpeedUp", true));
script.traits.traits[scriptTraitIndex].convertPackaged(null, scriptLeaf.getPath().toString(), abcList, abc, false, ExportMode.SOURCE, scriptIndex, -1, writer, new ArrayList<String>(), Configuration.getConfig("parallelSpeedUp", true));
}
String s = Graph.removeNonRefenrencedLoopLabels(writer.toString());
hilightedCode = s;
@@ -7,6 +7,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
import com.jpexs.decompiler.flash.gui.AppStrings;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
import java.util.ArrayList;
import java.util.List;
@@ -68,11 +69,11 @@ public class TraitsListItem {
String s = "";
if ((type != Type.INITIALIZER) && isStatic) {
HilightedTextWriter writer = new HilightedTextWriter(false);
abc.class_info[classIndex].static_traits.traits[index].convertHeader(null, "", abcTags, abc, true, false, scriptIndex, classIndex, writer, new ArrayList<String>(), false);
abc.class_info[classIndex].static_traits.traits[index].convertHeader(null, "", abcTags, abc, true, ExportMode.SOURCE, scriptIndex, classIndex, writer, new ArrayList<String>(), false);
s = writer.toString();
} else if ((type != Type.INITIALIZER) && (!isStatic)) {
HilightedTextWriter writer = new HilightedTextWriter(false);
abc.instance_info[classIndex].instance_traits.traits[index].convertHeader(null, "", abcTags, abc, false, false, scriptIndex, classIndex, writer, new ArrayList<String>(), false);
abc.instance_info[classIndex].instance_traits.traits[index].convertHeader(null, "", abcTags, abc, false, ExportMode.SOURCE, scriptIndex, classIndex, writer, new ArrayList<String>(), false);
s = writer.toString();
} else if (!isStatic) {
s = STR_INSTANCE_INITIALIZER;
@@ -38,6 +38,7 @@ import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Cache;
import com.jpexs.helpers.Helper;
@@ -278,7 +279,7 @@ public class ActionPanel extends JPanel implements ActionListener {
setText(hex ? srcWithHex : (hexOnly ? srcHexOnly : srcNoHex));
}
public void setSource(ASMSource src, final boolean useCache) {
public void setSource(final ASMSource src, final boolean useCache) {
this.src = src;
Main.startWork(translate("work.decompiling") + "...");
final ASMSource asm = (ASMSource) src;
@@ -310,12 +311,12 @@ public class ActionPanel extends JPanel implements ActionListener {
List<Action> actions = asm.getActions(SWF.DEFAULT_VERSION);
lastCode = actions;
HilightedTextWriter writer = new HilightedTextWriter(true);
asm.getASMSource(SWF.DEFAULT_VERSION, true, writer, actions);
asm.getASMSource(SWF.DEFAULT_VERSION, ExportMode.PCODEWITHHEX, writer, actions);
lastDisasm = writer.toString();
asm.removeDisassemblyListener(listener);
srcWithHex = Helper.hexToComments(lastDisasm);
srcNoHex = Helper.stripComments(lastDisasm);
srcHexOnly = getHexText(srcWithHex);
srcHexOnly = Helper.byteArrToString(src.getActionBytes());
setHex(hexButton.isSelected(), hexOnlyButton.isSelected());
if (Configuration.getConfig("decompile", true)) {
decompiledEditor.setText("//" + translate("work.decompiling") + "...");
@@ -717,33 +718,6 @@ public class ActionPanel extends JPanel implements ActionListener {
return data;
}
private String getHexText(String srcWithHex) {
StringBuilder result = new StringBuilder();
String nl = System.getProperty("line.separator");
result.append("#hexdata").append(nl);
/* // hex data from decompiled actions
Scanner scanner = new Scanner(srcWithHex);
while (scanner.hasNextLine()) {
String line = scanner.nextLine().trim();
if (line.startsWith(";")) {
result.append(line.substring(1).trim()).append(nl);
} else {
result.append(";").append(line).append(nl);
}
}*/
byte[] data = src.getActionBytes();
for (int i = 0; i < data.length; i++) {
if (i % 8 == 0) {
result.append(nl);
}
result.append(String.format("%02x ", data[i]));
}
return result.toString();
}
public void updateSearchPos() {
searchPos.setText((foundPos + 1) + "/" + found.size());
setSource(found.get(foundPos), true);
@@ -32,6 +32,8 @@ sounds.flv = FLV (Audio only)
actionscript = ActionScript
actionscript.as = ActionScript
actionscript.pcode = P-code
actionscript.pcodehex = P-code with Hex
actionscript.hex = Hex
dialog.title = Export...
@@ -30,8 +30,10 @@ sounds.mp3wavflv = MP3/WAV/FLV
sounds.flv = FLV (Csak hang)
actionscript = ActionScript
actionscript.as = AS
actionscript.pcode = PCODE
actionscript.as = ActionScript
actionscript.pcode = P-code
actionscript.pcodehex = P-code \u00e9s Hexa
actionscript.hex = Hexa
dialog.title = Export\u00e1l\u00e1s...
@@ -33,7 +33,9 @@ import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.types.BUTTONRECORD;
import com.jpexs.decompiler.flash.types.MATRIX;
import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.helpers.Cache;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.ReReadableInputStream;
import java.awt.Color;
import java.awt.Point;
@@ -137,11 +139,11 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT
* @return ASM source
*/
@Override
public HilightedTextWriter getASMSource(int version, boolean hex, HilightedTextWriter writer, List<Action> actions) {
public HilightedTextWriter getASMSource(int version, ExportMode exportMode, HilightedTextWriter writer, List<Action> actions) {
if (actions == null) {
actions = getActions(version);
}
return Action.actionsToString(listeners, 0, actions, null, version, hex, writer, getPos() + hdrSize, toString()/*FIXME?*/);
return Action.actionsToString(listeners, 0, actions, null, version, exportMode, writer, getPos() + hdrSize, toString()/*FIXME?*/);
}
/**
@@ -197,6 +199,11 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT
this.actionBytes = actionBytes;
}
@Override
public HilightedTextWriter getActionBytesAsHex(HilightedTextWriter writer) {
return Helper.byteArrayToHex(writer, actionBytes);
}
@Override
public Set<Integer> getNeededCharacters() {
HashSet<Integer> needed = new HashSet<>();
@@ -23,6 +23,8 @@ import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionListReader;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.ReReadableInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -75,11 +77,11 @@ public class DoActionTag extends Tag implements ASMSource {
* @return ASM source
*/
@Override
public HilightedTextWriter getASMSource(int version, boolean hex, HilightedTextWriter writer, List<Action> actions) {
public HilightedTextWriter getASMSource(int version, ExportMode exportMode, HilightedTextWriter writer, List<Action> actions) {
if (actions == null) {
actions = getActions(version);
}
return Action.actionsToString(listeners, 0, actions, null, version, hex, writer, getPos(), toString()/*FIXME?*/);
return Action.actionsToString(listeners, 0, actions, null, version, exportMode, writer, getPos(), toString()/*FIXME?*/);
}
/**
@@ -140,6 +142,12 @@ public class DoActionTag extends Tag implements ASMSource {
public void setActionBytes(byte[] actionBytes) {
this.actionBytes = actionBytes;
}
@Override
public HilightedTextWriter getActionBytesAsHex(HilightedTextWriter writer) {
return Helper.byteArrayToHex(writer, actionBytes);
}
List<DisassemblyListener> listeners = new ArrayList<>();
@Override
@@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.action.ActionListReader;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.ReReadableInputStream;
import java.io.ByteArrayInputStream;
@@ -102,11 +103,11 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource {
* @return ASM source
*/
@Override
public HilightedTextWriter getASMSource(int version, boolean hex, HilightedTextWriter writer, List<Action> actions) {
public HilightedTextWriter getASMSource(int version, ExportMode exportMode, HilightedTextWriter writer, List<Action> actions) {
if (actions == null) {
actions = getActions(version);
}
return Action.actionsToString(listeners, 0, actions, null, version, hex, writer, getPos() + 2, toString()/*FIXME?*/);
return Action.actionsToString(listeners, 0, actions, null, version, exportMode, writer, getPos() + 2, toString()/*FIXME?*/);
}
@Override
@@ -151,6 +152,11 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource {
this.actionBytes = actionBytes;
}
@Override
public HilightedTextWriter getActionBytesAsHex(HilightedTextWriter writer) {
return Helper.byteArrayToHex(writer, actionBytes);
}
@Override
public int getCharacterId() {
return spriteId;
@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.tags.base;
import com.jpexs.decompiler.flash.DisassemblyListener;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.ExportMode;
import java.util.List;
/**
@@ -35,7 +36,7 @@ public interface ASMSource {
* @param hex Add hexadecimal?
* @return ASM source
*/
public HilightedTextWriter getASMSource(int version, boolean hex, HilightedTextWriter writer, List<Action> actions);
public HilightedTextWriter getASMSource(int version, ExportMode exportMode, HilightedTextWriter writer, List<Action> actions);
/**
* Whether or not this object contains ASM source
@@ -64,6 +65,8 @@ public interface ASMSource {
public void setActionBytes(byte[] actionBytes);
public HilightedTextWriter getActionBytesAsHex(HilightedTextWriter writer);
public long getPos();
public void addDisassemblyListener(DisassemblyListener listener);
@@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
import com.jpexs.decompiler.flash.tags.base.Exportable;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.ReReadableInputStream;
import java.io.ByteArrayInputStream;
@@ -148,11 +149,11 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem {
* @return ASM source
*/
@Override
public HilightedTextWriter getASMSource(int version, boolean hex, HilightedTextWriter writer, List<Action> actions) {
public HilightedTextWriter getASMSource(int version, ExportMode exportMode, HilightedTextWriter writer, List<Action> actions) {
if (actions == null) {
actions = getActions(version);
}
return Action.actionsToString(listeners, 0, actions, null, version, hex, writer, getPos() + 4, toString()/*FIXME?*/);
return Action.actionsToString(listeners, 0, actions, null, version, exportMode, writer, getPos() + 4, toString()/*FIXME?*/);
}
/**
@@ -197,6 +198,12 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem {
public void setActionBytes(byte[] actionBytes) {
this.actionBytes = actionBytes;
}
@Override
public HilightedTextWriter getActionBytesAsHex(HilightedTextWriter writer) {
return Helper.byteArrayToHex(writer, actionBytes);
}
List<DisassemblyListener> listeners = new ArrayList<>();
@Override
@@ -25,6 +25,8 @@ import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
import com.jpexs.decompiler.flash.tags.base.Exportable;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.ReReadableInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -152,11 +154,11 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem {
* @return ASM source
*/
@Override
public HilightedTextWriter getASMSource(int version, boolean hex, HilightedTextWriter writer, List<Action> actions) {
public HilightedTextWriter getASMSource(int version, ExportMode exportMode, HilightedTextWriter writer, List<Action> actions) {
if (actions == null) {
actions = getActions(version);
}
return Action.actionsToString(listeners, 0, actions, null, version, hex, writer, getPos() + hdrPos, toString()/*FIXME?*/);
return Action.actionsToString(listeners, 0, actions, null, version, exportMode, writer, getPos() + hdrPos, toString()/*FIXME?*/);
}
/**
@@ -194,6 +196,12 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem {
public void setActionBytes(byte[] actionBytes) {
this.actionBytes = actionBytes;
}
@Override
public HilightedTextWriter getActionBytesAsHex(HilightedTextWriter writer) {
return Helper.byteArrayToHex(writer, actionBytes);
}
List<DisassemblyListener> listeners = new ArrayList<>();
@Override
@@ -89,6 +89,7 @@ import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD;
import com.jpexs.decompiler.flash.types.shaperecords.StraightEdgeRecord;
import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord;
import com.jpexs.decompiler.flash.types.sound.MP3FRAME;
import com.jpexs.decompiler.graph.ExportMode;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
@@ -2875,7 +2876,7 @@ public class XFLConverter {
}
if (useAS3) {
try {
swf.exportActionScript(handler, outDir.getAbsolutePath(), false, parallel);
swf.exportActionScript(handler, outDir.getAbsolutePath(), ExportMode.SOURCE, parallel);
} catch (Exception ex) {
Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, "Error during ActionScript3 export", ex);
}
@@ -0,0 +1,50 @@
/*
* 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.graph;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
/**
*
* @author JPEXS
*/
public enum ExportMode {
// The order (or values) shoud be the same as in ExportDialog
SOURCE(0), PCODE(1), PCODEWITHHEX(2), HEX(3);
private static final Map<Integer, ExportMode> lookup = new HashMap<>();
static {
for(ExportMode s : EnumSet.allOf(ExportMode.class))
lookup.put(s.getCode(), s);
}
private int code;
private ExportMode(int code) {
this.code = code;
}
public int getCode() { return code; }
public static ExportMode get(int code) {
return lookup.get(code);
}
}
+32
View File
@@ -17,6 +17,7 @@
package com.jpexs.helpers;
import com.jpexs.decompiler.flash.gui.Freed;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.awt.Component;
@@ -548,6 +549,37 @@ public class Helper {
return timeStr;
}
public static HilightedTextWriter byteArrayToHex(HilightedTextWriter writer, byte[] data) {
writer.appendNoHilight("#hexdata").newLine();
/* // hex data from decompiled actions
Scanner scanner = new Scanner(srcWithHex);
while (scanner.hasNextLine()) {
String line = scanner.nextLine().trim();
if (line.startsWith(";")) {
result.append(line.substring(1).trim()).append(nl);
} else {
result.append(";").append(line).append(nl);
}
}*/
for (int i = 0; i < data.length; i++) {
if (i % 8 == 0) {
writer.newLine();
}
writer.appendNoHilight(String.format("%02x ", data[i]));
}
writer.newLine();
return writer;
}
public static String byteArrayToHex(byte[] data) {
HilightedTextWriter writer = new HilightedTextWriter(false);
byteArrayToHex(writer, data);
return writer.toString();
}
public static <T> T timedCall(Callable<T> c, long timeout, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
FutureTask<T> task = new FutureTask<>(c);
THREAD_POOL.execute(task);