mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 03:40:47 +00:00
show abc data in dumpview (right click in the treenode to load it)
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.gui.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.ABCInputStream;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.UnknownInstructionCode;
|
||||
@@ -36,7 +37,7 @@ import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import com.jpexs.helpers.MemoryInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
@@ -194,7 +195,8 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi
|
||||
MethodBody mb = abc.bodies.get(bodyIndex);
|
||||
mb.codeBytes = data;
|
||||
try {
|
||||
mb.code = new AVM2Code(new ByteArrayInputStream(mb.codeBytes));
|
||||
ABCInputStream ais = new ABCInputStream(new MemoryInputStream(mb.codeBytes));
|
||||
mb.code = new AVM2Code(ais);
|
||||
} catch (UnknownInstructionCode re) {
|
||||
mb.code = new AVM2Code();
|
||||
Logger.getLogger(ABC.class.getName()).log(Level.SEVERE, null, re);
|
||||
|
||||
@@ -18,6 +18,9 @@ package com.jpexs.decompiler.flash.gui.dumpview;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.ABCInputStream;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.ActionListReader;
|
||||
import com.jpexs.decompiler.flash.action.model.ConstantPool;
|
||||
@@ -28,6 +31,7 @@ import com.jpexs.decompiler.flash.gui.Main;
|
||||
import com.jpexs.decompiler.flash.gui.MainPanel;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.MemoryInputStream;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
@@ -64,6 +68,8 @@ public class DumpTree extends JTree implements ActionListener {
|
||||
private static final String ACTION_EXPAND_RECURSIVE = "EXPANDRECURSIVE";
|
||||
private static final String ACTION_SAVE_TO_FILE = "SAVETOFILE";
|
||||
private static final String ACTION_PARSE_ACTIONS = "PARSEACTIONS";
|
||||
private static final String ACTION_PARSE_ABC = "PARSEABC";
|
||||
private static final String ACTION_PARSE_INSTRUCTIONS = "PARSEINSTRUCTIONS";
|
||||
|
||||
private final MainPanel mainPanel;
|
||||
|
||||
@@ -131,6 +137,16 @@ public class DumpTree extends JTree implements ActionListener {
|
||||
parseActionsMenuItem.addActionListener(this);
|
||||
contextPopupMenu.add(parseActionsMenuItem);
|
||||
|
||||
final JMenuItem parseAbcMenuItem = new JMenuItem(mainPanel.translate("contextmenu.parseABC"));
|
||||
parseAbcMenuItem.setActionCommand(ACTION_PARSE_ABC);
|
||||
parseAbcMenuItem.addActionListener(this);
|
||||
contextPopupMenu.add(parseAbcMenuItem);
|
||||
|
||||
final JMenuItem parseInstructionsMenuItem = new JMenuItem(mainPanel.translate("contextmenu.parseInstructions"));
|
||||
parseInstructionsMenuItem.setActionCommand(ACTION_PARSE_INSTRUCTIONS);
|
||||
parseInstructionsMenuItem.addActionListener(this);
|
||||
contextPopupMenu.add(parseInstructionsMenuItem);
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
@@ -150,6 +166,8 @@ public class DumpTree extends JTree implements ActionListener {
|
||||
expandRecursiveMenuItem.setVisible(false);
|
||||
saveToFileMenuItem.setVisible(false);
|
||||
parseActionsMenuItem.setVisible(false);
|
||||
parseAbcMenuItem.setVisible(false);
|
||||
parseInstructionsMenuItem.setVisible(false);
|
||||
|
||||
if (paths.length == 1) {
|
||||
DumpInfo treeNode = (DumpInfo) paths[0].getLastPathComponent();
|
||||
@@ -162,10 +180,19 @@ public class DumpTree extends JTree implements ActionListener {
|
||||
saveToFileMenuItem.setVisible(true);
|
||||
}
|
||||
|
||||
// todo honfika: do not use string names, because it has conflicts e.g with DefineFont.code
|
||||
if (treeNode.name.equals("actionBytes") && treeNode.getChildCount() == 0) {
|
||||
parseActionsMenuItem.setVisible(true);
|
||||
}
|
||||
|
||||
if (treeNode.name.equals("abcBytes") && treeNode.getChildCount() == 0) {
|
||||
parseAbcMenuItem.setVisible(true);
|
||||
}
|
||||
|
||||
if (treeNode.name.equals("code") && treeNode.parent.name.equals("method_body") && treeNode.getChildCount() == 0) {
|
||||
parseInstructionsMenuItem.setVisible(true);
|
||||
}
|
||||
|
||||
TreeModel model = getModel();
|
||||
expandRecursiveMenuItem.setVisible(model.getChildCount(treeNode) > 0);
|
||||
}
|
||||
@@ -229,11 +256,46 @@ public class DumpTree extends JTree implements ActionListener {
|
||||
rri.readAction(new ConstantPool());
|
||||
dumpInfo.getChildInfos().add(di);
|
||||
}
|
||||
repaint();
|
||||
} catch (IOException | InterruptedException ex) {
|
||||
Logger.getLogger(DumpTree.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ACTION_PARSE_ABC: {
|
||||
TreePath[] paths = getSelectionPaths();
|
||||
DumpInfo dumpInfo = (DumpInfo) paths[0].getLastPathComponent();
|
||||
SWF swf = DumpInfoSwfNode.getSwfNode(dumpInfo).getSwf();
|
||||
byte[] data = swf.uncompressedData;
|
||||
int prevLength = (int) dumpInfo.startByte;
|
||||
try {
|
||||
ABCInputStream ais = new ABCInputStream(new MemoryInputStream(data, 0, prevLength + (int) dumpInfo.lengthBytes));
|
||||
ais.seek(prevLength);
|
||||
ais.dumpInfo = dumpInfo;
|
||||
new ABC(ais, swf, null);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(DumpTree.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
break;
|
||||
case ACTION_PARSE_INSTRUCTIONS: {
|
||||
TreePath[] paths = getSelectionPaths();
|
||||
DumpInfo dumpInfo = (DumpInfo) paths[0].getLastPathComponent();
|
||||
SWF swf = DumpInfoSwfNode.getSwfNode(dumpInfo).getSwf();
|
||||
byte[] data = swf.uncompressedData;
|
||||
int prevLength = (int) dumpInfo.startByte;
|
||||
try {
|
||||
ABCInputStream ais = new ABCInputStream(new MemoryInputStream(data, 0, prevLength + (int) dumpInfo.lengthBytes));
|
||||
ais.seek(prevLength);
|
||||
ais.dumpInfo = dumpInfo;
|
||||
new AVM2Code(ais);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(DumpTree.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
break;
|
||||
case ACTION_CLOSE_SWF: {
|
||||
Main.closeFile(mainPanel.getCurrentSwfList());
|
||||
}
|
||||
|
||||
@@ -511,3 +511,5 @@ header.displayrect.value.pixels = %xmin%,%ymin% => %xmax%,%ymax% pixels
|
||||
|
||||
contextmenu.saveToFile = Save to File
|
||||
contextmenu.parseActions = Parse actions
|
||||
contextmenu.parseABC = Parse ABC
|
||||
contextmenu.parseInstructions = Parse AVM2 Instrctions
|
||||
|
||||
@@ -511,3 +511,5 @@ header.displayrect.value.pixels = %xmin%,%ymin% => %xmax%,%ymax% k\u00e9ppont
|
||||
|
||||
contextmenu.saveToFile = Ment\u00e9s f\u00e1jlba
|
||||
contextmenu.parseActions = Action-\u00f6k elemz\u00e9se
|
||||
contextmenu.parseABC = ABC elemz\u00e9se
|
||||
contextmenu.parseInstructions = AVM2 utas\u00edt\u00e1sok elemz\u00e9se
|
||||
|
||||
Reference in New Issue
Block a user