ReactOS 0.4.15-dev-7659-ga55345b
dbgtrace.cpp File Reference
#include "fxobjectpch.hpp"
#include "strsafe.h"
Include dependency graph for dbgtrace.cpp:

Go to the source code of this file.

Functions

VOID __cdecl DoTraceLevelMessage (__in PVOID FxDriverGlobals, __in ULONG DebugPrintLevel, __in ULONG DebugPrintFlag, __drv_formatString(FormatMessage) __in PCSTR DebugMessage,...)
 

Function Documentation

◆ DoTraceLevelMessage()

VOID __cdecl DoTraceLevelMessage ( __in PVOID  FxDriverGlobals,
__in ULONG  DebugPrintLevel,
__in ULONG  DebugPrintFlag,
__drv_formatString(FormatMessage) __in PCSTR  DebugMessage,
  ... 
)

Definition at line 34 of file dbgtrace.cpp.

58 {
59#if DBG
60 UNREFERENCED_PARAMETER(FxDriverGlobals);
61
62#define TEMP_BUFFER_SIZE 1024
64 CHAR debugMessageBuffer[TEMP_BUFFER_SIZE];
66
67 va_start(list, DebugMessage);
68
69 if (DebugMessage) {
70
71 //
72 // Using new safe string functions instead of _vsnprintf.
73 // This function takes care of NULL terminating if the message
74 // is longer than the buffer.
75 //
76#if FX_CORE_MODE==FX_CORE_KERNEL_MODE
77 status = RtlStringCbVPrintfA( debugMessageBuffer,
78 sizeof(debugMessageBuffer),
79 DebugMessage,
80 list );
81#else
82 HRESULT hr;
83 hr = StringCbVPrintfA( debugMessageBuffer,
84 sizeof(debugMessageBuffer),
85 DebugMessage,
86 list );
87
88
90 {
92 }
93 else
94 {
96 }
97#endif
98 if(!NT_SUCCESS(status)) {
99
100#if FX_CORE_MODE==FX_CORE_KERNEL_MODE
101 DbgPrint ("WDFTrace: RtlStringCbVPrintfA failed 0x%x\n", status);
102#else
103 OutputDebugString("WDFTrace: Unable to expand: ");
104 OutputDebugString(DebugMessage);
105#endif
106 return;
107 }
108 if (DebugPrintLevel <= TRACE_LEVEL_ERROR ||
109 (DebugPrintLevel <= DebugLevel &&
110 ((DebugPrintFlag & DebugFlag) == DebugPrintFlag))) {
111#if FX_CORE_MODE==FX_CORE_KERNEL_MODE
112 DbgPrint("WDFTrace: %s\n", debugMessageBuffer);
113#else
114 OutputDebugString("WDFTrace: ");
115 OutputDebugString(DebugMessage);
116#endif
117 }
118 }
119 va_end(list);
120
121 return;
122#else
123 UNREFERENCED_PARAMETER(FxDriverGlobals);
124 UNREFERENCED_PARAMETER(DebugPrintLevel);
125 UNREFERENCED_PARAMETER(DebugPrintFlag);
126 UNREFERENCED_PARAMETER(DebugMessage);
127#endif
128}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
LONG NTSTATUS
Definition: precomp.h:26
Definition: list.h:37
ULONG DebugFlag
Definition: fxobject.cpp:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS WinErrorToNtStatus(__in ULONG WinError)
Definition: errtostatus.cpp:60
ULONG DebugLevel
Definition: fbtusb.c:26
#define DbgPrint
Definition: hal.h:12
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define TEMP_BUFFER_SIZE
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
NTSTRSAFEAPI RtlStringCbVPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat, _In_ va_list argList)
Definition: ntstrsafe.h:1034
#define list
Definition: rosglue.h:35
#define STATUS_SUCCESS
Definition: shellext.h:65
HRESULT hr
Definition: shlfolder.c:183
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
STRSAFEAPI StringCbVPrintfA(STRSAFE_LPSTR pszDest, size_t cbDest, STRSAFE_LPCSTR pszFormat, va_list argList)
Definition: strsafe.h:502
Definition: ps.c:97
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define OutputDebugString
Definition: winbase.h:3825
#define HRESULT_FACILITY(hr)
Definition: winerror.h:79
#define FACILITY_WIN32
Definition: winerror.h:27
#define HRESULT_CODE(hr)
Definition: winerror.h:76
char CHAR
Definition: xmlstorage.h:175