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.

310 lines
8.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. vfsettings.h
  5. Abstract:
  6. This header contains prototypes for manipulating verifier options and
  7. values.
  8. Author:
  9. Adrian J. Oney (adriao) 31-May-2000
  10. Environment:
  11. Kernel mode
  12. Revision History:
  13. --*/
  14. typedef PVOID PVERIFIER_SETTINGS_SNAPSHOT;
  15. typedef enum {
  16. //
  17. // This option lets the verifer begin tracking all IRPs. It must be enabled
  18. // for most of the other IRP verification options to work.
  19. //
  20. VERIFIER_OPTION_TRACK_IRPS = 1,
  21. //
  22. // This option forces all IRPs to be allocated from the special pool.
  23. // VERIFIER_OPTION_TRACK_IRPS need not be enabled.
  24. //
  25. VERIFIER_OPTION_MONITOR_IRP_ALLOCS,
  26. //
  27. // This option enables various checks for basic/common IRP handling mistakes.
  28. //
  29. VERIFIER_OPTION_POLICE_IRPS,
  30. //
  31. // This option enables checks specific to major/minor codes.
  32. //
  33. VERIFIER_OPTION_MONITOR_MAJORS,
  34. //
  35. // This option causes the call stacks of IRP dispatch and completion
  36. // routines to be seeded with 0xFFFFFFFF. This value is illegal for a
  37. // status code, and such seeding flushes out uninitialized variable bugs.
  38. //
  39. VERIFIER_OPTION_SEEDSTACK,
  40. //
  41. // This option sends a bogus QueryDeviceRelations IRP to newly built stacks.
  42. // The particular IRP sent is of type -1, and has a -1 passed in for the
  43. // device list.
  44. //
  45. VERIFIER_OPTION_RELATION_IGNORANCE_TEST,
  46. //
  47. // This option causes the verifier to stop on unneccessary IRP stack copies.
  48. // It is useful for optimizing drivers.
  49. //
  50. VERIFIER_OPTION_FLAG_UNNECCESSARY_COPIES,
  51. VERIFIER_OPTION_SEND_BOGUS_WMI_IRPS,
  52. VERIFIER_OPTION_SEND_BOGUS_POWER_IRPS,
  53. //
  54. // If this option is enabled, the verifier makes sure drivers mark the IRP
  55. // pending if and only if STATUS_PENDING is returned, and visa versa.
  56. //
  57. VERIFIER_OPTION_MONITOR_PENDING_IO,
  58. //
  59. // If this option is enabled, the verifier makes all IRPs return in an
  60. // asynchronous manner. Specifically, all IRPs are marked pending, and
  61. // STATUS_PENDING is returned from every IoCallDriver.
  62. //
  63. VERIFIER_OPTION_FORCE_PENDING,
  64. //
  65. // If this option is enabled, the verifier will change the status code of
  66. // successful IRPs to alternate success status's. This catches many IRP
  67. // forwarding bugs.
  68. //
  69. VERIFIER_OPTION_ROTATE_STATUS,
  70. //
  71. // If this option is enabled, the verifier will undo the effects of
  72. // IoSkipCurrentIrpStackLocation so that all stacks appear to be copied.
  73. // (Exempting the case where an IRP was forwarded to another stack)
  74. //
  75. VERIFIER_OPTION_CONSUME_ALWAYS,
  76. //
  77. // If this option is enabled, the verifier will update SRB's to handle
  78. // surrogate IRPs. Some SCSI IRPs can't be surrogated unless the
  79. // SRB->OriginalRequest pointer is updated. This is due to a busted SRB
  80. // architecture. Note that the technique used to identify an SRB IRP is
  81. // "fuzzy", and could in theory touch an IRP it shouldn't have!
  82. //
  83. VERIFIER_OPTION_SMASH_SRBS,
  84. //
  85. // If this option is enabled, the verifier will replace original IRPs with
  86. // surrogates when travelling down the stack. The surrogates are allocated
  87. // from special pool, and get freed immediately upon completion. This lets
  88. // the verifier catch drivers that touch IRPs after they're completed.
  89. //
  90. VERIFIER_OPTION_SURROGATE_IRPS,
  91. //
  92. // If this option is enabled, the verifier buffers all direct I/O. It does
  93. // this by allocating an alternate MDL and copying the MDL contents back
  94. // to user mode only after IRP completion. This allows overruns, underruns,
  95. // and late accesses to be detected.
  96. //
  97. VERIFIER_OPTION_BUFFER_DIRECT_IO,
  98. //
  99. // If this option is enabled, the verifier delays completion of all IRPs
  100. // via timer. VERIFIER_OPTION_FORCE_PENDING is set by inference.
  101. //
  102. VERIFIER_OPTION_DEFER_COMPLETION,
  103. //
  104. // If this option is enabled, the verifier completes every IRP at
  105. // PASSIVE_LEVEL, regardless of major function.
  106. // VERIFIER_OPTION_FORCE_PENDING is set by inference.
  107. //
  108. VERIFIER_OPTION_COMPLETE_AT_PASSIVE,
  109. //
  110. // If this option is enabled, the verifier completes every IRP at
  111. // DISPATCH_LEVEL, regardless of major function.
  112. //
  113. VERIFIER_OPTION_COMPLETE_AT_DISPATCH,
  114. //
  115. // If this option is enabled, the verifier monitors cancel routines to make
  116. // sure they are cleared appropriately.
  117. //
  118. VERIFIER_OPTION_VERIFY_CANCEL_LOGIC,
  119. VERIFIER_OPTION_RANDOMLY_CANCEL_IRPS,
  120. //
  121. // If this option is enabled, the verifier inserts filter device objects
  122. // into WDM stacks to ensure IRPs are properly forwarded.
  123. //
  124. VERIFIER_OPTION_INSERT_WDM_FILTERS,
  125. //
  126. // If this option is enabled, the verifier monitors drivers to ensure they
  127. // don't send system reserved IRPs to WDM stacks.
  128. //
  129. VERIFIER_OPTION_PROTECT_RESERVED_IRPS,
  130. //
  131. // If this option is enabled, the verifier walks the entire stack to ensure
  132. // the DO bits are properly built during AddDevice. This includes the
  133. // DO_POWER_PAGABLE flag.
  134. //
  135. VERIFIER_OPTION_VERIFY_DO_FLAGS,
  136. //
  137. // If this option is enabled, the verifier watches Target device relation
  138. // IRPs to make sure the device object is properly reference counted.
  139. //
  140. VERIFIER_OPTION_TEST_TARGET_REFCOUNT,
  141. //
  142. // Lets you detect when deadlocks can occur
  143. //
  144. VERIFIER_OPTION_DETECT_DEADLOCKS,
  145. //
  146. // If this option is enabled, all dma operations will be hooked and
  147. // validated.
  148. //
  149. VERIFIER_OPTION_VERIFY_DMA,
  150. //
  151. // This option double buffers all dma and erects guard pages on each side
  152. // of all common buffers and mapped buffers. Is memory-intensive but can
  153. // catch hardware buffer overruns and drivers that don't flush adapter
  154. // buffers.
  155. //
  156. VERIFIER_OPTION_DOUBLE_BUFFER_DMA,
  157. //
  158. // If this option is enabled, you get notified when the performance counter
  159. // is being naughty
  160. //
  161. VERIFIER_OPTION_VERIFY_PERFORMANCE_COUNTER,
  162. //
  163. // If this option is enabled, the verifier checks for implementations of
  164. // IRP_MN_DEVICE_USAGE_NOTIFICATION and IRP_MN_SURPRISE_REMOVAL. The
  165. // verifier will also make sure PnP Cancel IRPs are not explicitely failed.
  166. //
  167. VERIFIER_OPTION_EXTENDED_REQUIRED_IRPS,
  168. //
  169. // If this option is enabled, the verifier mixes up device relations
  170. // to ensure drivers aren't depending on ordering.
  171. //
  172. VERIFIER_OPTION_SCRAMBLE_RELATIONS,
  173. //
  174. // If this option is enabled, the verifier ensures proper detaching and
  175. // deletion occurs on removes and surprise removes.
  176. //
  177. VERIFIER_OPTION_MONITOR_REMOVES,
  178. //
  179. // If this option is enabled, the verifier ensures device relations only
  180. // consist of PDO's.
  181. //
  182. VERIFIER_OPTION_EXAMINE_RELATION_PDOS,
  183. //
  184. // If this option is enabled, the verifier enabled hardware verification
  185. // (bus specific behavior)
  186. //
  187. VERIFIER_OPTION_HARDWARE_VERIFICATION,
  188. //
  189. // If this option is enabled, the verifier ensures system BIOS verification
  190. //
  191. VERIFIER_OPTION_SYSTEM_BIOS_VERIFICATION,
  192. VERIFIER_OPTION_MAX
  193. } VERIFIER_OPTION;
  194. typedef enum {
  195. //
  196. // If VERIFIER_OPTION_DEFER_COMPLETION is set, this value contains the time
  197. // an IRP will be deferred, in 100us units.
  198. //
  199. VERIFIER_VALUE_IRP_DEFERRAL_TIME = 1,
  200. //
  201. // This shall be the percentage of allocates to fail during low resource
  202. // simulation.
  203. //
  204. VERIFIER_VALUE_LOW_RESOURCE_PERCENTAGE,
  205. VERIFIER_VALUE_MAX
  206. } VERIFIER_VALUE;
  207. VOID
  208. FASTCALL
  209. VfSettingsInit(
  210. IN ULONG MmFlags
  211. );
  212. BOOLEAN
  213. FASTCALL
  214. VfSettingsIsOptionEnabled(
  215. IN PVERIFIER_SETTINGS_SNAPSHOT VerifierSettingsSnapshot OPTIONAL,
  216. IN VERIFIER_OPTION VerifierOption
  217. );
  218. VOID
  219. FASTCALL
  220. VfSettingsCreateSnapshot(
  221. IN OUT PVERIFIER_SETTINGS_SNAPSHOT VerifierSettingsSnapshot
  222. );
  223. ULONG
  224. FASTCALL
  225. VfSettingsGetSnapshotSize(
  226. VOID
  227. );
  228. VOID
  229. FASTCALL
  230. VfSettingsSetOption(
  231. IN PVERIFIER_SETTINGS_SNAPSHOT VerifierSettingsSnapshot OPTIONAL,
  232. IN VERIFIER_OPTION VerifierOption,
  233. IN BOOLEAN Setting
  234. );
  235. VOID
  236. FASTCALL
  237. VfSettingsGetValue(
  238. IN PVERIFIER_SETTINGS_SNAPSHOT VerifierSettingsSnapshot OPTIONAL,
  239. IN VERIFIER_VALUE VerifierValue,
  240. OUT ULONG *Value
  241. );
  242. VOID
  243. FASTCALL
  244. VfSettingsSetValue(
  245. IN PVERIFIER_SETTINGS_SNAPSHOT VerifierSettingsSnapshot OPTIONAL,
  246. IN VERIFIER_VALUE VerifierValue,
  247. IN ULONG Value
  248. );