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.

203 lines
4.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. gdisup.h
  5. Abstract:
  6. This is the NT Watchdog driver implementation.
  7. This module implements support routines for
  8. watchdog in win32k.
  9. Author:
  10. Michael Maciesowicz (mmacie) 23-April-2002
  11. Environment:
  12. Kernel mode only.
  13. Notes:
  14. This module cannot be moved to win32k since routines defined here can
  15. be called at any time and it is possible that win32k may not be mapped
  16. into running process space at this time (e.g. TS session).
  17. Revision History:
  18. --*/
  19. #include "watchdog.h"
  20. #define WD_HANDLER_IDLE 0
  21. #define WD_HANDLER_BUSY 1
  22. #define WD_GDI_STRESS_BREAK_POINT_DELAY 15
  23. typedef struct _WD_BUGCHECK_DATA
  24. {
  25. ULONG ulBugCheckCode;
  26. ULONG_PTR ulpBugCheckParameter1;
  27. ULONG_PTR ulpBugCheckParameter2;
  28. ULONG_PTR ulpBugCheckParameter3;
  29. ULONG_PTR ulpBugCheckParameter4;
  30. } WD_BUGCHECK_DATA, *PWD_BUGCHECK_DATA;
  31. typedef struct _WD_GDI_CONTEXT_DATA
  32. {
  33. PKEVENT pInjectionEvent;
  34. PKTHREAD pThread;
  35. PLDEV *ppldevDrivers;
  36. BOOLEAN bRecoveryAttempted;
  37. PWD_BUGCHECK_DATA pBugCheckData;
  38. KBUGCHECK_SECONDARY_DUMP_DATA SecondaryData;
  39. PVOID pvDump;
  40. ULONG ulDumpSize;
  41. } WD_GDI_CONTEXT_DATA, *PWD_GDI_CONTEXT_DATA;
  42. VOID
  43. WdpBugCheckStuckDriver(
  44. IN PVOID pvContext
  45. );
  46. VOID
  47. WdpKernelApc(
  48. IN PKAPC pApc,
  49. OUT PKNORMAL_ROUTINE *pNormalRoutine,
  50. IN OUT PVOID pvNormalContext,
  51. IN OUT PVOID *ppvSystemArgument1,
  52. IN OUT PVOID *ppvSystemArgument2
  53. );
  54. BOOLEAN
  55. WdpInjectExceptionIntoThread(
  56. PKTHREAD pThread,
  57. PWD_GDI_DPC_CONTEXT pDpcContext
  58. );
  59. VOID
  60. WdpRaiseExceptionInThread();
  61. ULONG
  62. pVpAppendSecondaryMinidumpData(
  63. PVOID pvSecondaryData,
  64. ULONG ulSecondaryDataSize,
  65. PVOID pvDump
  66. );
  67. //
  68. // BUGBUG:
  69. //
  70. // Find a way to share the same LDEV structure used by GDI.
  71. //
  72. typedef struct _LDEV
  73. {
  74. struct _LDEV *pldevNext; // Link to the next LDEV in list.
  75. struct _LDEV *pldevPrev; // Link to the previous LDEV in list.
  76. PSYSTEM_GDI_DRIVER_INFORMATION pGdiDriverInfo; // Driver module handle.
  77. } LDEV, *PLDEV;
  78. //
  79. // Internal ntos types / APIs (defined in kernel headers but it's hard to include them here).
  80. //
  81. // BUGBUG: Fix it later.
  82. //
  83. #define MAKESOFTWAREEXCEPTION(Severity, Facility, Exception) \
  84. ((ULONG) ((Severity << 30) | (1 << 29) | (Facility << 16) | (Exception)))
  85. #define WD_SE_THREAD_STUCK MAKESOFTWAREEXCEPTION(3,0,1)
  86. #if defined(_IA64_)
  87. #define PSR_RI 41
  88. #define PSR_CPL 32
  89. typedef struct _FRAME_MARKER
  90. {
  91. union
  92. {
  93. struct
  94. {
  95. ULONGLONG sof : 7;
  96. ULONGLONG sol : 7;
  97. ULONGLONG sor : 4;
  98. ULONGLONG rrbgr : 7;
  99. ULONGLONG rrbfr : 7;
  100. ULONGLONG rrbpr : 6;
  101. } f;
  102. ULONGLONG Ulong64;
  103. } u;
  104. } FRAME_MARKER;
  105. #endif
  106. NTSTATUS
  107. PsSetContextThread(
  108. IN PETHREAD Thread,
  109. IN PCONTEXT ThreadContext,
  110. IN KPROCESSOR_MODE Mode
  111. );
  112. NTSTATUS
  113. PsGetContextThread(
  114. IN PETHREAD Thread,
  115. IN OUT PCONTEXT ThreadContext,
  116. IN KPROCESSOR_MODE Mode
  117. );
  118. NTKERNELAPI
  119. VOID
  120. KeInitializeApc (
  121. IN PRKAPC Apc,
  122. IN PRKTHREAD Thread,
  123. IN KAPC_ENVIRONMENT Environment,
  124. IN PKKERNEL_ROUTINE KernelRoutine,
  125. IN PKRUNDOWN_ROUTINE RundownRoutine OPTIONAL,
  126. IN PKNORMAL_ROUTINE NormalRoutine OPTIONAL,
  127. IN KPROCESSOR_MODE ProcessorMode OPTIONAL,
  128. IN PVOID NormalContext OPTIONAL
  129. );
  130. NTKERNELAPI
  131. BOOLEAN
  132. KeInsertQueueApc(
  133. IN PRKAPC Apc,
  134. IN PVOID SystemArgument1,
  135. IN PVOID SystemArgument2,
  136. IN KPRIORITY Increment
  137. );
  138. NTKERNELAPI
  139. NTSTATUS
  140. ExRaiseHardError(
  141. IN NTSTATUS ErrorStatus,
  142. IN ULONG NumberOfParameters,
  143. IN ULONG UnicodeStringParameterMask,
  144. IN PULONG_PTR Parameters,
  145. IN ULONG ValidResponseOptions,
  146. OUT PULONG Response
  147. );
  148. #define WD_MAX_WAIT ((LONG)((ULONG)(-1) / 4))
  149. #define WD_KEY_WATCHDOG L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Watchdog"
  150. #define WD_KEY_WATCHDOG_DISPLAY L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Watchdog\\Display"
  151. #define WD_KEY_RELIABILITY L"\\Registry\\Machine\\Software\\Microsoft\\Windows\\CurrentVersion\\Reliability"
  152. #define WD_TAG 'godW' // Wdog
  153. #define WD_MAX_PROPERTY_SIZE 4096
  154. //
  155. // Define default configuration values - these can be overwriten via registry
  156. // in RTL_REGISTRY_CONTROL\Watchdog\DeviceClass key.
  157. //
  158. #define WD_DEFAULT_TRAP_ONCE 0
  159. #define WD_DEFAULT_DISABLE_BUGCHECK 0
  160. #define WD_DEFAULT_BREAK_POINT_DELAY 0
  161. BOOLEAN
  162. KdRefreshDebuggerNotPresent(
  163. VOID
  164. );