diff --git a/CHANGELOG.md b/CHANGELOG.md index e116f36f9..ba5eabc53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file. - Graphviz graphs colorized - AS3: Show try graph heads in Graphviz distinguished - #341, #1379 AS3: Support for scripts not using kill instruction -- AS3 method trait p-code indentation, instruction name padding +- AS3 method trait p-code indentation, (optional) instruction name padding - AS3 editation of method body traits (slot/const only) ### Fixed diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java index b040175ae..07bcca902 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java @@ -29,6 +29,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ThrowIns; import com.jpexs.decompiler.flash.abc.types.Float4; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.Multiname; +import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSource; @@ -380,8 +381,10 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem { public String toStringNoAddress(AVM2ConstantPool constants, List fullyQualifiedNames) { String s = definition.instructionName; - for (int i = s.length(); i < 19; i++) { - s += " "; + if (Configuration.padAs3PCodeInstructionName.get()) { + for (int i = s.length(); i < 19; i++) { + s += " "; + } } s += getParams(constants, fullyQualifiedNames) + getComment(); return s.trim(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index e9661fa09..931f09a66 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -190,6 +190,10 @@ public final class Configuration { @ConfigurationInternal public static ConfigurationItem showOriginalBytesInPcodeHex = null; + @ConfigurationDefaultBoolean(false) + @ConfigurationCategory("script") + public static ConfigurationItem padAs3PCodeInstructionName = null; + /** * Limit of code subs (for obfuscated code) */ diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DeobfuscatorTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DeobfuscatorTest.java index 7744c7a2c..7818194f6 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DeobfuscatorTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DeobfuscatorTest.java @@ -59,6 +59,7 @@ public class ActionScript3DeobfuscatorTest extends ActionScriptTestBase { Configuration.autoDeobfuscate.set(true); Configuration.decimalAddress.set(false); Configuration.decompilationTimeoutSingleMethod.set(Integer.MAX_VALUE); + Configuration.padAs3PCodeInstructionName.set(false); swf = new SWF(new BufferedInputStream(new FileInputStream("testdata/as3/as3.swf")), false); } @@ -240,14 +241,14 @@ public class ActionScript3DeobfuscatorTest extends ActionScriptTestBase { + "b:pushbyte 3\r\n"); Assert.assertEquals(res, "getlocal0\r\n" + "pushscope\r\n" - + "pushbyte 3\r\n" - + "pushbyte 4\r\n" - + "ifeq ofs000e\r\n" - + "jump ofs0010\r\n" + + "pushbyte 3\r\n" + + "pushbyte 4\r\n" + + "ifeq ofs000e\r\n" + + "jump ofs0010\r\n" + "ofs000e:\r\n" - + "pushbyte 4\r\n" + + "pushbyte 4\r\n" + "ofs0010:\r\n" - + "pushbyte 3\r\n" + + "pushbyte 3\r\n" + "returnvoid\r\n"); } diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties index bdd769f1d..76def5899 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties @@ -481,4 +481,7 @@ config.name.useAdobeFlashPlayerForPreviews = (Deprecated) Use Adobe Flash player config.description.useAdobeFlashPlayerForPreviews = Use Adobe Flash player for preview of objects. WARNING: FlashPlayer was discontinued on 2021-01-12 config.name.showLineNumbersInPCodeGraphvizGraph = Show line numbers in Graphviz graphs -config.description.showLineNumbersInPCodeGraphvizGraph = Show line numbers in the P-code graphviz graph. \ No newline at end of file +config.description.showLineNumbersInPCodeGraphvizGraph = Show line numbers in the P-code graphviz graph. + +config.name.padAs3PCodeInstructionName = Pad AS3 P-code instruction names +config.description.padAs3PCodeInstructionName = Pad AS3 P-code instruction names with spaces \ No newline at end of file