From eee92d02a48e94f6985ce066a08736f8aa585dbf Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Thu, 24 Sep 2015 15:01:08 +0200 Subject: [PATCH] better constant in action deobfuscator --- .../deobfuscation/ActionDeobfuscator.java | 2 +- .../action/model/DirectValueActionItem.java | 31 +++---------------- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java index 55a2365cc..b77790401 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java @@ -180,7 +180,7 @@ public class ActionDeobfuscator extends ActionDeobfuscatorSimple { } } - if (allValueValid && newIstructionCount * 5 < result.instructionsProcessed) { + if (allValueValid && newIstructionCount * 2 < result.instructionsProcessed) { Action target = actions.get(result.idx); Action prevAction = actions.get(i); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java index d1b63b180..07c0a554f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.action.swf4.ActionPush; import com.jpexs.decompiler.flash.action.swf4.ConstantIndex; import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.flash.ecma.Undefined; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; @@ -146,39 +147,17 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue { } public String toStringNoH(ConstantPool constants) { - if (value instanceof Double) { - if (Double.compare((double) (Double) value, 0) == 0) { - return "0"; - } - } - if (value instanceof Float) { - if (Float.compare((float) (Float) value, 0) == 0) { - return "0"; - } - } - if (value instanceof String) { - return (String) value; - } if (value instanceof ConstantIndex) { return this.constants.get(((ConstantIndex) value).index); } - return value.toString(); + + return EcmaScript.toString(value); } @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { - if (value instanceof Double) { - if (Double.compare((double) (Double) value, 0) == 0) { - return writer.append("0"); - } - } - if (value instanceof Float) { - if (Float.compare((float) (Float) value, 0) == 0) { - return writer.append("0"); - } - } if (value instanceof String) { - return writer.append("\"").append(Helper.escapeActionScriptString((String) value)).append("\""); + return writer.append("\"").append(Helper.escapeActionScriptString(EcmaScript.toString(value))).append("\""); } if (value instanceof ConstantIndex) { return writer.append("\"").append(Helper.escapeActionScriptString(this.constants.get(((ConstantIndex) value).index))).append("\""); @@ -186,7 +165,7 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue { if (value instanceof RegisterNumber) { return writer.append(((RegisterNumber) value).translate()); } - return writer.append(value.toString()); + return writer.append(EcmaScript.toString(value)); } @Override