Author: tkreuzer Date: Sun Oct 1 11:08:26 2017 New Revision: 76017
URL: http://svn.reactos.org/svn/reactos?rev=76017&view=rev Log: [FREELDR] Simplify DebugDumpBuffer
Modified: trunk/reactos/boot/freeldr/freeldr/lib/debug.c
Modified: trunk/reactos/boot/freeldr/freeldr/lib/debug.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/lib/de... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/lib/debug.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/lib/debug.c [iso-8859-1] Sun Oct 1 11:08:26 2017 @@ -297,7 +297,7 @@ DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length) { PUCHAR BufPtr = (PUCHAR)Buffer; - ULONG Idx, Idx2; + ULONG Offset, Count, i;
/* Mask out unwanted debug messages */ if (!(DbgChannels[Mask] & TRACE_LEVEL)) @@ -306,50 +306,20 @@ DebugStartOfLine = FALSE; // We don't want line headers DbgPrint("Dumping buffer at %p with length of %lu bytes:\n", Buffer, Length);
- for (Idx = 0; Idx < Length; ) - { - DebugStartOfLine = FALSE; // We don't want line headers - - if (Idx < 0x0010) - DbgPrint("000%x:\t", Idx); - else if (Idx < 0x0100) - DbgPrint("00%x:\t", Idx); - else if (Idx < 0x1000) - DbgPrint("0%x:\t", Idx); - else - DbgPrint("%x:\t", Idx); - - for (Idx2 = 0; Idx2 < 16; Idx2++, Idx++) - { - if (BufPtr[Idx] < 0x10) - { - DbgPrint("0"); - } - DbgPrint("%x", BufPtr[Idx]); - - if (Idx2 == 7) - { - DbgPrint("-"); - } - else - { - DbgPrint(" "); - } - } - - Idx -= 16; - DbgPrint(" "); - - for (Idx2 = 0; Idx2 < 16; Idx2++, Idx++) - { - if ((BufPtr[Idx] > 20) && (BufPtr[Idx] < 0x80)) - { - DbgPrint("%c", BufPtr[Idx]); - } - else - { - DbgPrint("."); - } + Offset = 0; + while (Offset < Length) + { + /* We don't want line headers */ + DebugStartOfLine = FALSE; + + /* Print the offset */ + DbgPrint("%04x:\t", Offset); + + /* Print either 16 or the remaining number of bytes */ + Count = min(Length - Offset, 16); + for (i = 0; i < Count; i++, Offset++) + { + DbgPrint("%02x%c", BufPtr[Offset], (i == 7) ? '-' : ' '); }
DbgPrint("\n");