From 791e8af6a6d1bb8147720b085e7178f2996129c0 Mon Sep 17 00:00:00 2001 From: David Hall Date: Mon, 8 Apr 2019 11:24:19 -0600 Subject: [PATCH] Added extension dump function for IntPtr --- Core/Extensions/HexDump.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Core/Extensions/HexDump.cs b/Core/Extensions/HexDump.cs index 8638ea10..90a5e8a4 100644 --- a/Core/Extensions/HexDump.cs +++ b/Core/Extensions/HexDump.cs @@ -11,8 +11,7 @@ namespace Vanara.Extensions /// The number of bytes to display before inserting an extra space to create a visual gap. /// /// The number of hexadecimal digits to display on the left side of each line to indicate position. If this value is 0, then no - /// position indicator will be shown. If this value is -1, then the size will be computed in increments of 4 based on the size of - /// . + /// position indicator will be shown. If this value is -1, then the size will be computed in increments of 4 based on the size of . /// /// A multi-line string that contains a hexadecimal dump of . /// bytes @@ -34,5 +33,19 @@ namespace Vanara.Extensions } return sb.ToString(); } + + /// Creates a multi-line dump of a byte array using hexadecimal values. + /// A pointer to the memory to dump. + /// The number of bytes to display starting at the location pointed to by . + /// The number of bytes to display on each line. + /// The number of bytes to display before inserting an extra space to create a visual gap. + /// + /// The number of hexadecimal digits to display on the left side of each line to indicate position. If this value is 0, then no + /// position indicator will be shown. If this value is -1, then the size will be computed in increments of 4 based on the size of . + /// + /// A multi-line string that contains a hexadecimal dump of . + /// bytes + public static string ToHexDumpString(this IntPtr ptr, int byteCount, int bytesPerRow = 16, int gapEvery = 4, int rowIdLen = -1) => + ptr.ToArray(byteCount).ToHexDumpString(bytesPerRow, gapEvery, rowIdLen); } } \ No newline at end of file