From ddf5f2eb6acd949e6b4a301c857688fbd350a9a5 Mon Sep 17 00:00:00 2001 From: Honfika Date: Sat, 28 Dec 2013 15:34:17 +0100 Subject: [PATCH] Show addesses in binary data view --- .../com/jpexs/decompiler/flash/gui/BinaryPanel.java | 2 +- trunk/src/com/jpexs/helpers/Helper.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java index 987224e47..6d624197f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java @@ -53,7 +53,7 @@ public final class BinaryPanel extends JPanel implements ActionListener, Compone this.data = data; hexEditor.setEditable(false); if (data != null) { - int widthInChars = getWidth() / 7 - 3; // -3: scrollbar + int widthInChars = getWidth() / 7 - 3 - 11; // -3: scrollbar, -11: address in hex format int blockCount = widthInChars / 34; hexEditor.setFont(new Font("Monospaced", Font.PLAIN, hexEditor.getFont().getSize())); hexEditor.setContentType("text/plain"); diff --git a/trunk/src/com/jpexs/helpers/Helper.java b/trunk/src/com/jpexs/helpers/Helper.java index e18befce9..361409afc 100644 --- a/trunk/src/com/jpexs/helpers/Helper.java +++ b/trunk/src/com/jpexs/helpers/Helper.java @@ -570,10 +570,10 @@ public class Helper { public static GraphTextWriter byteArrayToHexWithHeader(GraphTextWriter writer, byte[] data) { writer.appendNoHilight("#hexdata").newLine().newLine(); - return byteArrayToHex(writer, data, 8, 8, false); + return byteArrayToHex(writer, data, 8, 8, false, false); } - public static GraphTextWriter byteArrayToHex(GraphTextWriter writer, byte[] data, int bytesPerRow, int groupSize, boolean addChars) { + public static GraphTextWriter byteArrayToHex(GraphTextWriter writer, byte[] data, int bytesPerRow, int groupSize, boolean addChars, boolean showAddress) { /* // hex data from decompiled actions Scanner scanner = new Scanner(srcWithHex); @@ -591,11 +591,16 @@ public class Helper { rowCount++; } + long address = 0; for (int row = 0; row < rowCount; row++) { if (row > 0) { writer.newLine(); } + if (showAddress) { + writer.appendNoHilight("0x" + String.format("%08x ", address)); + } + for (int i = 0; i < bytesPerRow; i++) { int idx = row * bytesPerRow + i; if (data.length > idx) { @@ -611,6 +616,7 @@ public class Helper { writer.appendNoHilight(" "); } } + address += bytesPerRow; } if (addChars) { @@ -638,7 +644,7 @@ public class Helper { public static String byteArrayToHex(byte[] data, int bytesPerRow) { HilightedTextWriter writer = new HilightedTextWriter(false); - byteArrayToHex(writer, data, bytesPerRow, 8, true); + byteArrayToHex(writer, data, bytesPerRow, 8, true, true); return writer.toString(); }