blob: 285c8b2f843e58dec1e3d8cfec4c1ad87b17920c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/*++
Copyright (c) Microsoft Corporation
Module Name:
log.c
Abstract:
Debug log Code for serial.
Environment:
kernel mode only
--*/
#include "precomp.h"
extern ULONG DebugLevel;
extern ULONG DebugFlag;
#if !defined(EVENT_TRACING)
VOID
SerialDbgPrintEx (
IN ULONG TraceEventsLevel,
IN ULONG TraceEventsFlag,
IN PCCHAR DebugMessage,
...
)
/*++
Routine Description:
Debug print for the sample driver.
Arguments:
TraceEventsLevel - print level between 0 and 3, with 3 the most verbose
Return Value:
None.
--*/
{
#if DBG
#define TEMP_BUFFER_SIZE 1024
va_list list;
CHAR debugMessageBuffer [TEMP_BUFFER_SIZE];
NTSTATUS status;
va_start(list, DebugMessage);
if (DebugMessage) {
//
// Using new safe string functions instead of _vsnprintf.
// This function takes care of NULL terminating if the message
// is longer than the buffer.
//
status = RtlStringCbVPrintfA( debugMessageBuffer,
sizeof(debugMessageBuffer),
DebugMessage,
list );
if(!NT_SUCCESS(status)) {
KdPrint((_DRIVER_NAME_": RtlStringCbVPrintfA failed %x\n", status));
return;
}
if (TraceEventsLevel < TRACE_LEVEL_INFORMATION ||
(TraceEventsLevel <= DebugLevel &&
((TraceEventsFlag & DebugFlag) == TraceEventsFlag))) {
KdPrint((debugMessageBuffer));
}
}
va_end(list);
return;
#else
UNREFERENCED_PARAMETER(TraceEventsLevel);
UNREFERENCED_PARAMETER(TraceEventsFlag);
UNREFERENCED_PARAMETER(DebugMessage);
#endif
}
#endif
|