ReactOS 0.4.17-dev-1190-g4c812f4
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 118 of file dbgtrace.cpp.

142 {
143#if DBG
144 UNREFERENCED_PARAMETER(FxDriverGlobals);
145
146#define TEMP_BUFFER_SIZE 1024
148 CHAR debugMessageBuffer[TEMP_BUFFER_SIZE];
149#ifdef __REACTOS__
150#define FORMAT_BUFFER_SIZE 512
151 CHAR formatBuffer[FORMAT_BUFFER_SIZE];
152#endif
154
155 va_start(list, DebugMessage);
156
157 if (DebugMessage) {
158
159#ifdef __REACTOS__
160 FxTraceTranslateFormat(DebugMessage,
161 formatBuffer,
162 sizeof(formatBuffer));
163#endif
164
165 //
166 // Using new safe string functions instead of _vsnprintf.
167 // This function takes care of NULL terminating if the message
168 // is longer than the buffer.
169 //
170#if FX_CORE_MODE==FX_CORE_KERNEL_MODE
171 status = RtlStringCbVPrintfA( debugMessageBuffer,
172 sizeof(debugMessageBuffer),
173#ifdef __REACTOS__
174 formatBuffer,
175#else
176 DebugMessage,
177#endif
178 list );
179#else
180 HRESULT hr;
181 hr = StringCbVPrintfA( debugMessageBuffer,
182 sizeof(debugMessageBuffer),
183#ifdef __REACTOS__
184 formatBuffer,
185#else
186 DebugMessage,
187#endif
188 list );
189
190
192 {
194 }
195 else
196 {
198 }
199#endif
200#ifdef __REACTOS__
202#else
203 if(!NT_SUCCESS(status)) {
204#endif
205
206#if FX_CORE_MODE==FX_CORE_KERNEL_MODE
207 DbgPrint ("WDFTrace: RtlStringCbVPrintfA failed 0x%x\n", status);
208#else
209 OutputDebugString("WDFTrace: Unable to expand: ");
210#ifdef __REACTOS__
211 OutputDebugString(formatBuffer);
212#else
213 OutputDebugString(DebugMessage);
214#endif
215#endif
216#ifdef __REACTOS__
217 va_end(list);
218#endif
219 return;
220 }
221 if (DebugPrintLevel <= TRACE_LEVEL_ERROR ||
222 (DebugPrintLevel <= DebugLevel &&
223 ((DebugPrintFlag & DebugFlag) == DebugPrintFlag))) {
224#if FX_CORE_MODE==FX_CORE_KERNEL_MODE
225 DbgPrint("WDFTrace: %s\n", debugMessageBuffer);
226#else
227 OutputDebugString("WDFTrace: ");
228#ifdef __REACTOS__
229 OutputDebugString(debugMessageBuffer);
230#else
231 OutputDebugString(DebugMessage);
232#endif
233#endif
234 }
235 }
236 va_end(list);
237
238 return;
239#else
240 UNREFERENCED_PARAMETER(FxDriverGlobals);
241 UNREFERENCED_PARAMETER(DebugPrintLevel);
242 UNREFERENCED_PARAMETER(DebugPrintFlag);
243 UNREFERENCED_PARAMETER(DebugMessage);
244#endif
245}
LONG NTSTATUS
Definition: precomp.h:26
Definition: list.h:39
ULONG DebugFlag
Definition: fxobject.cpp:44
HRESULT hr
Definition: delayimp.cpp:582
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
char * va_list
Definition: vadefs.h:50
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 FORMAT_BUFFER_SIZE
Definition: logfile.c:36
#define TEMP_BUFFER_SIZE
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
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
char CHAR
Definition: pedump.c:57
#define list
Definition: rosglue.h:35
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#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:3613
#define HRESULT_FACILITY(hr)
Definition: winerror.h:191
#define FACILITY_WIN32
Definition: winerror.h:29
#define HRESULT_CODE(hr)
Definition: winerror.h:188