Defines | |
#define | DriverDbgPrint(_level_, _module_, _format_) |
Print message to Debuger. | |
#define | DriverDbgEnterFunc(_module_) |
Print name of function. | |
#define | DriverDbgLeaveFunc(_module_) |
Print name of function. | |
#define | DriverDbgLeaveFuncWithStatus(_module_, _status_) |
Print name of function and leave status. | |
#define | DriverDbgPrintIrpName(_module_, _Irp_) |
Print Irp name. | |
#define | DriverDbgPrintIrp(_module_, _Irp_) |
Print Irp details. | |
#define | DriverDbgError(_format_) |
Print Debug error message. | |
#define | DriverDbgWarn(_format_) |
Print Debug warining message. | |
#define | DriverDbgInfo(_format_) |
Print Debug info message. | |
#define | DriverDbgTrace(_module_, _format_) |
Print Debug trace message. | |
#define | DriverInfo() |
Print Driver information. | |
#define | DriverDbg(_format_) |
Print debug message. | |
Functions | |
VOID | DriverDbgDumpData (PCHAR Buffer, ULONG BufferSize) |
Send data dump to kernel debuger. | |
VOID | DriverDbgTest (VOID) |
Internal function that tests DriverDbg module. | |
VOID | DriverDbgSetDebugMask (ULONG NewDebugMask) |
Set Debug Mask. | |
Variables | |
ULONG | DebugMask |
Debug mask. |
#define DriverDbg | ( | _format_ | ) |
Value:
do { \ DbgPrint("[%s]: ", (DRIVER_NAME)); \ DbgPrint _format_; \ }while(0)
This macro print driver name and debug message.
_format_ | format of message eg. ("something %d\n", data) |
#define DriverDbgEnterFunc | ( | _module_ | ) |
Value:
do { \ DriverDbgPrint(DBGLVLTRACE, \ (_module_), \ ( "[%s]: %s begin\n", (DRIVER_NAME), (__FUNCTION__) ) ); \ } while(0)
You can use this macro in begining of all function. With a correct DebugMask you will have trace of all called fuctions. Useful with DriverDbgLeaveFunc and DriverDbgLeaveFuncWithStatus.
_module_ | debug module |
#define DriverDbgError | ( | _format_ | ) |
Value:
do { \ DriverDbgPrint(DBGLVLERROR, \ DBGALLMODULES, \ ("[%s] file: %s, line: %d error -> ", (DRIVER_NAME), (__FILE__), (__LINE__)));\ DriverDbgPrint(DBGLVLERROR, DBGALLMODULES, _format_); \ }while(0)
This macro print error message, when DebugMask is set to DBGLVLERROR, in all modules.
_format_ | message format eg. ("some data %d\n", data) |
#define DriverDbgInfo | ( | _format_ | ) |
Value:
do { \ DriverDbgPrint(DBGLVLINFO, \ DBGALLMODULES, \ ("[%s] ", (DRIVER_NAME))); \ DriverDbgPrint(DBGLVLINFO, \ DBGALLMODULES, \ (_format_)); \ }while(0)
This macro print info message, when DebugMask is set to DBGLVLINFO, in all modules.
/param _format_ message format eg. ("some data %d\n", data) /see DebugMask, DriverDbgSetDebugMask
#define DriverDbgLeaveFunc | ( | _module_ | ) |
Value:
do { \ DriverDbgPrint(DBGLVLTRACE, \ (_module_), \ ( "[%s]: %s end\n\n", (DRIVER_NAME), (__FUNCTION__) ) ); \ } while(0)
This macro is useful with DriverDbgEnterFunc
_module_ | debug module |
#define DriverDbgLeaveFuncWithStatus | ( | _module_, | |||
_status_ | ) |
Value:
do { \ DriverDbgPrint(DBGLVLTRACE, \ (_module_), \ ("[%s]: %s end (%s)\n\n", (DRIVER_NAME), \ (__FUNCTION__), \ OsrNTStatusToString( (_status_) )));\ }while(0)
This macro is useful with DriverDbgEnterFunc
_module_ | debug module | |
_status_ | leave status (NTSTATUS) |
#define DriverDbgPrint | ( | _level_, | |||
_module_, | |||||
_format_ | ) |
Value:
do { \ if( ( (_level_) <= (DebugMask & 0xFFFF) ) && ( (_module_) & DebugMask ) ) \ { \ DbgPrint _format_; \ } \ } while(0)
This fuction check level, module with DebugMask value, and next send message to Debuger.
_level_ | debug level, can be DBGLVLERROR, DBGLVLWARN, DBGLVLINFO, DBGLVLTRACE This value is compared with DebugMask | |
_module_ | debug module, can be DBGMSKMAIN, DBGMSKPNP, DBGMSKPOWER ... | |
_format_ | format of message that we want send to Debuger eg. ("%d some problems", DebugMask) |
#define DriverDbgPrintIrp | ( | _module_, | |||
_Irp_ | ) |
Value:
do { \ PIO_STACK_LOCATION _pIoStack_ = (_Irp_)->Tail.Overlay.CurrentStackLocation; \ DriverDbgPrint(DBGLVLTRACE, (_module_), (" StackCount=%d\n CurrentLocation=%d\n", \ (_Irp_)->StackCount, \ (_Irp_)->CurrentLocation)); \ DriverDbgPrint(DBGLVLTRACE, (_module_), (" DeviceObject: 0x%X\n FileObject: 0x%X\n", \ (_pIoStack_)->DeviceObject, \ (_pIoStack_)->FileObject)); \ } while(0)
This macro prints Irp details, like StackCount, CurrentLocation, address of DeviceObject and FileObject connected with this IRP.
_module_ | debug module | |
_Irp_ | pointer to IRP that we want inspect |
#define DriverDbgPrintIrpName | ( | _module_, | |||
_Irp_ | ) |
Value:
do { \ PIO_STACK_LOCATION _pIoStack_ = (_Irp_)->Tail.Overlay.CurrentStackLocation; \ DriverDbgPrint(DBGLVLTRACE, (_module_), ("[%s]: Major: %s, Minor: %s\n", \ (DRIVER_NAME), \ (IrpNames[(_pIoStack_)->MajorFunction]), \ ( ((_pIoStack_)->MajorFunction == IRP_MJ_PNP) ? PnpMinorFuncNames[(_pIoStack_)->MinorFunction] : 0))); \ } while(0)
This macro prints Irp name, Major and Minor Function.
_module_ | debug module | |
_Irp_ | pointer to IRP that we want inspect |
#define DriverDbgTrace | ( | _module_, | |||
_format_ | ) |
Value:
do { \ DriverDbgPrint(DBGLVLTRACE, (_module_), ("[%s]: ", (DRIVER_NAME))); \ DriverDbgPrint(DBGLVLTRACE, (_module_), (_format_)); \ }while(0)
This macro print trace message, when DebugMask is set to DBGLVLTRACE, in all modules.
_module_ | debug module | |
_format_ | message format eg. ("some data %d\n", data) |
#define DriverDbgWarn | ( | _format_ | ) |
Value:
do { \ DriverDbgPrint(DBGLVLWARN, \ DBGALLMODULES, \ ("[%s] file: %s, line: %d warning -> ", (DRIVER_NAME), (__FILE__), (__LINE__))); \ DriverDbgPrint(DBGLVLERROR, DBGALLMODULES, (_format_)); \ }while(0)
This macro print warning message, when DebugMask is set to DBGLVLWARN, in all modules.
_format_ | message format eg. ("some data %d\n", data) |
#define DriverInfo | ( | ) |
Value:
do { \ DbgPrint("\n[%s], date: %s, time: %s\n", (DRIVER_NAME), (__DATE__), (__TIME__)); \ }while(0)
This macro print driver specyfic information like driver name, compliation date and compilation time.
VOID DriverDbgDumpData | ( | PCHAR | Buffer, | |
ULONG | BufferSize | |||
) |
Send data dump to kernel debuger.
This function sends data dump to kernel debuger or DbgView programm. Dump data as hexadecimal and ASCII values. Use this function only for buffers that you allocated.
Buffer | is a pointer to user buffer | |
BufferSize | is a size of user buffer in Bytes |
VOID DriverDbgSetDebugMask | ( | ULONG | NewDebugMask | ) |
Set Debug Mask.
This function sets debug mask.
NewDebugMask | new DebugMask value |
VOID DriverDbgTest | ( | VOID | ) |
Internal function that tests DriverDbg module.
This function is useful to tests DriverDbg module. Check correct behavior of DriverDbg implementation.
ULONG DebugMask |
Debug mask.
DebugMask: 0xdmmmllll
d - device: FDO | PDO
m - module
l - debug level