diff --git a/CHANGELOG.md b/CHANGELOG.md index 6969cf86f..6edf183cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. ## [Unreleased] ### Added - #1594 Option to disable AS3 P-code indentation, label on separate line +- #1594 Option to use old style of getlocalx, setlocalx with underscore ### Fixed - #1114 Script search results dialogs closing on swf close 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 45e67a008..eae79f1b3 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 @@ -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.abc.avm2.instructions; import com.jpexs.decompiler.flash.BaseLocalData; @@ -41,7 +42,9 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @@ -65,6 +68,15 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem { private long virtualAddress = -1; + private static final Map oldStyleNames = new HashMap<>(); + + static { + for (int i = 0; i <= 3; i++) { + oldStyleNames.put("getlocal" + i, "getlocal_" + i); + oldStyleNames.put("setlocal" + i, "setlocal_" + i); + } + } + @Override public long getFileOffset() { return -1; @@ -373,13 +385,20 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem { } public GraphTextWriter toString(GraphTextWriter writer, LocalData localData) { - writer.appendNoHilight(Helper.formatAddress(address) + " " + String.format("%-30s", Helper.byteArrToString(getBytes())) + definition.instructionName); + writer.appendNoHilight(Helper.formatAddress(address) + " " + String.format("%-30s", Helper.byteArrToString(getBytes())) + getCustomizedInstructionName()); writer.appendNoHilight(getParams(localData.constantsAvm2, localData.fullyQualifiedNames) + getComment()); return writer; } + private String getCustomizedInstructionName() { + if (Configuration.useOldStyleGetSetLocalsAs3PCode.get() && oldStyleNames.containsKey(definition.instructionName)) { + return oldStyleNames.get(definition.instructionName); + } + return definition.instructionName; + } + public String toStringNoAddress(AVM2ConstantPool constants, List fullyQualifiedNames) { - String s = definition.instructionName; + String s = getCustomizedInstructionName(); if (Configuration.padAs3PCodeInstructionName.get()) { for (int i = s.length(); i < 19; i++) { s += " "; 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 b6853d82e..9afe3fcfe 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 @@ -664,6 +664,10 @@ public final class Configuration { @ConfigurationCategory("format") public static ConfigurationItem labelOnSeparateLineAs3PCode = null; + @ConfigurationDefaultBoolean(false) + @ConfigurationCategory("script") + public static ConfigurationItem useOldStyleGetSetLocalsAs3PCode = null; + private enum OSId { WINDOWS, OSX, UNIX } 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 78acab2d1..241233ba8 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DeobfuscatorTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DeobfuscatorTest.java @@ -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; @@ -59,6 +60,7 @@ public class ActionScript3DeobfuscatorTest extends ActionScriptTestBase { Configuration.decimalAddress.set(false); Configuration.decompilationTimeoutSingleMethod.set(Integer.MAX_VALUE); Configuration.padAs3PCodeInstructionName.set(false); + Configuration.useOldStyleGetSetLocalsAs3PCode.set(false); swf = new SWF(new BufferedInputStream(new FileInputStream("testdata/as3/as3.swf")), false); } diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties index 773a9d8e4..1b1a32918 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties @@ -491,3 +491,8 @@ config.description.indentAs3PCode = Indent AS3 P-code blocks like trait/body/cod config.name.labelOnSeparateLineAs3PCode = Label in AS3 P-code on separate line config.description.labelOnSeparateLineAs3PCode = Make label in AS3 P-code stand on separate line + +config.name.useOldStyleGetSetLocalsAs3PCode = Use oldstyle getlocal_x instead of getlocalx in AS3 P-code +config.description.useOldStyleGetSetLocalsAs3PCode = Use oldstyle getlocal_x, setlocal_x from FFDec 12.x or older + + diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_cs.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_cs.properties index 6db5efa3d..72efe6760 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_cs.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_cs.properties @@ -482,4 +482,7 @@ config.name.indentAs3PCode = Odsadit AS3 P-k\u00f3d config.description.indentAs3PCode = Odsadit AS3 P-k\u00f3d bloky jako trait/body/code config.name.labelOnSeparateLineAs3PCode = N\u00e1v\u011b\u0161t\u00ed v AS3 P-k\u00f3du na zvl\u00e1\u0161tn\u00edm \u0159\u00e1dku -config.description.labelOnSeparateLineAs3PCode = N\u00e1v\u011b\u0161t\u00ed v AS3 P-k\u00f3du budou st\u00e1t na zvl\u00e1\u0161tn\u00edm \u0159\u00e1dku \ No newline at end of file +config.description.labelOnSeparateLineAs3PCode = N\u00e1v\u011b\u0161t\u00ed v AS3 P-k\u00f3du budou st\u00e1t na zvl\u00e1\u0161tn\u00edm \u0159\u00e1dku + +config.name.useOldStyleGetSetLocalsAs3PCode = Pou\u017e\u00edvat postaru getlocal_x m\u00edsto getlocalx v AS3 P-k\u00f3du +config.description.useOldStyleGetSetLocalsAs3PCode = Pou\u017e\u00edvat postaru getlocal_x, setlocal_x z FFDec 12.x \u010di star\u0161\u00edho \ No newline at end of file