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.

63 lines
1.4 KiB

  1. //--------------------------------------------------------------------------------------------
  2. //
  3. // Copyright (c) Microsoft Corporation, 1996
  4. //
  5. // Description:
  6. //
  7. // Microsoft Normandy client debug code
  8. //
  9. // History:
  10. // davidsan 05/01/96 Created
  11. //
  12. //--------------------------------------------------------------------------------------------
  13. #ifdef DEBUG
  14. #include <windows.h>
  15. #include <cldbg.h>
  16. void
  17. AssertProc(LPCSTR szMsg, LPCSTR szFile, UINT iLine, DWORD grf)
  18. {
  19. char szAssert[MAX_PATH * 2];
  20. char *szFormatGLE = NULL;
  21. char szGLE[MAX_PATH];
  22. LONG lErr;
  23. DWORD dwRet;
  24. wnsprintf(szAssert, ARRAYSIZE(szAssert), "Assert failed: %s\n%s line %d.", szMsg, szFile, iLine);
  25. if (grf & ASSERT_GLE)
  26. {
  27. lErr = GetLastError();
  28. if (0 == FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
  29. NULL, lErr, 0, (PSTR) &szFormatGLE, 0, NULL))
  30. {
  31. wnsprintf(szGLE, ARRAYSIZE(szGLE), "\nLast error: %d", lErr);
  32. }
  33. else
  34. {
  35. wnsprintf(szGLE, ARRAYSIZE(szGLE), "\nLast error: '%s'", szFormatGLE);
  36. LocalFree((HLOCAL)szFormatGLE);
  37. }
  38. StrCatBUff(szAssert, szGLE, ARRAYSIZE(szAssert));
  39. }
  40. dwRet = MessageBox(NULL, szAssert, "Assertion failure", MB_ABORTRETRYIGNORE);
  41. switch (dwRet)
  42. {
  43. case IDRETRY:
  44. DebugBreak();
  45. break;
  46. case IDIGNORE:
  47. break;
  48. case IDABORT:
  49. ExitProcess(0);
  50. break;
  51. }
  52. }
  53. #endif // DEBUG