debug.c

来自「这是一个56K MODEM的驱动程序」· C语言 代码 · 共 113 行

C
113
字号
/***************************************************************************\
|* Copyright (c) 1994  Microsoft Corporation                               *|
|* Developed for Microsoft by TriplePoint, Inc. Beaverton, Oregon          *|
|*                                                                         *|
|* This file is part of the HT Communications DSU41 WAN Miniport Driver.   *|
\***************************************************************************/
#include "version.h"
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Module Name:

    debug.c

Abstract:

    This module contains code to support driver debugging.

Author:

    Larry Hattery - TriplePoint, Inc. (larryh@tpi.com) Jun-94

Environment:

    Development only.

Revision History:

---------------------------------------------------------------------------*/

#include <ndis.h>

#if DBG


VOID
DbgPrintData(
    IN PUCHAR Data,
    IN UINT NumBytes,
    IN ULONG Offset
    )

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Routine Description:

    Dumps data to the debug display formated in hex and ascii for easy viewing.
    Used for debug output only.  It is not compiled into the retail version.

Arguments:

    Data            Buffer of data to be displayed

    NumBytes        Number of bytes to display

    Offset          Beginning offset to be displayed before each line

Return Value:

    None

---------------------------------------------------------------------------*/

{
    UINT        i,j;

    for (i = 0; i < NumBytes; i += 16)
    {
        DbgPrint("%04lx: ", i + Offset);

        /*
        // Output the hex bytes
        */
        for (j = i; j < (i+16); j++)
        {
            if (j < NumBytes)
            {
                DbgPrint("%02x ",(UINT)((UCHAR)*(Data+j)));
            }
            else
            {
                DbgPrint("   ");
            }
        }

        DbgPrint("  ");

        /*
        // Output the ASCII bytes
        */
        for (j = i; j < (i+16); j++)
        {
            if (j < NumBytes)
            {
                char c = *(Data+j);

                if (c < ' ' || c > 'Z')
                {
                    c = '.';
                }
                DbgPrint("%c", (UINT)c);
            }
            else
            {
                DbgPrint(" ");
            }
        }
        DbgPrint("\n");
    }
}

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?