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.

100 lines
2.2 KiB

  1. /*++
  2. Copyright (c) 1991-2002 Microsoft Corporation
  3. Module Name:
  4. erdirty.cpp
  5. Abstract:
  6. This module contains the code to report pending dirty shutdown
  7. events at logon after dirty reboot.
  8. Author:
  9. Ian Service (ianserv) 29-May-2001
  10. Environment:
  11. User mode at logon.
  12. Revision History:
  13. --*/
  14. #include "savedump.h"
  15. #define SHUTDOWN_STATE_SNAPSHOT_KEY L"ShutDownStateSnapShot"
  16. HRESULT
  17. DirtyShutdownEventHandler(BOOL NotifyPcHealth)
  18. /*++
  19. Routine Description:
  20. This is the boot time routine to handle pending dirty shutdown event.
  21. Arguments:
  22. NotifyPcHealth - TRUE if we should report event to PC Health, FALSE otherwise.
  23. --*/
  24. {
  25. HKEY Key;
  26. HRESULT Status;
  27. WCHAR DumpName[MAX_PATH];
  28. ULONG Val;
  29. if (RegOpenKey(HKEY_LOCAL_MACHINE,
  30. SUBKEY_RELIABILITY,
  31. &Key) != ERROR_SUCCESS)
  32. {
  33. // No key so nothing to do.
  34. return S_OK;
  35. }
  36. //
  37. // Whenever we have had a blue screen event we are going to
  38. // post an unexpected restart shutdown event screen on startup
  39. // (assuming Server SKU or specially set Professional).
  40. // In order to make it easier on the user we attempt to prefill
  41. // the comment with the bugcheck data.
  42. //
  43. if (g_DumpBugCheckString[0] &&
  44. GetRegWord32(Key, L"DirtyShutDown", &Val, 0, FALSE) == S_OK)
  45. {
  46. RegSetValueEx(Key,
  47. L"BugCheckString",
  48. NULL,
  49. REG_SZ,
  50. (LPBYTE)g_DumpBugCheckString,
  51. (wcslen(g_DumpBugCheckString) + 1) * sizeof(WCHAR));
  52. }
  53. if ((Status = GetRegStr(Key, SHUTDOWN_STATE_SNAPSHOT_KEY,
  54. DumpName, RTL_NUMBER_OF(DumpName),
  55. NULL)) == S_OK)
  56. {
  57. if (NotifyPcHealth)
  58. {
  59. Status = FrrvToStatus(ReportEREvent(eetShutdown, DumpName, NULL));
  60. }
  61. else
  62. {
  63. Status = S_OK;
  64. }
  65. RegDeleteValue(Key, SHUTDOWN_STATE_SNAPSHOT_KEY);
  66. }
  67. else
  68. {
  69. // No snapshot to report.
  70. Status = S_OK;
  71. }
  72. RegCloseKey(Key);
  73. return Status;
  74. }