mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-08 00:48:17 +00:00
replace AS3 pcode from commanline
This commit is contained in:
@@ -202,6 +202,11 @@ public class MethodBody implements Cloneable, Serializable {
|
||||
if (convertException == null) {
|
||||
HashMap<Integer, String> localRegNames = getLocalRegNames(abc);
|
||||
writer.startMethod(this.method_info);
|
||||
if (Configuration.showMethodBodyId.get()) {
|
||||
writer.appendNoHilight("// method body id:");
|
||||
writer.appendNoHilight(abc.findBodyIndex(this.method_info));
|
||||
writer.newLine();
|
||||
}
|
||||
Graph.graphToString(convertedItems, writer, LocalData.create(constants, localRegNames, fullyQualifiedNames));
|
||||
writer.endMethod();
|
||||
} else if (convertException instanceof TimeoutException) {
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.configuration;
|
||||
|
||||
import com.jpexs.decompiler.flash.ApplicationInfo;
|
||||
@@ -329,6 +330,10 @@ public class Configuration {
|
||||
@ConfigurationDefaultInt(128)
|
||||
public static final ConfigurationItem<Integer> lzmaFastBytes = null;
|
||||
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
@ConfigurationCategory("debug")
|
||||
public static final ConfigurationItem<Boolean> showMethodBodyId = null;
|
||||
|
||||
public static final ConfigurationItem<String> pluginPath = null;
|
||||
|
||||
private enum OSId {
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -63,6 +64,7 @@ public class ActionScript3Test extends ActionScriptTestBase {
|
||||
Configuration.autoDeobfuscate.set(false);
|
||||
Configuration.decompile.set(true);
|
||||
Configuration.registerNameFormat.set("_loc%d_");
|
||||
Configuration.showMethodBodyId.set(false);
|
||||
}
|
||||
|
||||
private void decompileMethod(String methodName, String expectedResult, boolean isStatic) {
|
||||
|
||||
@@ -1381,11 +1381,15 @@ public class CommandLineArgumentParser {
|
||||
if (Path.getExtension(repFile).equals(".as")) {
|
||||
replaceAS3(repText, pack);
|
||||
} else {
|
||||
// todo: get Ids
|
||||
int bodyIndex = 0;
|
||||
int classIndex = 0;
|
||||
int traitId = 0;
|
||||
replaceAS3PCode(repText, pack.abc, bodyIndex, classIndex, traitId);
|
||||
// todo: get traits
|
||||
if (args.isEmpty()) {
|
||||
badArguments();
|
||||
}
|
||||
int bodyIndex = Integer.parseInt(args.remove());
|
||||
//int classIndex = 0;
|
||||
//int traitId = 0;
|
||||
Trait trait = null; //abc.findTraitByTraitId(classIndex, traitId);
|
||||
replaceAS3PCode(repText, pack.abc, bodyIndex, trait);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1448,7 +1452,7 @@ public class CommandLineArgumentParser {
|
||||
src.setModified();
|
||||
}
|
||||
|
||||
private static void replaceAS3PCode(String text, ABC abc, int bodyIndex, int classIndex, int traitId) throws IOException, InterruptedException {
|
||||
private static void replaceAS3PCode(String text, ABC abc, int bodyIndex, Trait trait) throws IOException, InterruptedException {
|
||||
System.out.println("Replace AS3 PCode");
|
||||
if (text.trim().startsWith("#hexdata")) {
|
||||
byte[] data = Helper.getBytesFromHexaText(text);
|
||||
@@ -1456,7 +1460,6 @@ public class CommandLineArgumentParser {
|
||||
mb.codeBytes = data;
|
||||
mb.setCode(null);
|
||||
} else {
|
||||
Trait trait = abc.findTraitByTraitId(classIndex, traitId);
|
||||
try {
|
||||
AVM2Code acode = ASM3Parser.parse(new StringReader(text), abc.constants, trait, new MissingSymbolHandler() {
|
||||
//no longer ask for adding new constants
|
||||
|
||||
@@ -60,7 +60,6 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
private int classIndex = -1;
|
||||
private boolean isStatic = false;
|
||||
private final Cache<CachedDecompilation> cache = Cache.getInstance(true);
|
||||
private Trait currentTrait = null;
|
||||
|
||||
private final List<Runnable> scriptListeners = new ArrayList<>();
|
||||
|
||||
@@ -83,7 +82,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
}
|
||||
|
||||
public Trait getCurrentTrait() {
|
||||
return currentTrait;
|
||||
return abc.findTraitByTraitId(classIndex, lastTraitIndex);
|
||||
}
|
||||
|
||||
public ScriptPack getScriptLeaf() {
|
||||
@@ -175,11 +174,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
if (bi == -1) {
|
||||
return false;
|
||||
}
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
}
|
||||
});
|
||||
|
||||
//fix for inner functions:
|
||||
if (trait instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter tm = (TraitMethodGetterSetter) trait;
|
||||
@@ -194,20 +189,21 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
}
|
||||
}
|
||||
abcPanel.detailPanel.showCard(DetailPanel.METHOD_TRAIT_CARD, trait);
|
||||
if (reset || (abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex() != bi)) {
|
||||
abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abc, name, trait);
|
||||
MethodCodePanel methodCodePanel = abcPanel.detailPanel.methodTraitPanel.methodCodePanel;
|
||||
if (reset || (methodCodePanel.getBodyIndex() != bi)) {
|
||||
methodCodePanel.setBodyIndex(bi, abc, name, trait);
|
||||
abcPanel.detailPanel.setEditMode(false);
|
||||
this.isStatic = isStatic;
|
||||
}
|
||||
boolean success = false;
|
||||
Highlighting h = Highlighting.search(highlights, pos);
|
||||
if (h != null) {
|
||||
abcPanel.detailPanel.methodTraitPanel.methodCodePanel.hilighOffset(h.getPropertyLong("offset"));
|
||||
methodCodePanel.hilighOffset(h.getPropertyLong("offset"));
|
||||
success = true;
|
||||
}
|
||||
Highlighting sh = Highlighting.search(specialHighlights, pos);
|
||||
if (sh != null) {
|
||||
abcPanel.detailPanel.methodTraitPanel.methodCodePanel.hilighSpecial(sh.getPropertyString("subtype"), (int) (long) sh.getPropertyLong("index"));
|
||||
methodCodePanel.hilighSpecial(sh.getPropertyString("subtype"), (int) (long) sh.getPropertyLong("index"));
|
||||
success = true;
|
||||
}
|
||||
return success;
|
||||
@@ -254,6 +250,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
}
|
||||
}
|
||||
int currentMethod = -1;
|
||||
Trait currentTrait = getCurrentTrait();
|
||||
if (currentTrait instanceof TraitMethodGetterSetter) {
|
||||
currentMethod = ((TraitMethodGetterSetter) currentTrait).method_info;
|
||||
}
|
||||
@@ -325,12 +322,12 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
name = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants, false);
|
||||
}
|
||||
}
|
||||
currentTrait = null;
|
||||
Trait currentTrait = null;
|
||||
currentTraitHighlight = Highlighting.search(traitHighlights, pos);
|
||||
if (currentTraitHighlight != null) {
|
||||
lastTraitIndex = (int) (long) currentTraitHighlight.getPropertyLong("index");
|
||||
if ((abc != null) && (classIndex != -1)) {
|
||||
currentTrait = abc.findTraitByTraitId(classIndex, lastTraitIndex);
|
||||
currentTrait = getCurrentTrait();
|
||||
isStatic = abc.isStaticTraitId(classIndex, lastTraitIndex);
|
||||
if (currentTrait != null) {
|
||||
name += ":" + currentTrait.getName(abc).getName(abc.constants, new ArrayList<String>(), false);
|
||||
@@ -347,11 +344,11 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
setNoTrait();
|
||||
return;
|
||||
}
|
||||
currentTrait = null;
|
||||
Trait currentTrait = null;
|
||||
currentTraitHighlight = Highlighting.search(traitHighlights, pos);
|
||||
if (currentTraitHighlight != null) {
|
||||
lastTraitIndex = (int) (long) currentTraitHighlight.getPropertyLong("index");
|
||||
currentTrait = abc.findTraitByTraitId(classIndex, (int) (long) currentTraitHighlight.getPropertyLong("index"));
|
||||
currentTrait = getCurrentTrait();
|
||||
if (currentTrait != null) {
|
||||
if (currentTrait instanceof TraitSlotConst) {
|
||||
abcPanel.detailPanel.slotConstTraitPanel.load((TraitSlotConst) currentTrait, abc,
|
||||
@@ -372,14 +369,14 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
currentTrait = null;
|
||||
if (abc != null) {
|
||||
name = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants, false);
|
||||
currentTrait = abc.findTraitByTraitId(classIndex, lastTraitIndex);
|
||||
currentTrait = getCurrentTrait();
|
||||
isStatic = abc.isStaticTraitId(classIndex, lastTraitIndex);
|
||||
if (currentTrait != null) {
|
||||
name += ":" + currentTrait.getName(abc).getName(abc.constants, new ArrayList<String>(), false);
|
||||
}
|
||||
}
|
||||
|
||||
displayMethod(pos, abc.findMethodIdByTraitId(classIndex, (int) (long) currentTraitHighlight.getPropertyLong("index")), name, currentTrait, isStatic);
|
||||
displayMethod(pos, abc.findMethodIdByTraitId(classIndex, lastTraitIndex), name, currentTrait, isStatic);
|
||||
return;
|
||||
}
|
||||
setNoTrait();
|
||||
|
||||
@@ -266,3 +266,6 @@ config.description.pluginPath = -
|
||||
|
||||
config.name.deobfuscationMode = Deobfuscation mode
|
||||
config.description.deobfuscationMode = Run deobfuscation on every file before ActionScript decompilation
|
||||
|
||||
config.name.showMethodBodyId = Show method body id
|
||||
config.description.showMethodBodyId = Shows the id of the methodbody for command lineimport
|
||||
|
||||
Reference in New Issue
Block a user