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.

202 lines
4.6 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 "wd.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. } WD_GDI_CONTEXT_DATA, *PWD_GDI_CONTEXT_DATA;
  38. VOID
  39. WdpBugCheckStuckDriver(
  40. IN PVOID pvContext
  41. );
  42. VOID
  43. WdpKernelApc(
  44. IN PKAPC pApc,
  45. OUT PKNORMAL_ROUTINE *pNormalRoutine,
  46. IN OUT PVOID pvNormalContext,
  47. IN OUT PVOID *ppvSystemArgument1,
  48. IN OUT PVOID *ppvSystemArgument2
  49. );
  50. VOID
  51. WdpInjectExceptionIntoThread(
  52. PKTHREAD pThread,
  53. PWD_GDI_DPC_CONTEXT pDpcContext
  54. );
  55. VOID
  56. WdpRaiseExceptionInThread();
  57. typedef struct _PIMAGE_EXPORT_DIRECTORY IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY;
  58. typedef struct _SYSTEM_GDI_DRIVER_INFORMATION {
  59. UNICODE_STRING DriverName;
  60. PVOID ImageAddress;
  61. PVOID SectionPointer;
  62. PVOID EntryPoint;
  63. PIMAGE_EXPORT_DIRECTORY ExportSectionPointer;
  64. ULONG ImageLength;
  65. } SYSTEM_GDI_DRIVER_INFORMATION, *PSYSTEM_GDI_DRIVER_INFORMATION;
  66. //
  67. // BUGBUG:
  68. //
  69. // Find a way to share the same LDEV structure used by GDI.
  70. //
  71. typedef struct _LDEV
  72. {
  73. struct _LDEV *pldevNext; // Link to the next LDEV in list.
  74. struct _LDEV *pldevPrev; // Link to the previous LDEV in list.
  75. PSYSTEM_GDI_DRIVER_INFORMATION pGdiDriverInfo; // Driver module handle.
  76. } LDEV, *PLDEV;
  77. //
  78. // Internal ntos types / APIs (defined in kernel headers but it's hard to include them here).
  79. //
  80. // BUGBUG: Fix it later.
  81. //
  82. #define MAKESOFTWAREEXCEPTION(Severity, Facility, Exception) \
  83. ((ULONG) ((Severity << 30) | (1 << 29) | (Facility << 16) | (Exception)))
  84. #define WD_SE_THREAD_STUCK MAKESOFTWAREEXCEPTION(3,0,1)
  85. typedef enum _KAPC_ENVIRONMENT
  86. {
  87. OriginalApcEnvironment,
  88. AttachedApcEnvironment,
  89. CurrentApcEnvironment,
  90. InsertApcEnvironment
  91. } KAPC_ENVIRONMENT;
  92. #if defined(_IA64_)
  93. #define PSR_RI 41
  94. #define PSR_CPL 32
  95. typedef struct _FRAME_MARKER
  96. {
  97. union
  98. {
  99. struct
  100. {
  101. ULONGLONG sof : 7;
  102. ULONGLONG sol : 7;
  103. ULONGLONG sor : 4;
  104. ULONGLONG rrbgr : 7;
  105. ULONGLONG rrbfr : 7;
  106. ULONGLONG rrbpr : 6;
  107. } f;
  108. ULONGLONG Ulong64;
  109. } u;
  110. } FRAME_MARKER;
  111. #endif
  112. NTSTATUS
  113. PsSetContextThread(
  114. IN PETHREAD Thread,
  115. IN PCONTEXT ThreadContext,
  116. IN KPROCESSOR_MODE Mode
  117. );
  118. NTSTATUS
  119. PsGetContextThread(
  120. IN PETHREAD Thread,
  121. IN OUT PCONTEXT ThreadContext,
  122. IN KPROCESSOR_MODE Mode
  123. );
  124. NTKERNELAPI
  125. VOID
  126. KeInitializeApc (
  127. IN PRKAPC Apc,
  128. IN PRKTHREAD Thread,
  129. IN KAPC_ENVIRONMENT Environment,
  130. IN PKKERNEL_ROUTINE KernelRoutine,
  131. IN PKRUNDOWN_ROUTINE RundownRoutine OPTIONAL,
  132. IN PKNORMAL_ROUTINE NormalRoutine OPTIONAL,
  133. IN KPROCESSOR_MODE ProcessorMode OPTIONAL,
  134. IN PVOID NormalContext OPTIONAL
  135. );
  136. NTKERNELAPI
  137. BOOLEAN
  138. KeInsertQueueApc(
  139. IN PRKAPC Apc,
  140. IN PVOID SystemArgument1,
  141. IN PVOID SystemArgument2,
  142. IN KPRIORITY Increment
  143. );
  144. typedef enum _HARDERROR_RESPONSE_OPTION {
  145. OptionAbortRetryIgnore,
  146. OptionOk,
  147. OptionOkCancel,
  148. OptionRetryCancel,
  149. OptionYesNo,
  150. OptionYesNoCancel,
  151. OptionShutdownSystem,
  152. OptionOkNoWait,
  153. OptionCancelTryContinue
  154. } HARDERROR_RESPONSE_OPTION;
  155. NTKERNELAPI
  156. NTSTATUS
  157. ExRaiseHardError(
  158. IN NTSTATUS ErrorStatus,
  159. IN ULONG NumberOfParameters,
  160. IN ULONG UnicodeStringParameterMask,
  161. IN PULONG_PTR Parameters,
  162. IN ULONG ValidResponseOptions,
  163. OUT PULONG Response
  164. );