Added #1701 Setting charset for SWF files with version 5 or lower

This commit is contained in:
Jindra Petřík
2022-11-10 23:16:53 +01:00
parent c43e68dc29
commit 1c9f81fceb
214 changed files with 1149 additions and 584 deletions

View File

@@ -183,6 +183,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -366,6 +367,8 @@ public final class SWF implements SWFContainerItem, Timelined {
private Set<Integer> cyclicCharacters = null;
private boolean headerModified = false;
private String charset = "UTF-8";
private static final DecompilerPool decompilerPool = new DecompilerPool();
@@ -385,6 +388,14 @@ public final class SWF implements SWFContainerItem, Timelined {
*/
public static final Color ERROR_COLOR = Color.red;
public String getCharset() {
return charset;
}
public void setCharset(String charset) {
this.charset = charset;
}
public void setHeaderModified(boolean headerModified) {
this.headerModified = headerModified;
}
@@ -973,7 +984,7 @@ public final class SWF implements SWFContainerItem, Timelined {
private byte[] saveToByteArray(boolean gfx) throws IOException {
byte[] data;
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version)) {
SWFOutputStream sos = new SWFOutputStream(baos, version, charset)) {
sos.write(getHeaderBytes(SWFCompression.NONE, gfx));
sos.writeUI8(version);
sos.writeUI32(0); // placeholder for file length
@@ -991,7 +1002,7 @@ public final class SWF implements SWFContainerItem, Timelined {
// update file size
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version)) {
SWFOutputStream sos = new SWFOutputStream(baos, version, charset)) {
sos.writeUI32(data.length);
byte[] lengthData = baos.toByteArray();
System.arraycopy(lengthData, 0, data, 4, lengthData.length);
@@ -1037,7 +1048,7 @@ public final class SWF implements SWFContainerItem, Timelined {
fileSize = sis.readUI32("fileSize");
}
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, version, Utf8Helper.charsetName);
sos.write(getHeaderBytes(compression, gfx));
sos.writeUI8(version);
sos.writeUI32(fileSize);
@@ -1152,6 +1163,11 @@ public final class SWF implements SWFContainerItem, Timelined {
displayRect = new RECT(0, 1, 0, 1);
dumpInfo = new DumpInfoSwfNode(this, "rootswf", "", null, 0, 0);
}
public SWF(String charset) {
this();
this.charset = charset;
}
/**
* Construct SWF from stream
@@ -1164,6 +1180,10 @@ public final class SWF implements SWFContainerItem, Timelined {
public SWF(InputStream is, boolean parallelRead) throws IOException, InterruptedException {
this(is, null, null, null, parallelRead, false, true);
}
public SWF(InputStream is, boolean parallelRead, String charset) throws IOException, InterruptedException {
this(is, null, null, null, parallelRead, false, true, charset);
}
/**
* Construct SWF from stream
@@ -1177,6 +1197,10 @@ public final class SWF implements SWFContainerItem, Timelined {
public SWF(InputStream is, boolean parallelRead, boolean lazy) throws IOException, InterruptedException {
this(is, null, null, null, parallelRead, false, lazy);
}
public SWF(InputStream is, boolean parallelRead, boolean lazy, String charset) throws IOException, InterruptedException {
this(is, null, null, null, parallelRead, false, lazy, charset);
}
/**
* Construct SWF from stream
@@ -1191,6 +1215,10 @@ public final class SWF implements SWFContainerItem, Timelined {
public SWF(InputStream is, String file, String fileTitle, boolean parallelRead) throws IOException, InterruptedException {
this(is, file, fileTitle, null, parallelRead, false, true);
}
public SWF(InputStream is, String file, String fileTitle, boolean parallelRead, String charset) throws IOException, InterruptedException {
this(is, file, fileTitle, null, parallelRead, false, true, charset);
}
/**
* Construct SWF from stream
@@ -1205,6 +1233,11 @@ public final class SWF implements SWFContainerItem, Timelined {
this(is, null, null, listener, parallelRead, false, true);
}
public SWF(InputStream is, ProgressListener listener, boolean parallelRead, String charset) throws IOException, InterruptedException {
this(is, null, null, listener, parallelRead, false, true, charset);
}
/**
* Construct SWF from stream
*
@@ -1219,6 +1252,10 @@ public final class SWF implements SWFContainerItem, Timelined {
public SWF(InputStream is, String file, String fileTitle, ProgressListener listener, boolean parallelRead) throws IOException, InterruptedException {
this(is, file, fileTitle, listener, parallelRead, false, true);
}
public SWF(InputStream is, String file, String fileTitle, ProgressListener listener, boolean parallelRead, String charset) throws IOException, InterruptedException {
this(is, file, fileTitle, listener, parallelRead, false, true, charset);
}
/**
* Faster constructor to check SWF only
@@ -1230,8 +1267,16 @@ public final class SWF implements SWFContainerItem, Timelined {
decompress(is, new NulStream(), true);
}
public SWF(InputStream is, String file, String fileTitle, ProgressListener listener, boolean parallelRead, boolean checkOnly, boolean lazy, String charset) throws IOException, InterruptedException {
this(is, file, fileTitle, listener, parallelRead, checkOnly, lazy, null, charset);
}
public SWF(InputStream is, String file, String fileTitle, ProgressListener listener, boolean parallelRead, boolean checkOnly, boolean lazy) throws IOException, InterruptedException {
this(is, file, fileTitle, listener, parallelRead, checkOnly, lazy, null);
this(is, file, fileTitle, listener, parallelRead, checkOnly, lazy, null, Utf8Helper.charsetName);
}
public SWF(InputStream is, String file, String fileTitle, ProgressListener listener, boolean parallelRead, boolean checkOnly, boolean lazy, UrlResolver resolver) throws IOException, InterruptedException {
this(is, file, fileTitle, listener, parallelRead, checkOnly, lazy, resolver, Utf8Helper.charsetName);
}
/**
@@ -1248,9 +1293,10 @@ public final class SWF implements SWFContainerItem, Timelined {
* @throws IOException
* @throws java.lang.InterruptedException
*/
public SWF(InputStream is, String file, String fileTitle, ProgressListener listener, boolean parallelRead, boolean checkOnly, boolean lazy, UrlResolver resolver) throws IOException, InterruptedException {
public SWF(InputStream is, String file, String fileTitle, ProgressListener listener, boolean parallelRead, boolean checkOnly, boolean lazy, UrlResolver resolver, String charset) throws IOException, InterruptedException {
this.file = file;
this.fileTitle = fileTitle;
this.charset = charset;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFHeader header = decompress(is, baos, true);
gfx = header.gfx;
@@ -1264,6 +1310,11 @@ public final class SWF implements SWFContainerItem, Timelined {
sis.dumpInfo = dumpInfo;
sis.skipBytesEx(3, "signature"); // skip siganture
version = sis.readUI8("version");
if (version > 5) {
this.charset = Utf8Helper.charsetName;
}
fileSize = sis.readUI32("fileSize");
dumpInfo.lengthBytes = fileSize;
if (listener != null) {
@@ -1617,7 +1668,7 @@ public final class SWF implements SWFContainerItem, Timelined {
SWFHeader header = decodeHeader(hdr);
long fileSize = header.fileSize;
try (SWFOutputStream sos = new SWFOutputStream(os, header.version)) {
try (SWFOutputStream sos = new SWFOutputStream(os, header.version, Utf8Helper.charsetName)) {
sos.write(getHeaderBytes(SWFCompression.NONE, header.gfx));
sos.writeUI8(header.version);
sos.writeUI32(fileSize);
@@ -2113,7 +2164,7 @@ public final class SWF implements SWFContainerItem, Timelined {
GraphSourceItem ins = code.get(ip);
if (debugMode) {
System.err.println("Visit " + ip + ": ofs" + Helper.formatAddress(((Action) ins).getAddress()) + ":" + ((Action) ins).getASMSource(new ActionList(), new HashSet<>(), ScriptExportMode.PCODE) + " stack:" + Helper.stackToString(stack, LocalData.create(new ConstantPool())));
System.err.println("Visit " + ip + ": ofs" + Helper.formatAddress(((Action) ins).getAddress()) + ":" + ((Action) ins).getASMSource(new ActionList(code.getCharset()), new HashSet<>(), ScriptExportMode.PCODE) + " stack:" + Helper.stackToString(stack, LocalData.create(new ConstantPool())));
}
if (ins.isExit()) {
break;
@@ -2171,7 +2222,7 @@ public final class SWF implements SWFContainerItem, Timelined {
ip = code.adr2pos(addr);
addr += size;
int nextip = code.adr2pos(addr);
getVariables(aLocalData.insideDoInitAction, variables, functions, strings, usageTypes, new ActionGraphSource(path, aLocalData.insideDoInitAction, code.getActions().subList(ip, nextip), code.version, new HashMap<>(), new HashMap<>(), new HashMap<>()), 0, path + (cntName == null ? "" : "/" + cntName));
getVariables(aLocalData.insideDoInitAction, variables, functions, strings, usageTypes, new ActionGraphSource(path, aLocalData.insideDoInitAction, code.getActions().subList(ip, nextip), code.version, new HashMap<>(), new HashMap<>(), new HashMap<>(), code.getCharset()), 0, path + (cntName == null ? "" : "/" + cntName));
ip = nextip;
}
List<List<GraphTargetItem>> r = new ArrayList<>();
@@ -2272,7 +2323,7 @@ public final class SWF implements SWFContainerItem, Timelined {
ActionList actions = src.getActions();
actionsMap.put(src, actions);
boolean insideDoInitAction = src instanceof DoInitActionTag;
getVariables(insideDoInitAction, variables, functions, strings, usageTypes, new ActionGraphSource(path, insideDoInitAction, actions, version, new HashMap<>(), new HashMap<>(), new HashMap<>()), 0, path);
getVariables(insideDoInitAction, variables, functions, strings, usageTypes, new ActionGraphSource(path, insideDoInitAction, actions, version, new HashMap<>(), new HashMap<>(), new HashMap<>(), src.getSwf().getCharset()), 0, path);
return ret;
}
@@ -2428,7 +2479,7 @@ public final class SWF implements SWFContainerItem, Timelined {
int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC;
List<GraphTargetItem> dec;
try {
dec = Action.actionsToTree(true /*Yes, inside doInitAction*/, false, dia.getActions(), version, staticOperation, ""/*FIXME*/);
dec = Action.actionsToTree(true /*Yes, inside doInitAction*/, false, dia.getActions(), version, staticOperation, ""/*FIXME*/, getCharset());
} catch (EmptyStackException ex) {
continue;
}
@@ -2851,7 +2902,7 @@ public final class SWF implements SWFContainerItem, Timelined {
throw ex;
} catch (Exception ex) {
logger.log(Level.SEVERE, null, ex);
return new ActionList();
return new ActionList(src.getSwf().getCharset());
}
}
}

View File

@@ -323,6 +323,13 @@ public class SWFInputStream implements AutoCloseable {
private int limit;
public String getCharset() {
if (swf == null) {
return Utf8Helper.charsetName;
}
return swf.getCharset();
}
public void addPercentListener(ProgressListener listener) {
listeners.add(listener);
}
@@ -363,7 +370,7 @@ public class SWFInputStream implements AutoCloseable {
this.swf = swf;
this.startingPos = startingPos;
this.data = data;
this.limit = limit;
this.limit = limit;
is = new MemoryInputStream(data, 0, limit);
}
@@ -502,7 +509,7 @@ public class SWFInputStream implements AutoCloseable {
r = readEx();
if (r == 0) {
endDumpLevel();
return new String(baos.toByteArray(), Utf8Helper.charset);
return new String(baos.toByteArray(), swf == null ? Utf8Helper.charsetName : swf.getCharset());
}
baos.write(r);
}
@@ -1680,7 +1687,7 @@ public class SWFInputStream implements AutoCloseable {
try {
actionCode = readUI8("actionCode");
if (actionCode == 0) {
return new ActionEnd();
return new ActionEnd(getCharset());
}
if (actionCode == -1) {
return null;
@@ -1727,7 +1734,7 @@ public class SWFInputStream implements AutoCloseable {
case 0x0D:
return new ActionDivide();
case 0x0E:
return new ActionEquals();
return new ActionEquals(getCharset());
case 0x0F:
return new ActionLess();
case 0x10:
@@ -1765,17 +1772,17 @@ public class SWFInputStream implements AutoCloseable {
case 0x9D:
return new ActionIf(actionLength, this);
case 0x9E:
return new ActionCall(actionLength);
return new ActionCall(actionLength, getCharset());
case 0x1C:
return new ActionGetVariable();
case 0x1D:
return new ActionSetVariable();
case 0x9A:
return new ActionGetURL2(actionLength, this);
return new ActionGetURL2(actionLength, this, getCharset());
case 0x9F:
return new ActionGotoFrame2(actionLength, this);
case 0x20:
return new ActionSetTarget2();
return new ActionSetTarget2(getCharset());
case 0x22:
return new ActionGetProperty();
case 0x23:
@@ -1862,11 +1869,11 @@ public class SWFInputStream implements AutoCloseable {
case 0x50:
return new ActionIncrement();
case 0x4C:
return new ActionPushDuplicate();
return new ActionPushDuplicate(getCharset());
case 0x3E:
return new ActionReturn();
case 0x4D:
return new ActionStackSwap();
return new ActionStackSwap(getCharset());
case 0x87:
return new ActionStoreRegister(actionLength, this);
// SWF6 Actions
@@ -1884,11 +1891,11 @@ public class SWFInputStream implements AutoCloseable {
case 0x8E:
return new ActionDefineFunction2(actionLength, this, swf.version);
case 0x69:
return new ActionExtends();
return new ActionExtends(getCharset());
case 0x2B:
return new ActionCastOp();
case 0x2C:
return new ActionImplementsOp();
return new ActionImplementsOp(getCharset());
case 0x8F:
return new ActionTry(actionLength, this, swf.version);
case 0x2A:
@@ -1898,7 +1905,7 @@ public class SWFInputStream implements AutoCloseable {
//skip(actionLength);
}*/
//throw new UnknownActionException(actionCode);
Action r = new ActionUnknown(actionCode, actionLength);
Action r = new ActionUnknown(actionCode, actionLength, getCharset());
if (Configuration.useDetailedLogging.get()) {
logger.log(Level.SEVERE, "Unknown action code: {0}", actionCode);
}

View File

@@ -109,6 +109,8 @@ public class SWFOutputStream extends OutputStream {
private int bitPos = 0;
private int tempByte = 0;
private String charset;
public long getPos() {
return pos;
@@ -120,9 +122,10 @@ public class SWFOutputStream extends OutputStream {
* @param os OutputStream for writing data
* @param version Version of SWF
*/
public SWFOutputStream(OutputStream os, int version) {
public SWFOutputStream(OutputStream os, int version, String charset) {
this.version = version;
this.os = os;
this.charset = charset;
}
/**
@@ -180,7 +183,7 @@ public class SWFOutputStream extends OutputStream {
* @throws IOException
*/
public void writeString(String value) throws IOException {
byte[] data = Utf8Helper.getBytes(value);
byte[] data = value.getBytes(charset);
for (int i = 0; i < data.length; i++) {
if (data[i] == 0) {
throw new IOException("String should not contain null character.");
@@ -806,7 +809,7 @@ public class SWFOutputStream extends OutputStream {
public void writeCLIPACTIONRECORD(CLIPACTIONRECORD value) throws IOException {
writeCLIPEVENTFLAGS(value.eventFlags);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (SWFOutputStream sos = new SWFOutputStream(baos, version)) {
try (SWFOutputStream sos = new SWFOutputStream(baos, version, charset)) {
if (value.eventFlags.clipEventKeyPress) {
sos.writeUI8(value.keyCode);
}
@@ -1154,7 +1157,7 @@ public class SWFOutputStream extends OutputStream {
*/
public void writeBUTTONCONDACTION(BUTTONCONDACTION value, boolean isLast) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (SWFOutputStream sos = new SWFOutputStream(baos, version)) {
try (SWFOutputStream sos = new SWFOutputStream(baos, version, charset)) {
sos.writeUB(1, value.condIdleToOverDown ? 1 : 0);
sos.writeUB(1, value.condOutDownToIdle ? 1 : 0);
sos.writeUB(1, value.condOutDownToOverDown ? 1 : 0);

View File

@@ -81,6 +81,7 @@ import com.jpexs.helpers.Helper;
import com.jpexs.helpers.Reference;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -122,12 +123,20 @@ public abstract class Action implements GraphSourceItem {
private long address;
private long virtualAddress = -1;
private String charset;
@Override
public long getLineOffset() {
return fileOffset;
}
public String getCharset() {
return charset;
}
/**
* Names of ActionScript properties
*/
@@ -174,12 +183,13 @@ public abstract class Action implements GraphSourceItem {
* @param actionCode Action type identifier
* @param actionLength Length of action data
*/
public Action(int actionCode, int actionLength) {
public Action(int actionCode, int actionLength, String charset) {
this.actionCode = actionCode;
this.actionLength = actionLength;
this.charset = charset;
}
public Action() {
public Action() {
}
/**
@@ -333,7 +343,7 @@ public abstract class Action implements GraphSourceItem {
*/
public final byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
SWFOutputStream sos = new SWFOutputStream(baos, version, charset);
try {
getContentBytes(sos);
sos.close();
@@ -377,7 +387,7 @@ public abstract class Action implements GraphSourceItem {
*/
private byte[] surroundWithAction(byte[] data, int version) {
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
SWFOutputStream sos2 = new SWFOutputStream(baos2, version);
SWFOutputStream sos2 = new SWFOutputStream(baos2, version, charset);
try {
sos2.writeUI8(actionCode);
if (actionCode >= 0x80) {
@@ -843,8 +853,8 @@ public abstract class Action implements GraphSourceItem {
return -1;
}
public static List<GraphTargetItem> actionsToTree(boolean insideDoInitAction, boolean insideFunction, List<Action> actions, int version, int staticOperation, String path) throws InterruptedException {
return actionsToTree(insideDoInitAction, insideFunction, new HashMap<>(), new HashMap<>(), new HashMap<>(), actions, version, staticOperation, path);
public static List<GraphTargetItem> actionsToTree(boolean insideDoInitAction, boolean insideFunction, List<Action> actions, int version, int staticOperation, String path, String charset) throws InterruptedException {
return actionsToTree(insideDoInitAction, insideFunction, new HashMap<>(), new HashMap<>(), new HashMap<>(), actions, version, staticOperation, path, charset);
}
/**
@@ -857,7 +867,7 @@ public abstract class Action implements GraphSourceItem {
* @return
* @throws java.lang.InterruptedException
*/
public static GraphTextWriter actionsToSource(final ASMSource asm, final List<Action> actions, final String path, GraphTextWriter writer) throws InterruptedException {
public static GraphTextWriter actionsToSource(final ASMSource asm, final List<Action> actions, final String path, GraphTextWriter writer, String charset) throws InterruptedException {
writer.suspendMeasure();
List<GraphTargetItem> tree = null;
Throwable convertException = null;
@@ -870,7 +880,7 @@ public abstract class Action implements GraphSourceItem {
public List<GraphTargetItem> call() throws Exception {
int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC;
boolean insideDoInitAction = (asm instanceof DoInitActionTag);
List<GraphTargetItem> tree = actionsToTree(insideDoInitAction, false, new HashMap<>(), new HashMap<>(), new HashMap<>(), actions, version, staticOperation, path);
List<GraphTargetItem> tree = actionsToTree(insideDoInitAction, false, new HashMap<>(), new HashMap<>(), new HashMap<>(), actions, version, staticOperation, path, charset);
SWFDecompilerPlugin.fireActionTreeCreated(tree, swf);
if (Configuration.autoDeobfuscate.get()) {
new ActionDeobfuscator().actionTreeCreated(tree, swf);
@@ -929,17 +939,17 @@ public abstract class Action implements GraphSourceItem {
* @return List of treeItems
* @throws java.lang.InterruptedException
*/
public static List<GraphTargetItem> actionsToTree(boolean insideDoInitAction, boolean insideFunction, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, List<Action> actions, int version, int staticOperation, String path) throws InterruptedException {
public static List<GraphTargetItem> actionsToTree(boolean insideDoInitAction, boolean insideFunction, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, List<Action> actions, int version, int staticOperation, String path, String charset) throws InterruptedException {
HashMap<String, GraphTargetItem> variablesBackup = new LinkedHashMap<>(variables);
HashMap<String, GraphTargetItem> functionsBackup = new LinkedHashMap<>(functions);
try {
return ActionGraph.translateViaGraph(null, insideDoInitAction, insideFunction, regNames, variables, functions, actions, version, staticOperation, path);
return ActionGraph.translateViaGraph(null, insideDoInitAction, insideFunction, regNames, variables, functions, actions, version, staticOperation, path, charset);
} catch (SecondPassException spe) {
variables.clear();
variables.putAll(variablesBackup);
functions.clear();
functions.putAll(functionsBackup);
return ActionGraph.translateViaGraph(spe.getData(), insideDoInitAction, insideFunction, regNames, variables, functions, actions, version, staticOperation, path);
return ActionGraph.translateViaGraph(spe.getData(), insideDoInitAction, insideFunction, regNames, variables, functions, actions, version, staticOperation, path, charset);
}
}
@@ -1000,7 +1010,7 @@ public abstract class Action implements GraphSourceItem {
return variables2;
}
public static List<GraphTargetItem> actionsPartToTree(SecondPassData secondPassData, boolean insideDoInitAction, Reference<GraphSourceItem> fi, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, TranslateStack stack, List<Action> actions, int start, int end, int version, int staticOperation, String path) throws InterruptedException, GraphPartChangeException {
public static List<GraphTargetItem> actionsPartToTree(SecondPassData secondPassData, boolean insideDoInitAction, Reference<GraphSourceItem> fi, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, TranslateStack stack, List<Action> actions, int start, int end, int version, int staticOperation, String path, String charset) throws InterruptedException, GraphPartChangeException {
if (start < actions.size() && (end > 0) && (start > 0)) {
logger.log(Level.FINE, "Entering {0}-{1}{2}", new Object[]{start, end, actions.size() > 0 ? (" (" + actions.get(start).toString() + " - " + actions.get(end == actions.size() ? end - 1 : end) + ")") : ""});
}
@@ -1068,10 +1078,10 @@ public abstract class Action implements GraphSourceItem {
}
}
try {
out = ActionGraph.translateViaGraph(null, insideDoInitAction, true, regNames, variables2, functions, actions.subList(adr2ip(actions, endAddr), adr2ip(actions, endAddr + size)), version, staticOperation, path + (cntName == null ? "" : "/" + cntName));
out = ActionGraph.translateViaGraph(null, insideDoInitAction, true, regNames, variables2, functions, actions.subList(adr2ip(actions, endAddr), adr2ip(actions, endAddr + size)), version, staticOperation, path + (cntName == null ? "" : "/" + cntName), charset);
} catch (SecondPassException spe) {
variables2 = prepareVariables(cnt, variables);
out = ActionGraph.translateViaGraph(spe.getData(), insideDoInitAction, true, regNames, variables2, functions, actions.subList(adr2ip(actions, endAddr), adr2ip(actions, endAddr + size)), version, staticOperation, path + (cntName == null ? "" : "/" + cntName));
out = ActionGraph.translateViaGraph(spe.getData(), insideDoInitAction, true, regNames, variables2, functions, actions.subList(adr2ip(actions, endAddr), adr2ip(actions, endAddr + size)), version, staticOperation, path + (cntName == null ? "" : "/" + cntName), charset);
}
} catch (OutOfMemoryError | TranslateException | StackOverflowError ex) {
logger.log(Level.SEVERE, "Decompilation error in: " + path, ex);

View File

@@ -293,7 +293,7 @@ public class ActionDefineFunctionPushRegistersCleaner extends SWFDecompilerAdapt
if (newPushedValues.size() != currentPushedValues.size()) {
code.removeAction(pos); //remove that push
if (!newPushedValues.isEmpty()) {
ActionPush newPush = new ActionPush(newPushedValues.toArray());
ActionPush newPush = new ActionPush(newPushedValues.toArray(), code.getCharset());
newPush.constantPool = currentPush.constantPool;
code.addAction(pos, newPush); //replace with different push
} else {

View File

@@ -70,6 +70,7 @@ import com.jpexs.decompiler.graph.model.SwitchItem;
import com.jpexs.decompiler.graph.model.WhileItem;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.Reference;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -88,8 +89,8 @@ public class ActionGraph extends Graph {
private boolean insideFunction;
public ActionGraph(String path, boolean insideDoInitAction, boolean insideFunction, List<Action> code, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int version) {
super(new ActionGraphSource(path, insideDoInitAction, code, version, registerNames, variables, functions), new ArrayList<>());
public ActionGraph(String path, boolean insideDoInitAction, boolean insideFunction, List<Action> code, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int version, String charset) {
super(new ActionGraphSource(path, insideDoInitAction, code, version, registerNames, variables, functions, charset), new ArrayList<>());
this.insideDoInitAction = insideDoInitAction;
this.insideFunction = insideFunction;
}
@@ -107,7 +108,7 @@ public class ActionGraph extends Graph {
List<ActionList> outs = new ArrayList<>();
for (long size : cnt.getContainerSizes()) {
if (size == 0) {
outs.add(new ActionList());
outs.add(new ActionList(((ActionGraphSource) code).getCharset()));
continue;
}
outs.add(new ActionList(alist.subList(adr2ip(alist, endAddr), adr2ip(alist, endAddr + size))));
@@ -116,7 +117,7 @@ public class ActionGraph extends Graph {
for (ActionList al : outs) {
subgraphs.put("loc" + Helper.formatAddress(code.pos2adr(ip)) + ": function " + functionName,
new ActionGraph("", false, false, al, new HashMap<>(), new HashMap<>(), new HashMap<>(), SWF.DEFAULT_VERSION)
new ActionGraph("", false, false, al, new HashMap<>(), new HashMap<>(), new HashMap<>(), SWF.DEFAULT_VERSION, ((ActionGraphSource)getGraphCode()).getCharset())
);
}
}
@@ -134,8 +135,8 @@ public class ActionGraph extends Graph {
}
public static List<GraphTargetItem> translateViaGraph(SecondPassData secondPassData, boolean insideDoInitAction, boolean insideFunction, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, List<Action> code, int version, int staticOperation, String path) throws InterruptedException {
ActionGraph g = new ActionGraph(path, insideDoInitAction, insideFunction, code, registerNames, variables, functions, version);
public static List<GraphTargetItem> translateViaGraph(SecondPassData secondPassData, boolean insideDoInitAction, boolean insideFunction, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, List<Action> code, int version, int staticOperation, String path, String charset) throws InterruptedException {
ActionGraph g = new ActionGraph(path, insideDoInitAction, insideFunction, code, registerNames, variables, functions, version, charset);
ActionLocalData localData = new ActionLocalData(secondPassData, insideDoInitAction, registerNames);
g.init(localData);
return g.translate(localData, staticOperation, path);

View File

@@ -26,6 +26,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.Reference;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -52,12 +53,14 @@ public class ActionGraphSource extends GraphSource {
private final boolean insideDoInitAction;
private final String path;
private String charset;
public List<Action> getActions() {
return actions;
}
public ActionGraphSource(String path, boolean insideDoInitAction, List<Action> actions, int version, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
public ActionGraphSource(String path, boolean insideDoInitAction, List<Action> actions, int version, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, String charset) {
this.actions = actions instanceof ActionList ? (ActionList) actions : new ActionList(actions);
this.version = version;
this.registerNames = registerNames;
@@ -65,8 +68,15 @@ public class ActionGraphSource extends GraphSource {
this.functions = functions;
this.insideDoInitAction = insideDoInitAction;
this.path = path;
this.charset = charset;
}
public String getCharset() {
return charset;
}
@Override
public Set<Long> getImportantAddresses() {
return Action.getActionsAllRefs(actions);
@@ -103,7 +113,7 @@ public class ActionGraphSource extends GraphSource {
public List<GraphTargetItem> translatePart(GraphPart part, BaseLocalData localData, TranslateStack stack, int start, int end, int staticOperation, String path) throws InterruptedException, GraphPartChangeException {
Reference<GraphSourceItem> fi = new Reference<>(localData.lineStartInstruction);
List<GraphTargetItem> r = Action.actionsPartToTree(localData.secondPassData, this.insideDoInitAction, fi, registerNames, variables, functions, stack, actions, start, end, version, staticOperation, path);
List<GraphTargetItem> r = Action.actionsPartToTree(localData.secondPassData, this.insideDoInitAction, fi, registerNames, variables, functions, stack, actions, start, end, version, staticOperation, path, charset);
localData.lineStartInstruction = fi.getVal();
return r;
}

View File

@@ -35,6 +35,7 @@ import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -51,10 +52,18 @@ public class ActionList extends ArrayList<Action> {
public int deobfuscationMode;
public byte[] fileData;
private String charset;
public ActionList() {
public ActionList(String charset) {
this.charset = charset;
}
public String getCharset() {
return charset;
}
public ActionList(Collection<Action> actions) {
super(actions);
}
@@ -501,7 +510,7 @@ public class ActionList extends ArrayList<Action> {
ActionPush push = (ActionPush) action;
ActionPush push2 = (ActionPush) action2;
if (!(push.constantPool != null && push2.constantPool != null && push.constantPool != push2.constantPool)) {
ActionPush newPush = new ActionPush(0);
ActionPush newPush = new ActionPush(0, charset);
newPush.constantPool = push.constantPool == null ? push2.constantPool : push.constantPool;
newPush.values.clear();
newPush.values.addAll(push.values);
@@ -525,7 +534,7 @@ public class ActionList extends ArrayList<Action> {
int j = 0;
for (Object value : push.values) {
j++;
ActionPush newPush = new ActionPush(value);
ActionPush newPush = new ActionPush(value, charset);
newPush.constantPool = push.constantPool;
addAction(i + j, newPush);
}
@@ -556,7 +565,7 @@ public class ActionList extends ArrayList<Action> {
public String toSource() {
try {
HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false);
actionsToSource(null, this, "", writer);
actionsToSource(null, this, "", writer, charset);
return writer.toString();
} catch (InterruptedException ex) {
Logger.getLogger(ActionList.class.getName()).log(Level.SEVERE, null, ex);

View File

@@ -34,6 +34,7 @@ import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import com.jpexs.helpers.CancellableWorker;
import com.jpexs.helpers.stat.Statistics;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
@@ -94,7 +95,7 @@ public class ActionListReader {
logger.log(Level.SEVERE, null, ex);
}
}
return new ActionList();
return new ActionList(sis.getCharset());
}
/**
@@ -119,10 +120,11 @@ public class ActionListReader {
Map<Long, Long> nextOffsets = new HashMap<>();
Action entryAction = readActionListAtPos(listeners, null,
sis, actionMap, nextOffsets,
ip, 0, endIp, path, false, new ArrayList<>());
ip, 0, endIp, path, false, new ArrayList<>(),
sis.getCharset());
if (actionMap.isEmpty()) {
return new ActionList();
return new ActionList(sis.getCharset());
}
List<Long> addresses = new ArrayList<>(actionMap.keySet());
@@ -131,7 +133,7 @@ public class ActionListReader {
Action lastAction = actionMap.get(addresses.get(addresses.size() - 1));
long endAddress;
if (!(lastAction instanceof ActionEnd)) {
Action aEnd = new ActionEnd();
Action aEnd = new ActionEnd(sis.getCharset());
aEnd.setAddress(nextOffsets.get(lastAction.getAddress()));
endAddress = aEnd.getAddress();
actionMap.put(aEnd.getAddress(), aEnd);
@@ -142,7 +144,7 @@ public class ActionListReader {
// jump to the entry action when it is diffrent from the first action in the map
if (entryAction != actions.get(0)) {
ActionJump jump = new ActionDeobfuscateJump(0);
ActionJump jump = new ActionDeobfuscateJump(0, sis.getCharset());
actions.addAction(0, jump);
jump.setJumpOffset((int) (entryAction.getAddress() - jump.getTotalActionLength()));
}
@@ -187,7 +189,7 @@ public class ActionListReader {
Map<Action, List<Action>> containerLastActions = new HashMap<>();
getContainerLastActions(actions, containerLastActions);
ActionList ret = new ActionList();
ActionList ret = new ActionList(actions.getCharset());
ret.fileData = actions.fileData;
if (nextOffsets != null) {
@@ -200,7 +202,7 @@ public class ActionListReader {
long nextAddress = nextOffsets.get(action.getAddress());
if (actions.get(index).getAddress() != nextAddress) {
if (!action.isExit() && !(action instanceof ActionJump)) {
ActionJump jump = new ActionDeobfuscateJump(0);
ActionJump jump = new ActionDeobfuscateJump(0, actions.getCharset());
jump.setAddress(action.getAddress());
int size = jump.getTotalActionLength();
jump.setJumpOffset((int) (nextAddress - action.getAddress() - size));
@@ -219,10 +221,10 @@ public class ActionListReader {
getJumps(ret, jumps);
updateActionLengths(ret);
updateAddresses(ret, 0);
updateAddresses(ret, 0, actions.getCharset());
long endAddress = ret.get(ret.size() - 1).getAddress();
updateJumps(ret, jumps, containerLastActions, endAddress);
updateJumps(ret, jumps, containerLastActions, endAddress, actions.getCharset());
updateActionStores(ret, jumps);
updateContainerSizes(ret, containerLastActions);
@@ -235,7 +237,8 @@ public class ActionListReader {
Map<Long, Long> nextOffsets = new HashMap<>();
readActionListAtPos(new ArrayList<>(), null,
sis, actionMap, nextOffsets,
startIp, startIp, endIp + 1, "", false, new ArrayList<>());
startIp, startIp, endIp + 1, "", false, new ArrayList<>(),
sis.getCharset());
return new ArrayList<>(actionMap.values());
}
@@ -328,14 +331,14 @@ public class ActionListReader {
}
}
private static long updateAddresses(List<Action> actions, long address) {
private static long updateAddresses(List<Action> actions, long address, String charset) {
for (int i = 0; i < actions.size(); i++) {
Action a = actions.get(i);
a.setAddress(address);
int length = a.getTotalActionLength();
if ((i != actions.size() - 1) && (a instanceof ActionEnd)) {
// placeholder for jump action
length = new ActionDeobfuscateJump(0).getTotalActionLength();
length = new ActionDeobfuscateJump(0, charset).getTotalActionLength();
}
address += length;
}
@@ -406,7 +409,7 @@ public class ActionListReader {
}
}
private static void updateJumps(List<Action> actions, Map<Action, Action> jumps, Map<Action, List<Action>> containerLastActions, long endAddress) {
private static void updateJumps(List<Action> actions, Map<Action, Action> jumps, Map<Action, List<Action>> containerLastActions, long endAddress, String charset) {
if (actions.isEmpty()) {
return;
}
@@ -414,7 +417,7 @@ public class ActionListReader {
for (int i = 0; i < actions.size(); i++) {
Action a = actions.get(i);
if ((i != actions.size() - 1) && (a instanceof ActionEnd)) {
ActionJump aJump = new ActionDeobfuscateJump(0);
ActionJump aJump = new ActionDeobfuscateJump(0, charset);
aJump.setJumpOffset((int) (endAddress - a.getAddress() - aJump.getTotalActionLength()));
aJump.setAddress(a.getAddress());
replaceJumpTargets(jumps, a, aJump);
@@ -501,8 +504,8 @@ public class ActionListReader {
actions.remove(index);
updateActionLengths(actions);
updateAddresses(actions, startIp);
updateJumps(actions, jumps, containerLastActions, endAddress);
updateAddresses(actions, startIp, actions.getCharset());
updateJumps(actions, jumps, containerLastActions, endAddress, actions.getCharset());
updateActionStores(actions, jumps);
updateContainerSizes(actions, containerLastActions);
@@ -564,8 +567,8 @@ public class ActionListReader {
}
updateActionLengths(actions);
updateAddresses(actions, startIp);
updateJumps(actions, jumps, containerLastActions, endAddress);
updateAddresses(actions, startIp, actions.getCharset());
updateJumps(actions, jumps, containerLastActions, endAddress, actions.getCharset());
updateActionStores(actions, jumps);
updateContainerSizes(actions, containerLastActions);
@@ -593,7 +596,7 @@ public class ActionListReader {
long startIp = actions.get(0).getAddress();
Action lastAction = actions.get(actions.size() - 1);
if (!(lastAction instanceof ActionEnd)) {
Action aEnd = new ActionEnd();
Action aEnd = new ActionEnd(actions.getCharset());
aEnd.setAddress(lastAction.getAddress() + lastAction.getTotalActionLength());
actions.add(aEnd);
lastAction = aEnd;
@@ -633,8 +636,8 @@ public class ActionListReader {
actions.add(index, action);
updateActionLengths(actions);
updateAddresses(actions, startIp);
updateJumps(actions, jumps, containerLastActions, endAddress);
updateAddresses(actions, startIp, actions.getCharset());
updateJumps(actions, jumps, containerLastActions, endAddress, actions.getCharset());
updateActionStores(actions, jumps);
updateContainerSizes(actions, containerLastActions);
@@ -659,7 +662,7 @@ public class ActionListReader {
long startIp = actions.get(0).getAddress();
Action lastAction = actions.get(actions.size() - 1);
if (!(lastAction instanceof ActionEnd)) {
Action aEnd = new ActionEnd();
Action aEnd = new ActionEnd(actions.getCharset());
aEnd.setAddress(lastAction.getAddress() + lastAction.getTotalActionLength());
actions.add(aEnd);
lastAction = aEnd;
@@ -678,8 +681,8 @@ public class ActionListReader {
actions.addAll(index, newActions);
updateActionLengths(actions);
updateAddresses(actions, startIp);
updateJumps(actions, jumps, containerLastActions, endAddress);
updateAddresses(actions, startIp, actions.getCharset());
updateJumps(actions, jumps, containerLastActions, endAddress, actions.getCharset());
updateActionStores(actions, jumps);
updateContainerSizes(actions, containerLastActions);
@@ -688,7 +691,7 @@ public class ActionListReader {
private static Action readActionListAtPos(List<DisassemblyListener> listeners, ConstantPool cpool,
SWFInputStream sis, Map<Long, Action> actions, Map<Long, Long> nextOffsets,
long ip, long startIp, long endIp, String path, boolean indeterminate, List<Long> visitedContainers) throws IOException {
long ip, long startIp, long endIp, String path, boolean indeterminate, List<Long> visitedContainers, String charset) throws IOException {
Action entryAction = null;
@@ -718,7 +721,7 @@ public class ActionListReader {
// unknown action, replace with jump
if (a instanceof ActionUnknown && a.getActionCode() >= 0x80) {
ActionJump aJump = new ActionDeobfuscateJump(0);
ActionJump aJump = new ActionDeobfuscateJump(0, charset);
int jumpLength = aJump.getTotalActionLength();
aJump.setAddress(a.getAddress());
//FIXME! This offset can be larger than SI16 value!
@@ -774,7 +777,8 @@ public class ActionListReader {
long endIp2 = ip + actionLengthWithHeader + size;
readActionListAtPos(listeners, cpool,
sis, actions, nextOffsets,
ip2, startIp, endIp2, newPath, indeterminate, visitedContainers);
ip2, startIp, endIp2, newPath, indeterminate, visitedContainers,
charset);
actionLengthWithHeader += size;
}
}

View File

@@ -146,7 +146,7 @@ public class ActionDeobfuscator extends SWFDecompilerAdapter {
}
if (isGetTime && a2 instanceof ActionIf) {
ActionJump jump = new ActionJump(0);
ActionJump jump = new ActionJump(0, actions.getCharset());
ActionItem jumpItem = new ActionItem(jump);
jumpItem.setJumpTarget(a2Item.getJumpTarget());
iterator.remove(); // GetTime
@@ -168,7 +168,7 @@ public class ActionDeobfuscator extends SWFDecompilerAdapter {
ActionItem a2Item = iterator.peek(1);
Action a2 = a2Item.action;
if (a instanceof ActionGetTime && a1 instanceof ActionIncrement && a2 instanceof ActionIf) {
ActionJump jump = new ActionJump(0);
ActionJump jump = new ActionJump(0, actions.getCharset());
ActionItem jumpItem = new ActionItem(jump);
jumpItem.setJumpTarget(a2Item.getJumpTarget());
iterator.remove(); // GetTime
@@ -259,17 +259,17 @@ public class ActionDeobfuscator extends SWFDecompilerAdapter {
} else {
ActionItem prevActionItem = actionItem.prev;
if (result.constantPool != null) {
ActionConstantPool constantPool2 = new ActionConstantPool(new ArrayList<>(result.constantPool.constantPool));
ActionConstantPool constantPool2 = new ActionConstantPool(new ArrayList<>(result.constantPool.constantPool), actions.getCharset());
ActionItem constantPoolItem = new ActionItem(constantPool2);
iterator.addBefore(constantPoolItem);
}
for (String variableName : result.variables.keySet()) {
Object value = result.variables.get(variableName);
ActionPush push = new ActionPush(variableName);
ActionPush push = new ActionPush(variableName, actions.getCharset());
ActionItem pushItem = new ActionItem(push);
iterator.addBefore(pushItem);
push = new ActionPush(value);
push = new ActionPush(value, actions.getCharset());
pushItem = new ActionItem(push);
iterator.addBefore(pushItem);
@@ -286,13 +286,13 @@ public class ActionDeobfuscator extends SWFDecompilerAdapter {
if (!result.stack.isEmpty()) {
for (Object obj : result.stack) {
ActionPush push = new ActionPush(obj);
ActionPush push = new ActionPush(obj, actions.getCharset());
ActionItem pushItem = new ActionItem(push);
iterator.addBefore(pushItem);
}
}
ActionJump jump = new ActionJump(0);
ActionJump jump = new ActionJump(0, actions.getCharset());
ActionItem jumpItem = new ActionItem(jump);
jumpItem.setJumpTarget(result.item);
iterator.addBefore(jumpItem);

View File

@@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.action.swf4.ActionIf;
import com.jpexs.decompiler.flash.action.swf4.ActionJump;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -45,6 +46,8 @@ public class FastActionList implements Collection<ActionItem> {
private final Map<Action, ActionItem> actionItemMap;
private final Set<ActionItem> actionItemSet;
private String charset;
public FastActionList(ActionList actions) {
actionItemMap = new HashMap<>(actions.size());
@@ -56,8 +59,15 @@ public class FastActionList implements Collection<ActionItem> {
size = actions.size();
getContainerLastActions(actions, actionItemMap);
getJumps(actions, actionItemMap);
charset = actions.getCharset();
}
public String getCharset() {
return charset;
}
public final ActionItem insertItemBefore(ActionItem item, Action action) {
ActionItem newItem = new ActionItem(action);
return insertItemBefore(item, newItem);
@@ -387,7 +397,7 @@ public class FastActionList implements Collection<ActionItem> {
if (push.values.size() > 1) {
for (int i = 1; i < push.values.size(); i++) {
Object value = push.values.get(i);
ActionPush newPush = new ActionPush(value);
ActionPush newPush = new ActionPush(value, charset);
newPush.constantPool = push.constantPool;
insertItemAfter(item, newPush);
item = item.next;

View File

@@ -24,6 +24,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -34,8 +35,8 @@ import java.util.List;
*/
public class ActionFSCommand2 extends Action {
public ActionFSCommand2() {
super(0x2D, 0);
public ActionFSCommand2(String charset) {
super(0x2D, 0, charset);
}
@Override

View File

@@ -28,6 +28,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -40,12 +41,12 @@ public class ActionStrictMode extends Action {
public int mode;
public ActionStrictMode(SWFInputStream sis) throws IOException {
super(0x89, 1);
super(0x89, 1, sis.getCharset());
mode = sis.readUI8("mode");
}
public ActionStrictMode(FlasmLexer lexer) throws IOException, ActionParseException {
super(0x89, 1);
public ActionStrictMode(FlasmLexer lexer, String charset) throws IOException, ActionParseException {
super(0x89, 1, charset);
mode = (int) lexLong(lexer);
}

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionPop;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
@@ -27,6 +28,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.io.Serializable;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
@@ -74,11 +76,14 @@ public abstract class ActionItem extends GraphTargetItem implements Serializable
}
protected List<GraphSourceItem> toSourceCall(SourceGeneratorLocalData localData, SourceGenerator gen, List<GraphTargetItem> list) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) gen;
String charset = asGenerator.getCharset();
List<GraphSourceItem> ret = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
ret.addAll(0, list.get(i).toSource(localData, gen));
}
ret.add(new ActionPush((Long) (long) list.size()));
ret.add(new ActionPush((Long) (long) list.size(), charset));
return ret;
}

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionCloneSprite;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.ecma.Undefined;
@@ -28,6 +29,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -81,7 +83,10 @@ public class CloneSpriteActionItem extends ActionItem {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return toSourceMerge(localData, generator, source, target, depth, new ActionCloneSprite(), new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}));
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, source, target, depth, new ActionCloneSprite(), new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset));
}
@Override

View File

@@ -94,7 +94,7 @@ public class DeleteActionItem extends ActionItem {
}
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
if (object == null) {
return toSourceMerge(localData, generator, propertyName, new ActionDelete2());
}

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.action.swf4.ConstantIndex;
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
@@ -33,6 +34,7 @@ import com.jpexs.decompiler.graph.SimpleValue;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.helpers.Helper;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -259,7 +261,10 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return toSourceMerge(localData, generator, new ActionPush(value));
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, new ActionPush(value, charset));
}
@Override

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.flashlite.ActionFSCommand2;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
@@ -27,6 +28,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -78,13 +80,18 @@ public class FSCommand2ActionItem extends ActionItem {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
List<GraphSourceItem> ret = new ArrayList<>();
for (GraphTargetItem a : arguments) {
ret.addAll(a.toSource(localData, generator));
}
ret.addAll(command.toSource(localData, generator));
ret.add(new ActionPush((Long) (long) arguments.size()));
ret.add(new ActionFSCommand2());
ret.add(new ActionPush((Long) (long) arguments.size(), charset));
ret.add(new ActionFSCommand2(charset));
return ret;
}

View File

@@ -29,6 +29,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -66,11 +67,12 @@ public class FSCommandActionItem extends ActionItem {
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
ActionSourceGenerator asg = (ActionSourceGenerator) generator;
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
if ((command instanceof DirectValueActionItem) && ((DirectValueActionItem) command).isString()) {
return toSourceMerge(localData, generator, new ActionGetURL("FSCommand:" + ((DirectValueActionItem) command).getAsString(), ""));
return toSourceMerge(localData, generator, new ActionGetURL("FSCommand:" + ((DirectValueActionItem) command).getAsString(), "", charset));
}
return toSourceMerge(localData, generator, new AddActionItem(null, null, asg.pushConstTargetItem("FSCommand:"), command, true), asg.pushConstTargetItem(""), new ActionGetURL2(1/*GET*/, false, false), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
return toSourceMerge(localData, generator, new AddActionItem(null, null, asGenerator.pushConstTargetItem("FSCommand:"), command, true), asGenerator.pushConstTargetItem(""), new ActionGetURL2(1/*GET*/, false, false, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -38,6 +38,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.BranchStackResistant;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.helpers.Helper;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -282,13 +283,15 @@ public class FunctionActionItem extends ActionItem implements BranchStackResista
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
Set<String> usedNames = new HashSet<>();
for (VariableActionItem v : variables) {
usedNames.add(v.getVariableName());
}
List<GraphSourceItem> ret = new ArrayList<>();
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
List<Integer> paramRegs = new ArrayList<>();
SourceGeneratorLocalData localDataCopy = Helper.deepCopy(localData);
localDataCopy.inFunction++;
@@ -437,7 +440,7 @@ public class FunctionActionItem extends ActionItem implements BranchStackResista
}
int len = Action.actionsToBytes(asGenerator.toActionList(ret), false, SWF.DEFAULT_VERSION).length;
if (!needsFun2 && paramNames.isEmpty()) {
ret.add(0, new ActionDefineFunction(functionName, paramNames, len, SWF.DEFAULT_VERSION));
ret.add(0, new ActionDefineFunction(functionName, paramNames, len, SWF.DEFAULT_VERSION, charset));
} else {
ret.add(0, new ActionDefineFunction2(functionName,
preloadParentFlag,
@@ -449,7 +452,7 @@ public class FunctionActionItem extends ActionItem implements BranchStackResista
suppressThisFlag,
preloadThisFlag,
preloadGlobalFlag,
regCount, len, SWF.DEFAULT_VERSION, paramNames, paramRegs));
regCount, len, SWF.DEFAULT_VERSION, paramNames, paramRegs, charset));
}
return ret;

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionGetProperty;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
@@ -28,6 +29,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -136,7 +138,9 @@ public class GetPropertyActionItem extends ActionItem {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return toSourceMerge(localData, generator, target, new ActionPush((Long) (long) propertyIndex), new ActionGetProperty());
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, target, new ActionPush((Long) (long) propertyIndex, charset), new ActionGetProperty());
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.ecma.Undefined;
@@ -28,6 +29,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -94,7 +96,9 @@ public class GetURL2ActionItem extends ActionItem {
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
return toSourceMerge(localData, generator, urlString, targetString, new ActionGetURL2(sendVarsMethod, false, false), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, urlString, targetString, new ActionGetURL2(sendVarsMethod, false, false, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf3.ActionGetURL;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
@@ -25,6 +26,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.helpers.Helper;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -57,7 +59,9 @@ public class GetURLActionItem extends ActionItem {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return toSourceMerge(localData, generator, new ActionGetURL(urlString, targetString));
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, new ActionGetURL(urlString, targetString, charset));
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionGetVariable;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
@@ -24,6 +25,7 @@ import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
/**
@@ -45,7 +47,9 @@ public class GetVersionActionItem extends ActionItem {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return toSourceMerge(localData, generator, new ActionPush("/:$version"), new ActionGetVariable());
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, new ActionPush("/:$version", charset), new ActionGetVariable());
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf3.ActionGoToLabel;
import com.jpexs.decompiler.flash.action.swf3.ActionGotoFrame;
import com.jpexs.decompiler.flash.action.swf3.ActionPlay;
@@ -31,6 +32,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -96,12 +98,14 @@ public class GotoFrame2ActionItem extends ActionItem {
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
if (!sceneBiasFlag && (frame instanceof DirectValueActionItem) && (((DirectValueActionItem) frame).isString())) {
return toSourceMerge(localData, generator, new ActionGoToLabel(((DirectValueActionItem) frame).getAsString()), playFlag ? new ActionPlay() : null, needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
return toSourceMerge(localData, generator, new ActionGoToLabel(((DirectValueActionItem) frame).getAsString(), charset), playFlag ? new ActionPlay() : null, needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
} else if (!sceneBiasFlag && (frame instanceof DirectValueActionItem) && (((DirectValueActionItem) frame).value instanceof Long)) {
return toSourceMerge(localData, generator, new ActionGotoFrame((int) ((long) (Long) ((DirectValueActionItem) frame).value) - 1), playFlag ? new ActionPlay() : null, needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
return toSourceMerge(localData, generator, new ActionGotoFrame((int) ((long) (Long) ((DirectValueActionItem) frame).value) - 1, charset), playFlag ? new ActionPlay() : null, needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
} else {
return toSourceMerge(localData, generator, frame, new ActionGotoFrame2(playFlag, sceneBiasFlag, sceneBias), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
return toSourceMerge(localData, generator, frame, new ActionGotoFrame2(playFlag, sceneBiasFlag, sceneBias, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
}

View File

@@ -17,12 +17,14 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf3.ActionGotoFrame;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
/**
@@ -49,7 +51,9 @@ public class GotoFrameActionItem extends ActionItem {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return toSourceMerge(localData, generator, new ActionGotoFrame(frame));
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, new ActionGotoFrame(frame, charset));
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf3.ActionGoToLabel;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
@@ -24,6 +25,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.helpers.Helper;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -51,7 +53,9 @@ public class GotoLabelActionItem extends ActionItem {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return toSourceMerge(localData, generator, new ActionGoToLabel(label));
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, new ActionGoToLabel(label, charset));
}
@Override

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.action.swf5.ActionInitObject;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
@@ -29,6 +30,7 @@ import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.decompiler.graph.model.TernarOpItem;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -90,12 +92,14 @@ public class InitObjectActionItem extends ActionItem {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
List<GraphSourceItem> ret = new ArrayList<>();
for (int i = values.size() - 1; i >= 0; i--) {
ret.addAll(names.get(i).toSource(localData, generator));
ret.addAll(values.get(i).toSource(localData, generator));
}
ret.add(new ActionPush((Long) (long) values.size()));
ret.add(new ActionPush((Long) (long) values.size(), charset));
ret.add(new ActionInitObject());
return ret;
}

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.ecma.Undefined;
@@ -27,6 +28,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -84,7 +86,9 @@ public class LoadMovieActionItem extends ActionItem {
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
return toSourceMerge(localData, generator, urlString, targetString, new ActionGetURL2(method, false, true), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, urlString, targetString, new ActionGetURL2(method, false, true, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -29,6 +29,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -87,13 +88,14 @@ public class LoadMovieNumActionItem extends ActionItem {
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
Object lev;
if ((num instanceof DirectValueActionItem) && (((DirectValueActionItem) num).value instanceof Long)) {
lev = asGenerator.pushConstTargetItem("_level" + ((DirectValueActionItem) num).value);
} else {
lev = new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("_level"), num, true);
}
return toSourceMerge(localData, generator, urlString, lev, new ActionGetURL2(method, false, false), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
return toSourceMerge(localData, generator, urlString, lev, new ActionGetURL2(method, false, false, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.ecma.Undefined;
@@ -27,6 +28,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -84,7 +86,9 @@ public class LoadVariablesActionItem extends ActionItem {
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
return toSourceMerge(localData, generator, urlString, targetString, new ActionGetURL2(method, true, true), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, urlString, targetString, new ActionGetURL2(method, true, true, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -29,6 +29,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -87,13 +88,14 @@ public class LoadVariablesNumActionItem extends ActionItem {
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
Object lev;
if ((num instanceof DirectValueActionItem) && (((DirectValueActionItem) num).value instanceof Long)) {
lev = asGenerator.pushConstTargetItem("_level" + ((DirectValueActionItem) num).value);
} else {
lev = new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("_level"), num, true);
}
return toSourceMerge(localData, generator, urlString, lev, new ActionGetURL2(method, true, false), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
return toSourceMerge(localData, generator, urlString, lev, new ActionGetURL2(method, true, false, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf3.ActionNextFrame;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.ecma.Undefined;
@@ -25,6 +26,7 @@ import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
/**
@@ -55,7 +57,9 @@ public class NextFrameActionItem extends ActionItem {
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
return toSourceMerge(localData, generator, new ActionNextFrame(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, new ActionNextFrame(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf3.ActionPlay;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.ecma.Undefined;
@@ -25,6 +26,7 @@ import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
/**
@@ -55,7 +57,9 @@ public class PlayActionItem extends ActionItem {
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
return toSourceMerge(localData, generator, new ActionPlay(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, new ActionPlay(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.model.operations.SubtractActionItem;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem;
import com.jpexs.decompiler.flash.action.swf4.ActionPop;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
@@ -34,6 +35,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -101,6 +103,9 @@ public class PostDecrementActionItem extends ActionItem implements SetTypeAction
@Override
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
List<GraphSourceItem> ret = new ArrayList<>();
GraphTargetItem val = object;
@@ -124,9 +129,9 @@ public class PostDecrementActionItem extends ActionItem implements SetTypeAction
ret.add(new ActionSetMember());
} else if ((val instanceof DirectValueActionItem) && ((DirectValueActionItem) val).value instanceof RegisterNumber) {
RegisterNumber rn = (RegisterNumber) ((DirectValueActionItem) val).value;
ret.add(new ActionPush(new RegisterNumber(rn.number)));
ret.add(new ActionPush(new RegisterNumber(rn.number), charset));
ret.add(new ActionDecrement());
ret.add(new ActionStoreRegister(rn.number));
ret.add(new ActionStoreRegister(rn.number, charset));
ret.add(new ActionPop());
} else if (val instanceof GetPropertyActionItem) {
GetPropertyActionItem gp = (GetPropertyActionItem) val;

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.model.operations.AddActionItem;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem;
import com.jpexs.decompiler.flash.action.swf4.ActionPop;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
@@ -34,6 +35,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -101,6 +103,10 @@ public class PostIncrementActionItem extends ActionItem implements SetTypeAction
@Override
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
List<GraphSourceItem> ret = new ArrayList<>();
GraphTargetItem val = object;
@@ -124,9 +130,9 @@ public class PostIncrementActionItem extends ActionItem implements SetTypeAction
ret.add(new ActionSetMember());
} else if ((val instanceof DirectValueActionItem) && ((DirectValueActionItem) val).value instanceof RegisterNumber) {
RegisterNumber rn = (RegisterNumber) ((DirectValueActionItem) val).value;
ret.add(new ActionPush(new RegisterNumber(rn.number)));
ret.add(new ActionPush(new RegisterNumber(rn.number), charset));
ret.add(new ActionIncrement());
ret.add(new ActionStoreRegister(rn.number));
ret.add(new ActionStoreRegister(rn.number, charset));
ret.add(new ActionPop());
} else if (val instanceof GetPropertyActionItem) {
GetPropertyActionItem gp = (GetPropertyActionItem) val;

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf3.ActionPrevFrame;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.ecma.Undefined;
@@ -25,6 +26,7 @@ import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
/**
@@ -55,7 +57,9 @@ public class PrevFrameActionItem extends ActionItem {
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
return toSourceMerge(localData, generator, new ActionPrevFrame(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, new ActionPrevFrame(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -29,6 +29,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -77,7 +78,8 @@ public class PrintActionItem extends ActionItem {
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
return toSourceMerge(localData, generator, new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("print:#"), boundingBox, true), target, new ActionGetURL2(0, false, false), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("print:#"), boundingBox, true), target, new ActionGetURL2(0, false, false, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -29,6 +29,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -77,7 +78,8 @@ public class PrintAsBitmapActionItem extends ActionItem {
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
return toSourceMerge(localData, generator, new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("printasbitmap:#"), boundingBox, true), target, new ActionGetURL2(0, false, false), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("printasbitmap:#"), boundingBox, true), target, new ActionGetURL2(0, false, false, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -29,6 +29,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -77,13 +78,14 @@ public class PrintAsBitmapNumActionItem extends ActionItem {
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
Object lev;
if ((num instanceof DirectValueActionItem) && (((DirectValueActionItem) num).value instanceof Long)) {
lev = asGenerator.pushConstTargetItem("_level" + ((DirectValueActionItem) num).value);
} else {
lev = new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("_level"), num, true);
}
return toSourceMerge(localData, generator, new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("printasbitmap:#"), boundingBox, true), lev, new ActionGetURL2(0, false, false), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
return toSourceMerge(localData, generator, new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("printasbitmap:#"), boundingBox, true), lev, new ActionGetURL2(0, false, false, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -29,6 +29,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -77,13 +78,14 @@ public class PrintNumActionItem extends ActionItem {
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
Object lev;
if ((num instanceof DirectValueActionItem) && (((DirectValueActionItem) num).value instanceof Long)) {
lev = asGenerator.pushConstTargetItem("_level" + ((DirectValueActionItem) num).value);
} else {
lev = new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("_level"), num, true);
}
return toSourceMerge(localData, generator, new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("print:#"), boundingBox, true), lev, new ActionGetURL2(0, false, false), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
return toSourceMerge(localData, generator, new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("print:#"), boundingBox, true), lev, new ActionGetURL2(0, false, false, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.action.swf4.ActionRemoveSprite;
import com.jpexs.decompiler.flash.ecma.Undefined;
@@ -27,6 +28,7 @@ import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -67,7 +69,9 @@ public class RemoveSpriteActionItem extends ActionItem {
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
return toSourceMerge(localData, generator, value, new ActionRemoveSprite(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, value, new ActionRemoveSprite(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -35,6 +35,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.ExitItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -71,20 +72,20 @@ public class ReturnActionItem extends ActionItem implements ExitItem {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
List<GraphSourceItem> ret = new ArrayList<>();
String charset = asGenerator.getCharset(); List<GraphSourceItem> ret = new ArrayList<>();
int forinlevel = asGenerator.getForInLevel(localData);
for (int i = 0; i < forinlevel; i++) { //Must POP all remaining values from enumerations (for..in)
List<Action> forinret = new ArrayList<>();
forinret.add(new ActionPush(Null.INSTANCE));
forinret.add(new ActionPush(Null.INSTANCE, charset));
forinret.add(new ActionEquals2());
forinret.add(new ActionNot());
ActionIf aforinif = new ActionIf(0);
ActionIf aforinif = new ActionIf(0, charset);
forinret.add(aforinif);
aforinif.setJumpOffset(-Action.actionsToBytes(forinret, false, SWF.DEFAULT_VERSION).length);
ret.addAll(forinret);
}
if (value == null) {
ret.add(new ActionPush(Undefined.INSTANCE));
ret.add(new ActionPush(Undefined.INSTANCE, charset));
} else {
ret.addAll(value.toSource(localData, generator));
}

View File

@@ -32,6 +32,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -140,9 +141,9 @@ public class SetMemberActionItem extends ActionItem implements SetTypeActionItem
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
int tmpReg = asGenerator.getTempRegister(localData);
String charset = asGenerator.getCharset(); int tmpReg = asGenerator.getTempRegister(localData);
try {
return toSourceMerge(localData, generator, object, objectName, value, new ActionStoreRegister(tmpReg), new ActionSetMember(), new ActionPush(new RegisterNumber(tmpReg)));
return toSourceMerge(localData, generator, object, objectName, value, new ActionStoreRegister(tmpReg, charset), new ActionSetMember(), new ActionPush(new RegisterNumber(tmpReg), charset));
} finally {
asGenerator.releaseTempRegister(localData, tmpReg);
}

View File

@@ -31,6 +31,7 @@ import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -117,9 +118,10 @@ public class SetPropertyActionItem extends ActionItem implements SetTypeActionIt
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
int tmpReg = asGenerator.getTempRegister(localData);
try {
return toSourceMerge(localData, generator, target, new ActionPush((Long) (long) propertyIndex), value, new ActionStoreRegister(tmpReg), new ActionSetProperty(), new ActionPush(new RegisterNumber(tmpReg)));
return toSourceMerge(localData, generator, target, new ActionPush((Long) (long) propertyIndex, charset), value, new ActionStoreRegister(tmpReg, charset), new ActionSetProperty(), new ActionPush(new RegisterNumber(tmpReg), charset));
} finally {
asGenerator.releaseTempRegister(localData, tmpReg);
}
@@ -127,7 +129,9 @@ public class SetPropertyActionItem extends ActionItem implements SetTypeActionIt
@Override
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return toSourceMerge(localData, generator, target, new ActionPush((Long) (long) propertyIndex), value, new ActionSetProperty());
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, target, new ActionPush((Long) (long) propertyIndex, charset), value, new ActionSetProperty());
}
@Override

View File

@@ -33,6 +33,7 @@ import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
import java.util.Set;
@@ -156,13 +157,14 @@ public class SetVariableActionItem extends ActionItem implements SetTypeActionIt
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
if (forceUseSet) {
return toSourceMerge(localData, generator, name, value, new ActionSetVariable(), new ActionPush(Undefined.INSTANCE));
return toSourceMerge(localData, generator, name, value, new ActionSetVariable(), new ActionPush(Undefined.INSTANCE, charset));
}
int tmpReg = asGenerator.getTempRegister(localData);
try {
return toSourceMerge(localData, generator, name, value, new ActionStoreRegister(tmpReg), new ActionSetVariable(), new ActionPush(new RegisterNumber(tmpReg)));
return toSourceMerge(localData, generator, name, value, new ActionStoreRegister(tmpReg, charset), new ActionSetVariable(), new ActionPush(new RegisterNumber(tmpReg), charset));
} finally {
asGenerator.releaseTempRegister(localData, tmpReg);
}

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.action.swf4.ActionStartDrag;
import com.jpexs.decompiler.flash.ecma.Undefined;
@@ -29,6 +30,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.FalseItem;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.decompiler.graph.model.TrueItem;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -113,6 +115,10 @@ public class StartDragActionItem extends ActionItem {
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
boolean hasConstrains = true;
if (constrain instanceof DirectValueActionItem) {
if (Double.compare(constrain.getResultAsNumber(), 0) == 0) {
@@ -120,9 +126,9 @@ public class StartDragActionItem extends ActionItem {
}
}
if (hasConstrains) {
return toSourceMerge(localData, generator, x1, y1, x2, y2, constrain, lockCenter, target, new ActionStartDrag(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
return toSourceMerge(localData, generator, x1, y1, x2, y2, constrain, lockCenter, target, new ActionStartDrag(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
} else {
return toSourceMerge(localData, generator, constrain, lockCenter, target, new ActionStartDrag(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
return toSourceMerge(localData, generator, constrain, lockCenter, target, new ActionStartDrag(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
}

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf3.ActionStop;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.ecma.Undefined;
@@ -25,6 +26,7 @@ import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
/**
@@ -55,7 +57,9 @@ public class StopActionItem extends ActionItem {
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
return toSourceMerge(localData, generator, new ActionStop(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, new ActionStop(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf3.ActionStopSounds;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.ecma.Undefined;
@@ -25,6 +26,7 @@ import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
/**
@@ -55,7 +57,9 @@ public class StopAllSoundsActionItem extends ActionItem {
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
return toSourceMerge(localData, generator, new ActionStopSounds(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, new ActionStopSounds(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionEndDrag;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.ecma.Undefined;
@@ -25,6 +26,7 @@ import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
/**
@@ -55,7 +57,9 @@ public class StopDragActionItem extends ActionItem {
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
return toSourceMerge(localData, generator, new ActionEndDrag(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, new ActionEndDrag(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
@@ -30,6 +31,7 @@ import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
import java.util.Set;
@@ -125,7 +127,9 @@ public class StoreRegisterActionItem extends ActionItem implements SetTypeAction
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return toSourceMerge(localData, generator, value, new ActionStoreRegister(register.number));
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, value, new ActionStoreRegister(register.number, charset));
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf3.ActionToggleQuality;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.ecma.Undefined;
@@ -25,6 +26,7 @@ import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
/**
@@ -60,7 +62,9 @@ public class ToggleHighQualityActionItem extends ActionItem {
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
return toSourceMerge(localData, generator, new ActionToggleQuality(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, new ActionToggleQuality(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.action.swf4.ActionTrace;
import com.jpexs.decompiler.flash.ecma.Undefined;
@@ -27,6 +28,7 @@ import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -67,7 +69,9 @@ public class TraceActionItem extends ActionItem {
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
return toSourceMerge(localData, generator, value, new ActionTrace(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, value, new ActionTrace(), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.ecma.Undefined;
@@ -27,6 +28,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -68,7 +70,9 @@ public class UnLoadMovieActionItem extends ActionItem {
}
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
return toSourceMerge(localData, generator, new ActionPush(""), targetString, new ActionGetURL2(0, false, true), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, new ActionPush("", charset), targetString, new ActionGetURL2(0, false, true, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
@Override

View File

@@ -30,6 +30,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
@@ -72,10 +73,11 @@ public class UnLoadMovieNumActionItem extends ActionItem {
private List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
if ((num instanceof DirectValueActionItem) && (((DirectValueActionItem) num).value instanceof Long)) {
return toSourceMerge(localData, generator, new ActionGetURL("", "_level" + ((DirectValueActionItem) num).value), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
return toSourceMerge(localData, generator, new ActionGetURL("", "_level" + ((DirectValueActionItem) num).value, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
} else {
return toSourceMerge(localData, generator, new ActionPush(""), new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("_level"), num, true), new ActionGetURL2(0, false, true), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}) : null);
return toSourceMerge(localData, generator, new ActionPush("", charset), new AddActionItem(getSrc(), getLineStartItem(), asGenerator.pushConstTargetItem("_level"), num, true), new ActionGetURL2(0, false, true, charset), needsReturn ? new ActionPush(new Object[]{Undefined.INSTANCE, Undefined.INSTANCE}, charset) : null);
}
}

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.action.swf4.ConstantIndex;
import com.jpexs.decompiler.flash.ecma.Undefined;
@@ -27,6 +28,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SimpleValue;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
import java.util.Set;
@@ -139,7 +141,9 @@ public class UnresolvedConstantActionItem extends ActionItem implements SimpleVa
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return toSourceMerge(localData, generator, new ActionPush(new ConstantIndex(index)));
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
return toSourceMerge(localData, generator, new ActionPush(new ConstantIndex(index), charset));
}
@Override

View File

@@ -45,6 +45,7 @@ import com.jpexs.decompiler.graph.Loop;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -159,6 +160,7 @@ public class ForInActionItem extends LoopActionItem implements Block {
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
List<GraphSourceItem> ret = new ArrayList<>();
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
HashMap<String, Integer> registerVars = asGenerator.getRegisterVars(localData);
ret.addAll(enumVariable.toSource(localData, generator));
ret.add(new ActionEnumerate2());
@@ -166,10 +168,10 @@ public class ForInActionItem extends LoopActionItem implements Block {
List<Action> loopExpr = new ArrayList<>();
int exprReg = asGenerator.getTempRegister(localData);
loopExpr.add(new ActionStoreRegister(exprReg));
loopExpr.add(new ActionPush(Null.INSTANCE));
loopExpr.add(new ActionStoreRegister(exprReg, charset));
loopExpr.add(new ActionPush(Null.INSTANCE, charset));
loopExpr.add(new ActionEquals2());
ActionIf forInEndIf = new ActionIf(0);
ActionIf forInEndIf = new ActionIf(0, charset);
loopExpr.add(forInEndIf);
List<Action> loopBody = new ArrayList<>();
@@ -184,7 +186,7 @@ public class ForInActionItem extends LoopActionItem implements Block {
asGenerator.setForInLevel(localData, oldForIn + 1);
loopBody.addAll(asGenerator.toActionList(asGenerator.generate(localData, commands)));
asGenerator.setForInLevel(localData, oldForIn);
ActionJump forinJmpBack = new ActionJump(0);
ActionJump forinJmpBack = new ActionJump(0, charset);
loopBody.add(forinJmpBack);
int bodyLen = Action.actionsToBytes(loopBody, false, SWF.DEFAULT_VERSION).length;
int exprLen = Action.actionsToBytes(loopExpr, false, SWF.DEFAULT_VERSION).length;

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model.clauses;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.model.ActionItem;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionWaitForFrame2;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.Block;
@@ -29,6 +30,7 @@ import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
@@ -94,7 +96,9 @@ public class IfFrameLoadedActionItem extends ActionItem implements Block {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
List<GraphSourceItem> body = generator.generate(localData, actions);
return toSourceMerge(localData, generator, frame, new ActionWaitForFrame2(body.size()), body);
ActionSourceGenerator actionGenerator = (ActionSourceGenerator) generator;
String charset = actionGenerator.getCharset();
return toSourceMerge(localData, generator, frame, new ActionWaitForFrame2(body.size(), charset), body);
}
@Override

View File

@@ -34,6 +34,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
@@ -82,22 +83,23 @@ public class TellTargetActionItem extends ActionItem implements Block {
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
List<GraphSourceItem> ret = new ArrayList<>();
ActionSourceGenerator actionGenerator = (ActionSourceGenerator) generator;
String charset = actionGenerator.getCharset();
if (nested) {
ret.add(new ActionPush(""));
ret.add(new ActionPush(11)); //_target
ret.add(new ActionPush("", charset));
ret.add(new ActionPush(11, charset)); //_target
ret.add(new ActionGetProperty());
}
if ((target instanceof DirectValueActionItem) && ((((DirectValueActionItem) target).value instanceof String) || (((DirectValueActionItem) target).value instanceof ConstantIndex))) {
ret.add(new ActionSetTarget((String) target.getResult()));
ret.add(new ActionSetTarget((String) target.getResult(), charset));
} else {
ret.addAll(target.toSource(localData, generator));
ret.add(new ActionSetTarget2());
ret.add(new ActionSetTarget2(charset));
}
ret.addAll(generator.generate(localData, commands));
ret.add(new ActionSetTarget(""));
ret.add(new ActionSetTarget("", charset));
if (nested) {
ret.add(new ActionSetTarget2());
ret.add(new ActionSetTarget2(charset));
}
return ret;
}

View File

@@ -44,6 +44,7 @@ import com.jpexs.decompiler.graph.GraphTargetVisitorInterface;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
@@ -178,6 +179,7 @@ public class TryActionItem extends ActionItem implements Block {
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
List<GraphSourceItem> ret = new ArrayList<>();
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
List<Action> tryCommandsA = asGenerator.toActionList(asGenerator.generate(localData, tryCommands));
List<Action> finallyCommandsA = finallyCommands == null ? null : asGenerator.toActionList(asGenerator.generate(localData, finallyCommands));
List<Action> catchCommandsA = null;
@@ -212,7 +214,7 @@ public class TryActionItem extends ActionItem implements Block {
if (!allCatched) {
fullCatchBody.addAll(0, GraphTargetItem.toSourceMerge(localData, generator,
new ActionPush(new RegisterNumber(catchRegister)),
new ActionPush(new RegisterNumber(catchRegister), charset),
new ActionThrow()
));
}
@@ -225,19 +227,19 @@ public class TryActionItem extends ActionItem implements Block {
fullCatchBody.addAll(0, GraphTargetItem.toSourceMerge(localData, generator,
new DirectValueActionItem(new RegisterNumber(catchRegister)),
ename,
new ActionStackSwap(),
new ActionStackSwap(charset),
new ActionDefineLocal(),
ebody
));
} else {
List<GraphSourceItem> ifBody = GraphTargetItem.toSourceMerge(localData, generator,
ename,
new ActionStackSwap(),
new ActionStackSwap(charset),
new ActionDefineLocal(),
ebody);
fullCatchBody.add(0, new ActionPop());
int toFinishSize = Action.actionsToBytes(asGenerator.toActionList(fullCatchBody), false, SWF.DEFAULT_VERSION).length;
ActionJump finishJump = new ActionJump(toFinishSize);
ActionJump finishJump = new ActionJump(toFinishSize, charset);
ifBody.add(finishJump);
List<Action> ifBodyA = asGenerator.toActionList(ifBody);
int ifBodySize = Action.actionsToBytes(ifBodyA, false, SWF.DEFAULT_VERSION).length;
@@ -245,12 +247,12 @@ public class TryActionItem extends ActionItem implements Block {
fullCatchBody.addAll(0,
GraphTargetItem.toSourceMerge(localData, generator,
etype,
new ActionPush(new RegisterNumber(catchRegister)),
new ActionPush(new RegisterNumber(catchRegister), charset),
new ActionCastOp(),
new ActionPushDuplicate(),
new ActionPush(Null.INSTANCE),
new ActionPushDuplicate(charset),
new ActionPush(Null.INSTANCE, charset),
new ActionEquals2(),
new ActionIf(ifBodySize)
new ActionIf(ifBodySize, charset)
));
}
@@ -259,14 +261,14 @@ public class TryActionItem extends ActionItem implements Block {
}
catchCommandsA = asGenerator.toActionList(fullCatchBody);
catchSize = Action.actionsToBytes(catchCommandsA, false, SWF.DEFAULT_VERSION).length;
tryCommandsA.add(new ActionJump(catchSize));
tryCommandsA.add(new ActionJump(catchSize, charset));
}
int finallySize = 0;
if (finallyCommandsA != null) {
finallySize = Action.actionsToBytes(finallyCommandsA, false, SWF.DEFAULT_VERSION).length;
}
int trySize = Action.actionsToBytes(tryCommandsA, false, SWF.DEFAULT_VERSION).length;
ret.add(new ActionTry(catchInRegisterFlag, finallyCommands != null, !catchCommands.isEmpty(), catchName, catchRegister, trySize, catchSize, finallySize, SWF.DEFAULT_VERSION));
ret.add(new ActionTry(catchInRegisterFlag, finallyCommands != null, !catchCommands.isEmpty(), catchName, catchRegister, trySize, catchSize, finallySize, SWF.DEFAULT_VERSION, charset));
ret.addAll(tryCommandsA);
if (catchCommandsA != null) {
ret.addAll(catchCommandsA);

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.ActionItem;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf5.ActionWith;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
@@ -27,6 +28,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
@@ -68,6 +70,8 @@ public class WithActionItem extends ActionItem {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
List<GraphSourceItem> data = generator.generate(localData, items);
List<Action> dataA = new ArrayList<>();
for (GraphSourceItem s : data) {
@@ -76,7 +80,7 @@ public class WithActionItem extends ActionItem {
}
}
int codeLen = Action.actionsToBytes(dataA, false, SWF.DEFAULT_VERSION).length;
return toSourceMerge(localData, generator, scope, new ActionWith(codeLen), data);
return toSourceMerge(localData, generator, scope, new ActionWith(codeLen, charset), data);
}
@Override

View File

@@ -35,6 +35,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.UnaryOpItem;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
@@ -56,6 +57,7 @@ public class PreDecrementActionItem extends UnaryOpItem {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
List<GraphSourceItem> ret = new ArrayList<>();
GraphTargetItem val = value;
if (val instanceof VariableActionItem) {
@@ -68,9 +70,9 @@ public class PreDecrementActionItem extends UnaryOpItem {
ret.addAll(gv.toSource(localData, generator));
ret.add(new ActionDecrement());
int tmpReg = asGenerator.getTempRegister(localData);
ret.add(new ActionStoreRegister(tmpReg));
ret.add(new ActionStoreRegister(tmpReg, charset));
ret.add(new ActionSetVariable());
ret.add(new ActionPush(new RegisterNumber(tmpReg)));
ret.add(new ActionPush(new RegisterNumber(tmpReg), charset));
asGenerator.releaseTempRegister(localData, tmpReg);
} else if (val instanceof GetMemberActionItem) {
GetMemberActionItem mem = (GetMemberActionItem) val;
@@ -79,15 +81,15 @@ public class PreDecrementActionItem extends UnaryOpItem {
ret.addAll(mem.toSource(localData, generator));
ret.add(new ActionDecrement());
int tmpReg = asGenerator.getTempRegister(localData);
ret.add(new ActionStoreRegister(tmpReg));
ret.add(new ActionStoreRegister(tmpReg, charset));
ret.add(new ActionSetMember());
ret.add(new ActionPush(new RegisterNumber(tmpReg)));
ret.add(new ActionPush(new RegisterNumber(tmpReg), charset));
asGenerator.releaseTempRegister(localData, tmpReg);
} else if ((val instanceof DirectValueActionItem) && ((DirectValueActionItem) val).value instanceof RegisterNumber) {
RegisterNumber rn = (RegisterNumber) ((DirectValueActionItem) val).value;
ret.add(new ActionPush(new RegisterNumber(rn.number)));
ret.add(new ActionPush(new RegisterNumber(rn.number), charset));
ret.add(new ActionDecrement());
ret.add(new ActionStoreRegister(rn.number));
ret.add(new ActionStoreRegister(rn.number, charset));
} else if (val instanceof GetPropertyActionItem) {
GetPropertyActionItem gp = (GetPropertyActionItem) val;
ret.addAll(gp.toSource(localData, generator)); // old value

View File

@@ -35,6 +35,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.UnaryOpItem;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
@@ -56,6 +57,7 @@ public class PreIncrementActionItem extends UnaryOpItem {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
String charset = asGenerator.getCharset();
List<GraphSourceItem> ret = new ArrayList<>();
GraphTargetItem val = value;
if (val instanceof VariableActionItem) {
@@ -69,9 +71,9 @@ public class PreIncrementActionItem extends UnaryOpItem {
ret.add(new ActionIncrement());
int tmpReg = asGenerator.getTempRegister(localData);
ret.add(new ActionStoreRegister(tmpReg));
ret.add(new ActionStoreRegister(tmpReg, charset));
ret.add(new ActionSetVariable());
ret.add(new ActionPush(new RegisterNumber(tmpReg)));
ret.add(new ActionPush(new RegisterNumber(tmpReg), charset));
asGenerator.releaseTempRegister(localData, tmpReg);
} else if (val instanceof GetMemberActionItem) {
GetMemberActionItem mem = (GetMemberActionItem) val;
@@ -80,15 +82,15 @@ public class PreIncrementActionItem extends UnaryOpItem {
ret.addAll(mem.toSource(localData, generator));
ret.add(new ActionIncrement());
int tmpReg = asGenerator.getTempRegister(localData);
ret.add(new ActionStoreRegister(tmpReg));
ret.add(new ActionStoreRegister(tmpReg, charset));
ret.add(new ActionSetMember());
ret.add(new ActionPush(new RegisterNumber(tmpReg)));
ret.add(new ActionPush(new RegisterNumber(tmpReg), charset));
asGenerator.releaseTempRegister(localData, tmpReg);
} else if ((val instanceof DirectValueActionItem) && ((DirectValueActionItem) val).value instanceof RegisterNumber) {
RegisterNumber rn = (RegisterNumber) ((DirectValueActionItem) val).value;
ret.add(new ActionPush(new RegisterNumber(rn.number)));
ret.add(new ActionPush(new RegisterNumber(rn.number), charset));
ret.add(new ActionIncrement());
ret.add(new ActionStoreRegister(rn.number));
ret.add(new ActionStoreRegister(rn.number, charset));
} else if (val instanceof GetPropertyActionItem) {
GetPropertyActionItem gp = (GetPropertyActionItem) val;
ret.addAll(gp.toSource(localData, generator)); // old value

View File

@@ -129,6 +129,7 @@ import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import com.jpexs.helpers.Helper;
import java.io.IOException;
import java.io.StringReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -145,11 +146,11 @@ public class ASMParser {
private static final Logger logger = Logger.getLogger(ASMParser.class.getName());
public static ActionList parse(boolean ignoreNops, List<Label> labels, Map<Action, Integer> lineMap, long address, FlasmLexer lexer, List<String> constantPool, int version) throws IOException, ActionParseException {
ActionList list = new ActionList();
public static ActionList parse(boolean ignoreNops, List<Label> labels, Map<Action, Integer> lineMap, long address, FlasmLexer lexer, List<String> constantPool, int version, String charset) throws IOException, ActionParseException {
ActionList list = new ActionList(charset);
Stack<GraphSourceItemContainer> containers = new Stack<>();
ActionConstantPool cpool = new ActionConstantPool(constantPool);
ActionConstantPool cpool = new ActionConstantPool(constantPool, charset);
cpool.setAddress(address);
address += cpool.getTotalActionLength();
list.add(cpool);
@@ -183,7 +184,7 @@ public class ASMParser {
}
} else if (symb.type == ASMParsedSymbol.TYPE_INSTRUCTION_NAME) {
String instructionName = (String) symb.value;
Action a = parseAction(instructionName, lexer, constantPool, version);
Action a = parseAction(instructionName, lexer, constantPool, version, charset);
if (ignoreNops && a instanceof ActionNop) {
a = null;
}
@@ -213,14 +214,14 @@ public class ASMParser {
}
}
private static Action parseAction(String instructionName, FlasmLexer lexer, List<String> constantPool, int version) throws IOException, ActionParseException {
private static Action parseAction(String instructionName, FlasmLexer lexer, List<String> constantPool, int version, String charset) throws IOException, ActionParseException {
Action a = null;
if (instructionName.compareToIgnoreCase("GetURL") == 0) {
a = new ActionGetURL(lexer);
a = new ActionGetURL(lexer, charset);
} else if (instructionName.compareToIgnoreCase("GoToLabel") == 0) {
a = new ActionGoToLabel(lexer);
a = new ActionGoToLabel(lexer, charset);
} else if (instructionName.compareToIgnoreCase("GotoFrame") == 0) {
a = new ActionGotoFrame(lexer);
a = new ActionGotoFrame(lexer, charset);
} else if (instructionName.compareToIgnoreCase("NextFrame") == 0) {
a = new ActionNextFrame();
} else if (instructionName.compareToIgnoreCase("Play") == 0) {
@@ -228,7 +229,7 @@ public class ASMParser {
} else if (instructionName.compareToIgnoreCase("PrevFrame") == 0) {
a = new ActionPrevFrame();
} else if (instructionName.compareToIgnoreCase("SetTarget") == 0) {
a = new ActionSetTarget(lexer);
a = new ActionSetTarget(lexer,charset);
} else if (instructionName.compareToIgnoreCase("Stop") == 0) {
a = new ActionStop();
} else if (instructionName.compareToIgnoreCase("StopSounds") == 0) {
@@ -236,7 +237,7 @@ public class ASMParser {
} else if (instructionName.compareToIgnoreCase("ToggleQuality") == 0) {
a = new ActionToggleQuality();
} else if (instructionName.compareToIgnoreCase("WaitForFrame") == 0) {
a = new ActionWaitForFrame(lexer);
a = new ActionWaitForFrame(lexer,charset);
} else if (instructionName.compareToIgnoreCase("Add") == 0) {
a = new ActionAdd();
} else if (instructionName.compareToIgnoreCase("And") == 0) {
@@ -254,21 +255,21 @@ public class ASMParser {
} else if (instructionName.compareToIgnoreCase("EndDrag") == 0) {
a = new ActionEndDrag();
} else if (instructionName.compareToIgnoreCase("Equals") == 0) {
a = new ActionEquals();
a = new ActionEquals(charset);
} else if (instructionName.compareToIgnoreCase("GetProperty") == 0) {
a = new ActionGetProperty();
} else if (instructionName.compareToIgnoreCase("GetTime") == 0) {
a = new ActionGetTime();
} else if (instructionName.compareToIgnoreCase("GetURL2") == 0) {
a = new ActionGetURL2(lexer);
a = new ActionGetURL2(lexer,charset);
} else if (instructionName.compareToIgnoreCase("GetVariable") == 0) {
a = new ActionGetVariable();
} else if (instructionName.compareToIgnoreCase("GotoFrame2") == 0) {
a = new ActionGotoFrame2(lexer);
a = new ActionGotoFrame2(lexer,charset);
} else if (instructionName.compareToIgnoreCase("If") == 0) {
a = new ActionIf(lexer);
a = new ActionIf(lexer,charset);
} else if (instructionName.compareToIgnoreCase("Jump") == 0) {
a = new ActionJump(lexer);
a = new ActionJump(lexer,charset);
} else if (instructionName.compareToIgnoreCase("Less") == 0) {
a = new ActionLess();
} else if (instructionName.compareToIgnoreCase("MBAsciiToChar") == 0) {
@@ -288,7 +289,7 @@ public class ASMParser {
} else if (instructionName.compareToIgnoreCase("Pop") == 0) {
a = new ActionPop();
} else if (instructionName.compareToIgnoreCase("Push") == 0) {
a = new ActionPush(lexer, constantPool);
a = new ActionPush(lexer, constantPool, charset);
} else if (instructionName.compareToIgnoreCase("RandomNumber") == 0) {
a = new ActionRandomNumber();
} else if (instructionName.compareToIgnoreCase("RemoveSprite") == 0) {
@@ -296,7 +297,7 @@ public class ASMParser {
} else if (instructionName.compareToIgnoreCase("SetProperty") == 0) {
a = new ActionSetProperty();
} else if (instructionName.compareToIgnoreCase("SetTarget2") == 0) {
a = new ActionSetTarget2();
a = new ActionSetTarget2(charset);
} else if (instructionName.compareToIgnoreCase("SetVariable") == 0) {
a = new ActionSetVariable();
} else if (instructionName.compareToIgnoreCase("StartDrag") == 0) {
@@ -318,7 +319,7 @@ public class ASMParser {
} else if (instructionName.compareToIgnoreCase("Trace") == 0) {
a = new ActionTrace();
} else if (instructionName.compareToIgnoreCase("WaitForFrame2") == 0) {
a = new ActionWaitForFrame2(lexer);
a = new ActionWaitForFrame2(lexer, charset);
} else if (instructionName.compareToIgnoreCase("Add2") == 0) {
a = new ActionAdd2();
} else if (instructionName.compareToIgnoreCase("BitAnd") == 0) {
@@ -338,11 +339,11 @@ public class ASMParser {
} else if (instructionName.compareToIgnoreCase("CallMethod") == 0) {
a = new ActionCallMethod();
} else if (instructionName.compareToIgnoreCase("ConstantPool") == 0) {
a = new ActionConstantPool(lexer);
a = new ActionConstantPool(lexer, charset);
} else if (instructionName.compareToIgnoreCase("Decrement") == 0) {
a = new ActionDecrement();
} else if (instructionName.compareToIgnoreCase("DefineFunction") == 0) {
a = new ActionDefineFunction(lexer);
a = new ActionDefineFunction(lexer, charset);
} else if (instructionName.compareToIgnoreCase("DefineLocal") == 0) {
a = new ActionDefineLocal();
} else if (instructionName.compareToIgnoreCase("DefineLocal2") == 0) {
@@ -372,15 +373,15 @@ public class ASMParser {
} else if (instructionName.compareToIgnoreCase("NewObject") == 0) {
a = new ActionNewObject();
} else if (instructionName.compareToIgnoreCase("PushDuplicate") == 0) {
a = new ActionPushDuplicate();
a = new ActionPushDuplicate(charset);
} else if (instructionName.compareToIgnoreCase("Return") == 0) {
a = new ActionReturn();
} else if (instructionName.compareToIgnoreCase("SetMember") == 0) {
a = new ActionSetMember();
} else if (instructionName.compareToIgnoreCase("StackSwap") == 0) {
a = new ActionStackSwap();
a = new ActionStackSwap(charset);
} else if (instructionName.compareToIgnoreCase("StoreRegister") == 0) {
a = new ActionStoreRegister(lexer);
a = new ActionStoreRegister(lexer, charset);
} else if (instructionName.compareToIgnoreCase("TargetPath") == 0) {
a = new ActionTargetPath();
} else if (instructionName.compareToIgnoreCase("ToNumber") == 0) {
@@ -390,7 +391,7 @@ public class ASMParser {
} else if (instructionName.compareToIgnoreCase("TypeOf") == 0) {
a = new ActionTypeOf();
} else if (instructionName.compareToIgnoreCase("With") == 0) {
a = new ActionWith(lexer);
a = new ActionWith(lexer, charset);
} else if (instructionName.compareToIgnoreCase("Enumerate2") == 0) {
a = new ActionEnumerate2();
} else if (instructionName.compareToIgnoreCase("Greater") == 0) {
@@ -404,30 +405,30 @@ public class ASMParser {
} else if (instructionName.compareToIgnoreCase("CastOp") == 0) {
a = new ActionCastOp();
} else if (instructionName.compareToIgnoreCase("DefineFunction2") == 0) {
a = new ActionDefineFunction2(lexer);
a = new ActionDefineFunction2(lexer, charset);
} else if (instructionName.compareToIgnoreCase("Extends") == 0) {
a = new ActionExtends();
a = new ActionExtends(charset);
} else if (instructionName.compareToIgnoreCase("ImplementsOp") == 0) {
a = new ActionImplementsOp();
a = new ActionImplementsOp(charset);
} else if (instructionName.compareToIgnoreCase("Throw") == 0) {
a = new ActionThrow();
} else if (instructionName.compareToIgnoreCase("Try") == 0) {
a = new ActionTry(lexer, version);
a = new ActionTry(lexer, version, charset);
} else if (instructionName.compareToIgnoreCase("FSCommand2") == 0) {
a = new ActionFSCommand2();
a = new ActionFSCommand2(charset);
} else if (instructionName.compareToIgnoreCase("StrictMode") == 0) {
a = new ActionStrictMode(lexer);
a = new ActionStrictMode(lexer, charset);
} else if (instructionName.compareToIgnoreCase("Nop") == 0) {
a = new ActionNop();
a = new ActionNop(charset);
} else if (instructionName.compareToIgnoreCase("End") == 0) {
a = new ActionEnd();
a = new ActionEnd(charset);
} else if (instructionName.compareToIgnoreCase("FFDec_DeobfuscatePop") == 0) {
a = new ActionDeobfuscatePop();
} else if (instructionName.compareToIgnoreCase("FFDec_DeobfuscateJump") == 0) {
a = new ActionDeobfuscateJump(lexer);
a = new ActionDeobfuscateJump(lexer, charset);
} else if (instructionName.length() == 10 && instructionName.substring(0, 8).compareToIgnoreCase("Unknown_") == 0) {
int actionCode = Integer.parseInt(instructionName.substring(8), 16);
a = new ActionUnknown(actionCode, 0);
a = new ActionUnknown(actionCode, 0, charset);
} else {
throw new ActionParseException("Unknown instruction name :" + instructionName, lexer.yyline());
}
@@ -436,7 +437,7 @@ public class ASMParser {
return a;
}
private static List<Action> parseAllActions(FlasmLexer lexer, int version) throws IOException, ActionParseException {
private static List<Action> parseAllActions(FlasmLexer lexer, int version, String charset) throws IOException, ActionParseException {
List<Action> list = new ArrayList<>();
Stack<GraphSourceItemContainer> containers = new Stack<>();
List<String> emptyList = new ArrayList<>();
@@ -452,7 +453,7 @@ public class ASMParser {
}
} else if (symb.type == ASMParsedSymbol.TYPE_INSTRUCTION_NAME) {
String instructionName = (String) symb.value;
Action a = parseAction(instructionName, lexer, emptyList, version);
Action a = parseAction(instructionName, lexer, emptyList, version, charset);
if (a instanceof GraphSourceItemContainer) {
containers.push((GraphSourceItemContainer) a);
}
@@ -465,9 +466,9 @@ public class ASMParser {
}
}
public static ActionList parse(long address, boolean ignoreNops, String source, int version, boolean throwOnError) throws IOException, ActionParseException {
public static ActionList parse(long address, boolean ignoreNops, String source, int version, boolean throwOnError, String charset) throws IOException, ActionParseException {
FlasmLexer lexer = new FlasmLexer(new StringReader(source));
List<Action> list = parseAllActions(lexer, version);
List<Action> list = parseAllActions(lexer, version, charset);
List<String> constantPool = new ArrayList<>();
for (Action a : list) {
@@ -479,7 +480,7 @@ public class ASMParser {
lexer = new FlasmLexer(new StringReader(source));
List<Label> labels = new ArrayList<>();
Map<Action, Integer> lineMap = new HashMap<>();
ActionList ret = parse(ignoreNops, labels, lineMap, address, lexer, constantPool, version);
ActionList ret = parse(ignoreNops, labels, lineMap, address, lexer, constantPool, version, charset);
//Action.setActionsAddresses(ret, address, version);
for (Action link : ret) {
if (!(link instanceof ActionIf || link instanceof ActionJump)) {
@@ -559,7 +560,7 @@ public class ASMParser {
}
if (ret.size() == 0 || !(ret.get(ret.size() - 1) instanceof ActionEnd)) {
ret.add(new ActionEnd());
ret.add(new ActionEnd(charset));
}
return ret;

View File

@@ -165,6 +165,7 @@ import com.jpexs.decompiler.graph.model.WhileItem;
import com.jpexs.helpers.Reference;
import java.io.IOException;
import java.io.StringReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -229,9 +230,11 @@ public class ActionScript2Parser {
private final int swfVersion;
private List<String> swfClasses = new ArrayList<>();
private final ASMSource targetSource;
private String charset;
public ActionScript2Parser(SWF swf, ASMSource targetSource) {
this.swfVersion = swf.version;
this.charset = swf.getCharset();
parseSwfClasses(swf);
this.targetSource = targetSource;
}
@@ -2333,12 +2336,12 @@ public class ActionScript2Parser {
}
private List<GraphSourceItem> generateActionList(List<GraphTargetItem> tree, List<String> constantPool) throws CompilationException {
ActionSourceGenerator gen = new ActionSourceGenerator(swfVersion, constantPool);
ActionSourceGenerator gen = new ActionSourceGenerator(swfVersion, constantPool, charset);
SourceGeneratorLocalData localData = new SourceGeneratorLocalData(new HashMap<>(), 0, Boolean.FALSE, 0);
return gen.generate(localData, tree);
}
private List<Action> actionsFromTree(List<GraphTargetItem> tree, List<String> constantPool, boolean doOrder) throws CompilationException, NeedsGenerateAgainException {
private List<Action> actionsFromTree(List<GraphTargetItem> tree, List<String> constantPool, boolean doOrder, String charset) throws CompilationException, NeedsGenerateAgainException {
List<Action> ret = new ArrayList<>();
List<GraphSourceItem> srcList = generateActionList(tree, constantPool);
@@ -2389,21 +2392,21 @@ public class ActionScript2Parser {
ret.add((Action) s);
}
}
ret.add(0, new ActionConstantPool(constantPool));
ret.add(0, new ActionConstantPool(constantPool, charset));
return ret;
}
public List<Action> actionsFromString(String s) throws ActionParseException, IOException, CompilationException, InterruptedException {
public List<Action> actionsFromString(String s, String charset) throws ActionParseException, IOException, CompilationException, InterruptedException {
try {
List<String> constantPool = new ArrayList<>();
List<GraphTargetItem> tree = treeFromString(s, constantPool);
return actionsFromTree(tree, constantPool, true);
return actionsFromTree(tree, constantPool, true, charset);
} catch (NeedsGenerateAgainException nga) {
//Can happen when constantpool needs reordering and number of constants > 256
try {
List<String> newConstantPool = nga.getNewConstantPool();
List<GraphTargetItem> tree = treeFromString(s, newConstantPool);
return actionsFromTree(tree, newConstantPool, false /*do not order again*/);
return actionsFromTree(tree, newConstantPool, false /*do not order again*/, charset);
} catch (NeedsGenerateAgainException ex) {
//should not happen as doOrder parameter is set to false
return new ArrayList<>();

View File

@@ -69,6 +69,7 @@ import com.jpexs.decompiler.graph.model.TernarOpItem;
import com.jpexs.decompiler.graph.model.TrueItem;
import com.jpexs.decompiler.graph.model.WhileItem;
import com.jpexs.helpers.Helper;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -82,26 +83,32 @@ import java.util.Set;
*/
public class ActionSourceGenerator implements SourceGenerator {
private final List<String> constantPool;
private final int swfVersion;
private String charset;
@Override
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, FalseItem item) throws CompilationException {
return GraphTargetItem.toSourceMerge(localData, this, new ActionPush(Boolean.FALSE));
return GraphTargetItem.toSourceMerge(localData, this, new ActionPush(Boolean.FALSE, charset));
}
@Override
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, TrueItem item) throws CompilationException {
return GraphTargetItem.toSourceMerge(localData, this, new ActionPush(Boolean.TRUE));
return GraphTargetItem.toSourceMerge(localData, this, new ActionPush(Boolean.TRUE, charset));
}
@Override
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, AndItem item) throws CompilationException {
List<GraphSourceItem> ret = new ArrayList<>();
ret.addAll(generateToActionList(localData, item.leftSide));
ret.add(new ActionPushDuplicate());
ret.add(new ActionPushDuplicate(charset));
ret.add(new ActionNot());
List<Action> andExpr = generateToActionList(localData, item.rightSide);
andExpr.add(0, new ActionPop());
int andExprLen = Action.actionsToBytes(andExpr, false, SWF.DEFAULT_VERSION).length;
ret.add(new ActionIf(andExprLen));
ret.add(new ActionIf(andExprLen,charset));
ret.addAll(andExpr);
return ret;
@@ -111,11 +118,11 @@ public class ActionSourceGenerator implements SourceGenerator {
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, OrItem item) throws CompilationException {
List<GraphSourceItem> ret = new ArrayList<>();
ret.addAll(generateToActionList(localData, item.leftSide));
ret.add(new ActionPushDuplicate());
ret.add(new ActionPushDuplicate(charset));
List<Action> orExpr = generateToActionList(localData, item.rightSide);
orExpr.add(0, new ActionPop());
int orExprLen = Action.actionsToBytes(orExpr, false, SWF.DEFAULT_VERSION).length;
ret.add(new ActionIf(orExprLen));
ret.add(new ActionIf(orExprLen,charset));
ret.addAll(orExpr);
return ret;
}
@@ -163,7 +170,7 @@ public class ActionSourceGenerator implements SourceGenerator {
byte[] onTrueBytes = Action.actionsToBytes(onTrue, false, SWF.DEFAULT_VERSION);
int onTrueLen = onTrueBytes.length;
ActionIf ifaif = new ActionIf(0);
ActionIf ifaif = new ActionIf(0, charset);
ret.add(ifaif);
ret.addAll(onTrue);
ifaif.setJumpOffset(onTrueLen);
@@ -173,7 +180,7 @@ public class ActionSourceGenerator implements SourceGenerator {
&& (onTrue.get(onTrue.size() - 1) instanceof ActionJump)
&& ((((ActionJump) onTrue.get(onTrue.size() - 1)).isContinue)
|| (((ActionJump) onTrue.get(onTrue.size() - 1)).isBreak)))) {
ajmp = new ActionJump(0);
ajmp = new ActionJump(0, charset);
ret.add(ajmp);
onTrueLen += ajmp.getTotalActionLength();
}
@@ -238,9 +245,9 @@ public class ActionSourceGenerator implements SourceGenerator {
List<Action> whileBody = generateToActionList(localData, item.commands);
whileExpr.add(new ActionNot());
ActionIf whileaif = new ActionIf(0);
ActionIf whileaif = new ActionIf(0, charset);
whileExpr.add(whileaif);
ActionJump whileajmp = new ActionJump(0);
ActionJump whileajmp = new ActionJump(0, charset);
whileBody.add(whileajmp);
int whileExprLen = Action.actionsToBytes(whileExpr, false, SWF.DEFAULT_VERSION).length;
int whileBodyLen = Action.actionsToBytes(whileBody, false, SWF.DEFAULT_VERSION).length;
@@ -271,7 +278,7 @@ public class ActionSourceGenerator implements SourceGenerator {
ret.addAll(doBody);
ret.addAll(doExpr);
ActionIf doif = new ActionIf(0);
ActionIf doif = new ActionIf(0, charset);
ret.add(doif);
int offset = doBodyLen + doExprLen + doif.getTotalActionLength();
doif.setJumpOffset(-offset);
@@ -287,9 +294,9 @@ public class ActionSourceGenerator implements SourceGenerator {
List<Action> forFinalCommands = generateToActionList(localData, item.finalCommands);
forExpr.add(new ActionNot());
ActionIf foraif = new ActionIf(0);
ActionIf foraif = new ActionIf(0, charset);
forExpr.add(foraif);
ActionJump forajmp = new ActionJump(0);
ActionJump forajmp = new ActionJump(0,charset);
int forajmpLen = forajmp.getTotalActionLength();
int forExprLen = Action.actionsToBytes(forExpr, false, SWF.DEFAULT_VERSION).length;
int forBodyLen = Action.actionsToBytes(forBody, false, SWF.DEFAULT_VERSION).length;
@@ -353,12 +360,12 @@ public class ActionSourceGenerator implements SourceGenerator {
List<Action> curCaseExpr = generateToActionList(localData, item.caseValues.get(m));
caseExprs.add(curCaseExpr);
if (firstCase) {
curCaseExpr.add(0, new ActionStoreRegister(exprReg));
curCaseExpr.add(0, new ActionStoreRegister(exprReg,charset));
} else {
curCaseExpr.add(0, new ActionPush(new RegisterNumber(exprReg)));
curCaseExpr.add(0, new ActionPush(new RegisterNumber(exprReg), charset));
}
curCaseExpr.add(new ActionStrictEquals());
ActionIf aif = new ActionIf(0);
ActionIf aif = new ActionIf(0,charset);
caseIfsOne.add(aif);
curCaseExpr.add(aif);
ret.addAll(curCaseExpr);
@@ -371,7 +378,7 @@ public class ActionSourceGenerator implements SourceGenerator {
caseCmds.add(caseCmd);
}
ActionJump defJump = new ActionJump(0);
ActionJump defJump = new ActionJump(0,charset);
ret.add(defJump);
for (List<Action> caseCmd : caseCmds) {
ret.addAll(caseCmd);
@@ -440,14 +447,14 @@ public class ActionSourceGenerator implements SourceGenerator {
@Override
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, DuplicateItem item) {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionPushDuplicate());
ret.add(new ActionPushDuplicate(charset));
return ret;
}
@Override
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, BreakItem item) {
List<GraphSourceItem> ret = new ArrayList<>();
ActionJump abreak = new ActionJump(0);
ActionJump abreak = new ActionJump(0,charset);
abreak.isBreak = true;
ret.add(abreak);
return ret;
@@ -456,7 +463,7 @@ public class ActionSourceGenerator implements SourceGenerator {
@Override
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, ContinueItem item) {
List<GraphSourceItem> ret = new ArrayList<>();
ActionJump acontinue = new ActionJump(0);
ActionJump acontinue = new ActionJump(0,charset);
acontinue.isContinue = true;
ret.add(acontinue);
return ret;
@@ -630,17 +637,16 @@ public class ActionSourceGenerator implements SourceGenerator {
return ret;
}
private final List<String> constantPool;
private final int swfVersion;
public int getSwfVersion() {
return swfVersion;
}
public ActionSourceGenerator(int swfVersion, List<String> constantPool) {
public ActionSourceGenerator(int swfVersion, List<String> constantPool, String charset) {
this.constantPool = constantPool;
this.swfVersion = swfVersion;
this.charset = charset;
}
public List<String> getConstantPool() {
@@ -662,7 +668,7 @@ public class ActionSourceGenerator implements SourceGenerator {
constantPool.add(s);
index = constantPool.indexOf(s);
}
return new ActionPush(new ConstantIndex(index));
return new ActionPush(new ConstantIndex(index), charset);
}
public List<GraphSourceItem> generateTraits(SourceGeneratorLocalData localData, boolean isInterface, GraphTargetItem name, GraphTargetItem extendsVal, List<GraphTargetItem> implementsStr, List<MyEntry<GraphTargetItem, GraphTargetItem>> traits, List<Boolean> traitsStatic) throws CompilationException {
@@ -678,14 +684,14 @@ public class ActionSourceGenerator implements SourceGenerator {
}
List<Action> val = new ArrayList<>();
val.add(new ActionPush((Double) 0.0));
val.add(new ActionPush((Double) 0.0, charset));
val.add(pushConst("Object"));
val.add(new ActionNewObject());
notBody.addAll(typeToActions(globalClassTypeStr, val));
ret.addAll(typeToActions(globalClassTypeStr, null));
ret.add(new ActionNot());
ret.add(new ActionNot());
ret.add(new ActionIf(Action.actionsToBytes(notBody, false, SWF.DEFAULT_VERSION).length));
ret.add(new ActionIf(Action.actionsToBytes(notBody, false, SWF.DEFAULT_VERSION).length,charset));
ret.addAll(notBody);
ret.add(new ActionPop());
}
@@ -712,14 +718,14 @@ public class ActionSourceGenerator implements SourceGenerator {
if (constructor == null) {
List<Action> val = new ArrayList<>();
val.add(new ActionDefineFunction("", new ArrayList<>(), 0, SWF.DEFAULT_VERSION));
val.add(new ActionDefineFunction("", new ArrayList<>(), 0, SWF.DEFAULT_VERSION, charset));
if (!isInterface) {
val.add(new ActionStoreRegister(1));
val.add(new ActionStoreRegister(1, charset));
}
constr.addAll(typeToActions(globalClassTypeStr, val));
} else {
constr.addAll(toActionList(((FunctionActionItem) constructor).toSource(localData, this)));
constr.add(new ActionStoreRegister(1));
constr.add(new ActionStoreRegister(1, charset));
constr = (typeToActions(globalClassTypeStr, constr));
}
@@ -766,12 +772,12 @@ public class ActionSourceGenerator implements SourceGenerator {
(traitsStatic.get(t) ? staticSetters : setters).add(fi.calculatedFunctionName.toString());
prefix = "__set__";
}
ifbody.add(new ActionPush(new RegisterNumber(traitsStatic.get(t) ? 1 : 2)));
ifbody.add(new ActionPush(new RegisterNumber(traitsStatic.get(t) ? 1 : 2),charset));
ifbody.add(pushConst(prefix + getName(en.getKey())));
ifbody.addAll(toActionList(fi.toSource(localData, this)));
ifbody.add(new ActionSetMember());
} else if (pass == 2 && !isFunc) { //add variables in second pass
ifbody.add(new ActionPush(new RegisterNumber(traitsStatic.get(t) ? 1 : 2)));
ifbody.add(new ActionPush(new RegisterNumber(traitsStatic.get(t) ? 1 : 2), charset));
ifbody.add(pushConst(getName(en.getKey())));
ifbody.addAll(toActionList(en.getValue().toSource(localData, this)));
ifbody.add(new ActionSetMember());
@@ -782,67 +788,67 @@ public class ActionSourceGenerator implements SourceGenerator {
for (String prop : staticProperties) {
if (staticSetters.contains(prop)) {
ifbody.add(new ActionPush(new Object[]{new RegisterNumber(1), "__set__" + prop}));
ifbody.add(new ActionPush(new Object[]{new RegisterNumber(1), "__set__" + prop},charset));
ifbody.add(new ActionGetMember());
} else {
ifbody.add(new ActionDefineFunction("", new ArrayList<String>(), 0, swfVersion));
ifbody.add(new ActionDefineFunction("", new ArrayList<String>(), 0, swfVersion,charset));
}
if (staticGetters.contains(prop)) {
ifbody.add(new ActionPush(new Object[]{new RegisterNumber(1), "__get__" + prop}));
ifbody.add(new ActionPush(new Object[]{new RegisterNumber(1), "__get__" + prop},charset));
ifbody.add(new ActionGetMember());
} else {
ifbody.add(new ActionDefineFunction("", new ArrayList<String>(), 0, swfVersion));
ifbody.add(new ActionDefineFunction("", new ArrayList<String>(), 0, swfVersion, charset));
}
ifbody.add(new ActionPush(new Object[]{prop, 3, new RegisterNumber(1), "addProperty"}));
ifbody.add(new ActionPush(new Object[]{prop, 3, new RegisterNumber(1), "addProperty"}, charset));
ifbody.add(new ActionCallMethod());
}
for (String prop : properties) {
if (setters.contains(prop)) {
ifbody.add(new ActionPush(new Object[]{new RegisterNumber(2), "__set__" + prop}));
ifbody.add(new ActionPush(new Object[]{new RegisterNumber(2), "__set__" + prop},charset));
ifbody.add(new ActionGetMember());
} else {
ifbody.add(new ActionDefineFunction("", new ArrayList<String>(), 0, swfVersion));
ifbody.add(new ActionDefineFunction("", new ArrayList<String>(), 0, swfVersion, charset));
}
if (getters.contains(prop)) {
ifbody.add(new ActionPush(new Object[]{new RegisterNumber(2), "__get__" + prop}));
ifbody.add(new ActionPush(new Object[]{new RegisterNumber(2), "__get__" + prop}, charset));
ifbody.add(new ActionGetMember());
} else {
ifbody.add(new ActionDefineFunction("", new ArrayList<String>(), 0, swfVersion));
ifbody.add(new ActionDefineFunction("", new ArrayList<String>(), 0, swfVersion, charset));
}
ifbody.add(new ActionPush(new Object[]{prop, 3, new RegisterNumber(2), "addProperty"}));
ifbody.add(new ActionPush(new Object[]{prop, 3, new RegisterNumber(2), "addProperty"}, charset));
ifbody.add(new ActionCallMethod());
}
if (!isInterface) {
ifbody.add(new ActionPush((Long) 1L));
ifbody.add(new ActionPush(Null.INSTANCE));
ifbody.add(new ActionPush((Long) 1L, charset));
ifbody.add(new ActionPush(Null.INSTANCE, charset));
ifbody.addAll(typeToActions(globalClassTypeStr, null));
ifbody.add(pushConst("prototype"));
ifbody.add(new ActionGetMember());
ifbody.add(new ActionPush((Long) 3L));
ifbody.add(new ActionPush((Long) 3L, charset));
ifbody.add(pushConst("ASSetPropFlags"));
ifbody.add(new ActionCallFunction());
}
if (constr.isEmpty()) {
List<Action> val = new ArrayList<>();
val.add(new ActionDefineFunction("", new ArrayList<>(), 0, SWF.DEFAULT_VERSION));
val.add(new ActionDefineFunction("", new ArrayList<>(), 0, SWF.DEFAULT_VERSION, charset));
if (!isInterface) {
val.add(new ActionStoreRegister(1));
val.add(new ActionStoreRegister(1, charset));
}
constr.addAll(typeToActions(globalClassTypeStr, val));
}
if (!extendsStr.isEmpty()) {
constr.addAll(typeToActions(globalClassTypeStr, null));
constr.addAll(typeToActions(extendsStr, null));
constr.add(new ActionExtends());
constr.add(new ActionExtends(charset));
}
if (!isInterface) {
constr.add(new ActionPush(new RegisterNumber(1)));
constr.add(new ActionPush(new RegisterNumber(1), charset));
constr.add(pushConst("prototype"));
constr.add(new ActionGetMember());
constr.add(new ActionStoreRegister(2));
constr.add(new ActionStoreRegister(2, charset));
constr.add(new ActionPop());
}
@@ -854,16 +860,16 @@ public class ActionSourceGenerator implements SourceGenerator {
globImp.addAll(impList);
constr.addAll(typeToActions(globImp, null));
}
constr.add(new ActionPush((long) implementsStr.size()));
constr.add(new ActionPush((long) implementsStr.size(), charset));
constr.addAll(typeToActions(globalClassTypeStr, null));
constr.add(new ActionImplementsOp());
constr.add(new ActionImplementsOp(charset));
}
ifbody.addAll(0, constr);
ret.addAll(typeToActions(globalClassTypeStr, null));
ret.add(new ActionNot());
ret.add(new ActionNot());
ret.add(new ActionIf(Action.actionsToBytes(ifbody, false, SWF.DEFAULT_VERSION).length));
ret.add(new ActionIf(Action.actionsToBytes(ifbody, false, SWF.DEFAULT_VERSION).length,charset));
ret.addAll(ifbody);
ret.add(new ActionPop());
return ret;
@@ -908,4 +914,8 @@ public class ActionSourceGenerator implements SourceGenerator {
return ret;
}
public String getCharset() {
return charset;
}
}

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.action.parser.ActionParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.swf4.ActionJump;
import java.io.IOException;
import java.nio.charset.Charset;
/**
*
@@ -27,12 +28,12 @@ import java.io.IOException;
*/
public class ActionDeobfuscateJump extends ActionJump {
public ActionDeobfuscateJump(int offset) {
super(2);
public ActionDeobfuscateJump(int offset, String charset) {
super(2, charset);
}
public ActionDeobfuscateJump(FlasmLexer lexer) throws IOException, ActionParseException {
super(lexer);
public ActionDeobfuscateJump(FlasmLexer lexer, String charset) throws IOException, ActionParseException {
super(lexer, charset);
}
@Override

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.BaseLocalData;
import com.jpexs.decompiler.flash.action.swf4.ActionPop;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.nio.charset.Charset;
import java.util.List;
/**

View File

@@ -23,6 +23,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -32,8 +33,8 @@ import java.util.List;
*/
public class ActionEnd extends Action {
public ActionEnd() {
super(0, 0);
public ActionEnd(String charset) {
super(0, 0, charset);
setIgnored(true, 0);
}

View File

@@ -22,6 +22,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -31,12 +32,12 @@ import java.util.List;
*/
public class ActionNop extends Action {
public ActionNop() {
super(-1, 0);
public ActionNop(String charset) {
super(-1, 0, charset);
}
protected ActionNop(int actionCode) {
super(actionCode, 0);
protected ActionNop(int actionCode, String charset) {
super(actionCode, 0, charset);
}
@Override

View File

@@ -22,6 +22,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -31,8 +32,8 @@ import java.util.List;
*/
public class ActionUnknown extends ActionNop {
public ActionUnknown(int actionCode, int actionLength) {
super(actionCode);
public ActionUnknown(int actionCode, int actionLength, String charset) {
super(actionCode, charset);
this.actionLength = actionLength;
}

View File

@@ -36,6 +36,7 @@ import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -57,22 +58,22 @@ public class ActionGetURL extends Action {
return true;
}
public ActionGetURL(String urlString, String targetString) {
super(0x83, 0);
public ActionGetURL(String urlString, String targetString, String charset) {
super(0x83, 0, charset);
this.urlString = urlString;
this.targetString = targetString;
}
public ActionGetURL(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x83, actionLength);
super(0x83, actionLength, sis.getCharset());
//byte[] data = sis.readBytes(actionLength);
//sis = new SWFInputStream(new ByteArrayInputStream(data), version);
urlString = sis.readString("urlString");
targetString = sis.readString("targetString");
}
public ActionGetURL(FlasmLexer lexer) throws IOException, ActionParseException {
super(0x83, 0);
public ActionGetURL(FlasmLexer lexer, String charset) throws IOException, ActionParseException {
super(0x83, 0, charset);
urlString = lexString(lexer);
targetString = lexString(lexer);
}

View File

@@ -32,6 +32,7 @@ import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -44,13 +45,13 @@ public class ActionGoToLabel extends Action {
public String label;
public ActionGoToLabel(String label) {
super(0x8C, 0);
public ActionGoToLabel(String label, String charset) {
super(0x8C, 0, charset);
this.label = label;
}
public ActionGoToLabel(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x8C, actionLength);
super(0x8C, actionLength, sis.getCharset());
//byte[] data = sis.readBytes(actionLength);
//sis = new SWFInputStream(new ByteArrayInputStream(data), version);
label = sis.readString("label");
@@ -82,8 +83,8 @@ public class ActionGoToLabel extends Action {
return Utf8Helper.getBytesLength(label) + 1;
}
public ActionGoToLabel(FlasmLexer lexer) throws IOException, ActionParseException {
super(0x8C, -1);
public ActionGoToLabel(FlasmLexer lexer, String charset) throws IOException, ActionParseException {
super(0x8C, -1, charset);
label = lexString(lexer);
}

View File

@@ -30,6 +30,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -42,8 +43,8 @@ public class ActionGotoFrame extends Action {
public int frame;
public ActionGotoFrame(int frame) {
super(0x81, 2);
public ActionGotoFrame(int frame, String charset) {
super(0x81, 2, charset);
this.frame = frame;
}
@@ -54,7 +55,7 @@ public class ActionGotoFrame extends Action {
}
public ActionGotoFrame(int actionLength, SWFInputStream sis) throws IOException {
super(0x81, actionLength);
super(0x81, actionLength, sis.getCharset());
frame = sis.readUI16("frame");
}
@@ -78,8 +79,8 @@ public class ActionGotoFrame extends Action {
return 2;
}
public ActionGotoFrame(FlasmLexer lexer) throws IOException, ActionParseException {
super(0x81, 0);
public ActionGotoFrame(FlasmLexer lexer, String charset) throws IOException, ActionParseException {
super(0x81, 0, charset);
frame = (int) lexLong(lexer);
}

View File

@@ -25,6 +25,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -36,7 +38,7 @@ import java.util.List;
public class ActionNextFrame extends Action {
public ActionNextFrame() {
super(0x04, 0);
super(0x04, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -28,6 +28,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -39,7 +41,7 @@ import java.util.List;
public class ActionPlay extends Action {
public ActionPlay() {
super(0x06, 0);
super(0x06, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -25,6 +25,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -36,7 +38,7 @@ import java.util.List;
public class ActionPrevFrame extends Action {
public ActionPrevFrame() {
super(0x05, 0);
super(0x05, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -31,6 +31,7 @@ import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -43,8 +44,8 @@ public class ActionSetTarget extends Action {
public String targetName;
public ActionSetTarget(String targetName) {
super(0x8B, 0);
public ActionSetTarget(String targetName, String charset) {
super(0x8B, 0, charset);
this.targetName = targetName;
}
@@ -60,7 +61,7 @@ public class ActionSetTarget extends Action {
}
public ActionSetTarget(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x8B, actionLength);
super(0x8B, actionLength, sis.getCharset());
//byte[] data = sis.readBytes(actionLength);
//sis = new SWFInputStream(new ByteArrayInputStream(data), version);
targetName = sis.readString("targetName");
@@ -86,8 +87,8 @@ public class ActionSetTarget extends Action {
return Utf8Helper.getBytesLength(targetName) + 1;
}
public ActionSetTarget(FlasmLexer lexer) throws IOException, ActionParseException {
super(0x8B, -1);
public ActionSetTarget(FlasmLexer lexer, String charset) throws IOException, ActionParseException {
super(0x8B, -1, charset);
targetName = lexString(lexer);
}

View File

@@ -25,6 +25,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -36,7 +38,7 @@ import java.util.List;
public class ActionStop extends Action {
public ActionStop() {
super(0x07, 0);
super(0x07, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -24,6 +24,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -35,7 +37,7 @@ import java.util.List;
public class ActionStopSounds extends Action {
public ActionStopSounds() {
super(0x09, 0);
super(0x09, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -24,6 +24,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -35,7 +37,7 @@ import java.util.List;
public class ActionToggleQuality extends Action {
public ActionToggleQuality() {
super(0x08, 0);
super(0x08, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -36,6 +36,7 @@ import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.SecondPassException;
import com.jpexs.decompiler.graph.TranslateStack;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -62,7 +63,7 @@ public class ActionWaitForFrame extends Action implements ActionStore {
}
public ActionWaitForFrame(int actionLength, SWFInputStream sis) throws IOException {
super(0x8A, actionLength);
super(0x8A, actionLength, sis.getCharset());
frame = sis.readUI16("frame");
skipCount = sis.readUI8("skipCount");
skipped = new ArrayList<>();
@@ -95,8 +96,8 @@ public class ActionWaitForFrame extends Action implements ActionStore {
return 3;
}
public ActionWaitForFrame(FlasmLexer lexer) throws IOException, ActionParseException {
super(0x8A, -1);
public ActionWaitForFrame(FlasmLexer lexer, String charset) throws IOException, ActionParseException {
super(0x8A, -1, charset);
frame = (int) lexLong(lexer);
skipCount = (int) lexLong(lexer);
skipped = new ArrayList<>();
@@ -110,13 +111,13 @@ public class ActionWaitForFrame extends Action implements ActionStore {
HashMap<String, GraphTargetItem> functionsBackup = new LinkedHashMap<>(functions);
try {
body = ActionGraph.translateViaGraph(null, insideDoInitAction, true, regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path);
body = ActionGraph.translateViaGraph(null, insideDoInitAction, true, regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path, getCharset());
} catch (SecondPassException spe) {
variables.clear();
variables.putAll(variablesBackup);
functions.clear();
functions.putAll(functionsBackup);
body = ActionGraph.translateViaGraph(spe.getData(), insideDoInitAction, true, regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path);
body = ActionGraph.translateViaGraph(spe.getData(), insideDoInitAction, true, regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path, getCharset());
}
output.add(new IfFrameLoadedActionItem(frameTi, body, this, lineStartAction));
}

View File

@@ -25,6 +25,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -36,7 +38,7 @@ import java.util.List;
public class ActionAdd extends Action {
public ActionAdd() {
super(0x0A, 0);
super(0x0A, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -25,6 +25,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -36,7 +38,7 @@ import java.util.List;
public class ActionAnd extends Action {
public ActionAnd() {
super(0x10, 0);
super(0x10, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -25,6 +25,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -36,7 +38,7 @@ import java.util.List;
public class ActionAsciiToChar extends Action {
public ActionAsciiToChar() {
super(0x33, 0);
super(0x33, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -26,6 +26,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -37,11 +39,11 @@ import java.util.List;
public class ActionCall extends Action {
public ActionCall() {
super(0x9E, 0);
super(0x9E, 0, Utf8Helper.charsetName);
}
public ActionCall(int actionLength) {
super(0x9E, actionLength);
public ActionCall(int actionLength, String charset) {
super(0x9E, actionLength, charset);
}
@Override

View File

@@ -25,6 +25,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -36,7 +38,7 @@ import java.util.List;
public class ActionCharToAscii extends Action {
public ActionCharToAscii() {
super(0x32, 0);
super(0x32, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -28,6 +28,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -39,7 +41,7 @@ import java.util.List;
public class ActionCloneSprite extends Action {
public ActionCloneSprite() {
super(0x24, 0);
super(0x24, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -25,6 +25,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -36,7 +38,7 @@ import java.util.List;
public class ActionDivide extends Action {
public ActionDivide() {
super(0x0D, 0);
super(0x0D, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -25,6 +25,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -36,7 +38,7 @@ import java.util.List;
public class ActionEndDrag extends Action {
public ActionEndDrag() {
super(0x28, 0);
super(0x28, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -25,6 +25,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -35,8 +36,8 @@ import java.util.List;
@SWFVersion(from = 4)
public class ActionEquals extends Action {
public ActionEquals() {
super(0x0E, 0);
public ActionEquals(String charset) {
super(0x0E, 0, charset);
}
@Override

View File

@@ -29,6 +29,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
@@ -42,7 +44,7 @@ import java.util.logging.Logger;
public class ActionGetProperty extends Action {
public ActionGetProperty() {
super(0x22, 0);
super(0x22, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -25,6 +25,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -36,7 +38,7 @@ import java.util.List;
public class ActionGetTime extends Action {
public ActionGetTime() {
super(0x34, 0);
super(0x34, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -43,6 +43,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -67,15 +68,15 @@ public class ActionGetURL2 extends Action {
@Reserved
public int reserved;
public ActionGetURL2(int sendVarsMethod, boolean loadVariablesFlag, boolean loadTargetFlag) {
super(0x9A, 1);
public ActionGetURL2(int sendVarsMethod, boolean loadVariablesFlag, boolean loadTargetFlag, String charset) {
super(0x9A, 1, charset);
this.loadTargetFlag = loadTargetFlag;
this.loadVariablesFlag = loadVariablesFlag;
this.sendVarsMethod = sendVarsMethod;
}
public ActionGetURL2(int actionLength, SWFInputStream sis) throws IOException {
super(0x9A, actionLength);
public ActionGetURL2(int actionLength, SWFInputStream sis, String charset) throws IOException {
super(0x9A, actionLength, charset);
loadVariablesFlag = sis.readUB(1, "loadVariablesFlag") == 1;
loadTargetFlag = sis.readUB(1, "loadTargetFlag") == 1;
reserved = (int) sis.readUB(4, "reserved");
@@ -105,8 +106,8 @@ public class ActionGetURL2 extends Action {
return 1;
}
public ActionGetURL2(FlasmLexer lexer) throws IOException, ActionParseException {
super(0x9A, -1);
public ActionGetURL2(FlasmLexer lexer, String charset) throws IOException, ActionParseException {
super(0x9A, -1, charset);
loadVariablesFlag = lexBoolean(lexer);
loadTargetFlag = lexBoolean(lexer);
sendVarsMethod = (int) lexLong(lexer);

View File

@@ -31,6 +31,8 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -42,7 +44,7 @@ import java.util.List;
public class ActionGetVariable extends Action {
public ActionGetVariable() {
super(0x1C, 0);
super(0x1C, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -33,6 +33,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -52,15 +53,15 @@ public class ActionGotoFrame2 extends Action {
@Reserved
int reserved;
public ActionGotoFrame2(boolean playFlag, boolean sceneBiasFlag, int sceneBias) {
super(0x9F, 0);
public ActionGotoFrame2(boolean playFlag, boolean sceneBiasFlag, int sceneBias, String charset) {
super(0x9F, 0, charset);
this.sceneBiasFlag = sceneBiasFlag;
this.playFlag = playFlag;
this.sceneBias = sceneBias;
}
public ActionGotoFrame2(int actionLength, SWFInputStream sis) throws IOException {
super(0x9F, actionLength);
super(0x9F, actionLength, sis.getCharset());
reserved = (int) sis.readUB(6, "reserved");
sceneBiasFlag = sis.readUB(1, "sceneBiasFlag") == 1;
playFlag = sis.readUB(1, "playFlag") == 1;
@@ -99,8 +100,8 @@ public class ActionGotoFrame2 extends Action {
return "GotoFrame2 " + sceneBiasFlag + " " + playFlag + " " + (sceneBiasFlag ? " " + sceneBias : "");
}
public ActionGotoFrame2(FlasmLexer lexer) throws IOException, ActionParseException {
super(0x9F, -1);
public ActionGotoFrame2(FlasmLexer lexer, String charset) throws IOException, ActionParseException {
super(0x9F, -1, charset);
sceneBiasFlag = lexBoolean(lexer);
playFlag = lexBoolean(lexer);
if (sceneBiasFlag) {

View File

@@ -29,6 +29,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
import com.jpexs.decompiler.graph.GraphSource;
import com.jpexs.helpers.Helper;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
@@ -57,13 +58,13 @@ public class ActionIf extends Action {
this.offset = offset;
}
public ActionIf(int offset) {
super(0x9D, 2);
public ActionIf(int offset, String charset) {
super(0x9D, 2, charset);
setJumpOffset(offset);
}
public ActionIf(int actionLength, SWFInputStream sis) throws IOException {
super(0x9D, actionLength);
super(0x9D, actionLength, sis.getCharset());
setJumpOffset(sis.readSI16("offset"));
}
@@ -98,8 +99,8 @@ public class ActionIf extends Action {
return "If loc" + ofsStr + (!jumpUsed ? " ;compileTimeIgnore" : (!ignoreUsed ? " ;compileTimeJump" : ""));
}
public ActionIf(FlasmLexer lexer) throws IOException, ActionParseException {
super(0x9D, 2);
public ActionIf(FlasmLexer lexer, String charset) throws IOException, ActionParseException {
super(0x9D, 2, charset);
identifier = lexIdentifier(lexer);
}

View File

@@ -28,6 +28,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
import com.jpexs.decompiler.graph.GraphSource;
import com.jpexs.helpers.Helper;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
@@ -56,13 +57,13 @@ public class ActionJump extends Action {
this.offset = offset;
}
public ActionJump(int offset) {
super(0x99, 2);
public ActionJump(int offset, String charset) {
super(0x99, 2, charset);
setJumpOffset(offset);
}
public ActionJump(int actionLength, SWFInputStream sis) throws IOException {
super(0x99, actionLength);
super(0x99, actionLength, sis.getCharset());
setJumpOffset(sis.readSI16("offset"));
}
@@ -97,8 +98,8 @@ public class ActionJump extends Action {
return "Jump loc" + ofsStr;
}
public ActionJump(FlasmLexer lexer) throws IOException, ActionParseException {
super(0x99, 2);
public ActionJump(FlasmLexer lexer, String charset) throws IOException, ActionParseException {
super(0x99, 2, charset);
identifier = lexIdentifier(lexer);
}

View File

@@ -25,6 +25,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -36,7 +38,7 @@ import java.util.List;
public class ActionLess extends Action {
public ActionLess() {
super(0x0F, 0);
super(0x0F, 0, Utf8Helper.charsetName);
}
@Override

View File

@@ -25,6 +25,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -36,7 +38,7 @@ import java.util.List;
public class ActionMBAsciiToChar extends Action {
public ActionMBAsciiToChar() {
super(0x37, 0);
super(0x37, 0, Utf8Helper.charsetName);
}
@Override

Some files were not shown because too many files have changed in this diff Show More