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.

185 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. wd.h
  5. Abstract:
  6. This is the NT Watchdog driver implementation.
  7. Author:
  8. Michael Maciesowicz (mmacie) 05-May-2000
  9. Environment:
  10. Kernel mode only.
  11. Notes:
  12. Revision History:
  13. --*/
  14. #ifndef _WD_H_
  15. #define _WD_H_
  16. #include "ntddk.h"
  17. #include "watchdog.h"
  18. #define WD_MAX_WAIT ((LONG)((ULONG)(-1) / 4))
  19. #define WD_KEY_WATCHDOG L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Watchdog"
  20. #define WD_KEY_WATCHDOG_DISPLAY L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Watchdog\\Display"
  21. #define WD_KEY_RELIABILITY L"\\Registry\\Machine\\Software\\Microsoft\\Windows\\CurrentVersion\\Reliability"
  22. #define WD_TAG 'godW' // Wdog
  23. #define WD_MAX_PROPERTY_SIZE 4096
  24. //
  25. // Define default configuration values - these can be overwriten via registry
  26. // in RTL_REGISTRY_CONTROL\Watchdog\DeviceClass key.
  27. //
  28. #define WD_DEFAULT_TRAP_ONCE 0
  29. #define WD_DEFAULT_DISABLE_BUGCHECK 0
  30. #define WD_DEFAULT_BREAK_POINT_DELAY 0
  31. #if DBG
  32. #define WD_DBG_SUSPENDED_WARNING(pWd, szRoutine) \
  33. { \
  34. if ((pWd)->SuspendCount) \
  35. { \
  36. DbgPrint("watchdog!%s: WARNING! Called while suspended!\n", (szRoutine)); \
  37. DbgPrint("watchdog!%s: Watchdog %p\n", (szRoutine), (pWd)); \
  38. } \
  39. }
  40. #else
  41. #define WD_DBG_SUSPENDED_WARNING(pWd, szRoutine) NULL
  42. #endif // DBG
  43. #define ASSERT_WATCHDOG_OBJECT(pWd) \
  44. ASSERT((NULL != (pWd)) && \
  45. (WdStandardWatchdog == ((PWATCHDOG_OBJECT)(pWd))->ObjectType) || \
  46. (WdDeferredWatchdog == ((PWATCHDOG_OBJECT)(pWd))->ObjectType))
  47. NTSTATUS
  48. DriverEntry(
  49. IN PDRIVER_OBJECT pDriverObject,
  50. IN PUNICODE_STRING wszRegistryPath
  51. );
  52. VOID
  53. WdpDeferredWatchdogDpcCallback(
  54. IN PKDPC pDpc,
  55. IN PVOID pDeferredContext,
  56. IN PVOID pSystemArgument1,
  57. IN PVOID pSystemArgument2
  58. );
  59. VOID
  60. WdpDestroyObject(
  61. IN PVOID pWatch
  62. );
  63. NTSTATUS
  64. WdpFlushRegistryKey(
  65. IN PVOID pWatch,
  66. IN PCWSTR pwszKeyName
  67. );
  68. VOID
  69. WdpInitializeObject(
  70. IN PVOID pWatch,
  71. IN PDEVICE_OBJECT pDeviceObject,
  72. IN WD_OBJECT_TYPE objectType,
  73. IN WD_TIME_TYPE timeType,
  74. IN ULONG ulTag
  75. );
  76. BOOLEAN
  77. WdpQueueDeferredEvent(
  78. IN PDEFERRED_WATCHDOG pWatch,
  79. IN WD_EVENT_TYPE eventType
  80. );
  81. VOID
  82. WdpWatchdogDpcCallback(
  83. IN PKDPC pDpc,
  84. IN PVOID pDeferredContext,
  85. IN PVOID pSystemArgument1,
  86. IN PVOID pSystemArgument2
  87. );
  88. //
  89. // Internal ntos API (this is declared in ntifs.h but it's hard to include it here).
  90. //
  91. // TODO: Fix it later.
  92. //
  93. PDEVICE_OBJECT
  94. IoGetDeviceAttachmentBaseRef(
  95. IN PDEVICE_OBJECT pDeviceObject
  96. );
  97. //
  98. // Debug code to trace the sequence of calls into watchdog.
  99. //
  100. #ifdef WDD_TRACE_ENABLED
  101. #define WDD_TRACE_SIZE 128
  102. #define WDD_TRACE_CALL(pWatch, function) WddTrace((pWatch), (function))
  103. typedef enum _WDD_FUNCTION
  104. {
  105. WddWdAllocateDeferredWatchdog = 1,
  106. WddWdFreeDeferredWatchdog,
  107. WddWdStartDeferredWatch,
  108. WddWdStopDeferredWatch,
  109. // WddWdSuspendDeferredWatch,
  110. // WddWdResumeDeferredWatch,
  111. WddWdResetDeferredWatch,
  112. // WddWdEnterMonitoredSection,
  113. // WddWdExitMonitoredSection,
  114. WddWdpDeferredWatchdogDpcCallback,
  115. WddWdpQueueDeferredEvent,
  116. WddWdDdiWatchdogDpcCallback,
  117. WddWdpBugCheckStuckDriver,
  118. WddWdAttachContext,
  119. WddWdCompleteEvent,
  120. WddWdDereferenceObject,
  121. WddWdDetachContext,
  122. WddWdGetDeviceObject,
  123. WddWdGetLastEvent,
  124. WddWdGetLowestDeviceObject,
  125. WddWdReferenceObject,
  126. WddWdpDestroyObject,
  127. WddWdpFlushRegistryKey,
  128. WddWdpInitializeObject
  129. } WDD_FUNCTION, *PWDD_FUNCTION;
  130. typedef struct _WDD_TRACE
  131. {
  132. PDEFERRED_WATCHDOG pWatch;
  133. WDD_FUNCTION function;
  134. } WDD_TRACE, *PWDD_TRACE;
  135. VOID
  136. FASTCALL
  137. WddTrace(
  138. PDEFERRED_WATCHDOG pWatch,
  139. WDD_FUNCTION function
  140. );
  141. #else // WDD_TRACE_ENABLED
  142. #define WDD_TRACE_CALL(pWatch, function) NULL
  143. #endif // WDD_TRACE_ENABLED
  144. #endif // _WD_H_