From db0d490fc9a70a8349b6e09c0a71ecb62001d6dc Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sun, 29 May 2016 12:32:50 +0200 Subject: [PATCH] #1241 File content is different to what FFDEC shows in HEX view near instructions --- .../src/com/jpexs/decompiler/flash/SWF.java | 1 + .../jpexs/decompiler/flash/action/Action.java | 17 ++++++++++++++++- .../decompiler/flash/action/ActionList.java | 2 ++ .../flash/action/ActionListReader.java | 1 + .../ffdec_lib/src/com/jpexs/helpers/Helper.java | 9 +++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 2714a30da..2770044fa 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -2586,6 +2586,7 @@ public final class SWF implements SWFContainerItem, Timelined { int version = swf == null ? SWF.DEFAULT_VERSION : swf.version; ActionList list = ActionListReader.readActionListTimeout(listeners, rri, version, prevLength, prevLength + actionBytes.getLength(), src.toString()/*FIXME?*/, deobfuscationMode); + list.fileData = actionBytes.getArray(); list.deobfuscationMode = deobfuscationMode; if (swf != null) { swf.as2PcodeCache.put(src, list); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java index fe169ffc0..b80825158 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java @@ -528,6 +528,7 @@ public abstract class Action implements GraphSourceItem { offset = address; int pos = 0; boolean lastPush = false; + byte[] fileData = list.fileData; for (Action a : list) { informListeners(listeners, pos, list.size()); @@ -537,7 +538,21 @@ public abstract class Action implements GraphSourceItem { lastPush = false; } writer.appendNoHilight("; "); - writer.appendNoHilight(Helper.bytesToHexString(a.getBytes(version))); + byte[] bytes = a.getBytes(version); + writer.appendNoHilight(Helper.bytesToHexString(bytes)); + long fileOffset = a.getFileOffset(); + if (fileData != null && fileOffset != -1 && fileData.length > fileOffset + bytes.length - 1) { + writer.appendNoHilight(" ("); + for (int i = 0; i < bytes.length; i++) { + writer.appendNoHilight(Helper.byteToHex(fileData[(int) (fileOffset + i)])); + writer.appendNoHilight(" "); + } + + writer.appendNoHilight("@"); + writer.appendNoHilight(Helper.formatHex(a.getFileOffset(), 8)); + writer.appendNoHilight(")"); + } + writer.newLine(); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionList.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionList.java index 4d82e20e1..5bb863a3b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionList.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionList.java @@ -46,6 +46,8 @@ public class ActionList extends ArrayList { public int deobfuscationMode; + public byte[] fileData; + public ActionList() { } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java index f48eca48d..94b5ad97a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java @@ -172,6 +172,7 @@ public class ActionListReader { getContainerLastActions(actions, containerLastActions); ActionList ret = new ActionList(); + ret.fileData = actions.fileData; if (nextOffsets != null) { int index = 0; diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java index a09292d55..f3302096b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java @@ -397,6 +397,15 @@ public class Helper { return sb.toString(); } + public static String formatHex(long value, int width) { + StringBuilder sb = new StringBuilder(); + sb.append(Long.toHexString(value)); + if (width > sb.length()) { + sb.insert(0, ZEROS8, 0, width - sb.length()); + } + return sb.toString(); + } + public static String formatInt(int value, int width) { StringBuilder sb = new StringBuilder(); sb.append(value);