dump view: names

This commit is contained in:
honfika
2014-06-22 00:25:28 +02:00
parent a0804e2cb9
commit 4e0ec9df93
106 changed files with 3758 additions and 3605 deletions

View File

@@ -514,19 +514,19 @@ public final class SWF implements TreeItem, Timelined {
SWFInputStream sis = new SWFInputStream(this, uncompressedData);
dumpInfo = new DumpInfo("rootswf", "", null, 0, 0);
sis.dumpInfo = dumpInfo;
sis.readBytesEx(3); // skip siganture
version = sis.readUI8();
fileSize = sis.readUI32();
sis.readBytesEx(3, "signature"); // skip siganture
version = sis.readUI8("version");
fileSize = sis.readUI32("fileSize");
sis.dumpInfo.lengthBytes = fileSize;
if (listener != null) {
sis.addPercentListener(listener);
}
sis.setPercentMax(fileSize);
displayRect = sis.readRECT();
displayRect = sis.readRECT("displayRect");
// FIXED8 (16 bit fixed point) frameRate
sis.readUI8(); //tmpFirstByetOfFrameRate
frameRate = sis.readUI8();
frameCount = sis.readUI16();
sis.readUI8("tmpFirstByetOfFrameRate"); //tmpFirstByetOfFrameRate
frameRate = sis.readUI8("frameRate");
frameCount = sis.readUI16("frameCount");
List<Tag> tags = sis.readTagList(this, 0, parallelRead, true, !checkOnly, gfx);
if (tags.get(tags.size() - 1).getId() == EndTag.ID) {
hasEndTag = true;
@@ -713,7 +713,7 @@ public final class SWF implements TreeItem, Timelined {
int version = hdr[3];
SWFInputStream sis = new SWFInputStream(null, Arrays.copyOfRange(hdr, 4, 8), 4, 4);
long fileSize = sis.readUI32();
long fileSize = sis.readUI32("fileSize");
SWFHeader header = new SWFHeader();
header.version = version;
header.fileSize = fileSize;
@@ -734,10 +734,10 @@ public final class SWF implements TreeItem, Timelined {
break;
}
case 'Z': { // ZWS
sis.readUI32(); // compressed LZMA data size = compressed SWF - 17 byte,
sis.readUI32("LZMAsize"); // compressed LZMA data size = compressed SWF - 17 byte,
// where 17 = 8 byte header + this 4 byte + 5 bytes decoder properties
int propertiesSize = 5;
byte[] lzmaProperties = sis.readBytes(propertiesSize);
byte[] lzmaProperties = sis.readBytes(propertiesSize, "lzmaproperties");
if (lzmaProperties.length != propertiesSize) {
throw new IOException("LZMA:input .lzma file is too short");
}

File diff suppressed because it is too large Load Diff

View File

@@ -1038,7 +1038,7 @@ public class SWFOutputStream extends OutputStream {
sos.writeUB(1, value.condOverUpToIddle ? 1 : 0);
sos.writeUB(1, value.condIdleToOverUp ? 1 : 0);
sos.writeUB(7, value.condKeyPress);
sos.writeUB(1, value.condOverDownToIddle ? 1 : 0);
sos.writeUB(1, value.condOverDownToIdle ? 1 : 0);
sos.write(value.actionBytes);
}
byte[] data = baos.toByteArray();

View File

@@ -1,67 +1,67 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.flashlite;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.StrictModeActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionStrictMode extends Action {
public int mode;
public ActionStrictMode(SWFInputStream sis) throws IOException {
super(0x89, 1);
mode = sis.readUI8();
}
public ActionStrictMode(FlasmLexer lexer) throws IOException, ParseException {
super(0x89, 1);
mode = (int) lexLong(lexer);
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUI8(mode);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
@Override
public String toString() {
return "StrictMode " + mode;
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
output.add(new StrictModeActionItem(this, mode));
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.flashlite;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.StrictModeActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionStrictMode extends Action {
public int mode;
public ActionStrictMode(SWFInputStream sis) throws IOException {
super(0x89, 1);
mode = sis.readUI8("mode");
}
public ActionStrictMode(FlasmLexer lexer) throws IOException, ParseException {
super(0x89, 1);
mode = (int) lexLong(lexer);
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUI8(mode);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
@Override
public String toString() {
return "StrictMode " + mode;
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
output.add(new StrictModeActionItem(this, mode));
}
}

View File

@@ -1,114 +1,114 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf3;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
import com.jpexs.decompiler.flash.action.model.FSCommandActionItem;
import com.jpexs.decompiler.flash.action.model.GetURLActionItem;
import com.jpexs.decompiler.flash.action.model.LoadMovieNumActionItem;
import com.jpexs.decompiler.flash.action.model.UnLoadMovieActionItem;
import com.jpexs.decompiler.flash.action.model.UnLoadMovieNumActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionGetURL extends Action {
public String urlString;
public String targetString;
public ActionGetURL(String urlString, String targetString) {
super(0x83, 0);
this.urlString = urlString;
this.targetString = targetString;
}
public ActionGetURL(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x83, actionLength);
//byte[] data = sis.readBytes(actionLength);
//sis = new SWFInputStream(new ByteArrayInputStream(data), version);
urlString = sis.readString();
targetString = sis.readString();
}
public ActionGetURL(FlasmLexer lexer) throws IOException, ParseException {
super(0x83, 0);
urlString = lexString(lexer);
targetString = lexString(lexer);
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeString(urlString);
sos.writeString(targetString);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
@Override
public String toString() {
return "GetUrl \"" + Helper.escapeString(urlString) + "\" \"" + Helper.escapeString(targetString) + "\"";
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
String fsCommandPrefix = "FSCommand:";
if (urlString.startsWith(fsCommandPrefix) && targetString.isEmpty()) {
String command = urlString.substring(fsCommandPrefix.length());
output.add(new FSCommandActionItem(this, new DirectValueActionItem(command)));
return;
}
String levelPrefix = "_level";
if (targetString.startsWith(levelPrefix)) {
try {
int num = Integer.valueOf(targetString.substring(levelPrefix.length()));
if (urlString.isEmpty()) {
output.add(new UnLoadMovieNumActionItem(this, new DirectValueActionItem((Long) (long) (int) num)));
} else {
DirectValueActionItem urlStringDi = new DirectValueActionItem(null, 0, urlString, new ArrayList<String>());
output.add(new LoadMovieNumActionItem(this, urlStringDi, new DirectValueActionItem((Long) (long) (int) num), 1/*GET*/));
}
return;
} catch (NumberFormatException nfe) {
}
}
if (urlString.isEmpty()) {
DirectValueActionItem targetStringDi = new DirectValueActionItem(null, 0, targetString, new ArrayList<String>());
output.add(new UnLoadMovieActionItem(this, targetStringDi));
} else {
output.add(new GetURLActionItem(this, urlString, targetString));
}
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf3;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
import com.jpexs.decompiler.flash.action.model.FSCommandActionItem;
import com.jpexs.decompiler.flash.action.model.GetURLActionItem;
import com.jpexs.decompiler.flash.action.model.LoadMovieNumActionItem;
import com.jpexs.decompiler.flash.action.model.UnLoadMovieActionItem;
import com.jpexs.decompiler.flash.action.model.UnLoadMovieNumActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionGetURL extends Action {
public String urlString;
public String targetString;
public ActionGetURL(String urlString, String targetString) {
super(0x83, 0);
this.urlString = urlString;
this.targetString = targetString;
}
public ActionGetURL(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x83, actionLength);
//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, ParseException {
super(0x83, 0);
urlString = lexString(lexer);
targetString = lexString(lexer);
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeString(urlString);
sos.writeString(targetString);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
@Override
public String toString() {
return "GetUrl \"" + Helper.escapeString(urlString) + "\" \"" + Helper.escapeString(targetString) + "\"";
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
String fsCommandPrefix = "FSCommand:";
if (urlString.startsWith(fsCommandPrefix) && targetString.isEmpty()) {
String command = urlString.substring(fsCommandPrefix.length());
output.add(new FSCommandActionItem(this, new DirectValueActionItem(command)));
return;
}
String levelPrefix = "_level";
if (targetString.startsWith(levelPrefix)) {
try {
int num = Integer.valueOf(targetString.substring(levelPrefix.length()));
if (urlString.isEmpty()) {
output.add(new UnLoadMovieNumActionItem(this, new DirectValueActionItem((Long) (long) (int) num)));
} else {
DirectValueActionItem urlStringDi = new DirectValueActionItem(null, 0, urlString, new ArrayList<String>());
output.add(new LoadMovieNumActionItem(this, urlStringDi, new DirectValueActionItem((Long) (long) (int) num), 1/*GET*/));
}
return;
} catch (NumberFormatException nfe) {
}
}
if (urlString.isEmpty()) {
DirectValueActionItem targetStringDi = new DirectValueActionItem(null, 0, targetString, new ArrayList<String>());
output.add(new UnLoadMovieActionItem(this, targetStringDi));
} else {
output.add(new GetURLActionItem(this, urlString, targetString));
}
}
}

View File

@@ -1,75 +1,75 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf3;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.GotoLabelActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionGoToLabel extends Action {
public String label;
public ActionGoToLabel(String label) {
super(0x8C, 0);
this.label = label;
}
public ActionGoToLabel(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x8C, actionLength);
//byte[] data = sis.readBytes(actionLength);
//sis = new SWFInputStream(new ByteArrayInputStream(data), version);
label = sis.readString();
}
@Override
public String toString() {
return "GoToLabel \"" + Helper.escapeString(label) + "\"";
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeString(label);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
public ActionGoToLabel(FlasmLexer lexer) throws IOException, ParseException {
super(0x8C, -1);
label = lexString(lexer);
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
output.add(new GotoLabelActionItem(this, label));
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf3;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.GotoLabelActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionGoToLabel extends Action {
public String label;
public ActionGoToLabel(String label) {
super(0x8C, 0);
this.label = label;
}
public ActionGoToLabel(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x8C, actionLength);
//byte[] data = sis.readBytes(actionLength);
//sis = new SWFInputStream(new ByteArrayInputStream(data), version);
label = sis.readString("label");
}
@Override
public String toString() {
return "GoToLabel \"" + Helper.escapeString(label) + "\"";
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeString(label);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
public ActionGoToLabel(FlasmLexer lexer) throws IOException, ParseException {
super(0x8C, -1);
label = lexString(lexer);
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
output.add(new GotoLabelActionItem(this, label));
}
}

View File

@@ -1,72 +1,72 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf3;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.GotoFrameActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionGotoFrame extends Action {
public int frame;
public ActionGotoFrame(int frame) {
super(0x81, 2);
this.frame = frame;
}
public ActionGotoFrame(int actionLength, SWFInputStream sis) throws IOException {
super(0x81, actionLength);
frame = sis.readUI16();
}
@Override
public String toString() {
return "GotoFrame " + frame;
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUI16(frame);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
public ActionGotoFrame(FlasmLexer lexer) throws IOException, ParseException {
super(0x81, 0);
frame = (int) lexLong(lexer);
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
output.add(new GotoFrameActionItem(this, frame));
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf3;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.GotoFrameActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionGotoFrame extends Action {
public int frame;
public ActionGotoFrame(int frame) {
super(0x81, 2);
this.frame = frame;
}
public ActionGotoFrame(int actionLength, SWFInputStream sis) throws IOException {
super(0x81, actionLength);
frame = sis.readUI16("frame");
}
@Override
public String toString() {
return "GotoFrame " + frame;
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUI16(frame);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
public ActionGotoFrame(FlasmLexer lexer) throws IOException, ParseException {
super(0x81, 0);
frame = (int) lexLong(lexer);
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
output.add(new GotoFrameActionItem(this, frame));
}
}

View File

@@ -1,75 +1,75 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf3;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.SetTargetActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionSetTarget extends Action {
public String targetName;
public ActionSetTarget(String targetName) {
super(0x8B, 0);
this.targetName = targetName;
}
public ActionSetTarget(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x8B, actionLength);
//byte[] data = sis.readBytes(actionLength);
//sis = new SWFInputStream(new ByteArrayInputStream(data), version);
targetName = sis.readString();
}
@Override
public String toString() {
return "SetTarget \"" + Helper.escapeString(targetName) + "\"";
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeString(targetName);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
public ActionSetTarget(FlasmLexer lexer) throws IOException, ParseException {
super(0x8B, -1);
targetName = lexString(lexer);
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
output.add(new SetTargetActionItem(this, targetName));
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf3;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.SetTargetActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionSetTarget extends Action {
public String targetName;
public ActionSetTarget(String targetName) {
super(0x8B, 0);
this.targetName = targetName;
}
public ActionSetTarget(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x8B, actionLength);
//byte[] data = sis.readBytes(actionLength);
//sis = new SWFInputStream(new ByteArrayInputStream(data), version);
targetName = sis.readString("targetName");
}
@Override
public String toString() {
return "SetTarget \"" + Helper.escapeString(targetName) + "\"";
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeString(targetName);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
public ActionSetTarget(FlasmLexer lexer) throws IOException, ParseException {
super(0x8B, -1);
targetName = lexString(lexer);
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
output.add(new SetTargetActionItem(this, targetName));
}
}

View File

@@ -1,101 +1,101 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf3;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraph;
import com.jpexs.decompiler.flash.action.model.ConstantPool;
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
import com.jpexs.decompiler.flash.action.model.clauses.IfFrameLoadedActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.special.ActionStore;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionWaitForFrame extends Action implements ActionStore {
public int frame;
public int skipCount;
public List<Action> skipped;
public ActionWaitForFrame(int actionLength, SWFInputStream sis, ConstantPool cpool) throws IOException {
super(0x8A, actionLength);
frame = sis.readUI16();
skipCount = sis.readUI8();
skipped = new ArrayList<>();
}
@Override
public String toString() {
return "WaitForFrame";
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode) {
String ret = "WaitForFrame " + frame + " " + skipCount;
return ret;
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUI16(frame);
sos.writeUI8(skipCount);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
public ActionWaitForFrame(FlasmLexer lexer) throws IOException, ParseException {
super(0x8A, -1);
frame = (int) lexLong(lexer);
skipCount = (int) lexLong(lexer);
skipped = new ArrayList<>();
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) throws InterruptedException {
GraphTargetItem frameTi = new DirectValueActionItem(null, 0, new Long(frame), new ArrayList<String>());
List<GraphTargetItem> body = ActionGraph.translateViaGraph(regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path);
output.add(new IfFrameLoadedActionItem(frameTi, body, this));
}
@Override
public int getStoreSize() {
return skipCount;
}
@Override
public void setStore(List<Action> store) {
skipped = store;
skipCount = store.size();
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf3;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraph;
import com.jpexs.decompiler.flash.action.model.ConstantPool;
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
import com.jpexs.decompiler.flash.action.model.clauses.IfFrameLoadedActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.special.ActionStore;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionWaitForFrame extends Action implements ActionStore {
public int frame;
public int skipCount;
public List<Action> skipped;
public ActionWaitForFrame(int actionLength, SWFInputStream sis, ConstantPool cpool) throws IOException {
super(0x8A, actionLength);
frame = sis.readUI16("frame");
skipCount = sis.readUI8("skipCount");
skipped = new ArrayList<>();
}
@Override
public String toString() {
return "WaitForFrame";
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode) {
String ret = "WaitForFrame " + frame + " " + skipCount;
return ret;
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUI16(frame);
sos.writeUI8(skipCount);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
public ActionWaitForFrame(FlasmLexer lexer) throws IOException, ParseException {
super(0x8A, -1);
frame = (int) lexLong(lexer);
skipCount = (int) lexLong(lexer);
skipped = new ArrayList<>();
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) throws InterruptedException {
GraphTargetItem frameTi = new DirectValueActionItem(null, 0, new Long(frame), new ArrayList<String>());
List<GraphTargetItem> body = ActionGraph.translateViaGraph(regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path);
output.add(new IfFrameLoadedActionItem(frameTi, body, this));
}
@Override
public int getStoreSize() {
return skipCount;
}
@Override
public void setStore(List<Action> store) {
skipped = store;
skipCount = store.size();
}
}

View File

@@ -1,155 +1,155 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf4;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
import com.jpexs.decompiler.flash.action.model.GetURL2ActionItem;
import com.jpexs.decompiler.flash.action.model.LoadMovieActionItem;
import com.jpexs.decompiler.flash.action.model.LoadMovieNumActionItem;
import com.jpexs.decompiler.flash.action.model.LoadVariablesActionItem;
import com.jpexs.decompiler.flash.action.model.LoadVariablesNumActionItem;
import com.jpexs.decompiler.flash.action.model.PrintActionItem;
import com.jpexs.decompiler.flash.action.model.PrintAsBitmapActionItem;
import com.jpexs.decompiler.flash.action.model.PrintAsBitmapNumActionItem;
import com.jpexs.decompiler.flash.action.model.PrintNumActionItem;
import com.jpexs.decompiler.flash.action.model.UnLoadMovieActionItem;
import com.jpexs.decompiler.flash.action.model.UnLoadMovieNumActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionGetURL2 extends Action {
public int sendVarsMethod;
public static final int GET = 1;
public static final int POST = 2;
public boolean loadTargetFlag;
public boolean loadVariablesFlag;
public int reserved;
public ActionGetURL2(int sendVarsMethod, boolean loadVariablesFlag, boolean loadTargetFlag) {
super(0x9A, 1);
this.loadTargetFlag = loadTargetFlag;
this.loadVariablesFlag = loadVariablesFlag;
this.sendVarsMethod = sendVarsMethod;
}
public ActionGetURL2(int actionLength, SWFInputStream sis) throws IOException {
super(0x9A, actionLength);
loadVariablesFlag = sis.readUB(1) == 1;
loadTargetFlag = sis.readUB(1) == 1;
reserved = (int) sis.readUB(4);
sendVarsMethod = (int) sis.readUB(2); //This is first in documentation, which is WRONG!
}
@Override
public String toString() {
return "GetURL2 " + loadVariablesFlag + " " + loadTargetFlag + " " + sendVarsMethod;
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUB(1, loadVariablesFlag ? 1 : 0);
sos.writeUB(1, loadTargetFlag ? 1 : 0);
sos.writeUB(4, reserved);
sos.writeUB(2, sendVarsMethod);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
public ActionGetURL2(FlasmLexer lexer) throws IOException, ParseException {
super(0x9A, -1);
loadVariablesFlag = lexBoolean(lexer);
loadTargetFlag = lexBoolean(lexer);
sendVarsMethod = (int) lexLong(lexer);
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
GraphTargetItem targetString = stack.pop();
GraphTargetItem urlString = stack.pop();
Integer num = null;
if (targetString.isCompileTime()) {
Object res = targetString.getResult();
if (res instanceof String) {
String tarStr = (String) res;
String levelPrefix = "_level";
if (tarStr.startsWith(levelPrefix)) {
try {
num = Integer.valueOf(tarStr.substring(levelPrefix.length()));
} catch (NumberFormatException nfe) {
}
}
}
}
if (loadVariablesFlag) {
if (num != null) {
output.add(new LoadVariablesNumActionItem(this, urlString, new DirectValueActionItem(null, 0, (Long) (long) (int) num, new ArrayList<String>()), sendVarsMethod));
} else {
output.add(new LoadVariablesActionItem(this, urlString, targetString, sendVarsMethod));
}
} else if (loadTargetFlag) {
if ((urlString instanceof DirectValueActionItem) && (urlString.getResult().equals(""))) {
output.add(new UnLoadMovieActionItem(this, targetString));
} else {
output.add(new LoadMovieActionItem(this, urlString, targetString, sendVarsMethod));
}
} else {
String printPrefix = "print:#";
String printAsBitmapPrefix = "printasbitmap:#";
String urlStr = null;
if (urlString.isCompileTime() && (urlString.getResult() instanceof String)) {
urlStr = (String) urlString.getResult();
}
if (num != null) {
if ("".equals(urlStr)) {
output.add(new UnLoadMovieNumActionItem(this, new DirectValueActionItem(null, 0, (Long) (long) (int) num, new ArrayList<String>())));
} else if (urlStr != null && urlStr.startsWith(printPrefix)) {
output.add(new PrintNumActionItem(this, new DirectValueActionItem((Long) (long) (int) num),
new DirectValueActionItem(urlStr.substring(printPrefix.length()))));
} else if (urlStr != null && urlStr.startsWith(printAsBitmapPrefix)) {
output.add(new PrintAsBitmapNumActionItem(this, new DirectValueActionItem((Long) (long) (int) num), new DirectValueActionItem(urlStr.substring(printAsBitmapPrefix.length()))));
} else {
output.add(new LoadMovieNumActionItem(this, urlString, new DirectValueActionItem(null, 0, (Long) (long) (int) num, new ArrayList<String>()), sendVarsMethod));
}
} else {
if (urlStr != null && urlStr.startsWith(printPrefix)) {
output.add(new PrintActionItem(this, targetString, new DirectValueActionItem(urlStr.substring(printPrefix.length()))));
} else if (urlStr != null && urlStr.startsWith(printAsBitmapPrefix)) {
output.add(new PrintAsBitmapActionItem(this, targetString, new DirectValueActionItem(urlStr.substring(printAsBitmapPrefix.length()))));
} else {
output.add(new GetURL2ActionItem(this, urlString, targetString, sendVarsMethod));
}
}
}
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf4;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
import com.jpexs.decompiler.flash.action.model.GetURL2ActionItem;
import com.jpexs.decompiler.flash.action.model.LoadMovieActionItem;
import com.jpexs.decompiler.flash.action.model.LoadMovieNumActionItem;
import com.jpexs.decompiler.flash.action.model.LoadVariablesActionItem;
import com.jpexs.decompiler.flash.action.model.LoadVariablesNumActionItem;
import com.jpexs.decompiler.flash.action.model.PrintActionItem;
import com.jpexs.decompiler.flash.action.model.PrintAsBitmapActionItem;
import com.jpexs.decompiler.flash.action.model.PrintAsBitmapNumActionItem;
import com.jpexs.decompiler.flash.action.model.PrintNumActionItem;
import com.jpexs.decompiler.flash.action.model.UnLoadMovieActionItem;
import com.jpexs.decompiler.flash.action.model.UnLoadMovieNumActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionGetURL2 extends Action {
public int sendVarsMethod;
public static final int GET = 1;
public static final int POST = 2;
public boolean loadTargetFlag;
public boolean loadVariablesFlag;
public int reserved;
public ActionGetURL2(int sendVarsMethod, boolean loadVariablesFlag, boolean loadTargetFlag) {
super(0x9A, 1);
this.loadTargetFlag = loadTargetFlag;
this.loadVariablesFlag = loadVariablesFlag;
this.sendVarsMethod = sendVarsMethod;
}
public ActionGetURL2(int actionLength, SWFInputStream sis) throws IOException {
super(0x9A, actionLength);
loadVariablesFlag = sis.readUB(1, "loadVariablesFlag") == 1;
loadTargetFlag = sis.readUB(1, "loadTargetFlag") == 1;
reserved = (int) sis.readUB(4, "reserved");
sendVarsMethod = (int) sis.readUB(2, "sendVarsMethod"); //This is first in documentation, which is WRONG!
}
@Override
public String toString() {
return "GetURL2 " + loadVariablesFlag + " " + loadTargetFlag + " " + sendVarsMethod;
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUB(1, loadVariablesFlag ? 1 : 0);
sos.writeUB(1, loadTargetFlag ? 1 : 0);
sos.writeUB(4, reserved);
sos.writeUB(2, sendVarsMethod);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
public ActionGetURL2(FlasmLexer lexer) throws IOException, ParseException {
super(0x9A, -1);
loadVariablesFlag = lexBoolean(lexer);
loadTargetFlag = lexBoolean(lexer);
sendVarsMethod = (int) lexLong(lexer);
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
GraphTargetItem targetString = stack.pop();
GraphTargetItem urlString = stack.pop();
Integer num = null;
if (targetString.isCompileTime()) {
Object res = targetString.getResult();
if (res instanceof String) {
String tarStr = (String) res;
String levelPrefix = "_level";
if (tarStr.startsWith(levelPrefix)) {
try {
num = Integer.valueOf(tarStr.substring(levelPrefix.length()));
} catch (NumberFormatException nfe) {
}
}
}
}
if (loadVariablesFlag) {
if (num != null) {
output.add(new LoadVariablesNumActionItem(this, urlString, new DirectValueActionItem(null, 0, (Long) (long) (int) num, new ArrayList<String>()), sendVarsMethod));
} else {
output.add(new LoadVariablesActionItem(this, urlString, targetString, sendVarsMethod));
}
} else if (loadTargetFlag) {
if ((urlString instanceof DirectValueActionItem) && (urlString.getResult().equals(""))) {
output.add(new UnLoadMovieActionItem(this, targetString));
} else {
output.add(new LoadMovieActionItem(this, urlString, targetString, sendVarsMethod));
}
} else {
String printPrefix = "print:#";
String printAsBitmapPrefix = "printasbitmap:#";
String urlStr = null;
if (urlString.isCompileTime() && (urlString.getResult() instanceof String)) {
urlStr = (String) urlString.getResult();
}
if (num != null) {
if ("".equals(urlStr)) {
output.add(new UnLoadMovieNumActionItem(this, new DirectValueActionItem(null, 0, (Long) (long) (int) num, new ArrayList<String>())));
} else if (urlStr != null && urlStr.startsWith(printPrefix)) {
output.add(new PrintNumActionItem(this, new DirectValueActionItem((Long) (long) (int) num),
new DirectValueActionItem(urlStr.substring(printPrefix.length()))));
} else if (urlStr != null && urlStr.startsWith(printAsBitmapPrefix)) {
output.add(new PrintAsBitmapNumActionItem(this, new DirectValueActionItem((Long) (long) (int) num), new DirectValueActionItem(urlStr.substring(printAsBitmapPrefix.length()))));
} else {
output.add(new LoadMovieNumActionItem(this, urlString, new DirectValueActionItem(null, 0, (Long) (long) (int) num, new ArrayList<String>()), sendVarsMethod));
}
} else {
if (urlStr != null && urlStr.startsWith(printPrefix)) {
output.add(new PrintActionItem(this, targetString, new DirectValueActionItem(urlStr.substring(printPrefix.length()))));
} else if (urlStr != null && urlStr.startsWith(printAsBitmapPrefix)) {
output.add(new PrintAsBitmapActionItem(this, targetString, new DirectValueActionItem(urlStr.substring(printAsBitmapPrefix.length()))));
} else {
output.add(new GetURL2ActionItem(this, urlString, targetString, sendVarsMethod));
}
}
}
}
}

View File

@@ -1,92 +1,92 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf4;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.GotoFrame2ActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionGotoFrame2 extends Action {
boolean sceneBiasFlag;
boolean playFlag;
public int sceneBias;
int reserved;
public ActionGotoFrame2(boolean playFlag, boolean sceneBiasFlag, int sceneBias) {
super(0x9F, 0);
this.sceneBiasFlag = sceneBiasFlag;
this.playFlag = playFlag;
this.sceneBias = sceneBias;
}
public ActionGotoFrame2(int actionLength, SWFInputStream sis) throws IOException {
super(0x9F, actionLength);
reserved = (int) sis.readUB(6);
sceneBiasFlag = sis.readUB(1) == 1;
playFlag = sis.readUB(1) == 1;
if (sceneBiasFlag) {
sceneBias = sis.readUI16();
}
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUB(6, reserved);
sos.writeUB(1, sceneBiasFlag ? 1 : 0);
sos.writeUB(1, playFlag ? 1 : 0);
if (sceneBiasFlag) {
sos.writeUI16(sceneBias);
}
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
@Override
public String toString() {
return "GotoFrame2 " + sceneBiasFlag + " " + playFlag + " " + (sceneBiasFlag ? " " + sceneBias : "");
}
public ActionGotoFrame2(FlasmLexer lexer) throws IOException, ParseException {
super(0x9F, -1);
sceneBiasFlag = lexBoolean(lexer);
playFlag = lexBoolean(lexer);
if (sceneBiasFlag) {
sceneBias = (int) lexLong(lexer);
}
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
GraphTargetItem frame = stack.pop();
output.add(new GotoFrame2ActionItem(this, frame, sceneBiasFlag, playFlag, sceneBias));
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf4;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.GotoFrame2ActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionGotoFrame2 extends Action {
boolean sceneBiasFlag;
boolean playFlag;
public int sceneBias;
int reserved;
public ActionGotoFrame2(boolean playFlag, boolean sceneBiasFlag, int sceneBias) {
super(0x9F, 0);
this.sceneBiasFlag = sceneBiasFlag;
this.playFlag = playFlag;
this.sceneBias = sceneBias;
}
public ActionGotoFrame2(int actionLength, SWFInputStream sis) throws IOException {
super(0x9F, actionLength);
reserved = (int) sis.readUB(6, "reserved");
sceneBiasFlag = sis.readUB(1, "sceneBiasFlag") == 1;
playFlag = sis.readUB(1, "playFlag") == 1;
if (sceneBiasFlag) {
sceneBias = sis.readUI16("sceneBias");
}
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUB(6, reserved);
sos.writeUB(1, sceneBiasFlag ? 1 : 0);
sos.writeUB(1, playFlag ? 1 : 0);
if (sceneBiasFlag) {
sos.writeUI16(sceneBias);
}
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
@Override
public String toString() {
return "GotoFrame2 " + sceneBiasFlag + " " + playFlag + " " + (sceneBiasFlag ? " " + sceneBias : "");
}
public ActionGotoFrame2(FlasmLexer lexer) throws IOException, ParseException {
super(0x9F, -1);
sceneBiasFlag = lexBoolean(lexer);
playFlag = lexBoolean(lexer);
if (sceneBiasFlag) {
sceneBias = (int) lexLong(lexer);
}
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
GraphTargetItem frame = stack.pop();
output.add(new GotoFrame2ActionItem(this, frame, sceneBiasFlag, playFlag, sceneBias));
}
}

View File

@@ -1,131 +1,131 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf4;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraphSource;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.graph.GraphSource;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ActionIf extends Action {
private int offset;
public String identifier;
public boolean jumpUsed = true;
public boolean ignoreUsed = true;
public int getJumpOffset() {
return offset;
}
public final void setJumpOffset(int offset) {
this.offset = offset;
}
public ActionIf(int offset) {
super(0x9D, 2);
setJumpOffset(offset);
}
public ActionIf(int actionLength, SWFInputStream sis) throws IOException {
super(0x9D, actionLength);
setJumpOffset(sis.readSI16());
}
@Override
public List<Long> getAllRefs(int version) {
List<Long> ret = new ArrayList<>();
ret.add(getRef(version));
return ret;
}
public long getRef(int version) {
return getAddress() + getBytes(version).length + offset;
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeSI16(offset);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode) {
String ofsStr = Helper.formatAddress(getAddress() + getBytes(version).length + offset);
return "If loc" + ofsStr + (!jumpUsed ? " ;compileTimeIgnore" : (!ignoreUsed ? " ;compileTimeJump" : ""));
}
public ActionIf(FlasmLexer lexer) throws IOException, ParseException {
super(0x9D, -1);
identifier = lexIdentifier(lexer);
}
@Override
public List<Action> getAllIfsOrJumps() {
List<Action> ret = new ArrayList<>();
ret.add(this);
return ret;
}
@Override
public String toString() {
return "ActionIf";
}
@Override
public boolean isBranch() {
return true;
}
@Override
public List<Integer> getBranches(GraphSource code) {
List<Integer> ret = super.getBranches(code);
int jmp = code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length + offset);
int after = code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length);
if (jmp == -1) {
Logger.getLogger(ActionIf.class.getName()).log(Level.SEVERE, "Invalid IF jump to ofs" + Helper.formatAddress(getAddress() + getBytes(((ActionGraphSource) code).version).length + offset));
ret.add(after);
} else {
ret.add(jmp);
}
ret.add(after);
return ret;
}
@Override
public boolean ignoredLoops() {
return false; //compileTime;
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf4;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraphSource;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.graph.GraphSource;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ActionIf extends Action {
private int offset;
public String identifier;
public boolean jumpUsed = true;
public boolean ignoreUsed = true;
public int getJumpOffset() {
return offset;
}
public final void setJumpOffset(int offset) {
this.offset = offset;
}
public ActionIf(int offset) {
super(0x9D, 2);
setJumpOffset(offset);
}
public ActionIf(int actionLength, SWFInputStream sis) throws IOException {
super(0x9D, actionLength);
setJumpOffset(sis.readSI16("offset"));
}
@Override
public List<Long> getAllRefs(int version) {
List<Long> ret = new ArrayList<>();
ret.add(getRef(version));
return ret;
}
public long getRef(int version) {
return getAddress() + getBytes(version).length + offset;
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeSI16(offset);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode) {
String ofsStr = Helper.formatAddress(getAddress() + getBytes(version).length + offset);
return "If loc" + ofsStr + (!jumpUsed ? " ;compileTimeIgnore" : (!ignoreUsed ? " ;compileTimeJump" : ""));
}
public ActionIf(FlasmLexer lexer) throws IOException, ParseException {
super(0x9D, -1);
identifier = lexIdentifier(lexer);
}
@Override
public List<Action> getAllIfsOrJumps() {
List<Action> ret = new ArrayList<>();
ret.add(this);
return ret;
}
@Override
public String toString() {
return "ActionIf";
}
@Override
public boolean isBranch() {
return true;
}
@Override
public List<Integer> getBranches(GraphSource code) {
List<Integer> ret = super.getBranches(code);
int jmp = code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length + offset);
int after = code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length);
if (jmp == -1) {
Logger.getLogger(ActionIf.class.getName()).log(Level.SEVERE, "Invalid IF jump to ofs" + Helper.formatAddress(getAddress() + getBytes(((ActionGraphSource) code).version).length + offset));
ret.add(after);
} else {
ret.add(jmp);
}
ret.add(after);
return ret;
}
@Override
public boolean ignoredLoops() {
return false; //compileTime;
}
}

View File

@@ -1,124 +1,124 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf4;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraphSource;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.graph.GraphSource;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ActionJump extends Action {
private int offset;
public String identifier;
public boolean isContinue = false;
public boolean isBreak = false;
public int getJumpOffset() {
return offset;
}
public final void setJumpOffset(int offset) {
this.offset = offset;
}
public ActionJump(int offset) {
super(0x99, 2);
setJumpOffset(offset);
}
public ActionJump(int actionLength, SWFInputStream sis) throws IOException {
super(0x99, actionLength);
setJumpOffset(sis.readSI16());
}
@Override
public List<Long> getAllRefs(int version) {
List<Long> ret = new ArrayList<>();
ret.add(getRef(version));
return ret;
}
public long getRef(int version) {
return getAddress() + getBytes(version).length + offset;
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeSI16(offset);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode) {
String ofsStr = Helper.formatAddress(getAddress() + getBytes(version).length + offset);
return "Jump loc" + ofsStr;
}
public ActionJump(FlasmLexer lexer) throws IOException, ParseException {
super(0x99, 0);
identifier = lexIdentifier(lexer);
}
@Override
public List<Action> getAllIfsOrJumps() {
List<Action> ret = new ArrayList<>();
ret.add(this);
return ret;
}
@Override
public String toString() {
return "Jump " + offset;
}
@Override
public boolean isJump() {
return true;
}
@Override
public List<Integer> getBranches(GraphSource code) {
List<Integer> ret = super.getBranches(code);
int ofs = code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length + offset);
if (ofs == -1) {
ofs = code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length);
new Exception().printStackTrace();
Logger.getLogger(ActionJump.class.getName()).log(Level.SEVERE, "Invalid jump to ofs" + Helper.formatAddress(getAddress() + getBytes(((ActionGraphSource) code).version).length + offset) + " from ofs" + Helper.formatAddress(getAddress()));
}
ret.add(ofs);
return ret;
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf4;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraphSource;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.graph.GraphSource;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ActionJump extends Action {
private int offset;
public String identifier;
public boolean isContinue = false;
public boolean isBreak = false;
public int getJumpOffset() {
return offset;
}
public final void setJumpOffset(int offset) {
this.offset = offset;
}
public ActionJump(int offset) {
super(0x99, 2);
setJumpOffset(offset);
}
public ActionJump(int actionLength, SWFInputStream sis) throws IOException {
super(0x99, actionLength);
setJumpOffset(sis.readSI16("offset"));
}
@Override
public List<Long> getAllRefs(int version) {
List<Long> ret = new ArrayList<>();
ret.add(getRef(version));
return ret;
}
public long getRef(int version) {
return getAddress() + getBytes(version).length + offset;
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeSI16(offset);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode) {
String ofsStr = Helper.formatAddress(getAddress() + getBytes(version).length + offset);
return "Jump loc" + ofsStr;
}
public ActionJump(FlasmLexer lexer) throws IOException, ParseException {
super(0x99, 0);
identifier = lexIdentifier(lexer);
}
@Override
public List<Action> getAllIfsOrJumps() {
List<Action> ret = new ArrayList<>();
ret.add(this);
return ret;
}
@Override
public String toString() {
return "Jump " + offset;
}
@Override
public boolean isJump() {
return true;
}
@Override
public List<Integer> getBranches(GraphSource code) {
List<Integer> ret = super.getBranches(code);
int ofs = code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length + offset);
if (ofs == -1) {
ofs = code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length);
new Exception().printStackTrace();
Logger.getLogger(ActionJump.class.getName()).log(Level.SEVERE, "Invalid jump to ofs" + Helper.formatAddress(getAddress() + getBytes(((ActionGraphSource) code).version).length + offset) + " from ofs" + Helper.formatAddress(getAddress()));
}
ret.add(ofs);
return ret;
}
}

View File

@@ -77,16 +77,16 @@ public class ActionPush extends Action {
super(0x96, actionLength);
int type;
values = new ArrayList<>();
sis = new SWFInputStream(sis.getSwf(), sis.readBytesEx(actionLength));
sis = new SWFInputStream(sis.getSwf(), sis.readBytesEx(actionLength, "actionPush"));
try {
while (sis.available() > 0) {
type = sis.readUI8();
type = sis.readUI8("type");
switch (type) {
case 0:
values.add(sis.readString());
values.add(sis.readString("string"));
break;
case 1:
values.add(sis.readFLOAT());
values.add(sis.readFLOAT("float"));
break;
case 2:
values.add(new Null());
@@ -95,10 +95,10 @@ public class ActionPush extends Action {
values.add(new Undefined());
break;
case 4:
values.add(new RegisterNumber(sis.readUI8()));
values.add(new RegisterNumber(sis.readUI8("registerNumber")));
break;
case 5:
int b = sis.readUI8();
int b = sis.readUI8("boolean");
if (b == 0) {
values.add((Boolean) false);
} else {
@@ -107,17 +107,17 @@ public class ActionPush extends Action {
break;
case 6:
values.add(sis.readDOUBLE());
values.add(sis.readDOUBLE("double"));
break;
case 7:
long el = sis.readSI32();
long el = sis.readSI32("el");
values.add((Long) el);
break;
case 8:
values.add(new ConstantIndex(sis.readUI8()));
values.add(new ConstantIndex(sis.readUI8("constantIndex")));
break;
case 9:
values.add(new ConstantIndex(sis.readUI16()));
values.add(new ConstantIndex(sis.readUI16("constantIndex")));
break;
}
}

View File

@@ -1,136 +1,136 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf4;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraph;
import com.jpexs.decompiler.flash.action.model.ConstantPool;
import com.jpexs.decompiler.flash.action.model.clauses.IfFrameLoadedActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.special.ActionStore;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionWaitForFrame2 extends Action implements ActionStore {
public int skipCount;
List<Action> skipped;
public ActionWaitForFrame2(int skipCount) {
super(0x8D, 1);
this.skipCount = skipCount;
skipped = new ArrayList<>();
}
@Override
public int getStoreSize() {
return skipCount;
}
@Override
public void setStore(List<Action> store) {
skipped = store;
skipCount = store.size();
}
public ActionWaitForFrame2(int actionLength, SWFInputStream sis, ConstantPool cpool) throws IOException {
super(0x8D, actionLength);
skipCount = sis.readUI8();
skipped = new ArrayList<>();
/*for (int i = 0; i < skipCount; i++) {
Action a = sis.readAction(cpool);
if (a instanceof ActionEnd) {
skipCount = i;
break;
}
if (a == null) {
skipCount = i;
break;
}
skipped.add(a);
}
boolean deobfuscate = Configuration.getConfig("autoDeobfuscate", true);
if (deobfuscate) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (int i = 0; i < skipCount; i++) {
baos.write(skipped.get(i).getBytes(sis.getVersion()));
}
baos.write(new ActionEnd().getBytes(sis.getVersion()));
SWFInputStream sis2 = new SWFInputStream(new ByteArrayInputStream(baos.toByteArray()), sis.getVersion());
skipped = sis2.readActionList(new ArrayList<DisassemblyListener>(), 0, "");
if (!skipped.isEmpty()) {
if (skipped.get(skipped.size() - 1) instanceof ActionEnd) {
skipped.remove(skipped.size() - 1);
}
}
skipCount = skipped.size();
}*/
}
public ActionWaitForFrame2(FlasmLexer lexer) throws IOException, ParseException {
super(0x8D, -1);
skipCount = (int) lexLong(lexer);
skipped = new ArrayList<>();
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUI8(skipCount);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
@Override
public String toString() {
return "WaitForFrame2";
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode) {
String ret = "WaitForFrame2 " + skipCount;
/*for (int i = 0; i < skipped.size(); i++) {
if (skipped.get(i) instanceof ActionEnd) {
break;
}
ret += "\r\n" + skipped.get(i).getASMSource(container, knownAddreses, constantPool, version, exportMode);
}*/
return ret;
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) throws InterruptedException {
GraphTargetItem frame = stack.pop();
List<GraphTargetItem> body = ActionGraph.translateViaGraph(regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path);
output.add(new IfFrameLoadedActionItem(frame, body, this));
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf4;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraph;
import com.jpexs.decompiler.flash.action.model.ConstantPool;
import com.jpexs.decompiler.flash.action.model.clauses.IfFrameLoadedActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.special.ActionStore;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionWaitForFrame2 extends Action implements ActionStore {
public int skipCount;
List<Action> skipped;
public ActionWaitForFrame2(int skipCount) {
super(0x8D, 1);
this.skipCount = skipCount;
skipped = new ArrayList<>();
}
@Override
public int getStoreSize() {
return skipCount;
}
@Override
public void setStore(List<Action> store) {
skipped = store;
skipCount = store.size();
}
public ActionWaitForFrame2(int actionLength, SWFInputStream sis, ConstantPool cpool) throws IOException {
super(0x8D, actionLength);
skipCount = sis.readUI8("skipCount");
skipped = new ArrayList<>();
/*for (int i = 0; i < skipCount; i++) {
Action a = sis.readAction(cpool);
if (a instanceof ActionEnd) {
skipCount = i;
break;
}
if (a == null) {
skipCount = i;
break;
}
skipped.add(a);
}
boolean deobfuscate = Configuration.getConfig("autoDeobfuscate", true);
if (deobfuscate) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (int i = 0; i < skipCount; i++) {
baos.write(skipped.get(i).getBytes(sis.getVersion()));
}
baos.write(new ActionEnd().getBytes(sis.getVersion()));
SWFInputStream sis2 = new SWFInputStream(new ByteArrayInputStream(baos.toByteArray()), sis.getVersion());
skipped = sis2.readActionList(new ArrayList<DisassemblyListener>(), 0, "");
if (!skipped.isEmpty()) {
if (skipped.get(skipped.size() - 1) instanceof ActionEnd) {
skipped.remove(skipped.size() - 1);
}
}
skipCount = skipped.size();
}*/
}
public ActionWaitForFrame2(FlasmLexer lexer) throws IOException, ParseException {
super(0x8D, -1);
skipCount = (int) lexLong(lexer);
skipped = new ArrayList<>();
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUI8(skipCount);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
@Override
public String toString() {
return "WaitForFrame2";
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode) {
String ret = "WaitForFrame2 " + skipCount;
/*for (int i = 0; i < skipped.size(); i++) {
if (skipped.get(i) instanceof ActionEnd) {
break;
}
ret += "\r\n" + skipped.get(i).getASMSource(container, knownAddreses, constantPool, version, exportMode);
}*/
return ret;
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) throws InterruptedException {
GraphTargetItem frame = stack.pop();
List<GraphTargetItem> body = ActionGraph.translateViaGraph(regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path);
output.add(new IfFrameLoadedActionItem(frame, body, this));
}
}

View File

@@ -1,95 +1,95 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf5;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionConstantPool extends Action {
public List<String> constantPool = new ArrayList<>();
public ActionConstantPool(List<String> constantPool) {
super(0x88, 0);
this.constantPool = constantPool;
}
public ActionConstantPool(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x88, actionLength);
//sis = new SWFInputStream(new ByteArrayInputStream(sis.readBytes(actionLength)), version);
int count = sis.readUI16();
for (int i = 0; i < count; i++) {
constantPool.add(sis.readString());
}
}
public ActionConstantPool(FlasmLexer lexer) throws IOException, ParseException {
super(0x88, 0);
while (true) {
ASMParsedSymbol symb = lexer.yylex();
if (symb.type == ASMParsedSymbol.TYPE_STRING) {
constantPool.add((String) symb.value);
} else {
lexer.yypushback(lexer.yylength());
break;
}
}
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUI16(constantPool.size());
for (String s : constantPool) {
sos.writeString(s);
}
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
@Override
public String toString() {
String ret = "";
for (int i = 0; i < constantPool.size(); i++) {
if (i > 0) {
ret += " ";
}
ret += "\"" + Helper.escapeString(constantPool.get(i)) + "\"";
}
return "ConstantPool " + ret;
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf5;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionConstantPool extends Action {
public List<String> constantPool = new ArrayList<>();
public ActionConstantPool(List<String> constantPool) {
super(0x88, 0);
this.constantPool = constantPool;
}
public ActionConstantPool(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x88, actionLength);
//sis = new SWFInputStream(new ByteArrayInputStream(sis.readBytes(actionLength)), version);
int count = sis.readUI16("count");
for (int i = 0; i < count; i++) {
constantPool.add(sis.readString("constant"));
}
}
public ActionConstantPool(FlasmLexer lexer) throws IOException, ParseException {
super(0x88, 0);
while (true) {
ASMParsedSymbol symb = lexer.yylex();
if (symb.type == ASMParsedSymbol.TYPE_STRING) {
constantPool.add((String) symb.value);
} else {
lexer.yypushback(lexer.yylength());
break;
}
}
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUI16(constantPool.size());
for (String s : constantPool) {
sos.writeString(s);
}
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
@Override
public String toString() {
String ret = "";
for (int i = 0; i < constantPool.size(); i++) {
if (i > 0) {
ret += " ";
}
ret += "\"" + Helper.escapeString(constantPool.get(i)) + "\"";
}
return "ConstantPool " + ret;
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
}
}

View File

@@ -1,248 +1,248 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf5;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.FunctionActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionDefineFunction extends Action implements GraphSourceItemContainer {
public String functionName;
public String replacedFunctionName;
public List<String> paramNames = new ArrayList<>();
public List<String> replacedParamNames;
//public List<Action> code;
public int codeSize;
private int version;
public List<String> constantPool;
private long hdrSize;
public ActionDefineFunction(String functionName, List<String> paramNames, int codeSize, int version) {
super(0x9B, 0);
this.functionName = functionName;
this.codeSize = codeSize;
this.version = version;
this.paramNames = paramNames;
}
public ActionDefineFunction(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x9B, actionLength);
this.version = version;
//byte[] data=sis.readBytes(actionLength);
//sis=new SWFInputStream(new ByteArrayInputStream(data),version);
long startPos = sis.getPos();
functionName = sis.readString();
int numParams = sis.readUI16();
for (int i = 0; i < numParams; i++) {
paramNames.add(sis.readString());
}
codeSize = sis.readUI16();
long endPos = sis.getPos();
//code = new ArrayList<Action>();
hdrSize = endPos - startPos;
//int posBef2 = (int) rri.getPos();
//code = sis.readActionList(rri.getPos(), getFileAddress() + hdrSize, rri, codeSize);
//rri.setPos(posBef2 + codeSize);
}
public ActionDefineFunction(FlasmLexer lexer) throws IOException, ParseException {
super(0x9B, -1);
functionName = lexString(lexer);
int numParams = (int) lexLong(lexer);
for (int i = 0; i < numParams; i++) {
paramNames.add(lexString(lexer));
}
lexBlockOpen(lexer);
}
@Override
public long getHeaderSize() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
try {
sos.writeString(functionName);
sos.writeUI16(paramNames.size());
for (String s : paramNames) {
sos.writeString(s);
}
sos.writeUI16(0);
sos.close();
baos2.write(surroundWithAction(baos.toByteArray(), version));
} catch (IOException e) {
}
return baos2.toByteArray().length;
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
try {
sos.writeString(functionName);
sos.writeUI16(paramNames.size());
for (String s : paramNames) {
sos.writeString(s);
}
//byte[] codeBytes = Action.actionsToBytes(code, false, version);
sos.writeUI16(codeSize); //codeBytes.length);
sos.close();
baos2.write(surroundWithAction(baos.toByteArray(), version));
//baos2.write(codeBytes);
} catch (IOException e) {
}
return baos2.toByteArray();
}
private long getPreLen(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeString(functionName);
sos.writeUI16(paramNames.size());
for (String s : paramNames) {
sos.writeString(s);
}
sos.writeUI16(0);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version).length;
}
@Override
public void setAddress(long address, int version, boolean recursive) {
super.setAddress(address, version, recursive);
if (recursive) {
//Action.setActionsAddresses(, address + getPreLen(version), version);
}
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode) {
String paramStr = "";
for (int i = 0; i < paramNames.size(); i++) {
paramStr += "\"" + Helper.escapeString(paramNames.get(i)) + "\"";
paramStr += " ";
}
return "DefineFunction \"" + Helper.escapeString(functionName) + "\" " + paramNames.size() + " " + paramStr + " {" + (codeSize == 0 ? "\r\n}" : "");// + "\r\n" +Action.actionsToString(getAddress() + getHeaderLength(),getItems(container) , knownAddreses, constantPool, version, hex, getFileAddress() + hdrSize) + "}";
}
@Override
public GraphTextWriter getASMSourceReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer) {
List<String> oldParamNames = paramNames;
if (replacedParamNames != null) {
paramNames = replacedParamNames;
}
String oldFunctionName = functionName;
if (replacedFunctionName != null) {
functionName = replacedFunctionName;
}
String ret = getASMSource(container, knownAddreses, constantPool, version, exportMode);
paramNames = oldParamNames;
functionName = oldFunctionName;
writer.appendNoHilight(ret);
return writer;
}
@Override
public List<Long> getAllRefs(int version) {
return super.getAllRefs(version);//Action.getActionsAllRefs(getActions(null), version);
}
@Override
public List<Action> getAllIfsOrJumps() {
return super.getAllIfsOrJumps(); //Action.getActionsAllIfsOrJumps(code);
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
}
@Override
public HashMap<Integer, String> getRegNames() {
return new HashMap<>();
}
@Override
public void translateContainer(List<List<GraphTargetItem>> content, Stack<GraphTargetItem> stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, 1, new ArrayList<VariableActionItem>());
//ActionGraph.translateViaGraph(regNames, variables, functions, code, version)
stack.push(fti);
functions.put(functionName, fti);
}
@Override
public String toString() {
return "DefineFunction";
}
@Override
public boolean parseDivision(long size, FlasmLexer lexer) {
codeSize = (int) (size - getHeaderSize());
return false;
}
@Override
public List<Long> getContainerSizes() {
List<Long> ret = new ArrayList<>();
ret.add((Long) (long) codeSize);
return ret;
}
@Override
public void setContainerSize(int index, long size) {
if (index == 0) {
codeSize = (int) size;
} else {
throw new IllegalArgumentException("Index must be 0.");
}
}
@Override
public String getASMSourceBetween(int pos) {
return "";
}
@Override
public String getName() {
return "function";
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf5;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.FunctionActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionDefineFunction extends Action implements GraphSourceItemContainer {
public String functionName;
public String replacedFunctionName;
public List<String> paramNames = new ArrayList<>();
public List<String> replacedParamNames;
//public List<Action> code;
public int codeSize;
private int version;
public List<String> constantPool;
private long hdrSize;
public ActionDefineFunction(String functionName, List<String> paramNames, int codeSize, int version) {
super(0x9B, 0);
this.functionName = functionName;
this.codeSize = codeSize;
this.version = version;
this.paramNames = paramNames;
}
public ActionDefineFunction(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x9B, actionLength);
this.version = version;
//byte[] data=sis.readBytes(actionLength);
//sis=new SWFInputStream(new ByteArrayInputStream(data),version);
long startPos = sis.getPos();
functionName = sis.readString("functionName");
int numParams = sis.readUI16("numParams");
for (int i = 0; i < numParams; i++) {
paramNames.add(sis.readString("paramName"));
}
codeSize = sis.readUI16("codeSize");
long endPos = sis.getPos();
//code = new ArrayList<Action>();
hdrSize = endPos - startPos;
//int posBef2 = (int) rri.getPos();
//code = sis.readActionList(rri.getPos(), getFileAddress() + hdrSize, rri, codeSize);
//rri.setPos(posBef2 + codeSize);
}
public ActionDefineFunction(FlasmLexer lexer) throws IOException, ParseException {
super(0x9B, -1);
functionName = lexString(lexer);
int numParams = (int) lexLong(lexer);
for (int i = 0; i < numParams; i++) {
paramNames.add(lexString(lexer));
}
lexBlockOpen(lexer);
}
@Override
public long getHeaderSize() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
try {
sos.writeString(functionName);
sos.writeUI16(paramNames.size());
for (String s : paramNames) {
sos.writeString(s);
}
sos.writeUI16(0);
sos.close();
baos2.write(surroundWithAction(baos.toByteArray(), version));
} catch (IOException e) {
}
return baos2.toByteArray().length;
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
try {
sos.writeString(functionName);
sos.writeUI16(paramNames.size());
for (String s : paramNames) {
sos.writeString(s);
}
//byte[] codeBytes = Action.actionsToBytes(code, false, version);
sos.writeUI16(codeSize); //codeBytes.length);
sos.close();
baos2.write(surroundWithAction(baos.toByteArray(), version));
//baos2.write(codeBytes);
} catch (IOException e) {
}
return baos2.toByteArray();
}
private long getPreLen(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeString(functionName);
sos.writeUI16(paramNames.size());
for (String s : paramNames) {
sos.writeString(s);
}
sos.writeUI16(0);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version).length;
}
@Override
public void setAddress(long address, int version, boolean recursive) {
super.setAddress(address, version, recursive);
if (recursive) {
//Action.setActionsAddresses(, address + getPreLen(version), version);
}
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode) {
String paramStr = "";
for (int i = 0; i < paramNames.size(); i++) {
paramStr += "\"" + Helper.escapeString(paramNames.get(i)) + "\"";
paramStr += " ";
}
return "DefineFunction \"" + Helper.escapeString(functionName) + "\" " + paramNames.size() + " " + paramStr + " {" + (codeSize == 0 ? "\r\n}" : "");// + "\r\n" +Action.actionsToString(getAddress() + getHeaderLength(),getItems(container) , knownAddreses, constantPool, version, hex, getFileAddress() + hdrSize) + "}";
}
@Override
public GraphTextWriter getASMSourceReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer) {
List<String> oldParamNames = paramNames;
if (replacedParamNames != null) {
paramNames = replacedParamNames;
}
String oldFunctionName = functionName;
if (replacedFunctionName != null) {
functionName = replacedFunctionName;
}
String ret = getASMSource(container, knownAddreses, constantPool, version, exportMode);
paramNames = oldParamNames;
functionName = oldFunctionName;
writer.appendNoHilight(ret);
return writer;
}
@Override
public List<Long> getAllRefs(int version) {
return super.getAllRefs(version);//Action.getActionsAllRefs(getActions(null), version);
}
@Override
public List<Action> getAllIfsOrJumps() {
return super.getAllIfsOrJumps(); //Action.getActionsAllIfsOrJumps(code);
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
}
@Override
public HashMap<Integer, String> getRegNames() {
return new HashMap<>();
}
@Override
public void translateContainer(List<List<GraphTargetItem>> content, Stack<GraphTargetItem> stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, 1, new ArrayList<VariableActionItem>());
//ActionGraph.translateViaGraph(regNames, variables, functions, code, version)
stack.push(fti);
functions.put(functionName, fti);
}
@Override
public String toString() {
return "DefineFunction";
}
@Override
public boolean parseDivision(long size, FlasmLexer lexer) {
codeSize = (int) (size - getHeaderSize());
return false;
}
@Override
public List<Long> getContainerSizes() {
List<Long> ret = new ArrayList<>();
ret.add((Long) (long) codeSize);
return ret;
}
@Override
public void setContainerSize(int index, long size) {
if (index == 0) {
codeSize = (int) size;
} else {
throw new IllegalArgumentException("Index must be 0.");
}
}
@Override
public String getASMSourceBetween(int pos) {
return "";
}
@Override
public String getName() {
return "function";
}
}

View File

@@ -1,140 +1,140 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf5;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.StoreTypeAction;
import com.jpexs.decompiler.flash.action.model.ConstantPool;
import com.jpexs.decompiler.flash.action.model.DecrementActionItem;
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
import com.jpexs.decompiler.flash.action.model.IncrementActionItem;
import com.jpexs.decompiler.flash.action.model.PostDecrementActionItem;
import com.jpexs.decompiler.flash.action.model.PostIncrementActionItem;
import com.jpexs.decompiler.flash.action.model.StoreRegisterActionItem;
import com.jpexs.decompiler.flash.action.model.TemporaryRegister;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionStoreRegister extends Action implements StoreTypeAction {
public int registerNumber;
public ActionStoreRegister(int registerNumber) {
super(0x87, 1);
this.registerNumber = registerNumber;
}
public ActionStoreRegister(int actionLength, SWFInputStream sis) throws IOException {
super(0x87, actionLength);
registerNumber = sis.readUI8();
}
public ActionStoreRegister(FlasmLexer lexer) throws IOException, ParseException {
super(0x87, 0);
registerNumber = (int) lexLong(lexer);
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUI8(registerNumber);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
@Override
public String toString() {
return "StoreRegister " + registerNumber;
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
GraphTargetItem value = stack.pop();
RegisterNumber rn = new RegisterNumber(registerNumber);
if (regNames.containsKey(registerNumber)) {
rn.name = regNames.get(registerNumber);
}
value.moreSrc.add(new GraphSourceItemPos(this, 0));
if (variables.containsKey("__register" + registerNumber)) {
if (variables.get("__register" + registerNumber) instanceof TemporaryRegister) {
variables.remove("__register" + registerNumber);
}
}
boolean define = !variables.containsKey("__register" + registerNumber);
if (regNames.containsKey(registerNumber)) {
define = false;
}
variables.put("__register" + registerNumber, value);
if (value instanceof DirectValueActionItem) {
if (((DirectValueActionItem) value).value instanceof RegisterNumber) {
if (((RegisterNumber) ((DirectValueActionItem) value).value).number == registerNumber) {
stack.push(value);
return;
}
}
}
if (value instanceof StoreRegisterActionItem) {
if (((StoreRegisterActionItem) value).register.number == registerNumber) {
stack.push(value);
return;
}
}
if (value instanceof IncrementActionItem) {
GraphTargetItem obj = ((IncrementActionItem) value).object;
if (!stack.isEmpty()) {
if (stack.peek().valueEquals(obj)) {
stack.pop();
stack.push(new PostIncrementActionItem(this, obj));
stack.push(obj);
return;
}
}
}
if (value instanceof DecrementActionItem) {
GraphTargetItem obj = ((DecrementActionItem) value).object;
if (!stack.isEmpty()) {
if (stack.peek().valueEquals(obj)) {
stack.pop();
stack.push(new PostDecrementActionItem(this, obj));
stack.push(obj);
return;
}
}
}
stack.push(new StoreRegisterActionItem(this, rn, value, define));
}
@Override
public String getVariableName(Stack<GraphTargetItem> stack, ConstantPool cpool) {
return "__register" + registerNumber;
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf5;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.StoreTypeAction;
import com.jpexs.decompiler.flash.action.model.ConstantPool;
import com.jpexs.decompiler.flash.action.model.DecrementActionItem;
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
import com.jpexs.decompiler.flash.action.model.IncrementActionItem;
import com.jpexs.decompiler.flash.action.model.PostDecrementActionItem;
import com.jpexs.decompiler.flash.action.model.PostIncrementActionItem;
import com.jpexs.decompiler.flash.action.model.StoreRegisterActionItem;
import com.jpexs.decompiler.flash.action.model.TemporaryRegister;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionStoreRegister extends Action implements StoreTypeAction {
public int registerNumber;
public ActionStoreRegister(int registerNumber) {
super(0x87, 1);
this.registerNumber = registerNumber;
}
public ActionStoreRegister(int actionLength, SWFInputStream sis) throws IOException {
super(0x87, actionLength);
registerNumber = sis.readUI8("registerNumber");
}
public ActionStoreRegister(FlasmLexer lexer) throws IOException, ParseException {
super(0x87, 0);
registerNumber = (int) lexLong(lexer);
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUI8(registerNumber);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
@Override
public String toString() {
return "StoreRegister " + registerNumber;
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
GraphTargetItem value = stack.pop();
RegisterNumber rn = new RegisterNumber(registerNumber);
if (regNames.containsKey(registerNumber)) {
rn.name = regNames.get(registerNumber);
}
value.moreSrc.add(new GraphSourceItemPos(this, 0));
if (variables.containsKey("__register" + registerNumber)) {
if (variables.get("__register" + registerNumber) instanceof TemporaryRegister) {
variables.remove("__register" + registerNumber);
}
}
boolean define = !variables.containsKey("__register" + registerNumber);
if (regNames.containsKey(registerNumber)) {
define = false;
}
variables.put("__register" + registerNumber, value);
if (value instanceof DirectValueActionItem) {
if (((DirectValueActionItem) value).value instanceof RegisterNumber) {
if (((RegisterNumber) ((DirectValueActionItem) value).value).number == registerNumber) {
stack.push(value);
return;
}
}
}
if (value instanceof StoreRegisterActionItem) {
if (((StoreRegisterActionItem) value).register.number == registerNumber) {
stack.push(value);
return;
}
}
if (value instanceof IncrementActionItem) {
GraphTargetItem obj = ((IncrementActionItem) value).object;
if (!stack.isEmpty()) {
if (stack.peek().valueEquals(obj)) {
stack.pop();
stack.push(new PostIncrementActionItem(this, obj));
stack.push(obj);
return;
}
}
}
if (value instanceof DecrementActionItem) {
GraphTargetItem obj = ((DecrementActionItem) value).object;
if (!stack.isEmpty()) {
if (stack.peek().valueEquals(obj)) {
stack.pop();
stack.push(new PostDecrementActionItem(this, obj));
stack.push(obj);
return;
}
}
}
stack.push(new StoreRegisterActionItem(this, rn, value, define));
}
@Override
public String getVariableName(Stack<GraphTargetItem> stack, ConstantPool cpool) {
return "__register" + registerNumber;
}
}

View File

@@ -1,137 +1,137 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf5;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.clauses.WithActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionWith extends Action implements GraphSourceItemContainer {
public int codeSize;
public int version;
public ActionWith(int codeSize) {
super(0x94, 2);
this.codeSize = codeSize;
}
@Override
public boolean parseDivision(long size, FlasmLexer lexer) {
codeSize = (int) (size - getHeaderSize());
return false;
}
public ActionWith(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x94, actionLength);
codeSize = sis.readUI16();
this.version = version;
}
public ActionWith(FlasmLexer lexer) throws IOException, ParseException {
super(0x94, 2);
lexBlockOpen(lexer);
}
@Override
public void setAddress(long address, int version, boolean recursive) {
super.setAddress(address, version, recursive);
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUI16(codeSize);//codeBytes.length);
sos.close();
baos2.write(surroundWithAction(baos.toByteArray(), version));
} catch (IOException e) {
}
return baos2.toByteArray();
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode) {
return "With {";
}
@Override
public List<Long> getAllRefs(int version) {
return super.getAllRefs(version);
}
@Override
public List<Action> getAllIfsOrJumps() {
return super.getAllIfsOrJumps();
}
@Override
public void translateContainer(List<List<GraphTargetItem>> content, Stack<GraphTargetItem> stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
output.add(new WithActionItem(this, stack.pop(), content.get(0)));
}
@Override
public List<Long> getContainerSizes() {
List<Long> ret = new ArrayList<>();
ret.add((Long) (long) codeSize);
return ret;
}
@Override
public void setContainerSize(int index, long size) {
if (index == 0) {
codeSize = (int) size;
} else {
throw new IllegalArgumentException("Index must be 0.");
}
}
@Override
public String getASMSourceBetween(int pos) {
return "";
}
@Override
public long getHeaderSize() {
return surroundWithAction(new byte[]{0, 0}, version).length;
}
@Override
public HashMap<Integer, String> getRegNames() {
return new HashMap<>();
}
@Override
public String getName() {
return null;
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf5;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.clauses.WithActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionWith extends Action implements GraphSourceItemContainer {
public int codeSize;
public int version;
public ActionWith(int codeSize) {
super(0x94, 2);
this.codeSize = codeSize;
}
@Override
public boolean parseDivision(long size, FlasmLexer lexer) {
codeSize = (int) (size - getHeaderSize());
return false;
}
public ActionWith(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x94, actionLength);
codeSize = sis.readUI16("codeSize");
this.version = version;
}
public ActionWith(FlasmLexer lexer) throws IOException, ParseException {
super(0x94, 2);
lexBlockOpen(lexer);
}
@Override
public void setAddress(long address, int version, boolean recursive) {
super.setAddress(address, version, recursive);
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUI16(codeSize);//codeBytes.length);
sos.close();
baos2.write(surroundWithAction(baos.toByteArray(), version));
} catch (IOException e) {
}
return baos2.toByteArray();
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode) {
return "With {";
}
@Override
public List<Long> getAllRefs(int version) {
return super.getAllRefs(version);
}
@Override
public List<Action> getAllIfsOrJumps() {
return super.getAllIfsOrJumps();
}
@Override
public void translateContainer(List<List<GraphTargetItem>> content, Stack<GraphTargetItem> stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
output.add(new WithActionItem(this, stack.pop(), content.get(0)));
}
@Override
public List<Long> getContainerSizes() {
List<Long> ret = new ArrayList<>();
ret.add((Long) (long) codeSize);
return ret;
}
@Override
public void setContainerSize(int index, long size) {
if (index == 0) {
codeSize = (int) size;
} else {
throw new IllegalArgumentException("Index must be 0.");
}
}
@Override
public String getASMSourceBetween(int pos) {
return "";
}
@Override
public long getHeaderSize() {
return surroundWithAction(new byte[]{0, 0}, version).length;
}
@Override
public HashMap<Integer, String> getRegNames() {
return new HashMap<>();
}
@Override
public String getName() {
return null;
}
}

View File

@@ -1,391 +1,391 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf7;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.FunctionActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionDefineFunction2 extends Action implements GraphSourceItemContainer {
public String functionName;
public String replacedFunctionName;
public List<String> paramNames = new ArrayList<>();
public List<String> replacedParamNames;
public List<Integer> paramRegisters = new ArrayList<>();
public boolean preloadParentFlag;
public boolean preloadRootFlag;
public boolean suppressSuperFlag;
public boolean preloadSuperFlag;
public boolean suppressArgumentsFlag;
public boolean preloadArgumentsFlag;
public boolean suppressThisFlag;
public boolean preloadThisFlag;
public int reserved;
public boolean preloadGlobalFlag;
public int registerCount;
public int codeSize;
//public List<Action> code;
private int version;
public List<String> constantPool;
private long hdrSize;
public ActionDefineFunction2(String functionName, boolean preloadParentFlag, boolean preloadRootFlag, boolean suppressSuperFlag, boolean preloadSuperFlag, boolean suppressArgumentsFlag, boolean preloadArgumentsFlag, boolean suppressThisFlag, boolean preloadThisFlag, boolean preloadGlobalFlag, int registerCount, int codeSize, int version, List<String> paramNames, List<Integer> paramRegisters) {
super(0x8E, 0);
this.functionName = functionName;
this.preloadParentFlag = preloadParentFlag;
this.preloadRootFlag = preloadRootFlag;
this.suppressSuperFlag = suppressSuperFlag;
this.preloadSuperFlag = preloadSuperFlag;
this.suppressArgumentsFlag = suppressArgumentsFlag;
this.preloadArgumentsFlag = preloadArgumentsFlag;
this.suppressThisFlag = suppressThisFlag;
this.preloadThisFlag = preloadThisFlag;
this.preloadGlobalFlag = preloadGlobalFlag;
this.registerCount = registerCount;
this.codeSize = codeSize;
this.version = version;
this.paramNames = paramNames;
this.paramRegisters = paramRegisters;
}
public ActionDefineFunction2(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x8E, actionLength);
long posBef = sis.getPos();
this.version = version;
functionName = sis.readString();
int numParams = sis.readUI16();
registerCount = sis.readUI8();
preloadParentFlag = sis.readUB(1) == 1;
preloadRootFlag = sis.readUB(1) == 1;
suppressSuperFlag = sis.readUB(1) == 1;
preloadSuperFlag = sis.readUB(1) == 1;
suppressArgumentsFlag = sis.readUB(1) == 1;
preloadArgumentsFlag = sis.readUB(1) == 1;
suppressThisFlag = sis.readUB(1) == 1;
preloadThisFlag = sis.readUB(1) == 1;
reserved = (int) sis.readUB(7);
preloadGlobalFlag = sis.readUB(1) == 1;
for (int i = 0; i < numParams; i++) {
paramRegisters.add(sis.readUI8());
paramNames.add(sis.readString());
}
codeSize = sis.readUI16();
long posAfter = sis.getPos();
hdrSize = posAfter - posBef;
//code = new ArrayList<Action>();
//int posBef2 = (int) rri.getPos();
//code = sis.readActionList(rri.getPos(), getFileAddress() + hdrSize, rri, codeSize);
//rri.setPos(posBef2 + codeSize);
}
public ActionDefineFunction2(FlasmLexer lexer) throws IOException, ParseException {
super(0x8E, -1);
functionName = lexString(lexer);
int numParams = (int) lexLong(lexer);
registerCount = (int) lexLong(lexer);
preloadParentFlag = lexBoolean(lexer);
preloadRootFlag = lexBoolean(lexer);
suppressSuperFlag = lexBoolean(lexer);
preloadSuperFlag = lexBoolean(lexer);
suppressArgumentsFlag = lexBoolean(lexer);
preloadArgumentsFlag = lexBoolean(lexer);
suppressThisFlag = lexBoolean(lexer);
preloadThisFlag = lexBoolean(lexer);
preloadGlobalFlag = lexBoolean(lexer);
for (int i = 0; i < numParams; i++) {
paramRegisters.add((int) lexLong(lexer));
paramNames.add(lexString(lexer));
}
lexBlockOpen(lexer);
}
@Override
public long getHeaderSize() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
try {
sos.writeString(functionName);
sos.writeUI16(paramNames.size());
sos.writeUI8(registerCount);
sos.writeUB(1, preloadParentFlag ? 1 : 0);
sos.writeUB(1, preloadRootFlag ? 1 : 0);
sos.writeUB(1, suppressSuperFlag ? 1 : 0);
sos.writeUB(1, preloadSuperFlag ? 1 : 0);
sos.writeUB(1, suppressArgumentsFlag ? 1 : 0);
sos.writeUB(1, preloadArgumentsFlag ? 1 : 0);
sos.writeUB(1, suppressThisFlag ? 1 : 0);
sos.writeUB(1, preloadThisFlag ? 1 : 0);
sos.writeUB(7, reserved);
sos.writeUB(1, preloadGlobalFlag ? 1 : 0);
for (int i = 0; i < paramNames.size(); i++) {
sos.writeUI8(paramRegisters.get(i));
sos.writeString(paramNames.get(i));
}
sos.writeUI16(0);
sos.close();
baos2.write(surroundWithAction(baos.toByteArray(), version));
} catch (IOException e) {
}
return baos2.toByteArray().length;
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
try {
sos.writeString(functionName);
sos.writeUI16(paramNames.size());
sos.writeUI8(registerCount);
sos.writeUB(1, preloadParentFlag ? 1 : 0);
sos.writeUB(1, preloadRootFlag ? 1 : 0);
sos.writeUB(1, suppressSuperFlag ? 1 : 0);
sos.writeUB(1, preloadSuperFlag ? 1 : 0);
sos.writeUB(1, suppressArgumentsFlag ? 1 : 0);
sos.writeUB(1, preloadArgumentsFlag ? 1 : 0);
sos.writeUB(1, suppressThisFlag ? 1 : 0);
sos.writeUB(1, preloadThisFlag ? 1 : 0);
sos.writeUB(7, 0);
sos.writeUB(1, preloadGlobalFlag ? 1 : 0);
for (int i = 0; i < paramNames.size(); i++) {
sos.writeUI8(paramRegisters.get(i));
sos.writeString(paramNames.get(i));
}
//byte[] codeBytes = Action.actionsToBytes(code, false, version);
sos.writeUI16(codeSize);//codeBytes.length);
sos.close();
baos2.write(surroundWithAction(baos.toByteArray(), version));
//baos2.write(codeBytes);
} catch (IOException e) {
}
return baos2.toByteArray();
}
private long getPreLen(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeString(functionName);
sos.writeUI16(paramNames.size());
sos.writeUI8(registerCount);
sos.writeUB(1, preloadParentFlag ? 1 : 0);
sos.writeUB(1, preloadRootFlag ? 1 : 0);
sos.writeUB(1, suppressSuperFlag ? 1 : 0);
sos.writeUB(1, preloadSuperFlag ? 1 : 0);
sos.writeUB(1, suppressArgumentsFlag ? 1 : 0);
sos.writeUB(1, preloadArgumentsFlag ? 1 : 0);
sos.writeUB(1, suppressThisFlag ? 1 : 0);
sos.writeUB(1, preloadThisFlag ? 1 : 0);
sos.writeUB(7, 0);
sos.writeUB(1, preloadGlobalFlag ? 1 : 0);
for (int i = 0; i < paramNames.size(); i++) {
sos.writeUI8(paramRegisters.get(i));
sos.writeString(paramNames.get(i));
}
sos.writeUI16(0);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version).length;
}
@Override
public void setAddress(long address, int version, boolean recursive) {
super.setAddress(address, version, recursive);
if (recursive) {
//Action.setActionsAddresses(code, address + getPreLen(version), version);
}
}
@Override
public GraphTextWriter getASMSourceReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer) {
List<String> oldParamNames = paramNames;
if (replacedParamNames != null) {
paramNames = replacedParamNames;
}
String oldFunctionName = functionName;
if (replacedFunctionName != null) {
functionName = replacedFunctionName;
}
String ret = getASMSource(container, knownAddreses, constantPool, version, exportMode);
paramNames = oldParamNames;
functionName = oldFunctionName;
writer.appendNoHilight(ret);
return writer;
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode) {
String paramStr = "";
for (int i = 0; i < paramNames.size(); i++) {
paramStr += paramRegisters.get(i) + " \"" + Helper.escapeString(paramNames.get(i)) + "\"";
paramStr += " ";
}
return ("DefineFunction2 \"" + Helper.escapeString(functionName) + "\" " + paramRegisters.size() + " " + registerCount
+ " " + preloadParentFlag
+ " " + preloadRootFlag
+ " " + suppressSuperFlag
+ " " + preloadSuperFlag
+ " " + suppressArgumentsFlag
+ " " + preloadArgumentsFlag
+ " " + suppressThisFlag
+ " " + preloadThisFlag
+ " " + preloadGlobalFlag).trim() + " " + paramStr + " {" + (codeSize == 0 ? "\r\n}" : "");// + "\r\n" + Action.actionsToString(getAddress() + getHeaderLength(), getItems(container), knownAddreses, constantPool, version, hex, getFileAddress() + hdrSize) + "}";
}
@Override
public String toString() {
return "DefineFunction2";
}
public int getFirstRegister() {
int pos = 1;
if (preloadThisFlag) {
pos++;
}
if (preloadArgumentsFlag) {
pos++;
}
if (preloadSuperFlag) {
pos++;
}
if (preloadRootFlag) {
pos++;
}
if (preloadParentFlag) {
pos++;
}
if (preloadGlobalFlag) {
pos++;
}
return pos;
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
}
@Override
public HashMap<Integer, String> getRegNames() {
HashMap<Integer, String> funcRegNames = new HashMap<>();
for (int f = 0; f < paramNames.size(); f++) {
int reg = paramRegisters.get(f);
if (reg != 0) {
funcRegNames.put(reg, paramNames.get(f));
}
}
int pos = 1;
if (preloadThisFlag) {
funcRegNames.put(pos, "this");
pos++;
}
if (preloadArgumentsFlag) {
funcRegNames.put(pos, "arguments");
pos++;
}
if (preloadSuperFlag) {
funcRegNames.put(pos, "super");
pos++;
}
if (preloadRootFlag) {
funcRegNames.put(pos, "_root");
pos++;
}
if (preloadParentFlag) {
funcRegNames.put(pos, "_parent");
pos++;
}
if (preloadGlobalFlag) {
funcRegNames.put(pos, "_global");
pos++;
}
return funcRegNames;
}
@Override
public void translateContainer(List<List<GraphTargetItem>> content, Stack<GraphTargetItem> stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, getFirstRegister(), new ArrayList<VariableActionItem>());
functions.put(functionName, fti);
stack.push(fti);
}
@Override
public List<Long> getAllRefs(int version) {
return super.getAllRefs(version);//return Action.getActionsAllRefs(code, version);
}
@Override
public List<Action> getAllIfsOrJumps() {
return super.getAllIfsOrJumps(); //return Action.getActionsAllIfsOrJumps(code);
}
@Override
public List<Long> getContainerSizes() {
List<Long> ret = new ArrayList<>();
ret.add((Long) (long) codeSize);
return ret;
}
@Override
public void setContainerSize(int index, long size) {
if (index == 0) {
codeSize = (int) size;
} else {
throw new IllegalArgumentException("Index must be 0.");
}
}
@Override
public boolean parseDivision(long size, FlasmLexer lexer) {
codeSize = (int) (size - getHeaderSize());
return false;
}
@Override
public String getASMSourceBetween(int pos) {
return "";
}
@Override
public String getName() {
return "function";
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf7;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.FunctionActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionDefineFunction2 extends Action implements GraphSourceItemContainer {
public String functionName;
public String replacedFunctionName;
public List<String> paramNames = new ArrayList<>();
public List<String> replacedParamNames;
public List<Integer> paramRegisters = new ArrayList<>();
public boolean preloadParentFlag;
public boolean preloadRootFlag;
public boolean suppressSuperFlag;
public boolean preloadSuperFlag;
public boolean suppressArgumentsFlag;
public boolean preloadArgumentsFlag;
public boolean suppressThisFlag;
public boolean preloadThisFlag;
public int reserved;
public boolean preloadGlobalFlag;
public int registerCount;
public int codeSize;
//public List<Action> code;
private int version;
public List<String> constantPool;
private long hdrSize;
public ActionDefineFunction2(String functionName, boolean preloadParentFlag, boolean preloadRootFlag, boolean suppressSuperFlag, boolean preloadSuperFlag, boolean suppressArgumentsFlag, boolean preloadArgumentsFlag, boolean suppressThisFlag, boolean preloadThisFlag, boolean preloadGlobalFlag, int registerCount, int codeSize, int version, List<String> paramNames, List<Integer> paramRegisters) {
super(0x8E, 0);
this.functionName = functionName;
this.preloadParentFlag = preloadParentFlag;
this.preloadRootFlag = preloadRootFlag;
this.suppressSuperFlag = suppressSuperFlag;
this.preloadSuperFlag = preloadSuperFlag;
this.suppressArgumentsFlag = suppressArgumentsFlag;
this.preloadArgumentsFlag = preloadArgumentsFlag;
this.suppressThisFlag = suppressThisFlag;
this.preloadThisFlag = preloadThisFlag;
this.preloadGlobalFlag = preloadGlobalFlag;
this.registerCount = registerCount;
this.codeSize = codeSize;
this.version = version;
this.paramNames = paramNames;
this.paramRegisters = paramRegisters;
}
public ActionDefineFunction2(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x8E, actionLength);
long posBef = sis.getPos();
this.version = version;
functionName = sis.readString("functionName");
int numParams = sis.readUI16("numParams");
registerCount = sis.readUI8("registerCount");
preloadParentFlag = sis.readUB(1, "preloadParentFlag") == 1;
preloadRootFlag = sis.readUB(1, "preloadRootFlag") == 1;
suppressSuperFlag = sis.readUB(1, "suppressSuperFlag") == 1;
preloadSuperFlag = sis.readUB(1, "preloadSuperFlag") == 1;
suppressArgumentsFlag = sis.readUB(1, "suppressArgumentsFlag") == 1;
preloadArgumentsFlag = sis.readUB(1, "preloadArgumentsFlag") == 1;
suppressThisFlag = sis.readUB(1, "suppressThisFlag") == 1;
preloadThisFlag = sis.readUB(1, "preloadThisFlag") == 1;
reserved = (int) sis.readUB(7, "reserved");
preloadGlobalFlag = sis.readUB(1, "preloadGlobalFlag") == 1;
for (int i = 0; i < numParams; i++) {
paramRegisters.add(sis.readUI8("paramRegister"));
paramNames.add(sis.readString("paramName"));
}
codeSize = sis.readUI16("codeSize");
long posAfter = sis.getPos();
hdrSize = posAfter - posBef;
//code = new ArrayList<Action>();
//int posBef2 = (int) rri.getPos();
//code = sis.readActionList(rri.getPos(), getFileAddress() + hdrSize, rri, codeSize);
//rri.setPos(posBef2 + codeSize);
}
public ActionDefineFunction2(FlasmLexer lexer) throws IOException, ParseException {
super(0x8E, -1);
functionName = lexString(lexer);
int numParams = (int) lexLong(lexer);
registerCount = (int) lexLong(lexer);
preloadParentFlag = lexBoolean(lexer);
preloadRootFlag = lexBoolean(lexer);
suppressSuperFlag = lexBoolean(lexer);
preloadSuperFlag = lexBoolean(lexer);
suppressArgumentsFlag = lexBoolean(lexer);
preloadArgumentsFlag = lexBoolean(lexer);
suppressThisFlag = lexBoolean(lexer);
preloadThisFlag = lexBoolean(lexer);
preloadGlobalFlag = lexBoolean(lexer);
for (int i = 0; i < numParams; i++) {
paramRegisters.add((int) lexLong(lexer));
paramNames.add(lexString(lexer));
}
lexBlockOpen(lexer);
}
@Override
public long getHeaderSize() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
try {
sos.writeString(functionName);
sos.writeUI16(paramNames.size());
sos.writeUI8(registerCount);
sos.writeUB(1, preloadParentFlag ? 1 : 0);
sos.writeUB(1, preloadRootFlag ? 1 : 0);
sos.writeUB(1, suppressSuperFlag ? 1 : 0);
sos.writeUB(1, preloadSuperFlag ? 1 : 0);
sos.writeUB(1, suppressArgumentsFlag ? 1 : 0);
sos.writeUB(1, preloadArgumentsFlag ? 1 : 0);
sos.writeUB(1, suppressThisFlag ? 1 : 0);
sos.writeUB(1, preloadThisFlag ? 1 : 0);
sos.writeUB(7, reserved);
sos.writeUB(1, preloadGlobalFlag ? 1 : 0);
for (int i = 0; i < paramNames.size(); i++) {
sos.writeUI8(paramRegisters.get(i));
sos.writeString(paramNames.get(i));
}
sos.writeUI16(0);
sos.close();
baos2.write(surroundWithAction(baos.toByteArray(), version));
} catch (IOException e) {
}
return baos2.toByteArray().length;
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
try {
sos.writeString(functionName);
sos.writeUI16(paramNames.size());
sos.writeUI8(registerCount);
sos.writeUB(1, preloadParentFlag ? 1 : 0);
sos.writeUB(1, preloadRootFlag ? 1 : 0);
sos.writeUB(1, suppressSuperFlag ? 1 : 0);
sos.writeUB(1, preloadSuperFlag ? 1 : 0);
sos.writeUB(1, suppressArgumentsFlag ? 1 : 0);
sos.writeUB(1, preloadArgumentsFlag ? 1 : 0);
sos.writeUB(1, suppressThisFlag ? 1 : 0);
sos.writeUB(1, preloadThisFlag ? 1 : 0);
sos.writeUB(7, 0);
sos.writeUB(1, preloadGlobalFlag ? 1 : 0);
for (int i = 0; i < paramNames.size(); i++) {
sos.writeUI8(paramRegisters.get(i));
sos.writeString(paramNames.get(i));
}
//byte[] codeBytes = Action.actionsToBytes(code, false, version);
sos.writeUI16(codeSize);//codeBytes.length);
sos.close();
baos2.write(surroundWithAction(baos.toByteArray(), version));
//baos2.write(codeBytes);
} catch (IOException e) {
}
return baos2.toByteArray();
}
private long getPreLen(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeString(functionName);
sos.writeUI16(paramNames.size());
sos.writeUI8(registerCount);
sos.writeUB(1, preloadParentFlag ? 1 : 0);
sos.writeUB(1, preloadRootFlag ? 1 : 0);
sos.writeUB(1, suppressSuperFlag ? 1 : 0);
sos.writeUB(1, preloadSuperFlag ? 1 : 0);
sos.writeUB(1, suppressArgumentsFlag ? 1 : 0);
sos.writeUB(1, preloadArgumentsFlag ? 1 : 0);
sos.writeUB(1, suppressThisFlag ? 1 : 0);
sos.writeUB(1, preloadThisFlag ? 1 : 0);
sos.writeUB(7, 0);
sos.writeUB(1, preloadGlobalFlag ? 1 : 0);
for (int i = 0; i < paramNames.size(); i++) {
sos.writeUI8(paramRegisters.get(i));
sos.writeString(paramNames.get(i));
}
sos.writeUI16(0);
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version).length;
}
@Override
public void setAddress(long address, int version, boolean recursive) {
super.setAddress(address, version, recursive);
if (recursive) {
//Action.setActionsAddresses(code, address + getPreLen(version), version);
}
}
@Override
public GraphTextWriter getASMSourceReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer) {
List<String> oldParamNames = paramNames;
if (replacedParamNames != null) {
paramNames = replacedParamNames;
}
String oldFunctionName = functionName;
if (replacedFunctionName != null) {
functionName = replacedFunctionName;
}
String ret = getASMSource(container, knownAddreses, constantPool, version, exportMode);
paramNames = oldParamNames;
functionName = oldFunctionName;
writer.appendNoHilight(ret);
return writer;
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode) {
String paramStr = "";
for (int i = 0; i < paramNames.size(); i++) {
paramStr += paramRegisters.get(i) + " \"" + Helper.escapeString(paramNames.get(i)) + "\"";
paramStr += " ";
}
return ("DefineFunction2 \"" + Helper.escapeString(functionName) + "\" " + paramRegisters.size() + " " + registerCount
+ " " + preloadParentFlag
+ " " + preloadRootFlag
+ " " + suppressSuperFlag
+ " " + preloadSuperFlag
+ " " + suppressArgumentsFlag
+ " " + preloadArgumentsFlag
+ " " + suppressThisFlag
+ " " + preloadThisFlag
+ " " + preloadGlobalFlag).trim() + " " + paramStr + " {" + (codeSize == 0 ? "\r\n}" : "");// + "\r\n" + Action.actionsToString(getAddress() + getHeaderLength(), getItems(container), knownAddreses, constantPool, version, hex, getFileAddress() + hdrSize) + "}";
}
@Override
public String toString() {
return "DefineFunction2";
}
public int getFirstRegister() {
int pos = 1;
if (preloadThisFlag) {
pos++;
}
if (preloadArgumentsFlag) {
pos++;
}
if (preloadSuperFlag) {
pos++;
}
if (preloadRootFlag) {
pos++;
}
if (preloadParentFlag) {
pos++;
}
if (preloadGlobalFlag) {
pos++;
}
return pos;
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
}
@Override
public HashMap<Integer, String> getRegNames() {
HashMap<Integer, String> funcRegNames = new HashMap<>();
for (int f = 0; f < paramNames.size(); f++) {
int reg = paramRegisters.get(f);
if (reg != 0) {
funcRegNames.put(reg, paramNames.get(f));
}
}
int pos = 1;
if (preloadThisFlag) {
funcRegNames.put(pos, "this");
pos++;
}
if (preloadArgumentsFlag) {
funcRegNames.put(pos, "arguments");
pos++;
}
if (preloadSuperFlag) {
funcRegNames.put(pos, "super");
pos++;
}
if (preloadRootFlag) {
funcRegNames.put(pos, "_root");
pos++;
}
if (preloadParentFlag) {
funcRegNames.put(pos, "_parent");
pos++;
}
if (preloadGlobalFlag) {
funcRegNames.put(pos, "_global");
pos++;
}
return funcRegNames;
}
@Override
public void translateContainer(List<List<GraphTargetItem>> content, Stack<GraphTargetItem> stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, getFirstRegister(), new ArrayList<VariableActionItem>());
functions.put(functionName, fti);
stack.push(fti);
}
@Override
public List<Long> getAllRefs(int version) {
return super.getAllRefs(version);//return Action.getActionsAllRefs(code, version);
}
@Override
public List<Action> getAllIfsOrJumps() {
return super.getAllIfsOrJumps(); //return Action.getActionsAllIfsOrJumps(code);
}
@Override
public List<Long> getContainerSizes() {
List<Long> ret = new ArrayList<>();
ret.add((Long) (long) codeSize);
return ret;
}
@Override
public void setContainerSize(int index, long size) {
if (index == 0) {
codeSize = (int) size;
} else {
throw new IllegalArgumentException("Index must be 0.");
}
}
@Override
public boolean parseDivision(long size, FlasmLexer lexer) {
codeSize = (int) (size - getHeaderSize());
return false;
}
@Override
public String getASMSourceBetween(int pos) {
return "";
}
@Override
public String getName() {
return "function";
}
}

View File

@@ -1,320 +1,320 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf7;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.ActionItem;
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
import com.jpexs.decompiler.flash.action.model.clauses.TryActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionTry extends Action implements GraphSourceItemContainer {
public int reserved;
public boolean catchInRegisterFlag;
public boolean finallyBlockFlag;
public boolean catchBlockFlag;
public String catchName;
public int catchRegister;
long trySize;
long catchSize;
long finallySize;
private final int version;
public ActionTry(boolean catchInRegisterFlag, boolean finallyBlockFlag, boolean catchBlockFlag, String catchName, int catchRegister, long trySize, long catchSize, long finallySize, int version) {
super(0x8F, 0);
this.catchInRegisterFlag = catchInRegisterFlag;
this.finallyBlockFlag = finallyBlockFlag;
this.catchBlockFlag = catchBlockFlag;
this.catchName = catchName;
this.catchRegister = catchRegister;
this.trySize = trySize;
this.catchSize = catchSize;
this.finallySize = finallySize;
this.version = version;
}
public ActionTry(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x8F, actionLength);
long startPos = sis.getPos();
this.version = version;
reserved = (int) sis.readUB(5);
catchInRegisterFlag = sis.readUB(1) == 1;
finallyBlockFlag = sis.readUB(1) == 1;
catchBlockFlag = sis.readUB(1) == 1;
trySize = sis.readUI16();
catchSize = sis.readUI16();
finallySize = sis.readUI16();
if (catchInRegisterFlag) {
catchRegister = sis.readUI8();
} else {
catchName = sis.readString();
}
}
@Override
public void setAddress(long address, int version, boolean recursive) {
super.setAddress(address, version, recursive);
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUB(5, reserved);
sos.writeUB(1, catchInRegisterFlag ? 1 : 0);
sos.writeUB(1, finallyBlockFlag ? 1 : 0);
sos.writeUB(1, catchBlockFlag ? 1 : 0);
sos.writeUI16((int) trySize);
sos.writeUI16((int) catchSize);
sos.writeUI16((int) finallySize);
if (catchInRegisterFlag) {
sos.writeUI8(catchRegister);
} else {
sos.writeString(catchName == null ? "" : catchName);
}
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
public ActionTry(FlasmLexer lexer, int version) throws IOException, ParseException {
super(0x8F, 0);
this.version = version;
ASMParsedSymbol symb = lexer.yylex();
if (symb.type == ASMParsedSymbol.TYPE_STRING) {
catchInRegisterFlag = false;
catchName = (String) symb.value;
} else if (symb.type == ASMParsedSymbol.TYPE_REGISTER) {
catchRegister = ((RegisterNumber) symb.value).number;
catchInRegisterFlag = true;
} else if (symb.type == ASMParsedSymbol.TYPE_BLOCK_START) {
return;
} else {
throw new ParseException("Unknown symbol after Try", lexer.yyline());
}
lexBlockOpen(lexer);
}
@Override
public String getASMSourceBetween(int pos) {
String ret = "";
if (pos == 0) {
if (catchBlockFlag) {
ret += "Catch";
ret += " {\r\n";
return ret;
}
if (finallyBlockFlag) {
ret += "Finally {\r\n";
return ret;
}
}
if (pos == 1) {
if (catchBlockFlag && finallyBlockFlag) {
ret += "Finally {\r\n";
return ret;
}
}
return ret;
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode) {
String ret = "";
ret += "Try ";
if (catchBlockFlag) {
if (catchInRegisterFlag) {
ret += "register" + catchRegister;
} else {
ret += "\"" + Helper.escapeString(catchName) + "\"";
}
ret += " ";
}
ret += "{";
return ret;
}
@Override
public List<Long> getAllRefs(int version) {
List<Long> ret = new ArrayList<>();
return ret;
}
@Override
public List<Action> getAllIfsOrJumps() {
List<Action> ret = new ArrayList<>();
return ret;
}
@Override
public long getHeaderSize() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUB(5, reserved);
sos.writeUB(1, catchInRegisterFlag ? 1 : 0);
sos.writeUB(1, finallyBlockFlag ? 1 : 0);
sos.writeUB(1, catchBlockFlag ? 1 : 0);
sos.writeUI16((int) trySize);
sos.writeUI16((int) catchSize);
sos.writeUI16((int) finallySize);
if (catchInRegisterFlag) {
sos.writeUI8(catchRegister);
} else {
sos.writeString(catchName == null ? "" : catchName);
}
/*sos.write(tryBodyBytes);
sos.write(catchBodyBytes);
sos.write(finallyBodyBytes);*/
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version).length;
}
public long getTrySize() {
return trySize;
}
@Override
public List<Long> getContainerSizes() {
List<Long> ret = new ArrayList<>();
ret.add(trySize);
ret.add(catchSize);
ret.add(finallySize);
return ret;
}
@Override
public void setContainerSize(int index, long size) {
switch (index) {
case 0:
trySize = size;
break;
case 1:
catchSize = size;
break;
case 2:
finallySize = size;
break;
default:
throw new IllegalArgumentException("Valid indexes are 0, 1, and 2.");
}
}
@Override
public boolean parseDivision(long size, FlasmLexer lexer) {
try {
ASMParsedSymbol symb = lexer.yylex();
//catchBlockFlag = false;
if (symb.type == ASMParsedSymbol.TYPE_INSTRUCTION_NAME) {
if (((String) symb.value).toLowerCase().equals("catch")) {
trySize = size - getHeaderSize();
catchBlockFlag = true;
lexBlockOpen(lexer);
return true;
}
if (symb.type == ASMParsedSymbol.TYPE_INSTRUCTION_NAME) {
if (((String) symb.value).toLowerCase().equals("finally")) {
if (catchBlockFlag) {
catchSize = size - getHeaderSize() - trySize;
} else {
trySize = size - getHeaderSize();
}
finallyBlockFlag = true;
lexBlockOpen(lexer);
return true;
} else {
//finallyBlockFlag = false;
lexer.yypushback(lexer.yylength());
}
} else {
//finallyBlockFlag = false;
lexer.yypushback(lexer.yylength());
}
} else {
lexer.yypushback(lexer.yylength());
}
} catch (IOException | ParseException ex) {
}
if (finallyBlockFlag) {
finallySize = size - getHeaderSize() - trySize - catchSize;
} else if (catchBlockFlag) {
catchSize = size - getHeaderSize() - trySize;
}
lexer.yybegin(0);
return false;
}
@Override
public void translateContainer(List<List<GraphTargetItem>> contents, Stack<GraphTargetItem> stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
List<GraphTargetItem> tryCommands = contents.get(0);
ActionItem catchName;
if (catchInRegisterFlag) {
catchName = new DirectValueActionItem(this, -1, new RegisterNumber(this.catchRegister), new ArrayList<String>());
} else {
catchName = new DirectValueActionItem(this, -1, this.catchName, new ArrayList<String>());
}
List<GraphTargetItem> catchExceptions = new ArrayList<>();
if (catchBlockFlag) {
catchExceptions.add(catchName);
}
List<List<GraphTargetItem>> catchCommands = new ArrayList<>();
if (catchBlockFlag) {
catchCommands.add(contents.get(1));
}
List<GraphTargetItem> finallyCommands = contents.get(2);
output.add(new TryActionItem(tryCommands, catchExceptions, catchCommands, finallyCommands));
}
@Override
public String toString() {
return "Try";
}
@Override
public HashMap<Integer, String> getRegNames() {
return new HashMap<>();
}
@Override
public String getName() {
return null;
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.swf7;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.ActionItem;
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
import com.jpexs.decompiler.flash.action.model.clauses.TryActionItem;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionTry extends Action implements GraphSourceItemContainer {
public int reserved;
public boolean catchInRegisterFlag;
public boolean finallyBlockFlag;
public boolean catchBlockFlag;
public String catchName;
public int catchRegister;
long trySize;
long catchSize;
long finallySize;
private final int version;
public ActionTry(boolean catchInRegisterFlag, boolean finallyBlockFlag, boolean catchBlockFlag, String catchName, int catchRegister, long trySize, long catchSize, long finallySize, int version) {
super(0x8F, 0);
this.catchInRegisterFlag = catchInRegisterFlag;
this.finallyBlockFlag = finallyBlockFlag;
this.catchBlockFlag = catchBlockFlag;
this.catchName = catchName;
this.catchRegister = catchRegister;
this.trySize = trySize;
this.catchSize = catchSize;
this.finallySize = finallySize;
this.version = version;
}
public ActionTry(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x8F, actionLength);
long startPos = sis.getPos();
this.version = version;
reserved = (int) sis.readUB(5, "reserved");
catchInRegisterFlag = sis.readUB(1, "catchInRegisterFlag") == 1;
finallyBlockFlag = sis.readUB(1, "finallyBlockFlag") == 1;
catchBlockFlag = sis.readUB(1, "catchBlockFlag") == 1;
trySize = sis.readUI16("trySize");
catchSize = sis.readUI16("catchSize");
finallySize = sis.readUI16("finallySize");
if (catchInRegisterFlag) {
catchRegister = sis.readUI8("catchRegister");
} else {
catchName = sis.readString("catchName");
}
}
@Override
public void setAddress(long address, int version, boolean recursive) {
super.setAddress(address, version, recursive);
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUB(5, reserved);
sos.writeUB(1, catchInRegisterFlag ? 1 : 0);
sos.writeUB(1, finallyBlockFlag ? 1 : 0);
sos.writeUB(1, catchBlockFlag ? 1 : 0);
sos.writeUI16((int) trySize);
sos.writeUI16((int) catchSize);
sos.writeUI16((int) finallySize);
if (catchInRegisterFlag) {
sos.writeUI8(catchRegister);
} else {
sos.writeString(catchName == null ? "" : catchName);
}
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version);
}
public ActionTry(FlasmLexer lexer, int version) throws IOException, ParseException {
super(0x8F, 0);
this.version = version;
ASMParsedSymbol symb = lexer.yylex();
if (symb.type == ASMParsedSymbol.TYPE_STRING) {
catchInRegisterFlag = false;
catchName = (String) symb.value;
} else if (symb.type == ASMParsedSymbol.TYPE_REGISTER) {
catchRegister = ((RegisterNumber) symb.value).number;
catchInRegisterFlag = true;
} else if (symb.type == ASMParsedSymbol.TYPE_BLOCK_START) {
return;
} else {
throw new ParseException("Unknown symbol after Try", lexer.yyline());
}
lexBlockOpen(lexer);
}
@Override
public String getASMSourceBetween(int pos) {
String ret = "";
if (pos == 0) {
if (catchBlockFlag) {
ret += "Catch";
ret += " {\r\n";
return ret;
}
if (finallyBlockFlag) {
ret += "Finally {\r\n";
return ret;
}
}
if (pos == 1) {
if (catchBlockFlag && finallyBlockFlag) {
ret += "Finally {\r\n";
return ret;
}
}
return ret;
}
@Override
public String getASMSource(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ScriptExportMode exportMode) {
String ret = "";
ret += "Try ";
if (catchBlockFlag) {
if (catchInRegisterFlag) {
ret += "register" + catchRegister;
} else {
ret += "\"" + Helper.escapeString(catchName) + "\"";
}
ret += " ";
}
ret += "{";
return ret;
}
@Override
public List<Long> getAllRefs(int version) {
List<Long> ret = new ArrayList<>();
return ret;
}
@Override
public List<Action> getAllIfsOrJumps() {
List<Action> ret = new ArrayList<>();
return ret;
}
@Override
public long getHeaderSize() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
try {
sos.writeUB(5, reserved);
sos.writeUB(1, catchInRegisterFlag ? 1 : 0);
sos.writeUB(1, finallyBlockFlag ? 1 : 0);
sos.writeUB(1, catchBlockFlag ? 1 : 0);
sos.writeUI16((int) trySize);
sos.writeUI16((int) catchSize);
sos.writeUI16((int) finallySize);
if (catchInRegisterFlag) {
sos.writeUI8(catchRegister);
} else {
sos.writeString(catchName == null ? "" : catchName);
}
/*sos.write(tryBodyBytes);
sos.write(catchBodyBytes);
sos.write(finallyBodyBytes);*/
sos.close();
} catch (IOException e) {
}
return surroundWithAction(baos.toByteArray(), version).length;
}
public long getTrySize() {
return trySize;
}
@Override
public List<Long> getContainerSizes() {
List<Long> ret = new ArrayList<>();
ret.add(trySize);
ret.add(catchSize);
ret.add(finallySize);
return ret;
}
@Override
public void setContainerSize(int index, long size) {
switch (index) {
case 0:
trySize = size;
break;
case 1:
catchSize = size;
break;
case 2:
finallySize = size;
break;
default:
throw new IllegalArgumentException("Valid indexes are 0, 1, and 2.");
}
}
@Override
public boolean parseDivision(long size, FlasmLexer lexer) {
try {
ASMParsedSymbol symb = lexer.yylex();
//catchBlockFlag = false;
if (symb.type == ASMParsedSymbol.TYPE_INSTRUCTION_NAME) {
if (((String) symb.value).toLowerCase().equals("catch")) {
trySize = size - getHeaderSize();
catchBlockFlag = true;
lexBlockOpen(lexer);
return true;
}
if (symb.type == ASMParsedSymbol.TYPE_INSTRUCTION_NAME) {
if (((String) symb.value).toLowerCase().equals("finally")) {
if (catchBlockFlag) {
catchSize = size - getHeaderSize() - trySize;
} else {
trySize = size - getHeaderSize();
}
finallyBlockFlag = true;
lexBlockOpen(lexer);
return true;
} else {
//finallyBlockFlag = false;
lexer.yypushback(lexer.yylength());
}
} else {
//finallyBlockFlag = false;
lexer.yypushback(lexer.yylength());
}
} else {
lexer.yypushback(lexer.yylength());
}
} catch (IOException | ParseException ex) {
}
if (finallyBlockFlag) {
finallySize = size - getHeaderSize() - trySize - catchSize;
} else if (catchBlockFlag) {
catchSize = size - getHeaderSize() - trySize;
}
lexer.yybegin(0);
return false;
}
@Override
public void translateContainer(List<List<GraphTargetItem>> contents, Stack<GraphTargetItem> stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
List<GraphTargetItem> tryCommands = contents.get(0);
ActionItem catchName;
if (catchInRegisterFlag) {
catchName = new DirectValueActionItem(this, -1, new RegisterNumber(this.catchRegister), new ArrayList<String>());
} else {
catchName = new DirectValueActionItem(this, -1, this.catchName, new ArrayList<String>());
}
List<GraphTargetItem> catchExceptions = new ArrayList<>();
if (catchBlockFlag) {
catchExceptions.add(catchName);
}
List<List<GraphTargetItem>> catchCommands = new ArrayList<>();
if (catchBlockFlag) {
catchCommands.add(contents.get(1));
}
List<GraphTargetItem> finallyCommands = contents.get(2);
output.add(new TryActionItem(tryCommands, catchExceptions, catchCommands, finallyCommands));
}
@Override
public String toString() {
return "Try";
}
@Override
public HashMap<Integer, String> getRegNames() {
return new HashMap<>();
}
@Override
public String getName() {
return null;
}
}

View File

@@ -65,6 +65,6 @@ public class DumpInfo {
@Override
public String toString() {
String value = previewValue == null ? "" : previewValue.toString();
return name + "(" + type + ")" + (value.isEmpty() ? "" : " = " + value);
return name + " (" + type + ")" + (value.isEmpty() ? "" : " = " + value);
}
}

View File

@@ -103,28 +103,28 @@ public class MovieExporter {
|| (videoStream.codecID == DefineVideoStreamTag.CODEC_VP6_ALPHA)) {
SWFInputStream sis = new SWFInputStream(swf, tag.videoData);
if (videoStream.codecID == DefineVideoStreamTag.CODEC_VP6_ALPHA) {
sis.readUI24(); //offsetToAlpha
sis.readUI24("offsetToAlpha"); //offsetToAlpha
}
int frameMode = (int) sis.readUB(1);
int frameMode = (int) sis.readUB(1, "frameMode");
if (frameMode == 0) {
frameType = 1; //intra
} else {
frameType = 2; //inter
}
sis.readUB(6); //qp
int marker = (int) sis.readUB(1);
sis.readUB(6, "qp"); //qp
int marker = (int) sis.readUB(1, "marker");
if (frameMode == 0) {
int version = (int) sis.readUB(5);
int version2 = (int) sis.readUB(2);
sis.readUB(1);//interlace
int version = (int) sis.readUB(5, "version");
int version2 = (int) sis.readUB(2, "version2");
sis.readUB(1, "interlace"); //interlace
if (marker == 1 || version2 == 0) {
sis.readUI16();//offset
sis.readUI16("offset"); //offset
}
int dim_y = sis.readUI8();
int dim_x = sis.readUI8();
sis.readUI8(); //render_y
sis.readUI8(); //render_x
int dim_y = sis.readUI8("dim_y");
int dim_x = sis.readUI8("dim_x");
sis.readUI8("render_y"); //render_y
sis.readUI8("render_x"); //render_x
horizontalAdjustment = (int) (dim_x * Math.ceil(((double) videoStream.width) / (double) dim_x)) - videoStream.width;
verticalAdjustment = (int) (dim_y * Math.ceil(((double) videoStream.height) / (double) dim_y)) - videoStream.height;
@@ -136,19 +136,19 @@ public class MovieExporter {
}
if (videoStream.codecID == DefineVideoStreamTag.CODEC_SORENSON_H263) {
SWFInputStream sis = new SWFInputStream(swf, tag.videoData);
sis.readUB(17);//pictureStartCode
sis.readUB(5); //version
sis.readUB(8); //temporalReference
int pictureSize = (int) sis.readUB(3); //pictureSize
sis.readUB(17, "pictureStartCode");//pictureStartCode
sis.readUB(5, "version"); //version
sis.readUB(8, "temporalReference"); //temporalReference
int pictureSize = (int) sis.readUB(3, "pictureSize"); //pictureSize
if (pictureSize == 0) {
sis.readUB(8); //customWidth
sis.readUB(8); //customHeight
sis.readUB(8, "customWidth"); //customWidth
sis.readUB(8, "customHeight"); //customHeight
}
if (pictureSize == 1) {
sis.readUB(16); //customWidth
sis.readUB(16); //customHeight
sis.readUB(16, "customWidth"); //customWidth
sis.readUB(16, "customHeight"); //customHeight
}
int pictureType = (int) sis.readUB(2);
int pictureType = (int) sis.readUB(2, "pictureType");
switch (pictureType) {
case 0: //intra
frameType = 1; //keyframe

View File

@@ -90,13 +90,13 @@ public class CSMTextSettingsTag extends Tag {
*/
public CSMTextSettingsTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "CSMTextSettings", pos, length);
textID = sis.readUI16();
useFlashType = (int) sis.readUB(2);
gridFit = (int) sis.readUB(3);
reserved = (int) sis.readUB(3);
thickness = sis.readFLOAT(); //F32 = FLOAT
sharpness = sis.readFLOAT(); //F32 = FLOAT
reserved2 = sis.readUI8(); //reserved
textID = sis.readUI16("textID");
useFlashType = (int) sis.readUB(2, "useFlashType");
gridFit = (int) sis.readUB(3, "gridFit");
reserved = (int) sis.readUB(3, "reserved");
thickness = sis.readFLOAT("thickness"); //F32 = FLOAT
sharpness = sis.readFLOAT("sharpness"); //F32 = FLOAT
reserved2 = sis.readUI8("reserved2"); //reserved
}
/**

View File

@@ -63,6 +63,6 @@ public class DebugIDTag extends Tag {
*/
public DebugIDTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DebugID", pos, length);
debugId = sis.readBytesEx(16);
debugId = sis.readBytesEx(16, "debugId");
}
}

View File

@@ -60,9 +60,9 @@ public class DefineBinaryDataTag extends CharacterTag {
public DefineBinaryDataTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineBinaryData", pos, length);
tag = sis.readUI16();
reserved = sis.readUI32();
binaryData = sis.readBytesEx(sis.available());
tag = sis.readUI16("tag");
reserved = sis.readUI32("reserved");
binaryData = sis.readBytesEx(sis.available(),"binaryData");
}
@Override

View File

@@ -70,8 +70,8 @@ public class DefineBitsJPEG2Tag extends ImageTag implements AloneTag {
public DefineBitsJPEG2Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineBitsJPEG2", pos, length);
characterID = sis.readUI16();
imageData = sis.readBytesEx(sis.available());
characterID = sis.readUI16("characterID");
imageData = sis.readBytesEx(sis.available(), "imageData");
}
public DefineBitsJPEG2Tag(SWF swf, long pos, int length, int characterID, byte[] imageData) throws IOException {

View File

@@ -109,10 +109,10 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag {
public DefineBitsJPEG3Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineBitsJPEG3", pos, length);
characterID = sis.readUI16();
long alphaDataOffset = sis.readUI32();
imageData = sis.readBytesEx(alphaDataOffset);
bitmapAlphaData = sis.readBytesZlib(sis.available());
characterID = sis.readUI16("characterID");
long alphaDataOffset = sis.readUI32("alphaDataOffset");
imageData = sis.readBytesEx(alphaDataOffset, "imageData");
bitmapAlphaData = sis.readBytesZlib(sis.available(), "bitmapAlphaData");
}
/**

View File

@@ -139,10 +139,10 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag {
*/
public DefineBitsJPEG4Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineBitsJPEG4", pos, length);
characterID = sis.readUI16();
long alphaDataOffset = sis.readUI32();
deblockParam = sis.readUI16();
imageData = sis.readBytesEx(alphaDataOffset);
bitmapAlphaData = sis.readBytesEx(sis.available());
characterID = sis.readUI16("characterID");
long alphaDataOffset = sis.readUI32("alphaDataOffset");
deblockParam = sis.readUI16("deblockParam");
imageData = sis.readBytesEx(alphaDataOffset, "imageData");
bitmapAlphaData = sis.readBytesEx(sis.available(), "bitmapAlphaData");
}
}

View File

@@ -109,14 +109,14 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
public DefineBitsLossless2Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineBitsLossless2", pos, length);
characterID = sis.readUI16();
bitmapFormat = sis.readUI8();
bitmapWidth = sis.readUI16();
bitmapHeight = sis.readUI16();
characterID = sis.readUI16("characterID");
bitmapFormat = sis.readUI8("bitmapFormat");
bitmapWidth = sis.readUI16("bitmapWidth");
bitmapHeight = sis.readUI16("bitmapHeight");
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
bitmapColorTableSize = sis.readUI8();
bitmapColorTableSize = sis.readUI8("bitmapColorTableSize");
}
zlibBitmapData = sis.readBytesEx(sis.available());
zlibBitmapData = sis.readBytesEx(sis.available(), "zlibBitmapData");
}
private ALPHACOLORMAPDATA colorMapData;
private ALPHABITMAPDATA bitmapData;
@@ -140,10 +140,10 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
try {
SWFInputStream sis = new SWFInputStream(swf, Helper.readStream(new InflaterInputStream(new ByteArrayInputStream(zlibBitmapData))));
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
colorMapData = sis.readALPHACOLORMAPDATA(bitmapColorTableSize, bitmapWidth, bitmapHeight);
colorMapData = sis.readALPHACOLORMAPDATA(bitmapColorTableSize, bitmapWidth, bitmapHeight, "colorMapData");
}
if (bitmapFormat == FORMAT_32BIT_ARGB) {
bitmapData = sis.readALPHABITMAPDATA(bitmapFormat, bitmapWidth, bitmapHeight);
bitmapData = sis.readALPHABITMAPDATA(bitmapFormat, bitmapWidth, bitmapHeight, "bitmapData");
}
} catch (IOException ex) {
}

View File

@@ -171,10 +171,10 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
try {
SWFInputStream sis = new SWFInputStream(swf, Helper.readStream(new InflaterInputStream(new ByteArrayInputStream(zlibBitmapData))));
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
colorMapData = sis.readCOLORMAPDATA(bitmapColorTableSize, bitmapWidth, bitmapHeight);
colorMapData = sis.readCOLORMAPDATA(bitmapColorTableSize, bitmapWidth, bitmapHeight, "colorMapData");
}
if ((bitmapFormat == FORMAT_15BIT_RGB) || (bitmapFormat == FORMAT_24BIT_RGB)) {
bitmapData = sis.readBITMAPDATA(bitmapFormat, bitmapWidth, bitmapHeight);
bitmapData = sis.readBITMAPDATA(bitmapFormat, bitmapWidth, bitmapHeight, "bitmapData");
}
} catch (IOException ex) {
}
@@ -183,14 +183,14 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
public DefineBitsLosslessTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineBitsLossless", pos, length);
characterID = sis.readUI16();
bitmapFormat = sis.readUI8();
bitmapWidth = sis.readUI16();
bitmapHeight = sis.readUI16();
characterID = sis.readUI16("characterID");
bitmapFormat = sis.readUI8("bitmapFormat");
bitmapWidth = sis.readUI16("bitmapWidth");
bitmapHeight = sis.readUI16("bitmapHeight");
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
bitmapColorTableSize = sis.readUI8();
bitmapColorTableSize = sis.readUI8("bitmapColorTableSize");
}
zlibBitmapData = sis.readBytesEx(sis.available());
zlibBitmapData = sis.readBytesEx(sis.available(), "zlibBitmapData");
}
/**

View File

@@ -56,8 +56,8 @@ public class DefineBitsTag extends ImageTag {
public DefineBitsTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineBits", pos, length);
characterID = sis.readUI16();
jpegData = sis.readBytesEx(sis.available());
characterID = sis.readUI16("characterID");
jpegData = sis.readBytesEx(sis.available(), "jpegData");
}
private void getJPEGTables() {

View File

@@ -103,13 +103,13 @@ public class DefineButton2Tag extends ButtonTag implements Container {
*/
public DefineButton2Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineButton2", pos, length);
buttonId = sis.readUI16();
reserved = (int) sis.readUB(7);
trackAsMenu = sis.readUB(1) == 1;
int actionOffset = sis.readUI16();
characters = sis.readBUTTONRECORDList(true);
buttonId = sis.readUI16("buttonId");
reserved = (int) sis.readUB(7, "reserved");
trackAsMenu = sis.readUB(1, "trackAsMenu") == 1;
int actionOffset = sis.readUI16("actionOffset");
characters = sis.readBUTTONRECORDList(true, "characters");
if (actionOffset > 0) {
actions = sis.readBUTTONCONDACTIONList(swf, this);
actions = sis.readBUTTONCONDACTIONList(swf, this, "actions");
}
}

View File

@@ -65,7 +65,7 @@ public class DefineButtonCxformTag extends Tag {
*/
public DefineButtonCxformTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineButtonCxform", pos, length);
buttonId = sis.readUI16();
buttonColorTransform = sis.readCXFORM();
buttonId = sis.readUI16("buttonId");
buttonColorTransform = sis.readCXFORM("buttonColorTransform");
}
}

View File

@@ -105,22 +105,22 @@ public class DefineButtonSoundTag extends CharacterIdTag {
*/
public DefineButtonSoundTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineButtonSound", pos, length);
buttonId = sis.readUI16();
buttonSoundChar0 = sis.readUI16();
buttonId = sis.readUI16("buttonId");
buttonSoundChar0 = sis.readUI16("buttonSoundChar0");
if (buttonSoundChar0 != 0) {
buttonSoundInfo0 = sis.readSOUNDINFO();
buttonSoundInfo0 = sis.readSOUNDINFO("buttonSoundInfo0");
}
buttonSoundChar1 = sis.readUI16();
buttonSoundChar1 = sis.readUI16("buttonSoundChar1");
if (buttonSoundChar1 != 0) {
buttonSoundInfo1 = sis.readSOUNDINFO();
buttonSoundInfo1 = sis.readSOUNDINFO("buttonSoundInfo1");
}
buttonSoundChar2 = sis.readUI16();
buttonSoundChar2 = sis.readUI16("buttonSoundChar2");
if (buttonSoundChar2 != 0) {
buttonSoundInfo2 = sis.readSOUNDINFO();
buttonSoundInfo2 = sis.readSOUNDINFO("buttonSoundInfo2");
}
buttonSoundChar3 = sis.readUI16();
buttonSoundChar3 = sis.readUI16("buttonSoundChar3");
if (buttonSoundChar3 != 0) {
buttonSoundInfo3 = sis.readSOUNDINFO();
buttonSoundInfo3 = sis.readSOUNDINFO("buttonSoundInfo3");
}
}
}

View File

@@ -101,10 +101,10 @@ public class DefineButtonTag extends ButtonTag implements ASMSource {
*/
public DefineButtonTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineButton", pos, length);
buttonId = sis.readUI16();
characters = sis.readBUTTONRECORDList(false);
buttonId = sis.readUI16("buttonId");
characters = sis.readBUTTONRECORDList(false, "characters");
hdrSize = sis.getPos();
actionBytes = sis.readBytesEx(sis.available());
actionBytes = sis.readBytesEx(sis.available(), "actionBytes");
}
/**

View File

@@ -701,49 +701,49 @@ public class DefineEditTextTag extends TextTag {
*/
public DefineEditTextTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineEditText", pos, length);
characterID = sis.readUI16();
bounds = sis.readRECT();
hasText = sis.readUB(1) == 1;
wordWrap = sis.readUB(1) == 1;
multiline = sis.readUB(1) == 1;
password = sis.readUB(1) == 1;
readOnly = sis.readUB(1) == 1;
hasTextColor = sis.readUB(1) == 1;
hasMaxLength = sis.readUB(1) == 1;
hasFont = sis.readUB(1) == 1;
hasFontClass = sis.readUB(1) == 1;
autoSize = sis.readUB(1) == 1;
hasLayout = sis.readUB(1) == 1;
noSelect = sis.readUB(1) == 1;
border = sis.readUB(1) == 1;
wasStatic = sis.readUB(1) == 1;
html = sis.readUB(1) == 1;
useOutlines = sis.readUB(1) == 1;
characterID = sis.readUI16("characterID");
bounds = sis.readRECT("bounds");
hasText = sis.readUB(1, "hasText") == 1;
wordWrap = sis.readUB(1, "wordWrap") == 1;
multiline = sis.readUB(1, "multiline") == 1;
password = sis.readUB(1, "password") == 1;
readOnly = sis.readUB(1, "readOnly") == 1;
hasTextColor = sis.readUB(1, "hasTextColor") == 1;
hasMaxLength = sis.readUB(1, "hasMaxLength") == 1;
hasFont = sis.readUB(1, "hasFont") == 1;
hasFontClass = sis.readUB(1, "hasFontClass") == 1;
autoSize = sis.readUB(1, "autoSize") == 1;
hasLayout = sis.readUB(1, "hasLayout") == 1;
noSelect = sis.readUB(1, "noSelect") == 1;
border = sis.readUB(1, "border") == 1;
wasStatic = sis.readUB(1, "wasStatic") == 1;
html = sis.readUB(1, "html") == 1;
useOutlines = sis.readUB(1, "useOutlines") == 1;
if (hasFont) {
fontId = sis.readUI16();
fontId = sis.readUI16("fontId");
}
if (hasFontClass) {
fontClass = sis.readString();
fontClass = sis.readString("fontClass");
}
if (hasFont) {
fontHeight = sis.readUI16();
fontHeight = sis.readUI16("fontHeight");
}
if (hasTextColor) {
textColor = sis.readRGBA();
textColor = sis.readRGBA("textColor");
}
if (hasMaxLength) {
maxLength = sis.readUI16();
maxLength = sis.readUI16("maxLength");
}
if (hasLayout) {
align = sis.readUI8(); //0 left,1 right, 2 center, 3 justify
leftMargin = sis.readUI16();
rightMargin = sis.readUI16();
indent = sis.readUI16();
leading = sis.readSI16();
align = sis.readUI8("align"); //0 left,1 right, 2 center, 3 justify
leftMargin = sis.readUI16("leftMargin");
rightMargin = sis.readUI16("rightMargin");
indent = sis.readUI16("indent");
leading = sis.readSI16("leading");
}
variableName = sis.readString();
variableName = sis.readString("variableName");
if (hasText) {
initialText = sis.readString();
initialText = sis.readString("initialText");
}
}

View File

@@ -198,68 +198,68 @@ public class DefineFont2Tag extends FontTag {
*/
public DefineFont2Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineFont2", pos, length);
fontId = sis.readUI16();
fontFlagsHasLayout = sis.readUB(1) == 1;
fontFlagsShiftJIS = sis.readUB(1) == 1;
fontFlagsSmallText = sis.readUB(1) == 1;
fontFlagsANSI = sis.readUB(1) == 1;
fontFlagsWideOffsets = sis.readUB(1) == 1;
fontFlagsWideCodes = sis.readUB(1) == 1;
fontFlagsItalic = sis.readUB(1) == 1;
fontFlagsBold = sis.readUB(1) == 1;
languageCode = sis.readLANGCODE();
int fontNameLen = sis.readUI8();
fontId = sis.readUI16("fontId");
fontFlagsHasLayout = sis.readUB(1, "fontFlagsHasLayout") == 1;
fontFlagsShiftJIS = sis.readUB(1, "fontFlagsShiftJIS") == 1;
fontFlagsSmallText = sis.readUB(1, "fontFlagsSmallText") == 1;
fontFlagsANSI = sis.readUB(1, "fontFlagsANSI") == 1;
fontFlagsWideOffsets = sis.readUB(1, "fontFlagsWideOffsets") == 1;
fontFlagsWideCodes = sis.readUB(1, "fontFlagsWideCodes") == 1;
fontFlagsItalic = sis.readUB(1, "fontFlagsItalic") == 1;
fontFlagsBold = sis.readUB(1, "fontFlagsBold") == 1;
languageCode = sis.readLANGCODE("languageCode");
int fontNameLen = sis.readUI8("fontNameLen");
if (swf.version >= 6) {
fontName = new String(sis.readBytesEx(fontNameLen), Utf8Helper.charset);
fontName = new String(sis.readBytesEx(fontNameLen, "fontName"), Utf8Helper.charset);
} else {
fontName = new String(sis.readBytesEx(fontNameLen));
fontName = new String(sis.readBytesEx(fontNameLen, "fontName"));
}
numGlyphs = sis.readUI16();
numGlyphs = sis.readUI16("numGlyphs");
//offsetTable = new long[numGlyphs];
for (int i = 0; i < numGlyphs; i++) { //offsetTable
if (fontFlagsWideOffsets) {
sis.readUI32();
sis.readUI32("offset");
} else {
sis.readUI16();
sis.readUI16("offset");
}
}
if (numGlyphs > 0) { //codeTableOffset
if (fontFlagsWideOffsets) {
sis.readUI32();
sis.readUI32("offset");
} else {
sis.readUI16();
sis.readUI16("offset");
}
}
glyphShapeTable = new ArrayList<>();
for (int i = 0; i < numGlyphs; i++) {
glyphShapeTable.add(sis.readSHAPE(1, false));
glyphShapeTable.add(sis.readSHAPE(1, false, "shape"));
}
codeTable = new ArrayList<>(); //[numGlyphs];
for (int i = 0; i < numGlyphs; i++) {
if (fontFlagsWideCodes) {
codeTable.add(sis.readUI16());
codeTable.add(sis.readUI16("code"));
} else {
codeTable.add(sis.readUI8());
codeTable.add(sis.readUI8("code"));
}
}
if (fontFlagsHasLayout) {
fontAscent = sis.readSI16();
fontDescent = sis.readSI16();
fontLeading = sis.readSI16();
fontAscent = sis.readSI16("fontAscent");
fontDescent = sis.readSI16("fontDescent");
fontLeading = sis.readSI16("fontLeading");
fontAdvanceTable = new ArrayList<>();
for (int i = 0; i < numGlyphs; i++) {
fontAdvanceTable.add(sis.readSI16());
fontAdvanceTable.add(sis.readSI16("fontAdvance"));
}
fontBoundsTable = new ArrayList<>();
for (int i = 0; i < numGlyphs; i++) {
fontBoundsTable.add(sis.readRECT());
fontBoundsTable.add(sis.readRECT("rect"));
}
int kerningCount = sis.readUI16();
int kerningCount = sis.readUI16("kerningCount");
fontKerningTable = new KERNINGRECORD[kerningCount];
for (int i = 0; i < kerningCount; i++) {
fontKerningTable[i] = sis.readKERNINGRECORD(fontFlagsWideCodes);
fontKerningTable[i] = sis.readKERNINGRECORD(fontFlagsWideCodes, "record");
}
}
}

View File

@@ -112,65 +112,65 @@ public class DefineFont3Tag extends FontTag {
public DefineFont3Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineFont3", pos, length);
fontId = sis.readUI16();
fontFlagsHasLayout = sis.readUB(1) == 1;
fontFlagsShiftJIS = sis.readUB(1) == 1;
fontFlagsSmallText = sis.readUB(1) == 1;
fontFlagsANSI = sis.readUB(1) == 1;
fontFlagsWideOffsets = sis.readUB(1) == 1;
fontFlagsWideCodes = sis.readUB(1) == 1;
fontFlagsItalic = sis.readUB(1) == 1;
fontFlagsBold = sis.readUB(1) == 1;
languageCode = sis.readLANGCODE();
int fontNameLen = sis.readUI8();
fontId = sis.readUI16("fontId");
fontFlagsHasLayout = sis.readUB(1, "fontFlagsHasLayout") == 1;
fontFlagsShiftJIS = sis.readUB(1, "fontFlagsShiftJIS") == 1;
fontFlagsSmallText = sis.readUB(1, "fontFlagsSmallText") == 1;
fontFlagsANSI = sis.readUB(1, "fontFlagsANSI") == 1;
fontFlagsWideOffsets = sis.readUB(1, "fontFlagsWideOffsets") == 1;
fontFlagsWideCodes = sis.readUB(1, "fontFlagsWideCodes") == 1;
fontFlagsItalic = sis.readUB(1, "fontFlagsItalic") == 1;
fontFlagsBold = sis.readUB(1, "fontFlagsBold") == 1;
languageCode = sis.readLANGCODE("languageCode");
int fontNameLen = sis.readUI8("fontNameLen");
if (swf.version >= 6) {
fontName = new String(sis.readBytesEx(fontNameLen), Utf8Helper.charset);
fontName = new String(sis.readBytesEx(fontNameLen, "fontName"), Utf8Helper.charset);
} else {
fontName = new String(sis.readBytesEx(fontNameLen));
fontName = new String(sis.readBytesEx(fontNameLen, "fontName"));
}
numGlyphs = sis.readUI16();
numGlyphs = sis.readUI16("numGlyphs");
for (int i = 0; i < numGlyphs; i++) { //offsetTable
if (fontFlagsWideOffsets) {
sis.readUI32();
sis.readUI32("offset");
} else {
sis.readUI16();
sis.readUI16("offset");
}
}
if (numGlyphs > 0) {
if (fontFlagsWideOffsets) {
sis.readUI32(); //codeTableOffset
sis.readUI32("offset"); //codeTableOffset
} else {
sis.readUI16(); //codeTableOffset
sis.readUI16("offset"); //codeTableOffset
}
}
glyphShapeTable = new ArrayList<>();
for (int i = 0; i < numGlyphs; i++) {
glyphShapeTable.add(sis.readSHAPE(1, false));
glyphShapeTable.add(sis.readSHAPE(1, false, "shape"));
}
codeTable = new ArrayList<>();
for (int i = 0; i < numGlyphs; i++) {
if (fontFlagsWideCodes) {
codeTable.add(sis.readUI16());
codeTable.add(sis.readUI16("code"));
} else {
codeTable.add(sis.readUI8());
codeTable.add(sis.readUI8("code"));
}
}
if (fontFlagsHasLayout) {
fontAscent = sis.readSI16();
fontDescent = sis.readSI16();
fontLeading = sis.readSI16();
fontAscent = sis.readSI16("fontAscent");
fontDescent = sis.readSI16("fontDescent");
fontLeading = sis.readSI16("fontLeading");
fontAdvanceTable = new ArrayList<>();
for (int i = 0; i < numGlyphs; i++) {
fontAdvanceTable.add(sis.readSI16());
fontAdvanceTable.add(sis.readSI16("fontAdvance"));
}
fontBoundsTable = new ArrayList<>();
for (int i = 0; i < numGlyphs; i++) {
fontBoundsTable.add(sis.readRECT());
fontBoundsTable.add(sis.readRECT("rect"));
}
int kerningCount = sis.readUI16();
int kerningCount = sis.readUI16("kerningCount");
fontKerningTable = new KERNINGRECORD[kerningCount];
for (int i = 0; i < kerningCount; i++) {
fontKerningTable[i] = sis.readKERNINGRECORD(fontFlagsWideCodes);
fontKerningTable[i] = sis.readKERNINGRECORD(fontFlagsWideCodes, "record");
}
}
}

View File

@@ -48,13 +48,13 @@ public class DefineFont4Tag extends CharacterTag {
public DefineFont4Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineFont4", pos, length);
fontID = sis.readUI16();
reserved = (int) sis.readUB(5);
fontFlagsHasFontData = sis.readUB(1) == 1;
fontFlagsItalic = sis.readUB(1) == 1;
fontFlagsBold = sis.readUB(1) == 1;
fontName = sis.readString();
fontData = sis.readBytesEx(sis.available());
fontID = sis.readUI16("fontID");
reserved = (int) sis.readUB(5, "reserved");
fontFlagsHasFontData = sis.readUB(1, "fontFlagsHasFontData") == 1;
fontFlagsItalic = sis.readUB(1, "fontFlagsItalic") == 1;
fontFlagsBold = sis.readUB(1, "fontFlagsBold") == 1;
fontName = sis.readString("fontName");
fontData = sis.readBytesEx(sis.available(), "fontData");
}
/**

View File

@@ -44,12 +44,12 @@ public class DefineFontAlignZonesTag extends Tag {
public DefineFontAlignZonesTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineFontAlignZones", pos, length);
fontID = sis.readUI16();
CSMTableHint = (int) sis.readUB(2);
reserved = (int) sis.readUB(6);
fontID = sis.readUI16("fontID");
CSMTableHint = (int) sis.readUB(2, "CSMTableHint");
reserved = (int) sis.readUB(6, "reserved");
zoneTable = new ArrayList<>();
while (sis.available() > 0) {
ZONERECORD zr = sis.readZONERECORD();
ZONERECORD zr = sis.readZONERECORD("record");
zoneTable.add(zr);
}
}

View File

@@ -94,25 +94,25 @@ public class DefineFontInfo2Tag extends Tag {
*/
public DefineFontInfo2Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineFontInfo2", pos, length);
fontID = sis.readUI16();
int fontNameLen = sis.readUI8();
fontID = sis.readUI16("fontID");
int fontNameLen = sis.readUI8("fontNameLen");
if (swf.version >= 6) {
fontName = new String(sis.readBytesEx(fontNameLen), Utf8Helper.charset);
fontName = new String(sis.readBytesEx(fontNameLen, "fontName"), Utf8Helper.charset);
} else {
fontName = new String(sis.readBytesEx(fontNameLen));
fontName = new String(sis.readBytesEx(fontNameLen, "fontName"));
}
reserved = (int) sis.readUB(2);
fontFlagsSmallText = sis.readUB(1) == 1;
fontFlagsShiftJIS = sis.readUB(1) == 1;
fontFlagsANSI = sis.readUB(1) == 1;
fontFlagsItalic = sis.readUB(1) == 1;
fontFlagsBold = sis.readUB(1) == 1;
fontFlagsWideCodes = sis.readUB(1) == 1; //Always 1
languageCode = sis.readLANGCODE();
reserved = (int) sis.readUB(2, "reserved");
fontFlagsSmallText = sis.readUB(1, "fontFlagsSmallText") == 1;
fontFlagsShiftJIS = sis.readUB(1, "fontFlagsShiftJIS") == 1;
fontFlagsANSI = sis.readUB(1, "fontFlagsANSI") == 1;
fontFlagsItalic = sis.readUB(1, "fontFlagsItalic") == 1;
fontFlagsBold = sis.readUB(1, "fontFlagsBold") == 1;
fontFlagsWideCodes = sis.readUB(1, "fontFlagsWideCodes") == 1; //Always 1
languageCode = sis.readLANGCODE("languageCode");
int ctLen = sis.available() / 2;
codeTable = new ArrayList<>();
for (int i = 0; i < ctLen; i++) {
codeTable.add(sis.readUI16());
codeTable.add(sis.readUI16("code"));
}
}
}

View File

@@ -95,26 +95,26 @@ public class DefineFontInfoTag extends Tag {
*/
public DefineFontInfoTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineFontInfo", pos, length);
fontId = sis.readUI16();
int fontNameLen = sis.readUI8();
fontId = sis.readUI16("fontId");
int fontNameLen = sis.readUI8("fontNameLen");
if (swf.version >= 6) {
fontName = new String(sis.readBytesEx(fontNameLen), Utf8Helper.charset);
fontName = new String(sis.readBytesEx(fontNameLen, "fontName"), Utf8Helper.charset);
} else {
fontName = new String(sis.readBytesEx(fontNameLen));
fontName = new String(sis.readBytesEx(fontNameLen, "fontName"));
}
reserved = (int) sis.readUB(2);
fontFlagsSmallText = sis.readUB(1) == 1;
fontFlagsShiftJIS = sis.readUB(1) == 1;
fontFlagsANSI = sis.readUB(1) == 1;
fontFlagsItalic = sis.readUB(1) == 1;
fontFlagsBold = sis.readUB(1) == 1;
fontFlagsWideCodes = sis.readUB(1) == 1;
reserved = (int) sis.readUB(2, "reserved");
fontFlagsSmallText = sis.readUB(1, "fontFlagsSmallText") == 1;
fontFlagsShiftJIS = sis.readUB(1, "fontFlagsShiftJIS") == 1;
fontFlagsANSI = sis.readUB(1, "fontFlagsANSI") == 1;
fontFlagsItalic = sis.readUB(1, "fontFlagsItalic") == 1;
fontFlagsBold = sis.readUB(1, "fontFlagsBold") == 1;
fontFlagsWideCodes = sis.readUB(1, "fontFlagsWideCodes") == 1;
codeTable = new ArrayList<>();
do {
if (fontFlagsWideCodes) {
codeTable.add(sis.readUI16());
codeTable.add(sis.readUI16("code"));
} else {
codeTable.add(sis.readUI8());
codeTable.add(sis.readUI8("code"));
}
} while (sis.available() > 0);
}

View File

@@ -31,8 +31,8 @@ public class DefineFontNameTag extends Tag {
public DefineFontNameTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineFontName", pos, length);
fontId = sis.readUI16();
fontName = sis.readString();
fontCopyright = sis.readString();
fontId = sis.readUI16("fontId");
fontName = sis.readString("fontName");
fontCopyright = sis.readString("fontCopyright");
}
}

View File

@@ -142,16 +142,16 @@ public class DefineFontTag extends FontTag {
*/
public DefineFontTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineFont", pos, length);
fontId = sis.readUI16();
int firstOffset = sis.readUI16();
fontId = sis.readUI16("fontId");
int firstOffset = sis.readUI16("firstOffset");
int nGlyphs = firstOffset / 2;
glyphShapeTable = new ArrayList<>();
for (int i = 1; i < nGlyphs; i++) {
sis.readUI16(); //offset
sis.readUI16("offset"); //offset
}
for (int i = 0; i < nGlyphs; i++) {
glyphShapeTable.add(sis.readSHAPE(1, false));
glyphShapeTable.add(sis.readSHAPE(1, false, "shape"));
}
}

View File

@@ -154,19 +154,19 @@ public class DefineMorphShape2Tag extends CharacterTag implements MorphShapeTag
*/
public DefineMorphShape2Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineMorphShape2", pos, length);
characterId = sis.readUI16();
startBounds = sis.readRECT();
endBounds = sis.readRECT();
startEdgeBounds = sis.readRECT();
endEdgeBounds = sis.readRECT();
reserved = (int) sis.readUB(6);
usesNonScalingStrokes = sis.readUB(1) == 1;
usesScalingStrokes = sis.readUB(1) == 1;
long offset = sis.readUI32();
morphFillStyles = sis.readMORPHFILLSTYLEARRAY();
morphLineStyles = sis.readMORPHLINESTYLEARRAY(2);
startEdges = sis.readSHAPE(2, true);
endEdges = sis.readSHAPE(2, true);
characterId = sis.readUI16("characterId");
startBounds = sis.readRECT("startBounds");
endBounds = sis.readRECT("endBounds");
startEdgeBounds = sis.readRECT("startEdgeBounds");
endEdgeBounds = sis.readRECT("endEdgeBounds");
reserved = (int) sis.readUB(6, "reserved");
usesNonScalingStrokes = sis.readUB(1, "usesNonScalingStrokes") == 1;
usesScalingStrokes = sis.readUB(1, "usesScalingStrokes") == 1;
long offset = sis.readUI32("offset");
morphFillStyles = sis.readMORPHFILLSTYLEARRAY("morphFillStyles");
morphLineStyles = sis.readMORPHLINESTYLEARRAY(2, "morphLineStyles");
startEdges = sis.readSHAPE(2, true, "startEdges");
endEdges = sis.readSHAPE(2, true, "endEdges");
}
@Override

View File

@@ -132,14 +132,14 @@ public class DefineMorphShapeTag extends CharacterTag implements MorphShapeTag {
*/
public DefineMorphShapeTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineMorphShape", pos, length);
characterId = sis.readUI16();
startBounds = sis.readRECT();
endBounds = sis.readRECT();
long offset = sis.readUI32(); //ignore
morphFillStyles = sis.readMORPHFILLSTYLEARRAY();
morphLineStyles = sis.readMORPHLINESTYLEARRAY(1);
startEdges = sis.readSHAPE(1, true);
endEdges = sis.readSHAPE(1, true);
characterId = sis.readUI16("characterId");
startBounds = sis.readRECT("startBounds");
endBounds = sis.readRECT("endBounds");
long offset = sis.readUI32("offset"); //ignore
morphFillStyles = sis.readMORPHFILLSTYLEARRAY("morphFillStyles");
morphLineStyles = sis.readMORPHLINESTYLEARRAY(1, "morphLineStyles");
startEdges = sis.readSHAPE(1, true, "startEdges");
endEdges = sis.readSHAPE(1, true, "endEdges");
}
@Override

View File

@@ -37,8 +37,8 @@ public class DefineScalingGridTag extends Tag {
public DefineScalingGridTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineScalingGrid", pos, length);
characterId = sis.readUI16();
splitter = sis.readRECT();
characterId = sis.readUI16("characterId");
splitter = sis.readRECT("splitter");
}
/**

View File

@@ -84,19 +84,19 @@ public class DefineSceneAndFrameLabelDataTag extends Tag {
*/
public DefineSceneAndFrameLabelDataTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineSceneAndFrameLabelData", pos, length);
int sceneCount = (int) sis.readEncodedU32();
int sceneCount = (int) sis.readEncodedU32("sceneCount");
sceneOffsets = new long[sceneCount];
sceneNames = new String[sceneCount];
for (int i = 0; i < sceneCount; i++) {
sceneOffsets[i] = sis.readEncodedU32();
sceneNames[i] = sis.readString();
sceneOffsets[i] = sis.readEncodedU32("sceneOffset");
sceneNames[i] = sis.readString("sceneName");
}
int frameLabelCount = (int) sis.readEncodedU32();
int frameLabelCount = (int) sis.readEncodedU32("frameLabelCount");
frameNums = new long[frameLabelCount];
frameNames = new String[frameLabelCount];
for (int i = 0; i < frameLabelCount; i++) {
frameNums[i] = sis.readEncodedU32();
frameNames[i] = sis.readString();
frameNums[i] = sis.readEncodedU32("frameNum");
frameNames[i] = sis.readString("frameName");
}
}

View File

@@ -69,9 +69,9 @@ public class DefineShape2Tag extends ShapeTag {
public DefineShape2Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineShape2", pos, length);
shapeId = sis.readUI16();
shapeBounds = sis.readRECT();
shapes = sis.readSHAPEWITHSTYLE(2, false);
shapeId = sis.readUI16("shapeId");
shapeBounds = sis.readRECT("shapeBounds");
shapes = sis.readSHAPEWITHSTYLE(2, false, "shapes");
}
@Override

View File

@@ -69,9 +69,9 @@ public class DefineShape3Tag extends ShapeTag {
public DefineShape3Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineShape3", pos, length);
shapeId = sis.readUI16();
shapeBounds = sis.readRECT();
shapes = sis.readSHAPEWITHSTYLE(3, false);
shapeId = sis.readUI16("shapeId");
shapeBounds = sis.readRECT("shapeBounds");
shapes = sis.readSHAPEWITHSTYLE(3, false, "shapes");
}
@Override

View File

@@ -77,14 +77,14 @@ public class DefineShape4Tag extends ShapeTag {
public DefineShape4Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineShape4", pos, length);
shapeId = sis.readUI16();
shapeBounds = sis.readRECT();
edgeBounds = sis.readRECT();
reserved = (int) sis.readUB(5);
usesFillWindingRule = sis.readUB(1) == 1;
usesNonScalingStrokes = sis.readUB(1) == 1;
usesScalingStrokes = sis.readUB(1) == 1;
shapes = sis.readSHAPEWITHSTYLE(4, false);
shapeId = sis.readUI16("shapeId");
shapeBounds = sis.readRECT("shapeBounds");
edgeBounds = sis.readRECT("edgeBounds");
reserved = (int) sis.readUB(5, "reserved");
usesFillWindingRule = sis.readUB(1, "usesFillWindingRule") == 1;
usesNonScalingStrokes = sis.readUB(1, "usesNonScalingStrokes") == 1;
usesScalingStrokes = sis.readUB(1, "usesScalingStrokes") == 1;
shapes = sis.readSHAPEWITHSTYLE(4, false, "shapes");
}
@Override

View File

@@ -66,9 +66,9 @@ public class DefineShapeTag extends ShapeTag {
public DefineShapeTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineShape", pos, length);
shapeId = sis.readUI16();
shapeBounds = sis.readRECT();
shapes = sis.readSHAPEWITHSTYLE(1, false);
shapeId = sis.readUI16("shapeId");
shapeBounds = sis.readRECT("shapeBounds");
shapes = sis.readSHAPEWITHSTYLE(1, false, "shapes");
}
/**

View File

@@ -102,13 +102,13 @@ public class DefineSoundTag extends CharacterTag implements SoundTag {
*/
public DefineSoundTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineSound", pos, length);
soundId = sis.readUI16();
soundFormat = (int) sis.readUB(4);
soundRate = (int) sis.readUB(2);
soundSize = sis.readUB(1) == 1;
soundType = sis.readUB(1) == 1;
soundSampleCount = sis.readUI32();
soundData = sis.readBytesEx(sis.available());
soundId = sis.readUI16("soundId");
soundFormat = (int) sis.readUB(4, "soundFormat");
soundRate = (int) sis.readUB(2, "soundRate");
soundSize = sis.readUB(1, "soundSize") == 1;
soundType = sis.readUB(1, "soundType") == 1;
soundSampleCount = sis.readUI32("soundSampleCount");
soundData = sis.readBytesEx(sis.available(), "soundData");
}
@Override

View File

@@ -203,8 +203,8 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable
*/
public DefineSpriteTag(SWFInputStream sis, int level, long pos, int length, boolean parallel, boolean skipUnusualTags) throws IOException, InterruptedException {
super(sis.getSwf(), ID, "DefineSprite", pos, length);
spriteId = sis.readUI16();
frameCount = sis.readUI16();
spriteId = sis.readUI16("spriteId");
frameCount = sis.readUI16("frameCount");
List<Tag> subTags = sis.readTagList(this, level + 1, parallel, skipUnusualTags, true, swf.gfx);
if (subTags.get(subTags.size() - 1).getId() == EndTag.ID) {
hasEndTag = true;

View File

@@ -466,14 +466,14 @@ public class DefineText2Tag extends TextTag {
*/
public DefineText2Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineText2", pos, length);
characterID = sis.readUI16();
textBounds = sis.readRECT();
textMatrix = sis.readMatrix();
int glyphBits = sis.readUI8();
int advanceBits = sis.readUI8();
characterID = sis.readUI16("characterID");
textBounds = sis.readRECT("textBounds");
textMatrix = sis.readMatrix("textMatrix");
int glyphBits = sis.readUI8("glyphBits");
int advanceBits = sis.readUI8("advanceBits");
textRecords = new ArrayList<>();
TEXTRECORD tr;
while ((tr = sis.readTEXTRECORD(true, glyphBits, advanceBits)) != null) {
while ((tr = sis.readTEXTRECORD(true, glyphBits, advanceBits, "record")) != null) {
textRecords.add(tr);
}
}

View File

@@ -477,14 +477,14 @@ public class DefineTextTag extends TextTag {
*/
public DefineTextTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineText", pos, length);
characterID = sis.readUI16();
textBounds = sis.readRECT();
textMatrix = sis.readMatrix();
int glyphBits = sis.readUI8();
int advanceBits = sis.readUI8();
characterID = sis.readUI16("characterID");
textBounds = sis.readRECT("textBounds");
textMatrix = sis.readMatrix("textMatrix");
int glyphBits = sis.readUI8("glyphBits");
int advanceBits = sis.readUI8("advanceBits");
textRecords = new ArrayList<>();
TEXTRECORD tr;
while ((tr = sis.readTEXTRECORD(false, glyphBits, advanceBits)) != null) {
while ((tr = sis.readTEXTRECORD(false, glyphBits, advanceBits, "record")) != null) {
textRecords.add(tr);
}
}

View File

@@ -105,14 +105,14 @@ public class DefineVideoStreamTag extends CharacterTag implements BoundedTag {
*/
public DefineVideoStreamTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineVideoStream", pos, length);
characterID = sis.readUI16();
numFrames = sis.readUI16();
width = sis.readUI16();
height = sis.readUI16();
reserved = (int) sis.readUB(4);
videoFlagsDeblocking = (int) sis.readUB(3);
videoFlagsSmoothing = sis.readUB(1) == 1;
codecID = sis.readUI8();
characterID = sis.readUI16("characterID");
numFrames = sis.readUI16("numFrames");
width = sis.readUI16("width");
height = sis.readUI16("height");
reserved = (int) sis.readUB(4, "reserved");
videoFlagsDeblocking = (int) sis.readUB(3, "videoFlagsDeblocking");
videoFlagsSmoothing = sis.readUB(1, "videoFlagsSmoothing") == 1;
codecID = sis.readUI8("codecID");
}
@Override

View File

@@ -72,8 +72,8 @@ public class DoABCDefineTag extends Tag implements ABCContainerTag {
*/
public DoABCDefineTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DoABCDefine", pos, length);
flags = sis.readUI32();
name = sis.readString();
flags = sis.readUI32("flags");
name = sis.readString("name");
abc = new ABC(sis, swf, this);
}

View File

@@ -61,9 +61,9 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource {
*/
public DoInitActionTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DoInitAction", pos, length);
spriteId = sis.readUI16();
spriteId = sis.readUI16("spriteId");
//actions = sis.readActionList();
actionBytes = sis.readBytesEx(sis.available());
actionBytes = sis.readBytesEx(sis.available(), "actionBytes");
}
/**

View File

@@ -70,7 +70,7 @@ public class EnableDebugger2Tag extends Tag {
*/
public EnableDebugger2Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "EnableDebugger2", pos, length);
reserved = sis.readUI16();
passwordHash = sis.readString();
reserved = sis.readUI16("reserved");
passwordHash = sis.readString("passwordHash");
}
}

View File

@@ -64,6 +64,6 @@ public class EnableDebuggerTag extends Tag {
*/
public EnableDebuggerTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "EnableDebugger", pos, length);
passwordHash = sis.readString();
passwordHash = sis.readString("passwordHash");
}
}

View File

@@ -73,9 +73,9 @@ public class EnableTelemetryTag extends Tag {
*/
public EnableTelemetryTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "", pos, length);
reserved = (int) sis.readUB(16);
reserved = (int) sis.readUB(16, "reserved");
if (sis.available() > 0) {
passwordHash = sis.readBytesEx(32);
passwordHash = sis.readBytesEx(32, "passwordHash");
}
}
}

View File

@@ -62,13 +62,13 @@ public class ExportAssetsTag extends Tag {
*/
public ExportAssetsTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "ExportAssets", pos, length);
int count = sis.readUI16();
int count = sis.readUI16("count");
tags = new ArrayList<>();
names = new ArrayList<>();
for (int i = 0; i < count; i++) {
int characterId = sis.readUI16();
int characterId = sis.readUI16("characterId");
tags.add(characterId);
String name = sis.readString();
String name = sis.readString("name");
names.add(name);
}
}

View File

@@ -50,17 +50,17 @@ public class FileAttributesTag extends Tag {
public FileAttributesTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "FileAttributes", pos, length);
reserved1 = sis.readUB(1) == 1; // reserved
reserved1 = sis.readUB(1, "reserved1") == 1; // reserved
// UB[1] == 0 (reserved)
useDirectBlit = sis.readUB(1) != 0;
useGPU = sis.readUB(1) != 0;
hasMetadata = sis.readUB(1) != 0;
actionScript3 = sis.readUB(1) != 0;
noCrossDomainCache = sis.readUB(1) != 0;
reserved2 = sis.readUB(1) == 1; // reserved
useNetwork = sis.readUB(1) != 0;
useDirectBlit = sis.readUB(1, "useDirectBlit") != 0;
useGPU = sis.readUB(1, "useGPU") != 0;
hasMetadata = sis.readUB(1, "hasMetadata") != 0;
actionScript3 = sis.readUB(1, "actionScript3") != 0;
noCrossDomainCache = sis.readUB(1, "noCrossDomainCache") != 0;
reserved2 = sis.readUB(1, "reserved2") == 1; // reserved
useNetwork = sis.readUB(1, "useNetwork") != 0;
// UB[24] == 0 (reserved)
reserved3 = (int) sis.readUB(24); //reserved
reserved3 = (int) sis.readUB(24, "reserved3"); //reserved
}
/**

View File

@@ -38,9 +38,9 @@ public class FrameLabelTag extends Tag {
public FrameLabelTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "FrameLabel", pos, length);
name = sis.readString();
name = sis.readString("name");
if (sis.available() > 0) {
if (sis.readUI8() == 1) {
if (sis.readUI8("namedAnchor") == 1) {
namedAnchor = true;
}
}

View File

@@ -67,13 +67,13 @@ public class ImportAssets2Tag extends Tag implements ImportTag {
super(sis.getSwf(), ID, "ImportAssets2", pos, length);
tags = new ArrayList<>();
names = new ArrayList<>();
url = sis.readString();
reserved1 = sis.readUI8();//reserved, must be 1
reserved2 = sis.readUI8();//reserved, must be 0
int count = sis.readUI16();
url = sis.readString("url");
reserved1 = sis.readUI8("reserved1");//reserved, must be 1
reserved2 = sis.readUI8("reserved2");//reserved, must be 0
int count = sis.readUI16("count");
for (int i = 0; i < count; i++) {
int charId = sis.readUI16();
String tagName = sis.readString();
int charId = sis.readUI16("charId");
String tagName = sis.readString("tagName");
tags.add(charId);
names.add(tagName);
}

View File

@@ -60,11 +60,11 @@ public class ImportAssetsTag extends Tag implements ImportTag {
super(sis.getSwf(), ID, "ImportAssets", pos, length);
tags = new ArrayList<>();
names = new ArrayList<>();
url = sis.readString();
int count = sis.readUI16();
url = sis.readString("url");
int count = sis.readUI16("count");
for (int i = 0; i < count; i++) {
int charId = sis.readUI16();
String tagName = sis.readString();
int charId = sis.readUI16("charId");
String tagName = sis.readString("tagName");
tags.add(charId);
names.add(tagName);
}

View File

@@ -28,6 +28,6 @@ public class JPEGTablesTag extends Tag {
public JPEGTablesTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "JPEGTables", pos, length);
jpegData = sis.readBytesEx(sis.available());
jpegData = sis.readBytesEx(sis.available(), "jpegData");
}
}

View File

@@ -32,7 +32,7 @@ public class MetadataTag extends Tag {
public MetadataTag(SWFInputStream sis, long pos, int length) {
super(sis.getSwf(), ID, "Metadata", pos, length);
try {
xmlMetadata = sis.readString();
xmlMetadata = sis.readString("xmlMetadata");
} catch (IOException ex) {
}
}

View File

@@ -220,35 +220,35 @@ public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceO
*/
public PlaceObject2Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "PlaceObject2", pos, length);
placeFlagHasClipActions = sis.readUB(1) == 1;
placeFlagHasClipDepth = sis.readUB(1) == 1;
placeFlagHasName = sis.readUB(1) == 1;
placeFlagHasRatio = sis.readUB(1) == 1;
placeFlagHasColorTransform = sis.readUB(1) == 1;
placeFlagHasMatrix = sis.readUB(1) == 1;
placeFlagHasCharacter = sis.readUB(1) == 1;
placeFlagMove = sis.readUB(1) == 1;
depth = sis.readUI16();
placeFlagHasClipActions = sis.readUB(1, "placeFlagHasClipActions") == 1;
placeFlagHasClipDepth = sis.readUB(1, "placeFlagHasClipDepth") == 1;
placeFlagHasName = sis.readUB(1, "placeFlagHasName") == 1;
placeFlagHasRatio = sis.readUB(1, "placeFlagHasRatio") == 1;
placeFlagHasColorTransform = sis.readUB(1, "placeFlagHasColorTransform") == 1;
placeFlagHasMatrix = sis.readUB(1, "placeFlagHasMatrix") == 1;
placeFlagHasCharacter = sis.readUB(1, "placeFlagHasCharacter") == 1;
placeFlagMove = sis.readUB(1, "placeFlagMove") == 1;
depth = sis.readUI16("depth");
if (placeFlagHasCharacter) {
characterId = sis.readUI16();
characterId = sis.readUI16("characterId");
}
if (placeFlagHasMatrix) {
matrix = sis.readMatrix();
matrix = sis.readMatrix("matrix");
}
if (placeFlagHasColorTransform) {
colorTransform = sis.readCXFORMWITHALPHA();
colorTransform = sis.readCXFORMWITHALPHA("colorTransform");
}
if (placeFlagHasRatio) {
ratio = sis.readUI16();
ratio = sis.readUI16("ratio");
}
if (placeFlagHasName) {
name = sis.readString();
name = sis.readString("name");
}
if (placeFlagHasClipDepth) {
clipDepth = sis.readUI16();
clipDepth = sis.readUI16("clipDepth");
}
if (placeFlagHasClipActions) {
clipActions = sis.readCLIPACTIONS(swf, this);
clipActions = sis.readCLIPACTIONS(swf, this, "clipActions");
}
}

View File

@@ -304,55 +304,55 @@ public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceO
*/
public PlaceObject3Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "PlaceObject3", pos, length);
placeFlagHasClipActions = sis.readUB(1) == 1;
placeFlagHasClipDepth = sis.readUB(1) == 1;
placeFlagHasName = sis.readUB(1) == 1;
placeFlagHasRatio = sis.readUB(1) == 1;
placeFlagHasColorTransform = sis.readUB(1) == 1;
placeFlagHasMatrix = sis.readUB(1) == 1;
placeFlagHasCharacter = sis.readUB(1) == 1;
placeFlagMove = sis.readUB(1) == 1;
reserved = sis.readUB(1) == 1;
placeFlagOpaqueBackground = sis.readUB(1) == 1; //SWF11
placeFlagHasVisible = sis.readUB(1) == 1; //SWF11
placeFlagHasImage = sis.readUB(1) == 1;
placeFlagHasClassName = sis.readUB(1) == 1;
placeFlagHasCacheAsBitmap = sis.readUB(1) == 1;
placeFlagHasBlendMode = sis.readUB(1) == 1;
placeFlagHasFilterList = sis.readUB(1) == 1;
placeFlagHasClipActions = sis.readUB(1, "placeFlagHasClipActions") == 1;
placeFlagHasClipDepth = sis.readUB(1, "placeFlagHasClipDepth") == 1;
placeFlagHasName = sis.readUB(1, "placeFlagHasName") == 1;
placeFlagHasRatio = sis.readUB(1, "placeFlagHasRatio") == 1;
placeFlagHasColorTransform = sis.readUB(1, "placeFlagHasColorTransform") == 1;
placeFlagHasMatrix = sis.readUB(1, "placeFlagHasMatrix") == 1;
placeFlagHasCharacter = sis.readUB(1, "placeFlagHasCharacter") == 1;
placeFlagMove = sis.readUB(1, "placeFlagMove") == 1;
reserved = sis.readUB(1, "reserved") == 1;
placeFlagOpaqueBackground = sis.readUB(1, "placeFlagOpaqueBackground") == 1; //SWF11
placeFlagHasVisible = sis.readUB(1, "placeFlagHasVisible") == 1; //SWF11
placeFlagHasImage = sis.readUB(1, "placeFlagHasImage") == 1;
placeFlagHasClassName = sis.readUB(1, "placeFlagHasClassName") == 1;
placeFlagHasCacheAsBitmap = sis.readUB(1, "placeFlagHasCacheAsBitmap") == 1;
placeFlagHasBlendMode = sis.readUB(1, "placeFlagHasBlendMode") == 1;
placeFlagHasFilterList = sis.readUB(1, "placeFlagHasFilterList") == 1;
depth = sis.readUI16();
depth = sis.readUI16("depth");
if (placeFlagHasClassName || (placeFlagHasImage && placeFlagHasCharacter)) {
className = sis.readString();
className = sis.readString("className");
}
if (placeFlagHasCharacter) {
characterId = sis.readUI16();
characterId = sis.readUI16("characterId");
}
if (placeFlagHasMatrix) {
matrix = sis.readMatrix();
matrix = sis.readMatrix("matrix");
}
if (placeFlagHasColorTransform) {
colorTransform = sis.readCXFORMWITHALPHA();
colorTransform = sis.readCXFORMWITHALPHA("colorTransform");
}
if (placeFlagHasRatio) {
ratio = sis.readUI16();
ratio = sis.readUI16("ratio");
}
if (placeFlagHasName) {
name = sis.readString();
name = sis.readString("name");
}
if (placeFlagHasClipDepth) {
clipDepth = sis.readUI16();
clipDepth = sis.readUI16("clipDepth");
}
if (placeFlagHasFilterList) {
surfaceFilterList = sis.readFILTERLIST();
surfaceFilterList = sis.readFILTERLIST("surfaceFilterList");
}
if (placeFlagHasBlendMode) {
blendMode = sis.readUI8();
blendMode = sis.readUI8("blendMode");
}
bitmapCacheBug = false;
if (placeFlagHasCacheAsBitmap) {
try {
bitmapCache = sis.readUI8();
bitmapCache = sis.readUI8("bitmapCache");
} catch (EndOfStreamException eex) {
bitmapCacheBug = true;
bitmapCache = 1;
@@ -360,14 +360,14 @@ public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceO
}
if (placeFlagHasVisible) {
visible = sis.readUI8();
visible = sis.readUI8("visible");
}
if (placeFlagOpaqueBackground) {
backgroundColor = sis.readRGBA();
backgroundColor = sis.readRGBA("backgroundColor");
}
if (placeFlagHasClipActions) {
clipActions = sis.readCLIPACTIONS(swf, this);
clipActions = sis.readCLIPACTIONS(swf, this, "clipActions");
}
}

View File

@@ -305,55 +305,55 @@ public class PlaceObject4Tag extends CharacterIdTag implements Container, PlaceO
*/
public PlaceObject4Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "PlaceObject4", pos, length);
placeFlagHasClipActions = sis.readUB(1) == 1;
placeFlagHasClipDepth = sis.readUB(1) == 1;
placeFlagHasName = sis.readUB(1) == 1;
placeFlagHasRatio = sis.readUB(1) == 1;
placeFlagHasColorTransform = sis.readUB(1) == 1;
placeFlagHasMatrix = sis.readUB(1) == 1;
placeFlagHasCharacter = sis.readUB(1) == 1;
placeFlagMove = sis.readUB(1) == 1;
reserved = sis.readUB(1) == 1;
placeFlagOpaqueBackground = sis.readUB(1) == 1; //SWF11
placeFlagHasVisible = sis.readUB(1) == 1; //SWF11
placeFlagHasImage = sis.readUB(1) == 1;
placeFlagHasClassName = sis.readUB(1) == 1;
placeFlagHasCacheAsBitmap = sis.readUB(1) == 1;
placeFlagHasBlendMode = sis.readUB(1) == 1;
placeFlagHasFilterList = sis.readUB(1) == 1;
placeFlagHasClipActions = sis.readUB(1, "placeFlagHasClipActions") == 1;
placeFlagHasClipDepth = sis.readUB(1, "placeFlagHasClipDepth") == 1;
placeFlagHasName = sis.readUB(1, "placeFlagHasName") == 1;
placeFlagHasRatio = sis.readUB(1, "placeFlagHasRatio") == 1;
placeFlagHasColorTransform = sis.readUB(1, "placeFlagHasColorTransform") == 1;
placeFlagHasMatrix = sis.readUB(1, "placeFlagHasMatrix") == 1;
placeFlagHasCharacter = sis.readUB(1, "placeFlagHasCharacter") == 1;
placeFlagMove = sis.readUB(1, "placeFlagMove") == 1;
reserved = sis.readUB(1, "reserved") == 1;
placeFlagOpaqueBackground = sis.readUB(1, "placeFlagOpaqueBackground") == 1; //SWF11
placeFlagHasVisible = sis.readUB(1, "placeFlagHasVisible") == 1; //SWF11
placeFlagHasImage = sis.readUB(1, "placeFlagHasImage") == 1;
placeFlagHasClassName = sis.readUB(1, "placeFlagHasClassName") == 1;
placeFlagHasCacheAsBitmap = sis.readUB(1, "placeFlagHasCacheAsBitmap") == 1;
placeFlagHasBlendMode = sis.readUB(1, "placeFlagHasBlendMode") == 1;
placeFlagHasFilterList = sis.readUB(1, "placeFlagHasFilterList") == 1;
depth = sis.readUI16();
depth = sis.readUI16("depth");
if (placeFlagHasClassName || (placeFlagHasImage && placeFlagHasCharacter)) {
className = sis.readString();
className = sis.readString("className");
}
if (placeFlagHasCharacter) {
characterId = sis.readUI16();
characterId = sis.readUI16("characterId");
}
if (placeFlagHasMatrix) {
matrix = sis.readMatrix();
matrix = sis.readMatrix("matrix");
}
if (placeFlagHasColorTransform) {
colorTransform = sis.readCXFORMWITHALPHA();
colorTransform = sis.readCXFORMWITHALPHA("colorTransform");
}
if (placeFlagHasRatio) {
ratio = sis.readUI16();
ratio = sis.readUI16("ratio");
}
if (placeFlagHasName) {
name = sis.readString();
name = sis.readString("name");
}
if (placeFlagHasClipDepth) {
clipDepth = sis.readUI16();
clipDepth = sis.readUI16("clipDepth");
}
if (placeFlagHasFilterList) {
surfaceFilterList = sis.readFILTERLIST();
surfaceFilterList = sis.readFILTERLIST("surfaceFilterList");
}
if (placeFlagHasBlendMode) {
blendMode = sis.readUI8();
blendMode = sis.readUI8("blendMode");
}
bitmapCacheBug = false;
if (placeFlagHasCacheAsBitmap) {
try {
bitmapCache = sis.readUI8();
bitmapCache = sis.readUI8("bitmapCache");
} catch (EndOfStreamException eex) {
bitmapCacheBug = true;
bitmapCache = 1;
@@ -361,16 +361,16 @@ public class PlaceObject4Tag extends CharacterIdTag implements Container, PlaceO
}
if (placeFlagHasVisible) {
visible = sis.readUI8();
visible = sis.readUI8("visible");
}
if (placeFlagOpaqueBackground) {
backgroundColor = sis.readRGBA();
backgroundColor = sis.readRGBA("backgroundColor");
}
if (placeFlagHasClipActions) {
clipActions = sis.readCLIPACTIONS(swf, this);
clipActions = sis.readCLIPACTIONS(swf, this, "clipActions");
}
amfData = sis.readBytesEx(sis.available());
amfData = sis.readBytesEx(sis.available(), "amfData");
}
/**

View File

@@ -106,11 +106,11 @@ public class PlaceObjectTag extends CharacterIdTag implements PlaceObjectTypeTag
*/
public PlaceObjectTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "PlaceObject", pos, length);
characterId = sis.readUI16();
depth = sis.readUI16();
matrix = sis.readMatrix();
characterId = sis.readUI16("characterId");
depth = sis.readUI16("depth");
matrix = sis.readMatrix("matrix");
if (sis.available() > 0) {
colorTransform = sis.readCXFORM();
colorTransform = sis.readCXFORM("colorTransform");
}
}

View File

@@ -52,7 +52,7 @@ public class ProductInfoTag extends Tag {
* 2: Macromedia Flex for .NET
* 3: Adobe Flex
*/
productID = sis.readUI32();
productID = sis.readUI32("productID");
/*
* 0: Developer Edition
@@ -63,13 +63,13 @@ public class ProductInfoTag extends Tag {
* 5: Trial Edition
* 6: None
*/
edition = sis.readUI32();
majorVersion = sis.readUI8();
minorVersion = sis.readUI8();
buildLow = sis.readUI32();
buildHigh = sis.readUI32();
compilationDateLow = sis.readUI32();
compilationDateHigh = sis.readUI32();
edition = sis.readUI32("edition");
majorVersion = sis.readUI8("majorVersion");
minorVersion = sis.readUI8("minorVersion");
buildLow = sis.readUI32("buildLow");
buildHigh = sis.readUI32("buildHigh");
compilationDateLow = sis.readUI32("compilationDateLow");
compilationDateHigh = sis.readUI32("compilationDateHigh");
}
@Override

View File

@@ -65,7 +65,7 @@ public class ProtectTag extends Tag {
public ProtectTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "Protect", pos, length);
if (sis.available() > 0) {
passwordHash = sis.readString();
passwordHash = sis.readString("passwordHash");
} else {
passwordHash = "";
}

View File

@@ -30,7 +30,7 @@ public class RemoveObject2Tag extends Tag implements RemoveTag {
public RemoveObject2Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "RemoveObject2", pos, length);
depth = sis.readUI16();
depth = sis.readUI16("depth");
}
@Override

View File

@@ -73,8 +73,8 @@ public class RemoveObjectTag extends CharacterIdTag implements RemoveTag {
*/
public RemoveObjectTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "RemoveObject", pos, length);
characterId = sis.readUI16();
depth = sis.readUI16();
characterId = sis.readUI16("characterId");
depth = sis.readUI16("depth");
}
@Override

View File

@@ -36,8 +36,8 @@ public class ScriptLimitsTag extends Tag {
public ScriptLimitsTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "ScriptLimits", pos, length);
maxRecursionDepth = sis.readUI16();
scriptTimeoutSeconds = sis.readUI16();
maxRecursionDepth = sis.readUI16("maxRecursionDepth");
scriptTimeoutSeconds = sis.readUI16("scriptTimeoutSeconds");
}
/**

View File

@@ -30,7 +30,7 @@ public class SetBackgroundColorTag extends Tag {
public SetBackgroundColorTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "SetBackgroundColor", pos, length);
backgroundColor = sis.readRGB();
backgroundColor = sis.readRGB("backgroundColor");
}
public SetBackgroundColorTag(SWF swf, RGB backgroundColor) {

View File

@@ -71,7 +71,7 @@ public class SetTabIndexTag extends Tag {
*/
public SetTabIndexTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "SetTabIndex", pos, length);
depth = sis.readUI16();
tabIndex = sis.readUI16();
depth = sis.readUI16("depth");
tabIndex = sis.readUI16("tabIndex");
}
}

View File

@@ -43,6 +43,6 @@ public class SoundStreamBlockTag extends Tag {
public SoundStreamBlockTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "SoundStreamBlock", pos, length);
//all data is streamSoundData
streamSoundData = sis.readBytesEx(sis.available());
streamSoundData = sis.readBytesEx(sis.available(), "streamSoundData");
}
}

View File

@@ -143,17 +143,17 @@ public class SoundStreamHead2Tag extends CharacterIdTag implements SoundStreamHe
*/
public SoundStreamHead2Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "SoundStreamHead2", pos, length);
reserved = (int) sis.readUB(4);
playBackSoundRate = (int) sis.readUB(2);
playBackSoundSize = sis.readUB(1) == 1;
playBackSoundType = sis.readUB(1) == 1;
streamSoundCompression = (int) sis.readUB(4);
streamSoundRate = (int) sis.readUB(2);
streamSoundSize = sis.readUB(1) == 1;
streamSoundType = sis.readUB(1) == 1;
streamSoundSampleCount = sis.readUI16();
reserved = (int) sis.readUB(4, "reserved");
playBackSoundRate = (int) sis.readUB(2, "playBackSoundRate");
playBackSoundSize = sis.readUB(1, "playBackSoundSize") == 1;
playBackSoundType = sis.readUB(1, "playBackSoundType") == 1;
streamSoundCompression = (int) sis.readUB(4, "streamSoundCompression");
streamSoundRate = (int) sis.readUB(2, "streamSoundRate");
streamSoundSize = sis.readUB(1, "streamSoundSize") == 1;
streamSoundType = sis.readUB(1, "streamSoundType") == 1;
streamSoundSampleCount = sis.readUI16("streamSoundSampleCount");
if (streamSoundCompression == 2) {
latencySeek = sis.readSI16();
latencySeek = sis.readSI16("latencySeek");
}
}

View File

@@ -136,17 +136,17 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea
*/
public SoundStreamHeadTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "SoundStreamHead", pos, length);
reserved = (int) sis.readUB(4);
playBackSoundRate = (int) sis.readUB(2);
playBackSoundSize = sis.readUB(1) == 1;
playBackSoundType = sis.readUB(1) == 1;
streamSoundCompression = (int) sis.readUB(4);
streamSoundRate = (int) sis.readUB(2);
streamSoundSize = sis.readUB(1) == 1;
streamSoundType = sis.readUB(1) == 1;
streamSoundSampleCount = sis.readUI16();
reserved = (int) sis.readUB(4, "reserved");
playBackSoundRate = (int) sis.readUB(2, "playBackSoundRate");
playBackSoundSize = sis.readUB(1, "playBackSoundSize") == 1;
playBackSoundType = sis.readUB(1, "playBackSoundType") == 1;
streamSoundCompression = (int) sis.readUB(4, "streamSoundCompression");
streamSoundRate = (int) sis.readUB(2, "streamSoundRate");
streamSoundSize = sis.readUB(1, "streamSoundSize") == 1;
streamSoundType = sis.readUB(1, "streamSoundType") == 1;
streamSoundSampleCount = sis.readUI16("streamSoundSampleCount");
if (streamSoundCompression == 2) {
latencySeek = sis.readSI16();
latencySeek = sis.readSI16("latencySeek");
}
}

View File

@@ -61,7 +61,7 @@ public class StartSound2Tag extends Tag {
*/
public StartSound2Tag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "StartSound2", pos, length);
soundClassName = sis.readString();
soundInfo = sis.readSOUNDINFO();
soundClassName = sis.readString("soundClassName");
soundInfo = sis.readSOUNDINFO("soundInfo");
}
}

View File

@@ -65,7 +65,7 @@ public class StartSoundTag extends Tag {
*/
public StartSoundTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "StartSound", pos, length);
soundId = sis.readUI16();
soundInfo = sis.readSOUNDINFO();
soundId = sis.readUI16("soundId");
soundInfo = sis.readSOUNDINFO("soundInfo");
}
}

View File

@@ -36,12 +36,12 @@ public class SymbolClassTag extends Tag {
public SymbolClassTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "SymbolClass", pos, length);
int numSymbols = sis.readUI16();
int numSymbols = sis.readUI16("numSymbols");
tags = new int[numSymbols];
names = new String[numSymbols];
for (int ii = 0; ii < numSymbols; ii++) {
int tagID = sis.readUI16();
String className = sis.readString();
int tagID = sis.readUI16("tagID");
String className = sis.readString("className");
tags[ii] = tagID;
names[ii] = className;
}

View File

@@ -67,8 +67,8 @@ public class VideoFrameTag extends Tag {
*/
public VideoFrameTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "VideoFrame", pos, length);
streamID = sis.readUI16();
frameNum = sis.readUI16();
videoData = sis.readBytesEx(sis.available()); //TODO: Parse video packets
streamID = sis.readUI16("streamID");
frameNum = sis.readUI16("frameNum");
videoData = sis.readBytesEx(sis.available(), "videoData"); //TODO: Parse video packets
}
}

View File

@@ -91,7 +91,7 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag {
public DefineCompactedFont(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineCompactedFont", pos, length);
fontId = sis.readUI16();
fontId = sis.readUI16("fontId");
fonts = new ArrayList<>();
while (sis.available() > 0) {

View File

@@ -71,10 +71,10 @@ public class DefineExternalGradient extends Tag {
*/
public DefineExternalGradient(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineExternalGradient", pos, length);
gradientId = sis.readUI16();
bitmapsFormat = sis.readUI16();
gradientSize = sis.readUI16();
int fileNameLen = sis.readUI8();
fileName = new String(sis.readBytesEx(fileNameLen));
gradientId = sis.readUI16("gradientId");
bitmapsFormat = sis.readUI16("bitmapsFormat");
gradientSize = sis.readUI16("gradientSize");
int fileNameLen = sis.readUI8("fileNameLen");
fileName = new String(sis.readBytesEx(fileNameLen, "fileName"));
}
}

View File

@@ -73,12 +73,12 @@ public class DefineExternalImage extends Tag {
*/
public DefineExternalImage(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineExternalImage", pos, length);
characterId = sis.readUI16();
bitmapFormat = sis.readUI16();
targetWidth = sis.readUI16();
targetHeight = sis.readUI16();
int fileNameLen = sis.readUI8();
fileName = new String(sis.readBytesEx(fileNameLen));
characterId = sis.readUI16("characterId");
bitmapFormat = sis.readUI16("bitmapFormat");
targetWidth = sis.readUI16("targetWidth");
targetHeight = sis.readUI16("targetHeight");
int fileNameLen = sis.readUI8("fileNameLen");
fileName = new String(sis.readBytesEx(fileNameLen, "fileName"));
}
}

View File

@@ -81,16 +81,16 @@ public class DefineExternalImage2 extends Tag {
*/
public DefineExternalImage2(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineExternalImage2", pos, length);
characterId = sis.readUI32();
bitmapFormat = sis.readUI16();
targetWidth = sis.readUI16();
targetHeight = sis.readUI16();
int exportNameLen = sis.readUI8();
exportName = new String(sis.readBytesEx(exportNameLen));
int fileNameLen = sis.readUI8();
fileName = new String(sis.readBytesEx(fileNameLen));
characterId = sis.readUI32("characterId");
bitmapFormat = sis.readUI16("bitmapFormat");
targetWidth = sis.readUI16("targetWidth");
targetHeight = sis.readUI16("targetHeight");
int exportNameLen = sis.readUI8("exportNameLen");
exportName = new String(sis.readBytesEx(exportNameLen, "exportName"));
int fileNameLen = sis.readUI8("fileNameLen");
fileName = new String(sis.readBytesEx(fileNameLen, "fileName"));
if (sis.available() > 0) { //there is usually one zero byte, bod knows why
extraData = sis.readBytesEx(sis.available());
extraData = sis.readBytesEx(sis.available(), "extraData");
}
}
}

View File

@@ -81,17 +81,17 @@ public class DefineExternalSound extends Tag {
*/
public DefineExternalSound(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineExternalSound", pos, length);
characterId = sis.readUI16();
soundFormat = sis.readUI16();
bits = sis.readUI16();
channels = sis.readUI16();
sampleRate = sis.readUI32();
sampleCount = sis.readUI32();
seekSample = sis.readUI32();
int exportNameLen = sis.readUI8();
exportName = new String(sis.readBytesEx(exportNameLen));
int fileNameLen = sis.readUI8();
fileName = new String(sis.readBytesEx(fileNameLen));
characterId = sis.readUI16("characterId");
soundFormat = sis.readUI16("soundFormat");
bits = sis.readUI16("bits");
channels = sis.readUI16("channels");
sampleRate = sis.readUI32("sampleRate");
sampleCount = sis.readUI32("sampleCount");
seekSample = sis.readUI32("seekSample");
int exportNameLen = sis.readUI8("exportNameLen");
exportName = new String(sis.readBytesEx(exportNameLen, "exportName"));
int fileNameLen = sis.readUI8("fileNameLen");
fileName = new String(sis.readBytesEx(fileNameLen, "fileName"));
}
}

View File

@@ -79,16 +79,16 @@ public class DefineExternalStreamSound extends Tag {
*/
public DefineExternalStreamSound(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineExternalStreamSound", pos, length);
soundFormat = sis.readUI16();
bits = sis.readUI16();
channels = sis.readUI16();
sampleRate = sis.readUI32();
sampleCount = sis.readUI32();
seekSample = sis.readUI32();
startFrame = sis.readUI32();
lastFrame = sis.readUI32();
int fileNameLen = sis.readUI8();
fileName = new String(sis.readBytesEx(fileNameLen));
soundFormat = sis.readUI16("soundFormat");
bits = sis.readUI16("bits");
channels = sis.readUI16("channels");
sampleRate = sis.readUI32("sampleRate");
sampleCount = sis.readUI32("sampleCount");
seekSample = sis.readUI32("seekSample");
startFrame = sis.readUI32("startFrame");
lastFrame = sis.readUI32("lastFrame");
int fileNameLen = sis.readUI8("fileNameLen");
fileName = new String(sis.readBytesEx(fileNameLen, "fileName"));
}
}

View File

@@ -63,10 +63,10 @@ public class DefineGradientMap extends Tag {
*/
public DefineGradientMap(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineGradientMap", pos, length);
int numGradients = sis.readUI16();
int numGradients = sis.readUI16("numGradients");
indices = new int[numGradients];
for (int i = 0; i < numGradients; i++) {
indices[i] = sis.readUI16();
indices[i] = sis.readUI16("index");
}
}
}

View File

@@ -70,11 +70,11 @@ public class DefineSubImage extends Tag {
*/
public DefineSubImage(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "DefineSubImage", pos, length);
characterId = sis.readUI16();
imageCharacterId = sis.readUI16();
x1 = sis.readUI16();
y1 = sis.readUI16();
x2 = sis.readUI16();
y2 = sis.readUI16();
characterId = sis.readUI16("characterId");
imageCharacterId = sis.readUI16("imageCharacterId");
x1 = sis.readUI16("x1");
y1 = sis.readUI16("y1");
x2 = sis.readUI16("x2");
y2 = sis.readUI16("y2");
}
}

View File

@@ -89,21 +89,21 @@ public class ExporterInfoTag extends Tag {
*/
public ExporterInfoTag(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "ExporterInfo", pos, length);
this.version = sis.readUI16();
this.version = sis.readUI16("version");
if (this.version >= 0x10a) {
flags = sis.readUI32();
flags = sis.readUI32("flags");
}
bitmapFormat = sis.readUI16();
int prefixLen = sis.readUI8();
prefix = sis.readBytesEx(prefixLen);
int swfNameLen = sis.readUI8();
swfName = new String(sis.readBytesEx(swfNameLen));
bitmapFormat = sis.readUI16("bitmapFormat");
int prefixLen = sis.readUI8("prefixLen");
prefix = sis.readBytesEx(prefixLen, "prefix");
int swfNameLen = sis.readUI8("swfNameLen");
swfName = new String(sis.readBytesEx(swfNameLen, "swfName"));
if (sis.available() > 0) // (version >= 0x401) //?
{
codeOffsets = new ArrayList<>();
int numCodeOffsets = sis.readUI16();
int numCodeOffsets = sis.readUI16("numCodeOffsets");
for (int i = 0; i < numCodeOffsets; i++) {
codeOffsets.add(sis.readUI32());
codeOffsets.add(sis.readUI32("codeOffset"));
}
}
}

View File

@@ -91,20 +91,20 @@ public class FontTextureInfo extends Tag {
*/
public FontTextureInfo(SWFInputStream sis, long pos, int length) throws IOException {
super(sis.getSwf(), ID, "FontTextureInfo", pos, length);
textureID = sis.readUI32();
textureFormat = sis.readUI16();
int fileNameLen = sis.readUI8();
fileName = new String(sis.readBytesEx(fileNameLen));
textureWidth = sis.readUI16();
textureHeight = sis.readUI16();
padPixels = sis.readUI8();
nominalGlyphSz = sis.readUI16();
int numTexGlyphs = sis.readUI16();
textureID = sis.readUI32("textureID");
textureFormat = sis.readUI16("textureFormat");
int fileNameLen = sis.readUI8("fileNameLen");
fileName = new String(sis.readBytesEx(fileNameLen, "fileName"));
textureWidth = sis.readUI16("textureWidth");
textureHeight = sis.readUI16("textureHeight");
padPixels = sis.readUI8("padPixels");
nominalGlyphSz = sis.readUI16("nominalGlyphSz");
int numTexGlyphs = sis.readUI16("numTexGlyphs");
texGlyphs = new TEXGLYPH[numTexGlyphs];
for (int i = 0; i < numTexGlyphs; i++) {
texGlyphs[i] = new TEXGLYPH(new GFxInputStream(sis.getBaseStream()));
}
int numFonts = sis.readUI16();
int numFonts = sis.readUI16("numFonts");
fonts = new FONTINFO[numFonts];
for (int i = 0; i < numFonts; i++) {
fonts[i] = new FONTINFO(new GFxInputStream(sis.getBaseStream()));

View File

@@ -63,22 +63,22 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, S
this.swf = swf;
this.tag = tag;
pos = containerOffset;
int condActionSize = sis.readUI16();
int condActionSize = sis.readUI16("condActionSize");
isLast = condActionSize <= 0;
condIdleToOverDown = sis.readUB(1) == 1;
condOutDownToIdle = sis.readUB(1) == 1;
condOutDownToOverDown = sis.readUB(1) == 1;
condOverDownToOutDown = sis.readUB(1) == 1;
condOverDownToOverUp = sis.readUB(1) == 1;
condOverUpToOverDown = sis.readUB(1) == 1;
condOverUpToIddle = sis.readUB(1) == 1;
condIdleToOverUp = sis.readUB(1) == 1;
condKeyPress = (int) sis.readUB(7);
condOverDownToIddle = sis.readUB(1) == 1;
condIdleToOverDown = sis.readUB(1, "condIdleToOverDown") == 1;
condOutDownToIdle = sis.readUB(1, "condOutDownToIdle") == 1;
condOutDownToOverDown = sis.readUB(1, "condOutDownToOverDown") == 1;
condOverDownToOutDown = sis.readUB(1, "condOverDownToOutDown") == 1;
condOverDownToOverUp = sis.readUB(1, "condOverDownToOverUp") == 1;
condOverUpToOverDown = sis.readUB(1, "condOverUpToOverDown") == 1;
condOverUpToIddle = sis.readUB(1, "condOverUpToIddle") == 1;
condIdleToOverUp = sis.readUB(1, "condIdleToOverUp") == 1;
condKeyPress = (int) sis.readUB(7, "condKeyPress");
condOverDownToIdle = sis.readUB(1, "condOverDownToIdle") == 1;
if (condActionSize <= 0) {
actionBytes = sis.readBytesEx(sis.available());
actionBytes = sis.readBytesEx(sis.available(), "actionBytes");
} else {
actionBytes = sis.readBytesEx(condActionSize - 4);
actionBytes = sis.readBytesEx(condActionSize - 4, "actionBytes");
}
}
/**
@@ -127,7 +127,7 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, S
/**
* OverDown to Idle
*/
public boolean condOverDownToIddle;
public boolean condOverDownToIdle;
/**
* Actions to perform
*/

View File

@@ -108,17 +108,17 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S
public CLIPACTIONRECORD(SWF swf, SWFInputStream sis, long pos, Tag tag) throws IOException {
this.swf = swf;
this.tag = tag;
eventFlags = sis.readCLIPEVENTFLAGS();
eventFlags = sis.readCLIPEVENTFLAGS("eventFlags");
if (eventFlags.isClear()) {
return;
}
long actionRecordSize = sis.readUI32();
long actionRecordSize = sis.readUI32("actionRecordSize");
if (eventFlags.clipEventKeyPress) {
keyCode = sis.readUI8();
keyCode = sis.readUI8("keyCode");
actionRecordSize--;
}
hdrPos = sis.getPos();
actionBytes = sis.readBytesEx(actionRecordSize);
actionBytes = sis.readBytesEx(actionRecordSize, "actionBytes");
this.pos = pos;
}

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