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.

61 lines
1.2 KiB

  1. //*************************************************************
  2. //
  3. // Debugging functions
  4. //
  5. // Microsoft Confidential
  6. // Copyright (c) Microsoft Corporation 1995
  7. // All rights reserved
  8. //
  9. //*************************************************************
  10. #include "pch.h"
  11. VOID
  12. _DebugMsg (
  13. UINT mask,
  14. PCSTR Format,
  15. ...
  16. )
  17. {
  18. va_list args;
  19. DWORD Error;
  20. WCHAR Output[2048];
  21. PWSTR UnicodeFormat;
  22. UINT Size;
  23. HRESULT hr;
  24. Error = GetLastError();
  25. va_start (args, Format);
  26. Size = (lstrlenA (Format) + 1) * sizeof (WCHAR);
  27. UnicodeFormat = LocalAlloc (LPTR, Size);
  28. if (!UnicodeFormat) {
  29. SetLastError (Error);
  30. return;
  31. }
  32. MultiByteToWideChar (CP_ACP, 0, Format, -1, UnicodeFormat, Size/sizeof(WCHAR));
  33. hr = StringCchVPrintf(Output, ARRAYSIZE(Output) - 3, UnicodeFormat, args);
  34. if (FAILED(hr))
  35. goto Exit;
  36. hr = StringCchCat(Output, ARRAYSIZE(Output), L"\r\n");
  37. if (FAILED(hr))
  38. goto Exit;
  39. OutputDebugStringW (Output);
  40. Exit:
  41. if (mask == DM_ASSERT) {
  42. DebugBreak();
  43. }
  44. va_end (args);
  45. LocalFree (UnicodeFormat);
  46. SetLastError (Error);
  47. }