Source code of Windows XP (NT5)
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.

335 lines
8.2 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. trackirp.h
  5. Abstract:
  6. The module associated with the header asserts Irps are handled correctly
  7. by drivers. No IRP-major specific testing is done;
  8. Author:
  9. Adrian J. Oney (adriao) 20-Apr-1998
  10. Revision History:
  11. --*/
  12. #ifndef _TRACKIRP_H_
  13. #define _TRACKIRP_H_
  14. #if DBG
  15. extern ULONG IovpIrpTrackingSpewLevel;
  16. #endif
  17. #define IRP_DIAG_HAS_SURROGATE 0x02000000
  18. #define IRP_DIAG_IS_SURROGATE 0x01000000
  19. //#define TRACKFLAG_ACTIVE 0x00000001
  20. #define TRACKFLAG_SURROGATE 0x00000002
  21. #define TRACKFLAG_HAS_SURROGATE 0x00000004
  22. #define TRACKFLAG_PROTECTEDIRP 0x00000008
  23. #define TRACKFLAG_QUEUED_INTERNALLY 0x00000010
  24. #define TRACKFLAG_BOGUS 0x00000020
  25. #define TRACKFLAG_RELEASED 0x00000040
  26. #define TRACKFLAG_SRB_MUNGED 0x00000080
  27. #define TRACKFLAG_SWAPPED_BACK 0x00000100
  28. #define TRACKFLAG_DIRECT_BUFFERED 0x00000200
  29. #define TRACKFLAG_WATERMARKED 0x00100000
  30. #define TRACKFLAG_IO_ALLOCATED 0x00200000
  31. #define TRACKFLAG_UNWOUND_BADLY 0x00400000
  32. #define TRACKFLAG_PASSED_AT_BAD_IRQL 0x02000000
  33. #define TRACKFLAG_IN_TRANSIT 0x40000000
  34. #define STACKFLAG_NO_HANDLER 0x80000000
  35. #define STACKFLAG_REQUEST_COMPLETED 0x40000000
  36. #define STACKFLAG_CHECK_FOR_REFERENCE 0x20000000
  37. #define STACKFLAG_REACHED_PDO 0x10000000
  38. #define STACKFLAG_FIRST_REQUEST 0x08000000
  39. #define STACKFLAG_UNWOUND_PENDING 0x04000000
  40. #define STACKFLAG_FAILURE_FORWARDED 0x02000000
  41. #define STACKFLAG_BOGUS_IRP_TOUCHED 0x01000000
  42. #define CALLFLAG_STACK_DATA_ALLOCATED 0x80000000
  43. #define CALLFLAG_COMPLETED 0x40000000
  44. #define CALLFLAG_IS_REMOVE_IRP 0x20000000
  45. #define CALLFLAG_REMOVING_FDO_STACK_DO 0x10000000
  46. #define CALLFLAG_OVERRIDE_STATUS 0x08000000
  47. #define CALLFLAG_TOPMOST_IN_SLOT 0x04000000
  48. #define CALLFLAG_MARKED_PENDING 0x02000000
  49. #define CALLFLAG_ARRIVED_PENDING 0x01000000
  50. #define ALLOCFLAG_PROTECTEDIRP 0x00000001
  51. #define SESSIONFLAG_UNWOUND_INCONSISTANT 0x00000001
  52. #define SESSIONFLAG_MARKED_INCONSISTANT 0x00000002
  53. #define IRP_SYSTEM_RESTRICTED 0x00000001
  54. #define IRP_BOGUS 0x00000002
  55. #define SL_NOTCOPIED 0x10
  56. #define IRP_ALLOCATION_MONITORED 0x80
  57. #define STARTED_TOP_OF_STACK 1
  58. #define FORWARDED_TO_NEXT_DO 2
  59. #define SKIPPED_A_DO 3
  60. #define STARTED_INSIDE_STACK 4
  61. #define CHANGED_STACKS_AT_BOTTOM 5
  62. #define CHANGED_STACKS_MID_STACK 6
  63. typedef enum {
  64. DEFERACTION_QUEUE_WORKITEM,
  65. DEFERACTION_QUEUE_PASSIVE_TIMER,
  66. DEFERACTION_QUEUE_DISPATCH_TIMER,
  67. DEFERACTION_NORMAL
  68. } DEFER_ACTION;
  69. typedef struct _DEFERRAL_CONTEXT {
  70. PIOV_REQUEST_PACKET IovRequestPacket;
  71. PIO_COMPLETION_ROUTINE OriginalCompletionRoutine;
  72. PVOID OriginalContext;
  73. PIRP OriginalIrp;
  74. CCHAR OriginalPriorityBoost;
  75. PDEVICE_OBJECT DeviceObject;
  76. PIO_STACK_LOCATION IrpSpNext;
  77. WORK_QUEUE_ITEM WorkQueueItem;
  78. KDPC DpcItem;
  79. KTIMER DeferralTimer;
  80. DEFER_ACTION DeferAction;
  81. } DEFERRAL_CONTEXT, *PDEFERRAL_CONTEXT;
  82. //
  83. // These are in trackirp.c
  84. //
  85. VOID
  86. FASTCALL
  87. IovpPacketFromIrp(
  88. IN PIRP Irp,
  89. OUT PIOV_REQUEST_PACKET *IovPacket
  90. );
  91. BOOLEAN
  92. FASTCALL
  93. IovpCheckIrpForCriticalTracking(
  94. IN PIRP Irp
  95. );
  96. VOID
  97. FASTCALL
  98. IovpCallDriver1(
  99. IN PDEVICE_OBJECT DeviceObject,
  100. IN OUT PIRP *IrpPointer,
  101. IN OUT PIOFCALLDRIVER_STACKDATA IofCallDriverStackData OPTIONAL
  102. );
  103. VOID
  104. FASTCALL
  105. IovpCallDriver2(
  106. IN PDEVICE_OBJECT DeviceObject,
  107. IN OUT NTSTATUS *FinalStatus,
  108. IN PIOFCALLDRIVER_STACKDATA IofCallDriverStackData OPTIONAL
  109. );
  110. VOID
  111. FASTCALL
  112. IovpCompleteRequest1(
  113. IN PIRP Irp,
  114. IN CCHAR PriorityBoost,
  115. IN OUT PIOFCOMPLETEREQUEST_STACKDATA CompletionPacket
  116. );
  117. VOID
  118. FASTCALL
  119. IovpCompleteRequest2(
  120. IN PIRP Irp,
  121. IN OUT PIOFCOMPLETEREQUEST_STACKDATA CompletionPacket
  122. );
  123. VOID
  124. FASTCALL
  125. IovpCompleteRequest3(
  126. IN PIRP Irp,
  127. IN PVOID Routine,
  128. IN OUT PIOFCOMPLETEREQUEST_STACKDATA CompletionPacket
  129. );
  130. VOID
  131. FASTCALL
  132. IovpCompleteRequest4(
  133. IN PIRP Irp,
  134. IN NTSTATUS ReturnedStatus,
  135. IN OUT PIOFCOMPLETEREQUEST_STACKDATA CompletionPacket
  136. );
  137. VOID
  138. FASTCALL
  139. IovpCompleteRequest5(
  140. IN PIRP Irp,
  141. IN OUT PIOFCOMPLETEREQUEST_STACKDATA CompletionPacket
  142. );
  143. VOID
  144. FASTCALL
  145. IovpCompleteRequestApc(
  146. IN PIRP Irp,
  147. IN PVOID BestStackOffset
  148. );
  149. VOID
  150. FASTCALL
  151. IovpCancelIrp(
  152. IN PIRP Irp,
  153. IN OUT PBOOLEAN CancelHandled,
  154. IN OUT PBOOLEAN ReturnValue
  155. );
  156. VOID
  157. IovpExamineIrpStackForwarding(
  158. IN OUT PIOV_REQUEST_PACKET IovPacket,
  159. IN BOOLEAN IsNewSession,
  160. IN ULONG ForwardMethod,
  161. IN PDEVICE_OBJECT DeviceObject,
  162. IN PIRP Irp,
  163. IN PVOID CallerAddress,
  164. IN OUT PIO_STACK_LOCATION *IoCurrentStackLocation,
  165. OUT PIO_STACK_LOCATION *IoLastStackLocation,
  166. OUT ULONG *StackLocationsAdvanced
  167. );
  168. NTSTATUS
  169. IovpSwapSurrogateIrp(
  170. IN PDEVICE_OBJECT DeviceObject,
  171. IN PIRP Irp,
  172. IN PVOID Context
  173. );
  174. VOID
  175. FASTCALL
  176. IovpExamineDevObjForwarding(
  177. IN PDEVICE_OBJECT DeviceBeingCalled,
  178. IN PDEVICE_OBJECT DeviceLastCalled,
  179. OUT PULONG ForwardingTechnique
  180. );
  181. VOID
  182. FASTCALL
  183. IovpFinalizeIrpSettings(
  184. IN OUT PIOV_REQUEST_PACKET IrpTrackingData,
  185. IN BOOLEAN SurrogateIrpSwapped
  186. );
  187. NTSTATUS
  188. IovpInternalCompletionTrap(
  189. IN PDEVICE_OBJECT DeviceObject,
  190. IN PIRP Irp,
  191. IN PVOID Context
  192. );
  193. NTSTATUS
  194. IovpInternalDeferredCompletion(
  195. IN PDEVICE_OBJECT DeviceObject,
  196. IN PIRP Irp,
  197. IN PVOID Context
  198. );
  199. VOID
  200. IovpInternalCompleteAfterWait(
  201. IN PVOID Context
  202. );
  203. VOID
  204. IovpInternalCompleteAtDPC(
  205. IN PKDPC Dpc,
  206. IN PVOID DeferredContext,
  207. IN PVOID SystemArgument1,
  208. IN PVOID SystemArgument2
  209. );
  210. BOOLEAN
  211. IovpAdvanceStackDownwards(
  212. IN PIOV_STACK_LOCATION StackDataArray,
  213. IN CCHAR CurrentLocation,
  214. IN PIO_STACK_LOCATION IrpSp,
  215. IN PIO_STACK_LOCATION IrpLastSp OPTIONAL,
  216. IN ULONG LocationsAdvanced,
  217. IN BOOLEAN IsNewRequest,
  218. IN BOOLEAN MarkAsTaken,
  219. OUT PIOV_STACK_LOCATION *StackLocationInfo
  220. );
  221. VOID
  222. IovpBuildIrpSnapshot(
  223. IN PIRP Irp,
  224. OUT IRP_SNAPSHOT *IrpSnapshot
  225. );
  226. #define SPECIALIRP_MARK_NON_TRACKABLE(Irp) { \
  227. (Irp)->Flags |= IRPFLAG_EXAMINE_NOT_TRACKED; \
  228. }
  229. #define SPECIALIRP_IOF_COMPLETE_1(Irp, PriorityBoost, CompletionPacket) \
  230. {\
  231. IovpCompleteRequest1((Irp), (PriorityBoost), (CompletionPacket));\
  232. }
  233. #define SPECIALIRP_IOF_COMPLETE_2(Irp, CompletionPacket) \
  234. {\
  235. IovpCompleteRequest2((Irp), (CompletionPacket));\
  236. }
  237. #define SPECIALIRP_IOF_COMPLETE_3(Irp, Routine, CompletionPacket) \
  238. {\
  239. IovpCompleteRequest3((Irp), (Routine), (CompletionPacket));\
  240. }
  241. #define SPECIALIRP_IOF_COMPLETE_4(Irp, ReturnedStatus, CompletionPacket) \
  242. {\
  243. IovpCompleteRequest4((Irp), (ReturnedStatus), (CompletionPacket));\
  244. }
  245. #define SPECIALIRP_IOF_COMPLETE_5(Irp, CompletionPacket) \
  246. {\
  247. IovpCompleteRequest5((Irp), (CompletionPacket));\
  248. }
  249. #define SPECIALIRP_IO_CANCEL_IRP(Irp, CancelHandled, ReturnValue) \
  250. {\
  251. IovpCancelIrp((Irp), (CancelHandled), (ReturnValue));\
  252. }
  253. #define SPECIALIRP_WATERMARK_IRP(Irp, Flags) \
  254. {\
  255. IovUtilWatermarkIrp(Irp, Flags);\
  256. }
  257. #define SPECIALIRP_IOP_COMPLETE_REQUEST(Irp, StackPointer) \
  258. {\
  259. IovpCompleteRequestApc(Irp, StackPointer);\
  260. }
  261. #if DBG
  262. #define TRACKIRP_DBGPRINT(txt,level) \
  263. { \
  264. if (IovpIrpTrackingSpewLevel>(level)) { \
  265. DbgPrint##txt ; \
  266. }\
  267. }
  268. #else
  269. #define TRACKIRP_DBGPRINT(txt,level)
  270. #endif
  271. #endif // _TRACKIRP_H_