ReactOS  0.4.15-dev-1632-g4e289ce
dbgtrace.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 ModuleName:
6 
7  DbgTrace.cpp
8 
9 Abstract:
10 
11  Temporary file to be used until ETW can be used
12  for UM
13 
14 Author:
15 
16 
17 
18 Revision History:
19 
20 
21 
22 --*/
23 
24 #include "fxobjectpch.hpp"
25 
26 #if FX_CORE_MODE==FX_CORE_USER_MODE
27 #include "strsafe.h"
28 #endif
29 
30 #if !defined(EVENT_TRACING)
31 
32 VOID
33 __cdecl
35  __in PVOID FxDriverGlobals,
36  __in ULONG DebugPrintLevel,
37  __in ULONG DebugPrintFlag,
39  __in PCSTR DebugMessage,
40  ...
41  )
42 
43 /*++
44 
45 Routine Description:
46 
47  Print the trace message to debugger.
48 
49 Arguments:
50 
51  TraceEventsLevel - print level between 0 and 3, with 3 the most verbose
52 
53 Return Value:
54 
55  None.
56 
57  --*/
58  {
59 #if DBG
60  UNREFERENCED_PARAMETER(FxDriverGlobals);
61 
62 #define TEMP_BUFFER_SIZE 1024
63  va_list list;
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 }
129 
130 #endif
NTSTATUS WinErrorToNtStatus(__in ULONG WinError)
Definition: errtostatus.cpp:60
HRESULT hr
Definition: shlfolder.c:183
#define __cdecl
Definition: accygwin.h:79
#define DbgPrint
Definition: loader.c:25
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
#define OutputDebugString
Definition: winbase.h:3730
ULONG DebugLevel
Definition: fbtusb.c:26
#define va_end(ap)
Definition: acmsvcex.h:90
#define HRESULT_FACILITY(hr)
Definition: winerror.h:79
if SUCCEEDED(hr)
#define __drv_formatString(kind)
Definition: driverspecs.h:253
NTSTATUS RtlStringCbVPrintfA(char *pszDest, size_t cbDest, const char *pszFormat, va_list argList)
char * va_list
Definition: acmsvcex.h:78
VOID __cdecl DoTraceLevelMessage(__in PVOID FxDriverGlobals, __in ULONG DebugPrintLevel, __in ULONG DebugPrintFlag, __drv_formatString(FormatMessage) __in PCSTR DebugMessage,...)
Definition: dbgtrace.cpp:34
#define TEMP_BUFFER_SIZE
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LONG HRESULT
Definition: typedefs.h:79
va_start(ap, x)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
STRSAFEAPI StringCbVPrintfA(STRSAFE_LPSTR pszDest, size_t cbDest, STRSAFE_LPCSTR pszFormat, va_list argList)
Definition: strsafe.h:502
#define FormatMessage
Definition: winbase.h:3635
Definition: _list.h:228
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define FACILITY_WIN32
Definition: winerror.h:27
ULONG DebugFlag
Definition: fxobject.cpp:44
#define list
Definition: rosglue.h:35
#define HRESULT_CODE(hr)
Definition: winerror.h:76
unsigned int ULONG
Definition: retypes.h:1
const char * PCSTR
Definition: typedefs.h:52
#define STATUS_SUCCESS
Definition: shellext.h:65
#define __in
Definition: dbghelp.h:35
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97