From 167a343937701d258e86e6844c85d10e11e5b5ad Mon Sep 17 00:00:00 2001 From: jakcron Date: Wed, 25 Apr 2018 19:36:21 +0800 Subject: [PATCH] [fnd] Fix/Enhance fnd::SimpleTextOutput::hxdStyleDump(). --- lib/libfnd/source/SimpleTextOutput.cpp | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/libfnd/source/SimpleTextOutput.cpp b/lib/libfnd/source/SimpleTextOutput.cpp index 8703386..6482454 100644 --- a/lib/libfnd/source/SimpleTextOutput.cpp +++ b/lib/libfnd/source/SimpleTextOutput.cpp @@ -6,6 +6,7 @@ void fnd::SimpleTextOutput::hxdStyleDump(const byte_t* data, size_t len, size_t // iterate over blocks for (size_t i = 0; i < (len / row_len); i++) { + printf("%08" PRIx64 " | ", i*row_len); // for block i print each byte for (size_t j = 0; j < row_len; j++) { @@ -22,6 +23,32 @@ void fnd::SimpleTextOutput::hxdStyleDump(const byte_t* data, size_t len, size_t } printf("\n"); } + if ((len % row_len) > 0) + { + size_t i = (len / row_len); + printf("%08" PRIx64 " | ", i * row_len); + // for block i print each byte + for (size_t j = 0; j < row_len; j++) + { + if (j < (len % row_len)) + printf("%02X", data[(i * row_len) + j]); + else + printf(" "); + if (((j+1) % byte_grouping_size) == 0) + { + putchar(' '); + } + } + printf(" "); + for (size_t j = 0; j < row_len; j++) + { + if (j < (len % row_len)) + printf("%c", isalnum(data[(i * row_len) + j]) ? data[(i * row_len) + j] : '.'); + else + printf(" "); + } + printf("\n"); + } } void fnd::SimpleTextOutput::hxdStyleDump(const byte_t* data, size_t len)