svn path=/trunk/; revision=76017
DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length)
{
PUCHAR BufPtr = (PUCHAR)Buffer;
DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length)
{
PUCHAR BufPtr = (PUCHAR)Buffer;
+ ULONG Offset, Count, i;
/* Mask out unwanted debug messages */
if (!(DbgChannels[Mask] & TRACE_LEVEL))
/* Mask out unwanted debug messages */
if (!(DbgChannels[Mask] & TRACE_LEVEL))
DebugStartOfLine = FALSE; // We don't want line headers
DbgPrint("Dumping buffer at %p with length of %lu bytes:\n", Buffer, Length);
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; )
+ Offset = 0;
+ while (Offset < 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(" ");
- }
- }
+ /* We don't want line headers */
+ DebugStartOfLine = FALSE;
- Idx -= 16;
- DbgPrint(" ");
+ /* Print the offset */
+ DbgPrint("%04x:\t", Offset);
- for (Idx2 = 0; Idx2 < 16; Idx2++, Idx++)
+ /* Print either 16 or the remaining number of bytes */
+ Count = min(Length - Offset, 16);
+ for (i = 0; i < Count; i++, Offset++)
- if ((BufPtr[Idx] > 20) && (BufPtr[Idx] < 0x80))
- {
- DbgPrint("%c", BufPtr[Idx]);
- }
- else
- {
- DbgPrint(".");
- }
+ DbgPrint("%02x%c", BufPtr[Offset], (i == 7) ? '-' : ' ');