Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
1.9 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. debug.c
  5. Abstract:
  6. Debug infrastructure for this component.
  7. Author:
  8. Jim Cavalaris (jamesca) 07-Mar-2000
  9. Environment:
  10. User-mode only.
  11. Revision History:
  12. 07-March-2000 jamesca
  13. Creation and initial implementation.
  14. --*/
  15. //
  16. // includes
  17. //
  18. #include "precomp.h"
  19. #include "debug.h"
  20. //
  21. // debug infrastructure
  22. //
  23. #if DBG
  24. VOID
  25. pSifDebugPrintEx(
  26. DWORD Level,
  27. PCTSTR Format,
  28. ... OPTIONAL
  29. )
  30. /*++
  31. Routine Description:
  32. Send a formatted string to the debugger.
  33. Note that this is expected to work cross-platform, but use preferred debugger
  34. Arguments:
  35. Format - standard printf format string.
  36. Return Value:
  37. NONE.
  38. --*/
  39. {
  40. typedef ULONG (__cdecl *PFNDbgPrintEx)(IN ULONG ComponentId,IN ULONG Level,IN PCH Format, ...);
  41. static PFNDbgPrintEx pfnDbgPrintEx = NULL;
  42. static BOOL fInitDebug = FALSE;
  43. TCHAR buf[1026]; // bigger than max size
  44. va_list arglist;
  45. if (!fInitDebug) {
  46. pfnDbgPrintEx = (PFNDbgPrintEx)GetProcAddress(GetModuleHandle(TEXT("NTDLL")), "DbgPrintEx");
  47. fInitDebug = TRUE;
  48. }
  49. va_start(arglist, Format);
  50. if (FAILED(StringCchVPrintf(buf, 1026, Format, arglist))) {
  51. return;
  52. }
  53. if (pfnDbgPrintEx) {
  54. #ifdef UNICODE
  55. (*pfnDbgPrintEx)(DPFLTR_SETUP_ID, Level, "%ls",buf);
  56. #else
  57. (*pfnDbgPrintEx)(DPFLTR_SETUP_ID, Level, "%s",buf);
  58. #endif
  59. } else {
  60. OutputDebugString(buf);
  61. }
  62. return;
  63. }
  64. ULONG
  65. DebugPrint(
  66. IN ULONG Level,
  67. IN PCHAR Format,
  68. ...
  69. )
  70. {
  71. va_list ap;
  72. va_start(ap, Format);
  73. KdPrintEx((DPFLTR_PNPMGR_ID, Level, Format, ap));
  74. va_end(ap);
  75. return Level;
  76. }
  77. #else
  78. NOTHING;
  79. #endif