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.

224 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. vfirp.h
  5. Abstract:
  6. This module contains prototypes for functions used to manage IRPs used in
  7. the verification process.
  8. Author:
  9. Adrian J. Oney (adriao) 20-Apr-1998
  10. Environment:
  11. Kernel mode
  12. Revision History:
  13. AdriaO 05/02/2000 - Seperated out from ntos\io\hashirp.h
  14. --*/
  15. struct _IOV_STACK_LOCATION;
  16. struct _IOV_REQUEST_PACKET;
  17. struct _IOFCALLDRIVER_STACKDATA;
  18. typedef struct _IOV_STACK_LOCATION *PIOV_STACK_LOCATION;
  19. typedef struct _IOV_REQUEST_PACKET *PIOV_REQUEST_PACKET;
  20. typedef struct _IOV_SESSION_DATA *PIOV_SESSION_DATA;
  21. typedef struct _IOFCALLDRIVER_STACKDATA *PIOFCALLDRIVER_STACKDATA;
  22. //
  23. // Mini-snapshots of the IRP are stored on the stack for cases when the
  24. // verifier needs to inform the developer as to the mistake, but no longer
  25. // has the original IRP in memory. Because these may be stored on the stack,
  26. // they need to be small and light.
  27. //
  28. typedef struct _IRP_MINI_SNAPSHOT {
  29. PIRP Irp;
  30. IO_STACK_LOCATION IoStackLocation;
  31. } IRP_MINI_SNAPSHOT, *PIRP_MINI_SNAPSHOT;
  32. typedef struct _IOV_STACK_LOCATION {
  33. BOOLEAN InUse;
  34. ULONG Flags;
  35. PIOV_STACK_LOCATION RequestsFirstStackLocation;
  36. LIST_ENTRY CallStackData;
  37. PIO_STACK_LOCATION IrpSp;
  38. PVOID LastDispatch;
  39. LARGE_INTEGER PerfDispatchStart;
  40. LARGE_INTEGER PerfStackLocationStart;
  41. PDEVICE_OBJECT ReferencingObject;
  42. LONG ReferencingCount;
  43. IO_STATUS_BLOCK InitialStatusBlock;
  44. IO_STATUS_BLOCK LastStatusBlock;
  45. PETHREAD ThreadDispatchedTo;
  46. } IOV_STACK_LOCATION;
  47. typedef struct _IOV_SESSION_DATA {
  48. PIOV_REQUEST_PACKET IovRequestPacket;
  49. LONG SessionRefCount;
  50. LIST_ENTRY SessionLink;
  51. ULONG SessionFlags;
  52. PETHREAD OriginatorThread;
  53. PDEVICE_OBJECT DeviceLastCalled; // Last device called
  54. ULONG ForwardMethod;
  55. PIRP BestVisibleIrp;
  56. PVERIFIER_SETTINGS_SNAPSHOT VerifierSettings;
  57. IOV_STACK_LOCATION StackData[ANYSIZE_ARRAY];
  58. } IOV_SESSION_DATA;
  59. typedef struct _IOFCALLDRIVER_STACKDATA {
  60. PIOV_SESSION_DATA IovSessionData;
  61. PIOV_STACK_LOCATION IovStackLocation;
  62. PIOV_REQUEST_PACKET IovPacket;
  63. ULONG Flags;
  64. LIST_ENTRY SharedLocationList;
  65. PDRIVER_DISPATCH DispatchRoutine;
  66. NTSTATUS ExpectedStatus;
  67. NTSTATUS NewStatus;
  68. PDEVICE_OBJECT RemovePdo;
  69. IRP_MINI_SNAPSHOT IrpSnapshot;
  70. } IOFCALLDRIVER_STACKDATA;
  71. typedef struct _IOFCOMPLETEREQUEST_STACKDATA {
  72. PIOV_SESSION_DATA IovSessionData;
  73. PIOV_REQUEST_PACKET IovRequestPacket;
  74. BOOLEAN IsRemoveIrp;
  75. LONG LocationsAdvanced;
  76. ULONG RaisedCount;
  77. KIRQL PreviousIrql;
  78. PVOID CompletionRoutine;
  79. } IOFCOMPLETEREQUEST_STACKDATA, *PIOFCOMPLETEREQUEST_STACKDATA;
  80. VOID
  81. FASTCALL
  82. VfIrpInit(
  83. VOID
  84. );
  85. PIRP
  86. FASTCALL
  87. VfIrpAllocate(
  88. IN CCHAR StackSize
  89. );
  90. VOID
  91. FASTCALL
  92. VfIrpMakeTouchable(
  93. IN PIRP Irp
  94. );
  95. VOID
  96. FASTCALL
  97. VfIrpMakeUntouchable(
  98. IN PIRP Irp OPTIONAL
  99. );
  100. VOID
  101. FASTCALL
  102. VfIrpFree(
  103. IN PIRP Irp OPTIONAL
  104. );
  105. VOID
  106. FASTCALL
  107. VerifierIoAllocateIrp1(
  108. IN CCHAR StackSize,
  109. IN BOOLEAN ChargeQuota,
  110. IN OUT PIRP *IrpPointer
  111. );
  112. VOID
  113. FASTCALL
  114. VerifierIoAllocateIrp2(
  115. IN PIRP Irp
  116. );
  117. VOID
  118. FASTCALL
  119. VerifierIoFreeIrp(
  120. IN PIRP Irp,
  121. IN OUT PBOOLEAN FreeHandled
  122. );
  123. VOID
  124. FASTCALL
  125. VerifierIoInitializeIrp(
  126. IN OUT PIRP Irp,
  127. IN USHORT PacketSize,
  128. IN CCHAR StackSize,
  129. IN OUT PBOOLEAN InitializeHandled
  130. );
  131. BOOLEAN
  132. FASTCALL
  133. VfIrpReserveCallStackData(
  134. IN PIRP Irp,
  135. OUT PIOFCALLDRIVER_STACKDATA *IofCallDriverStackData
  136. );
  137. VOID
  138. FASTCALL
  139. VfIrpPrepareAllocaCallStackData(
  140. OUT PIOFCALLDRIVER_STACKDATA IofCallDriverStackData
  141. );
  142. VOID
  143. FASTCALL
  144. VfIrpReleaseCallStackData(
  145. IN PIOFCALLDRIVER_STACKDATA IofCallDriverStackData OPTIONAL
  146. );
  147. //
  148. // VfIrpCallDriverPreprocess is a macro function that may do an alloca as
  149. // part of it's operation. As such callers must be careful not to use
  150. // variable lengthed arrays in a scope that encompasses
  151. // VfIrpCallDriverPreProcess but not VfIrpCallDriverPostProcess.
  152. //
  153. #define VfIrpCallDriverPreProcess(DeviceObject, IrpPointer, CallStackData, CallerAddress) \
  154. if (!VfIrpReserveCallStackData(*(IrpPointer), (CallStackData))) { \
  155. *(CallStackData) = alloca(sizeof(IOFCALLDRIVER_STACKDATA)); \
  156. VfIrpPrepareAllocaCallStackData(*(CallStackData)); \
  157. } \
  158. IovpCallDriver1((DeviceObject), (IrpPointer), *(CallStackData), (CallerAddress))
  159. #define VfIrpCallDriverPostProcess(DeviceObject, FinalStatus, CallStackData) \
  160. IovpCallDriver2(DeviceObject, FinalStatus, CallStackData); \
  161. VfIrpReleaseCallStackData(CallStackData)
  162. BOOLEAN
  163. VfIrpSendSynchronousIrp(
  164. IN PDEVICE_OBJECT DeviceObject,
  165. IN PIO_STACK_LOCATION TopStackLocation,
  166. IN BOOLEAN Untouchable,
  167. IN NTSTATUS InitialStatus,
  168. IN ULONG_PTR InitialInformation OPTIONAL,
  169. OUT ULONG_PTR *FinalInformation OPTIONAL,
  170. OUT NTSTATUS *FinalStatus OPTIONAL
  171. );
  172. VOID
  173. FASTCALL
  174. VfIrpWatermark(
  175. IN PIRP Irp,
  176. IN ULONG Flags
  177. );