mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-02 08:44:51 +00:00
@@ -619,7 +619,7 @@ public class SWFInputStream extends InputStream {
|
||||
//Action.setConstantPool(ret, cpool);
|
||||
|
||||
try {
|
||||
s = Highlighting.stripHilights(Action.actionsToString(ret, null, version));
|
||||
s = Highlighting.stripHilights(Action.actionsToString(ret, null, version,false));
|
||||
ret = ASMParser.parse(false, new ByteArrayInputStream(s.getBytes()), SWF.DEFAULT_VERSION);
|
||||
} catch (ParseException ex) {
|
||||
Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "parsing error", ex);
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.action.parser.ASMParser;
|
||||
import com.jpexs.decompiler.flash.action.parser.FlasmLexer;
|
||||
import com.jpexs.decompiler.flash.action.parser.ParseException;
|
||||
import com.jpexs.decompiler.flash.action.parser.ParsedSymbol;
|
||||
import com.jpexs.decompiler.flash.action.special.ActionContainer;
|
||||
import com.jpexs.decompiler.flash.action.swf4.*;
|
||||
import com.jpexs.decompiler.flash.action.swf5.*;
|
||||
import com.jpexs.decompiler.flash.action.swf6.ActionEnumerate2;
|
||||
@@ -335,10 +336,11 @@ public class Action implements GraphSourceItem {
|
||||
* @param list List of actions
|
||||
* @param importantOffsets List of important offsets to mark as labels
|
||||
* @param version SWF version
|
||||
* @param hex Add hexadecimal?
|
||||
* @return ASM source as String
|
||||
*/
|
||||
public static String actionsToString(List<Action> list, List<Long> importantOffsets, int version) {
|
||||
return actionsToString(list, importantOffsets, new ArrayList<String>(), version);
|
||||
public static String actionsToString(List<Action> list, List<Long> importantOffsets, int version, boolean hex) {
|
||||
return actionsToString(list, importantOffsets, new ArrayList<String>(), version,hex);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,9 +350,10 @@ public class Action implements GraphSourceItem {
|
||||
* @param importantOffsets List of important offsets to mark as labels
|
||||
* @param constantPool Constant pool
|
||||
* @param version SWF version
|
||||
* @param hex Add hexadecimal?
|
||||
* @return ASM source as String
|
||||
*/
|
||||
public static String actionsToString(List<Action> list, List<Long> importantOffsets, List<String> constantPool, int version) {
|
||||
public static String actionsToString(List<Action> list, List<Long> importantOffsets, List<String> constantPool, int version, boolean hex) {
|
||||
String ret = "";
|
||||
long offset;
|
||||
if (importantOffsets == null) {
|
||||
@@ -360,6 +363,9 @@ public class Action implements GraphSourceItem {
|
||||
|
||||
offset = 0;
|
||||
for (Action a : list) {
|
||||
if(hex){
|
||||
ret+="<ffdec:hex>"+Helper.bytesToHexString((a instanceof ActionContainer)?((ActionContainer)a).getHeaderBytes():a.getBytes(version))+"</ffdec:hex>\r\n";
|
||||
}
|
||||
offset = a.getAddress();
|
||||
if (importantOffsets.contains(offset)) {
|
||||
ret += "loc" + Helper.formatAddress(offset) + ":";
|
||||
@@ -372,10 +378,10 @@ public class Action implements GraphSourceItem {
|
||||
}
|
||||
} else {
|
||||
if (a.beforeInsert != null) {
|
||||
ret += a.beforeInsert.getASMSource(importantOffsets, constantPool, version) + "\r\n";
|
||||
ret += a.beforeInsert.getASMSource(importantOffsets, constantPool, version,hex) + "\r\n";
|
||||
}
|
||||
//if (!(a instanceof ActionNop)) {
|
||||
ret += Highlighting.hilighOffset("", offset) + a.getASMSource(importantOffsets, constantPool, version) + (a.ignored ? "; ignored" : "") + "\r\n";
|
||||
ret += Highlighting.hilighOffset("", offset) + a.getASMSource(importantOffsets, constantPool, version,hex) + (a.ignored ? "; ignored" : "") + "\r\n";
|
||||
//}
|
||||
}
|
||||
offset += a.getBytes(version).length;
|
||||
@@ -392,9 +398,10 @@ public class Action implements GraphSourceItem {
|
||||
* @param knownAddreses List of important offsets to mark as labels
|
||||
* @param constantPool Constant pool
|
||||
* @param version SWF version
|
||||
* @param hex Add hexadecimal
|
||||
* @return
|
||||
*/
|
||||
public String getASMSource(List<Long> knownAddreses, List<String> constantPool, int version) {
|
||||
public String getASMSource(List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
|
||||
return toString();
|
||||
}
|
||||
|
||||
@@ -994,7 +1001,7 @@ public class Action implements GraphSourceItem {
|
||||
List<Action> ret = actions;
|
||||
String s = null;
|
||||
try {
|
||||
s = Highlighting.stripHilights(Action.actionsToString(ret, null, version));
|
||||
s = Highlighting.stripHilights(Action.actionsToString(ret, null, version,false));
|
||||
ret = ASMParser.parse(true, new ByteArrayInputStream(s.getBytes()), SWF.DEFAULT_VERSION);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "parsing error", ex);
|
||||
|
||||
@@ -24,12 +24,15 @@ import com.jpexs.decompiler.flash.action.parser.ASMParser;
|
||||
import com.jpexs.decompiler.flash.action.parser.ParseException;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.flash.gui.GraphFrame;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.decompiler.flash.helpers.Helper;
|
||||
import com.jpexs.decompiler.flash.helpers.Highlighting;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSource;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -53,7 +56,7 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
public JButton saveButton = new JButton("Save");
|
||||
public JButton editButton = new JButton("Edit");
|
||||
public JButton cancelButton = new JButton("Cancel");
|
||||
public JButton graphButton = new JButton("Graph");
|
||||
public JToggleButton hexButton;
|
||||
public JButton saveHexButton = new JButton("Save hex");
|
||||
public JButton loadHexButton = new JButton("Load hex");
|
||||
public JLabel asmLabel = new JLabel("P-code source");
|
||||
@@ -65,6 +68,34 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
private boolean editMode = false;
|
||||
private List<com.jpexs.decompiler.flash.action.Action> lastCode;
|
||||
private ASMSource src;
|
||||
public JPanel topButtonsPan;
|
||||
private String srcWithHex;
|
||||
private String srcNoHex;
|
||||
|
||||
public void setText(String text){
|
||||
int pos = editor.getCaretPosition();
|
||||
Highlighting lastH = new Highlighting(0, 0, 0);
|
||||
for (Highlighting h : disassembledHilights) {
|
||||
if (pos < h.startPos) {
|
||||
break;
|
||||
}
|
||||
lastH = h;
|
||||
}
|
||||
long offset=lastH.offset;
|
||||
disassembledHilights = Highlighting.getInstrHighlights(text);
|
||||
editor.setText(Highlighting.stripHilights(text));
|
||||
for (Highlighting h : disassembledHilights) {
|
||||
if (h.offset == offset) {
|
||||
editor.setCaretPosition(h.startPos);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setHex(boolean hex) {
|
||||
setText(hex ? srcWithHex : srcNoHex);
|
||||
}
|
||||
|
||||
public void setSource(ASMSource src) {
|
||||
this.src = src;
|
||||
@@ -77,10 +108,10 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
if (Main.DO_DECOMPILE) {
|
||||
decompiledEditor.setText("//Decompiling...");
|
||||
}
|
||||
lastDisasm = asm.getASMSource(SWF.DEFAULT_VERSION);
|
||||
disassembledHilights = Highlighting.getInstrHighlights(lastDisasm);
|
||||
lastDisasm = Highlighting.stripHilights(lastDisasm);
|
||||
editor.setText(lastDisasm);
|
||||
lastDisasm = asm.getASMSource(SWF.DEFAULT_VERSION, true);
|
||||
srcWithHex = Helper.hexToComments(lastDisasm);
|
||||
srcNoHex = Helper.stripComments(lastDisasm);
|
||||
setHex(hexButton.isSelected());
|
||||
if (Main.DO_DECOMPILE) {
|
||||
List<com.jpexs.decompiler.flash.action.Action> as = asm.getActions(SWF.DEFAULT_VERSION);
|
||||
lastCode = as;
|
||||
@@ -95,6 +126,9 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void hilightOffset(long offset) {
|
||||
}
|
||||
|
||||
public ActionPanel() {
|
||||
this.list = list;
|
||||
DefaultSyntaxKit.initKit();
|
||||
@@ -104,26 +138,46 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
decompiledEditor.setEditable(false);
|
||||
|
||||
|
||||
JButton graphButton = new JButton(View.getIcon("graph16"));
|
||||
graphButton.setActionCommand("GRAPH");
|
||||
graphButton.addActionListener(this);
|
||||
graphButton.setToolTipText("View Graph");
|
||||
graphButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
|
||||
hexButton = new JToggleButton(View.getIcon("hex16"));
|
||||
hexButton.setActionCommand("HEX");
|
||||
hexButton.addActionListener(this);
|
||||
hexButton.setToolTipText("View Hex");
|
||||
hexButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
|
||||
topButtonsPan = new JPanel();
|
||||
topButtonsPan.setLayout(new BoxLayout(topButtonsPan, BoxLayout.X_AXIS));
|
||||
topButtonsPan.add(graphButton);
|
||||
topButtonsPan.add(hexButton);
|
||||
JPanel panCode=new JPanel(new BorderLayout());
|
||||
panCode.add(new JScrollPane(editor), BorderLayout.CENTER);
|
||||
panCode.add(topButtonsPan, BorderLayout.NORTH);
|
||||
|
||||
JPanel panB = new JPanel();
|
||||
panB.setLayout(new BorderLayout());
|
||||
asmLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
asmLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
|
||||
panB.add(asmLabel, BorderLayout.NORTH);
|
||||
panB.add(new JScrollPane(editor), BorderLayout.CENTER);
|
||||
panB.add(panCode,BorderLayout.CENTER);
|
||||
|
||||
|
||||
|
||||
JPanel buttonsPan = new JPanel();
|
||||
buttonsPan.setLayout(new FlowLayout());
|
||||
buttonsPan.add(editButton);
|
||||
buttonsPan.add(saveButton);
|
||||
buttonsPan.add(cancelButton);
|
||||
buttonsPan.add(graphButton);
|
||||
|
||||
//buttonsPan.add(saveHexButton);
|
||||
//buttonsPan.add(loadHexButton);
|
||||
panB.add(buttonsPan, BorderLayout.SOUTH);
|
||||
|
||||
|
||||
graphButton.addActionListener(this);
|
||||
graphButton.setActionCommand("GRAPH");
|
||||
saveHexButton.addActionListener(this);
|
||||
saveHexButton.setActionCommand("SAVEHEXACTION");
|
||||
loadHexButton.addActionListener(this);
|
||||
@@ -228,18 +282,21 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
|
||||
public void setEditMode(boolean val) {
|
||||
if (val) {
|
||||
setText(srcNoHex);
|
||||
editor.setEditable(true);
|
||||
saveButton.setVisible(true);
|
||||
editButton.setVisible(false);
|
||||
cancelButton.setVisible(true);
|
||||
editor.getCaret().setVisible(true);
|
||||
} else {
|
||||
setText(hexButton.isSelected()?srcWithHex:srcNoHex);
|
||||
editor.setEditable(false);
|
||||
saveButton.setVisible(false);
|
||||
editButton.setVisible(true);
|
||||
cancelButton.setVisible(false);
|
||||
editor.getCaret().setVisible(true);
|
||||
}
|
||||
topButtonsPan.setVisible(!val);
|
||||
editMode = val;
|
||||
}
|
||||
|
||||
@@ -251,9 +308,11 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
}
|
||||
} else if (e.getActionCommand().equals("EDITACTION")) {
|
||||
setEditMode(true);
|
||||
} else if (e.getActionCommand().equals("HEX")) {
|
||||
setHex(hexButton.isSelected());
|
||||
} else if (e.getActionCommand().equals("CANCELACTION")) {
|
||||
setEditMode(false);
|
||||
editor.setText(lastDisasm);
|
||||
setHex(hexButton.isSelected());
|
||||
} else if (e.getActionCommand().equals("SAVEACTION")) {
|
||||
try {
|
||||
src.setActions(ASMParser.parse(true, new ByteArrayInputStream(editor.getText().getBytes()), SWF.DEFAULT_VERSION), SWF.DEFAULT_VERSION);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.jpexs.decompiler.flash.action.special;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface ActionContainer {
|
||||
public byte[] getHeaderBytes();
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class ActionIf extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getASMSource(List<Long> knownAddreses, List<String> constantPool, int version) {
|
||||
public String getASMSource(List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
|
||||
String ofsStr = Helper.formatAddress(getAddress() + getBytes(version).length + offset);
|
||||
return "If loc" + ofsStr + (compileTime ? " ;compileTime" : "");
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ActionJump extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getASMSource(List<Long> knownAddreses, List<String> constantPool, int version) {
|
||||
public String getASMSource(List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
|
||||
String ofsStr = Helper.formatAddress(getAddress() + getBytes(version).length + offset);
|
||||
return "Jump loc" + ofsStr;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.action.parser.ASMParser;
|
||||
import com.jpexs.decompiler.flash.action.parser.FlasmLexer;
|
||||
import com.jpexs.decompiler.flash.action.parser.Label;
|
||||
import com.jpexs.decompiler.flash.action.parser.ParseException;
|
||||
import com.jpexs.decompiler.flash.action.special.ActionContainer;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.FunctionTreeItem;
|
||||
@@ -37,7 +38,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
public class ActionDefineFunction extends Action {
|
||||
public class ActionDefineFunction extends Action implements ActionContainer {
|
||||
|
||||
public String functionName;
|
||||
public List<String> paramNames = new ArrayList<String>();
|
||||
@@ -87,6 +88,28 @@ public class ActionDefineFunction extends Action {
|
||||
code = ASMParser.parse(ignoreNops, labels, address + getPreLen(version), lexer, constantPool, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getHeaderBytes() {
|
||||
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(codeBytes.length);
|
||||
sos.close();
|
||||
|
||||
|
||||
baos2.write(surroundWithAction(baos.toByteArray(), version));
|
||||
} catch (IOException e) {
|
||||
}
|
||||
return baos2.toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes(int version) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
@@ -134,13 +157,13 @@ public class ActionDefineFunction extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getASMSource(List<Long> knownAddreses, List<String> constantPool, int version) {
|
||||
public String getASMSource(List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
|
||||
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 + " {\r\n" + Action.actionsToString(code, knownAddreses, constantPool, version) + "}";
|
||||
return "DefineFunction \"" + Helper.escapeString(functionName) + "\" " + paramNames.size() + " " + paramStr + " {\r\n" + Action.actionsToString(code, knownAddreses, constantPool, version, hex) + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,19 +23,22 @@ import com.jpexs.decompiler.flash.action.parser.ASMParser;
|
||||
import com.jpexs.decompiler.flash.action.parser.FlasmLexer;
|
||||
import com.jpexs.decompiler.flash.action.parser.Label;
|
||||
import com.jpexs.decompiler.flash.action.parser.ParseException;
|
||||
import com.jpexs.decompiler.flash.action.special.ActionContainer;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class ActionWith extends Action {
|
||||
public class ActionWith extends Action implements ActionContainer{
|
||||
|
||||
public List<Action> actions;
|
||||
public int size;
|
||||
public int version;
|
||||
|
||||
public ActionWith(SWFInputStream sis, int version) throws IOException {
|
||||
super(0x94, 2);
|
||||
size = sis.readUI16();
|
||||
this.version = version;
|
||||
//actions = new ArrayList<Action>();
|
||||
actions = (new SWFInputStream(new ByteArrayInputStream(sis.readBytes(size)), version)).readActionList();
|
||||
}
|
||||
@@ -52,6 +55,21 @@ public class ActionWith extends Action {
|
||||
Action.setActionsAddresses(actions, address + 5, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getHeaderBytes() {
|
||||
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, version);
|
||||
try {
|
||||
byte codeBytes[] = Action.actionsToBytes(actions, false, version);
|
||||
sos.writeUI16(codeBytes.length);
|
||||
sos.close();
|
||||
baos2.write(surroundWithAction(baos.toByteArray(), version));
|
||||
} catch (IOException e) {
|
||||
}
|
||||
return baos2.toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes(int version) {
|
||||
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
|
||||
@@ -69,8 +87,8 @@ public class ActionWith extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getASMSource(List<Long> knownAddreses, List<String> constantPool, int version) {
|
||||
return "With {\r\n" + Action.actionsToString(actions, knownAddreses, constantPool, version) + "}";
|
||||
public String getASMSource(List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
|
||||
return "With {\r\n" + Action.actionsToString(actions, knownAddreses, constantPool, version,hex) + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,4 +100,6 @@ public class ActionWith extends Action {
|
||||
public List<Action> getAllIfsOrJumps() {
|
||||
return Action.getActionsAllIfsOrJumps(actions);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.action.parser.ASMParser;
|
||||
import com.jpexs.decompiler.flash.action.parser.FlasmLexer;
|
||||
import com.jpexs.decompiler.flash.action.parser.Label;
|
||||
import com.jpexs.decompiler.flash.action.parser.ParseException;
|
||||
import com.jpexs.decompiler.flash.action.special.ActionContainer;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDefineFunction;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.FunctionTreeItem;
|
||||
@@ -37,7 +38,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
public class ActionDefineFunction2 extends Action {
|
||||
public class ActionDefineFunction2 extends Action implements ActionContainer {
|
||||
|
||||
public String functionName;
|
||||
public List<String> paramNames = new ArrayList<String>();
|
||||
@@ -120,6 +121,40 @@ public class ActionDefineFunction2 extends Action {
|
||||
code = ASMParser.parse(ignoreNops, labels, address + getPreLen(version), lexer, constantPool, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getHeaderBytes() {
|
||||
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(codeBytes.length);
|
||||
sos.close();
|
||||
|
||||
|
||||
baos2.write(surroundWithAction(baos.toByteArray(), version));
|
||||
} catch (IOException e) {
|
||||
}
|
||||
return baos2.toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes(int version) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
@@ -191,7 +226,7 @@ public class ActionDefineFunction2 extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getASMSource(List<Long> knownAddreses, List<String> constantPool, int version) {
|
||||
public String getASMSource(List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
|
||||
String paramStr = "";
|
||||
for (int i = 0; i < paramNames.size(); i++) {
|
||||
paramStr += paramRegisters.get(i) + " \"" + Helper.escapeString(paramNames.get(i)) + "\"";
|
||||
@@ -207,7 +242,7 @@ public class ActionDefineFunction2 extends Action {
|
||||
+ " " + preloadArgumentsFlag
|
||||
+ " " + suppressThisFlag
|
||||
+ " " + preloadThisFlag
|
||||
+ " " + preloadGlobalFlag).trim() + " " + paramStr + " {\r\n" + Action.actionsToString(code, knownAddreses, constantPool, version) + "}";
|
||||
+ " " + preloadGlobalFlag).trim() + " " + paramStr + " {\r\n" + Action.actionsToString(code, knownAddreses, constantPool, version, hex) + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -163,10 +163,10 @@ public class ActionTry extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getASMSource(List<Long> knownAddreses, List<String> constantPool, int version) {
|
||||
public String getASMSource(List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
|
||||
String ret = "";
|
||||
ret += "Try {";
|
||||
ret += Action.actionsToString(tryBody, knownAddreses, constantPool, version);
|
||||
ret += Action.actionsToString(tryBody, knownAddreses, constantPool, version,hex);
|
||||
ret += "}";
|
||||
if (catchBlockFlag) {
|
||||
ret += "\r\nCatch ";
|
||||
@@ -176,12 +176,12 @@ public class ActionTry extends Action {
|
||||
ret += "\"" + Helper.escapeString(catchName) + "\"";
|
||||
}
|
||||
ret += " {\r\n";
|
||||
ret += Action.actionsToString(catchBody, knownAddreses, constantPool, version);
|
||||
ret += Action.actionsToString(catchBody, knownAddreses, constantPool, version,hex);
|
||||
ret += "}";
|
||||
}
|
||||
if (finallyBlockFlag) {
|
||||
ret += "\r\nFinally {\r\n";
|
||||
ret += Action.actionsToString(finallyBody, knownAddreses, constantPool, version);
|
||||
ret += Action.actionsToString(finallyBody, knownAddreses, constantPool, version,hex);
|
||||
ret += "}";
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -262,7 +262,7 @@ public class TagNode {
|
||||
}
|
||||
String ret;
|
||||
if (isPcode) {
|
||||
ret = Highlighting.stripHilights(((ASMSource) node.tag).getASMSource(SWF.DEFAULT_VERSION));
|
||||
ret = Highlighting.stripHilights(((ASMSource) node.tag).getASMSource(SWF.DEFAULT_VERSION,false));
|
||||
} else {
|
||||
List<Action> as = ((ASMSource) node.tag).getActions(SWF.DEFAULT_VERSION);
|
||||
Action.setActionsAddresses(as, 0, SWF.DEFAULT_VERSION);
|
||||
|
||||
@@ -115,8 +115,8 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT
|
||||
* @param version SWF version
|
||||
* @return ASM source
|
||||
*/
|
||||
public String getASMSource(int version) {
|
||||
return Action.actionsToString(getActions(version), null, version);
|
||||
public String getASMSource(int version,boolean hex) {
|
||||
return Action.actionsToString(getActions(version), null, version,hex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,8 +71,8 @@ public class DoActionTag extends Tag implements ASMSource {
|
||||
* @return ASM source
|
||||
*/
|
||||
@Override
|
||||
public String getASMSource(int version) {
|
||||
return Action.actionsToString(getActions(version), null, version);
|
||||
public String getASMSource(int version,boolean hex) {
|
||||
return Action.actionsToString(getActions(version), null, version,hex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -93,8 +93,8 @@ public class DoInitActionTag extends CharacterTag implements ASMSource {
|
||||
* @return ASM source
|
||||
*/
|
||||
@Override
|
||||
public String getASMSource(int version) {
|
||||
return Action.actionsToString(getActions(version), null, version);
|
||||
public String getASMSource(int version,boolean hex) {
|
||||
return Action.actionsToString(getActions(version), null, version,hex);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,9 +30,10 @@ public interface ASMSource {
|
||||
* Converts actions to ASM source
|
||||
*
|
||||
* @param version SWF version
|
||||
* @param hex Add hexadecimal?
|
||||
* @return ASM source
|
||||
*/
|
||||
public String getASMSource(int version);
|
||||
public String getASMSource(int version,boolean hex);
|
||||
|
||||
/**
|
||||
* Whether or not this object contains ASM source
|
||||
|
||||
@@ -111,8 +111,8 @@ public class BUTTONCONDACTION implements ASMSource {
|
||||
* @param version SWF version
|
||||
* @return ASM source
|
||||
*/
|
||||
public String getASMSource(int version) {
|
||||
return Action.actionsToString(getActions(version), null, version);
|
||||
public String getASMSource(int version,boolean hex) {
|
||||
return Action.actionsToString(getActions(version), null, version,hex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -78,8 +78,8 @@ public class CLIPACTIONRECORD implements ASMSource {
|
||||
* @param version SWF version
|
||||
* @return ASM source
|
||||
*/
|
||||
public String getASMSource(int version) {
|
||||
return Action.actionsToString(getActions(version), null, version);
|
||||
public String getASMSource(int version,boolean hex) {
|
||||
return Action.actionsToString(getActions(version), null, version,hex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user