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.

929 lines
22 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. iovutil.c
  5. Abstract:
  6. This module implements various utilities required to do driver verification.
  7. Author:
  8. Adrian J. Oney (adriao) 20-Apr-1998
  9. Environment:
  10. Kernel mode
  11. Revision History:
  12. AdriaO 02/10/2000 - Seperated out from ntos\io\trackirp.c
  13. --*/
  14. #include "iop.h"
  15. #include "pnpi.h"
  16. #include "arbiter.h"
  17. #include "dockintf.h"
  18. #include "pnprlist.h"
  19. #include "pnpiop.h"
  20. #include "iovputil.h"
  21. #ifdef ALLOC_PRAGMA
  22. #pragma alloc_text(PAGEVRFY, IovUtilInit)
  23. //#pragma alloc_text(PAGEVRFY, IovUtilMarkDeviceObject)
  24. //#pragma alloc_text(PAGEVRFY, IovUtilMarkStack)
  25. //#pragma alloc_text(PAGEVRFY, IovUtilWatermarkIrp)
  26. #ifndef NO_VERIFIER
  27. #pragma alloc_text(PAGEVRFY, IovUtilGetLowerDeviceObject)
  28. #pragma alloc_text(PAGEVRFY, IovUtilGetBottomDeviceObject)
  29. #pragma alloc_text(PAGEVRFY, IovUtilGetUpperDeviceObject)
  30. #pragma alloc_text(PAGEVRFY, IovUtilIsVerifiedDeviceStack)
  31. #pragma alloc_text(PAGEVRFY, IovUtilFlushStackCache)
  32. #pragma alloc_text(PAGEVRFY, IovUtilFlushVerifierDriverListCache)
  33. #pragma alloc_text(PAGEVRFY, IovpUtilFlushListCallback)
  34. #pragma alloc_text(PAGEVRFY, IovUtilIsPdo)
  35. #pragma alloc_text(PAGEVRFY, IovUtilIsWdmStack)
  36. #pragma alloc_text(PAGEVRFY, IovUtilHasDispatchHandler)
  37. #pragma alloc_text(PAGEVRFY, IovUtilIsInFdoStack)
  38. #pragma alloc_text(PAGEVRFY, IovUtilIsRawPdo)
  39. #pragma alloc_text(PAGEVRFY, IovUtilIsDesignatedFdo)
  40. #pragma alloc_text(PAGEVRFY, IovUtilIsDeviceObjectMarked)
  41. #endif // NO_VERIFIER
  42. #endif // ALLOC_PRAGMA
  43. //
  44. // This entire implementation is specific to the verifier
  45. //
  46. #ifndef NO_VERIFIER
  47. BOOLEAN IovUtilVerifierEnabled = FALSE;
  48. VOID
  49. FASTCALL
  50. IovUtilInit(
  51. VOID
  52. )
  53. {
  54. IovUtilVerifierEnabled = TRUE;
  55. }
  56. VOID
  57. FASTCALL
  58. IovUtilGetLowerDeviceObject(
  59. IN PDEVICE_OBJECT UpperDeviceObject,
  60. OUT PDEVICE_OBJECT *LowerDeviceObject
  61. )
  62. /*++
  63. Routine Description:
  64. This routine returns the device object below the passed in parameter. In
  65. other words, it is the inverse of DeviceObject->AttachedDevice. Note that
  66. the returned device object is referenced by this routine.
  67. Arguments:
  68. UpperDeviceObject - Device object to look beneath.
  69. LowerDeviceObject - Receives device object beneath UpperDeviceObject, or
  70. NULL if none.
  71. Return Value:
  72. None.
  73. --*/
  74. {
  75. PDEVOBJ_EXTENSION deviceExtension;
  76. PDEVICE_OBJECT deviceAttachedTo;
  77. KIRQL irql;
  78. irql = KeAcquireQueuedSpinLock( LockQueueIoDatabaseLock );
  79. deviceExtension = UpperDeviceObject->DeviceObjectExtension;
  80. deviceAttachedTo = deviceExtension->AttachedTo;
  81. if (deviceAttachedTo) {
  82. ObReferenceObject(deviceAttachedTo);
  83. }
  84. KeReleaseQueuedSpinLock( LockQueueIoDatabaseLock, irql );
  85. *LowerDeviceObject = deviceAttachedTo;
  86. }
  87. VOID
  88. FASTCALL
  89. IovUtilGetBottomDeviceObject(
  90. IN PDEVICE_OBJECT DeviceObject,
  91. OUT PDEVICE_OBJECT *BottomDeviceObject
  92. )
  93. /*++
  94. Routine Description:
  95. This routine returns the device object at the bottom of the stack in which
  96. the passed in parameter is a member. In other words, it is the inverse of
  97. IoGetAttachedDeviceReference. Note that the returned device object is
  98. referenced by this routine.
  99. Arguments:
  100. DeviceObject - Device object to examine.
  101. BottomDeviceObject - Receives device object at the bottom of DeviceObject's
  102. stack, NULL if none.
  103. Return Value:
  104. None.
  105. --*/
  106. {
  107. PDEVOBJ_EXTENSION deviceExtension;
  108. PDEVICE_OBJECT lowerDeviceObject, deviceAttachedTo;
  109. KIRQL irql;
  110. deviceAttachedTo = DeviceObject;
  111. irql = KeAcquireQueuedSpinLock( LockQueueIoDatabaseLock );
  112. do {
  113. lowerDeviceObject = deviceAttachedTo;
  114. deviceExtension = lowerDeviceObject->DeviceObjectExtension;
  115. deviceAttachedTo = deviceExtension->AttachedTo;
  116. } while ( deviceAttachedTo );
  117. ObReferenceObject(lowerDeviceObject);
  118. KeReleaseQueuedSpinLock( LockQueueIoDatabaseLock, irql );
  119. *BottomDeviceObject = lowerDeviceObject;
  120. }
  121. VOID
  122. FASTCALL
  123. IovUtilGetUpperDeviceObject(
  124. IN PDEVICE_OBJECT LowerDeviceObject,
  125. OUT PDEVICE_OBJECT *UpperDeviceObject
  126. )
  127. /*++
  128. Routine Description:
  129. This routine returns the device object above the passed in parameter. In
  130. other words, it retrieves DeviceObject->AttachedDevice under the database
  131. lock.. Note that the returned device object is referenced by this routine.
  132. Arguments:
  133. LowerDeviceObject - Device object to look above.
  134. UpperDeviceObject - Receives device object above LowerDeviceObject, or
  135. NULL if none.
  136. Return Value:
  137. None.
  138. --*/
  139. {
  140. PDEVICE_OBJECT deviceAbove;
  141. KIRQL irql;
  142. irql = KeAcquireQueuedSpinLock( LockQueueIoDatabaseLock );
  143. deviceAbove = LowerDeviceObject->AttachedDevice;
  144. if (deviceAbove) {
  145. ObReferenceObject(deviceAbove);
  146. }
  147. KeReleaseQueuedSpinLock( LockQueueIoDatabaseLock, irql );
  148. *UpperDeviceObject = deviceAbove;
  149. }
  150. BOOLEAN
  151. FASTCALL
  152. IovUtilIsVerifiedDeviceStack(
  153. IN PDEVICE_OBJECT DeviceObject
  154. )
  155. /*++
  156. Routine Description:
  157. This routine determines whether a device object in the stack is marked for
  158. verification.
  159. Arguments:
  160. DeviceObject - Device object to examine.
  161. Return Value:
  162. TRUE if at least one device object in the stack is marked for verification,
  163. FALSE otherwise.
  164. --*/
  165. {
  166. PDEVOBJ_EXTENSION deviceExtension;
  167. PDEVICE_OBJECT currentDevObj, deviceAttachedTo;
  168. BOOLEAN stackIsInteresting;
  169. KIRQL irql;
  170. //
  171. // Quickly check the cached result stored on the device object...
  172. //
  173. if (DeviceObject->DeviceObjectExtension->ExtensionFlags & DOV_EXAMINED) {
  174. stackIsInteresting =
  175. ((DeviceObject->DeviceObjectExtension->ExtensionFlags & DOV_TRACKED) != 0);
  176. return stackIsInteresting;
  177. }
  178. //
  179. // Walk the entire stack and update everything appropriately.
  180. //
  181. irql = KeAcquireQueuedSpinLock( LockQueueIoDatabaseLock );
  182. stackIsInteresting = FALSE;
  183. deviceAttachedTo = DeviceObject;
  184. do {
  185. currentDevObj = deviceAttachedTo;
  186. deviceExtension = currentDevObj->DeviceObjectExtension;
  187. deviceAttachedTo = deviceExtension->AttachedTo;
  188. //
  189. // Remember this...
  190. //
  191. if (MmIsDriverVerifying(currentDevObj->DriverObject)) {
  192. stackIsInteresting = TRUE;
  193. }
  194. } while (deviceAttachedTo &&
  195. (!(deviceAttachedTo->DeviceObjectExtension->ExtensionFlags & DOV_EXAMINED))
  196. );
  197. if (deviceAttachedTo &&
  198. (deviceAttachedTo->DeviceObjectExtension->ExtensionFlags & DOV_TRACKED)) {
  199. //
  200. // Propogate upwards the "interesting-ness" of the last examined device
  201. // in the stack...
  202. //
  203. stackIsInteresting = TRUE;
  204. }
  205. //
  206. // Walk upwards, marking everything examined and appropriately tracked.
  207. //
  208. do {
  209. deviceExtension = currentDevObj->DeviceObjectExtension;
  210. if (stackIsInteresting) {
  211. deviceExtension->ExtensionFlags |= DOV_TRACKED;
  212. } else {
  213. deviceExtension->ExtensionFlags &=~ DOV_TRACKED;
  214. }
  215. deviceExtension->ExtensionFlags |= DOV_EXAMINED;
  216. currentDevObj = currentDevObj->AttachedDevice;
  217. } while (currentDevObj);
  218. KeReleaseQueuedSpinLock( LockQueueIoDatabaseLock, irql );
  219. return stackIsInteresting;
  220. }
  221. VOID
  222. FASTCALL
  223. IovUtilFlushStackCache(
  224. IN PDEVICE_OBJECT DeviceObject,
  225. IN DATABASELOCKSTATE DatabaseLockState
  226. )
  227. /*++
  228. Routine Description:
  229. This routine causes the verifier to reexamine the stack of which the given
  230. device object is a member. This needs to be done whenever the attachment
  231. chain is updated.
  232. Arguments:
  233. DeviceObject - Device that is a member of the stack requiring
  234. reexamination.
  235. DatabaseLockState - Indicates current state of Database lock, either
  236. DATABASELOCKSTATE_HELD or DATABASELOCKSTATE_NOT_HELD.
  237. If the lock is not held, this routine will acquire and
  238. release it.
  239. Return Value:
  240. None.
  241. --*/
  242. {
  243. PDEVICE_OBJECT pBottomDeviceObject, pCurrentDeviceObject;
  244. PDEVOBJ_EXTENSION deviceExtension;
  245. KIRQL irql;
  246. if (DatabaseLockState == DATABASELOCKSTATE_NOT_HELD) {
  247. irql = KeAcquireQueuedSpinLock( LockQueueIoDatabaseLock );
  248. }
  249. //
  250. // Walk to the bottom of the stack
  251. //
  252. pCurrentDeviceObject = DeviceObject;
  253. do {
  254. pBottomDeviceObject = pCurrentDeviceObject;
  255. deviceExtension = pBottomDeviceObject->DeviceObjectExtension;
  256. pCurrentDeviceObject = deviceExtension->AttachedTo;
  257. } while ( pCurrentDeviceObject );
  258. //
  259. // Walk back up clearing the appropriate flags.
  260. //
  261. pCurrentDeviceObject = pBottomDeviceObject;
  262. while(pCurrentDeviceObject) {
  263. deviceExtension = pCurrentDeviceObject->DeviceObjectExtension;
  264. deviceExtension->ExtensionFlags &= ~(DOV_EXAMINED | DOV_TRACKED);
  265. pCurrentDeviceObject = pCurrentDeviceObject->AttachedDevice;
  266. }
  267. if (DatabaseLockState == DATABASELOCKSTATE_NOT_HELD) {
  268. KeReleaseQueuedSpinLock( LockQueueIoDatabaseLock, irql );
  269. }
  270. }
  271. VOID
  272. FASTCALL
  273. IovUtilFlushVerifierDriverListCache(
  274. VOID
  275. )
  276. /*++
  277. Routine Description:
  278. This routine causes the verifier to reexamine all previously examined
  279. stacks. This is a prerequisite for updating the list of verified drivers.
  280. Arguments:
  281. None.
  282. Return Value:
  283. None.
  284. --*/
  285. {
  286. //
  287. // We must be called at PASSIVE_LEVEL!
  288. //
  289. PAGED_CODE();
  290. ObEnumerateObjectsByType(
  291. IoDeviceObjectType,
  292. IovpUtilFlushListCallback,
  293. NULL
  294. );
  295. }
  296. BOOLEAN
  297. IovpUtilFlushListCallback(
  298. IN PVOID Object,
  299. IN PUNICODE_STRING ObjectName,
  300. IN ULONG_PTR HandleCount,
  301. IN ULONG_PTR PointerCount,
  302. IN PVOID Context
  303. )
  304. /*++
  305. Routine Description:
  306. This is a worker routine for IovUtilFlushVerifierDriverListCache. It is
  307. called on each device object in the system.
  308. Arguments:
  309. Object - Device Object enumerated by ObEnumerateObjectsByType.
  310. ObjectName - Name of the object
  311. HandleCount - Handle count of the object
  312. PointerCount - Pointer count of the object
  313. Context - Context supplied to ObEnumerateObjectsByType (not used)
  314. Return Value:
  315. BOOLEAN that indicates whether the enumeration should continue.
  316. --*/
  317. {
  318. PDEVICE_OBJECT deviceObject;
  319. PDEVOBJ_EXTENSION deviceExtension;
  320. deviceObject = (PDEVICE_OBJECT) Object;
  321. deviceExtension = deviceObject->DeviceObjectExtension;
  322. if (PointerCount || HandleCount) {
  323. deviceExtension->ExtensionFlags &= ~(DOV_EXAMINED | DOV_TRACKED);
  324. }
  325. return TRUE;
  326. }
  327. VOID
  328. IovUtilRelateDeviceObjects(
  329. IN PDEVICE_OBJECT FirstDeviceObject,
  330. IN PDEVICE_OBJECT SecondDeviceObject,
  331. OUT DEVOBJ_RELATION *DeviceObjectRelation
  332. )
  333. /*++
  334. Routine Description:
  335. This routine determines the relationship between two device objects,
  336. relative to their stacks.
  337. Arguments:
  338. FirstDeviceObject - First device object
  339. SecondDeviceObject - Second device object
  340. DeviceObjectRelation - Receives stack relationship of device objects:
  341. DEVOBJ_RELATION_IDENTICAL -
  342. The two device objects are identical.
  343. DEVOBJ_RELATION_FIRST_IMMEDIATELY_ABOVE_SECOND -
  344. The first device object is immediately above the second device
  345. object in the same stack.
  346. DEVOBJ_RELATION_FIRST_ABOVE_SECOND -
  347. The first device object is above the second device object in the
  348. same stack, but not immediately above.
  349. DEVOBJ_RELATION_FIRST_IMMEDIATELY_BELOW_SECOND -
  350. The first device object is immediately below the second device
  351. object in the same stack.
  352. DEVOBJ_RELATION_FIRST_BELOW_SECOND -
  353. The first device object is below the second device object in the
  354. same stack, but not immediately above.
  355. DEVOBJ_RELATION_NOT_IN_SAME_STACK -
  356. The device objects do not belong to the same stack.
  357. Return Value:
  358. None.
  359. --*/
  360. {
  361. PDEVOBJ_EXTENSION deviceExtension;
  362. PDEVICE_OBJECT upperDevobj, lowerDeviceObject, deviceAttachedTo;
  363. ULONG result;
  364. KIRQL irql;
  365. //
  366. // Try the easiest early out
  367. //
  368. if (FirstDeviceObject == SecondDeviceObject) {
  369. *DeviceObjectRelation = DEVOBJ_RELATION_IDENTICAL;
  370. return;
  371. }
  372. irql = KeAcquireQueuedSpinLock( LockQueueIoDatabaseLock );
  373. //
  374. // Try the most common early out
  375. //
  376. if (FirstDeviceObject == SecondDeviceObject->AttachedDevice){
  377. *DeviceObjectRelation = DEVOBJ_RELATION_FIRST_IMMEDIATELY_ABOVE_SECOND;
  378. KeReleaseQueuedSpinLock( LockQueueIoDatabaseLock, irql );
  379. return;
  380. } else if (FirstDeviceObject->AttachedDevice == SecondDeviceObject) {
  381. *DeviceObjectRelation = DEVOBJ_RELATION_FIRST_IMMEDIATELY_BELOW_SECOND;
  382. KeReleaseQueuedSpinLock( LockQueueIoDatabaseLock, irql );
  383. return;
  384. }
  385. //
  386. // We'll have to walk a stack. Start by getting the bottom of the first
  387. // device object.
  388. //
  389. deviceAttachedTo = FirstDeviceObject;
  390. do {
  391. if (deviceAttachedTo == SecondDeviceObject) {
  392. break;
  393. }
  394. lowerDeviceObject = deviceAttachedTo;
  395. deviceExtension = lowerDeviceObject->DeviceObjectExtension;
  396. deviceAttachedTo = deviceExtension->AttachedTo;
  397. } while ( deviceAttachedTo );
  398. //
  399. // If deviceAttachedTo isn't NULL, then we walked down from
  400. // FirstDeviceObject and found SecondDeviceObject.
  401. //
  402. if (deviceAttachedTo) {
  403. *DeviceObjectRelation = DEVOBJ_RELATION_FIRST_ABOVE_SECOND;
  404. KeReleaseQueuedSpinLock( LockQueueIoDatabaseLock, irql );
  405. return;
  406. }
  407. //
  408. // Now try walking *up* FirstDeviceObject and see if we find
  409. // SecondDeviceObject.
  410. //
  411. upperDevobj = FirstDeviceObject->AttachedDevice;
  412. while(upperDevobj && (upperDevobj != SecondDeviceObject)) {
  413. upperDevobj = upperDevobj->AttachedDevice;
  414. }
  415. if (upperDevobj == NULL) {
  416. *DeviceObjectRelation = DEVOBJ_RELATION_NOT_IN_SAME_STACK;
  417. } else {
  418. *DeviceObjectRelation = DEVOBJ_RELATION_FIRST_BELOW_SECOND;
  419. }
  420. KeReleaseQueuedSpinLock( LockQueueIoDatabaseLock, irql );
  421. }
  422. BOOLEAN
  423. IovUtilIsPdo(
  424. IN PDEVICE_OBJECT DeviceObject
  425. )
  426. {
  427. PDEVICE_NODE deviceNode;
  428. PDEVICE_OBJECT possiblePdo;
  429. BOOLEAN isPdo;
  430. IovUtilGetBottomDeviceObject(DeviceObject, &possiblePdo);
  431. if (possiblePdo != DeviceObject) {
  432. ObDereferenceObject(possiblePdo);
  433. return FALSE;
  434. }
  435. deviceNode = possiblePdo->DeviceObjectExtension->DeviceNode;
  436. isPdo =
  437. (deviceNode && (!(deviceNode->Flags & DNF_LEGACY_RESOURCE_DEVICENODE)));
  438. //
  439. // Free our reference.
  440. //
  441. ObDereferenceObject(possiblePdo);
  442. return isPdo;
  443. }
  444. BOOLEAN
  445. IovUtilIsWdmStack(
  446. IN PDEVICE_OBJECT DeviceObject
  447. )
  448. {
  449. PDEVICE_NODE deviceNode;
  450. PDEVICE_OBJECT possiblePdo;
  451. BOOLEAN isWdmStack;
  452. IovUtilGetBottomDeviceObject(DeviceObject, &possiblePdo);
  453. deviceNode = possiblePdo->DeviceObjectExtension->DeviceNode;
  454. isWdmStack =
  455. (deviceNode && (!(deviceNode->Flags & DNF_LEGACY_RESOURCE_DEVICENODE)));
  456. //
  457. // Free our reference.
  458. //
  459. ObDereferenceObject(possiblePdo);
  460. return isWdmStack;
  461. }
  462. BOOLEAN
  463. FASTCALL
  464. IovUtilHasDispatchHandler(
  465. IN PDRIVER_OBJECT DriverObject,
  466. IN UCHAR MajorFunction
  467. )
  468. {
  469. return (DriverObject->MajorFunction[MajorFunction] != IopInvalidDeviceRequest);
  470. }
  471. BOOLEAN
  472. FASTCALL
  473. IovUtilIsInFdoStack(
  474. IN PDEVICE_OBJECT DeviceObject
  475. )
  476. {
  477. PDEVOBJ_EXTENSION deviceExtension;
  478. PDEVICE_OBJECT deviceAttachedTo, lowerDevobj;
  479. KIRQL irql;
  480. deviceAttachedTo = DeviceObject;
  481. irql = KeAcquireQueuedSpinLock( LockQueueIoDatabaseLock );
  482. do {
  483. if (IovUtilIsDeviceObjectMarked(DeviceObject, MARKTYPE_BOTTOM_OF_FDO_STACK)) {
  484. break;
  485. }
  486. deviceAttachedTo = deviceAttachedTo->DeviceObjectExtension->AttachedTo;
  487. } while ( deviceAttachedTo );
  488. KeReleaseQueuedSpinLock( LockQueueIoDatabaseLock, irql );
  489. return (deviceAttachedTo != NULL);
  490. }
  491. BOOLEAN
  492. FASTCALL
  493. IovUtilIsRawPdo(
  494. IN PDEVICE_OBJECT DeviceObject
  495. )
  496. {
  497. return IovUtilIsDeviceObjectMarked(DeviceObject, MARKTYPE_RAW_PDO);
  498. }
  499. BOOLEAN
  500. FASTCALL
  501. IovUtilIsDesignatedFdo(
  502. IN PDEVICE_OBJECT DeviceObject
  503. )
  504. {
  505. return IovUtilIsDeviceObjectMarked(DeviceObject, MARKTYPE_DESIGNATED_FDO);
  506. }
  507. VOID
  508. FASTCALL
  509. IovUtilMarkDeviceObject(
  510. IN PDEVICE_OBJECT DeviceObject,
  511. IN MARK_TYPE MarkType
  512. )
  513. {
  514. PULONG extensionFlags;
  515. if (!IovUtilVerifierEnabled) {
  516. return;
  517. }
  518. extensionFlags = &DeviceObject->DeviceObjectExtension->ExtensionFlags;
  519. switch(MarkType) {
  520. case MARKTYPE_DELETED:
  521. *extensionFlags |= DOV_DELETED;
  522. break;
  523. case MARKTYPE_BOTTOM_OF_FDO_STACK:
  524. *extensionFlags |= DOV_BOTTOM_OF_FDO_STACK;
  525. break;
  526. case MARKTYPE_DESIGNATED_FDO:
  527. *extensionFlags |= DOV_DESIGNATED_FDO;
  528. break;
  529. case MARKTYPE_RAW_PDO:
  530. *extensionFlags |= DOV_RAW_PDO;
  531. break;
  532. case MARKTYPE_DEVICE_CHECKED:
  533. *extensionFlags |= DOV_FLAGS_CHECKED;
  534. break;
  535. case MARKTYPE_RELATION_PDO_EXAMINED:
  536. *extensionFlags |= DOV_FLAGS_RELATION_EXAMINED;
  537. break;
  538. default:
  539. ASSERT(0);
  540. break;
  541. }
  542. }
  543. BOOLEAN
  544. FASTCALL
  545. IovUtilIsDeviceObjectMarked(
  546. IN PDEVICE_OBJECT DeviceObject,
  547. IN MARK_TYPE MarkType
  548. )
  549. {
  550. ULONG extensionFlags;
  551. extensionFlags = DeviceObject->DeviceObjectExtension->ExtensionFlags;
  552. switch(MarkType) {
  553. case MARKTYPE_DELETED:
  554. return ((extensionFlags & DOV_DELETED) != 0);
  555. case MARKTYPE_BOTTOM_OF_FDO_STACK:
  556. return ((extensionFlags & DOV_BOTTOM_OF_FDO_STACK) != 0);
  557. case MARKTYPE_DESIGNATED_FDO:
  558. return ((extensionFlags & DOV_DESIGNATED_FDO) != 0);
  559. case MARKTYPE_RAW_PDO:
  560. return ((extensionFlags & DOV_RAW_PDO) != 0);
  561. case MARKTYPE_DEVICE_CHECKED:
  562. return ((extensionFlags & DOV_FLAGS_CHECKED) != 0);
  563. case MARKTYPE_RELATION_PDO_EXAMINED:
  564. return ((extensionFlags & DOV_FLAGS_RELATION_EXAMINED) != 0);
  565. default:
  566. ASSERT(0);
  567. return FALSE;
  568. }
  569. }
  570. VOID
  571. FASTCALL
  572. IovUtilMarkStack(
  573. IN PDEVICE_OBJECT PhysicalDeviceObject,
  574. IN PDEVICE_OBJECT BottomOfFdoStack OPTIONAL,
  575. IN PDEVICE_OBJECT FunctionalDeviceObject OPTIONAL,
  576. IN BOOLEAN RawStack
  577. )
  578. /*++
  579. Description:
  580. This routine marks device objects in a PnP stack appropriately. It is
  581. called by AddDevice once the stack is properly constructed.
  582. Arguments:
  583. PhysicalDeviceObject - Device object at the bottom of the PnP stack.
  584. BottomOfFdoStack - First device object added during AddDevice. Below this
  585. device object is either a bus filter or the PDO itself.
  586. FunctionalDeviceObject - Specifies the device object as identified in the
  587. service branch. This should be NULL if the devnode
  588. is raw and no overriding service was specified.
  589. RawStack - True if stack was marked raw.
  590. Return Value:
  591. None.
  592. --*/
  593. {
  594. PDEVICE_OBJECT trueFunctionalDeviceObject;
  595. if (BottomOfFdoStack) {
  596. IovUtilMarkDeviceObject(BottomOfFdoStack, MARKTYPE_BOTTOM_OF_FDO_STACK);
  597. }
  598. if (FunctionalDeviceObject) {
  599. trueFunctionalDeviceObject = FunctionalDeviceObject;
  600. if (IovUtilVerifierEnabled) {
  601. VfDevObjAdjustFdoForVerifierFilters(&trueFunctionalDeviceObject);
  602. }
  603. IovUtilMarkDeviceObject(trueFunctionalDeviceObject, MARKTYPE_DESIGNATED_FDO);
  604. } else if (RawStack) {
  605. IovUtilMarkDeviceObject(PhysicalDeviceObject, MARKTYPE_DESIGNATED_FDO);
  606. IovUtilMarkDeviceObject(PhysicalDeviceObject, MARKTYPE_RAW_PDO);
  607. }
  608. }
  609. VOID
  610. FASTCALL
  611. IovUtilWatermarkIrp(
  612. IN PIRP Irp,
  613. IN ULONG Flags
  614. )
  615. {
  616. if (IovUtilVerifierEnabled) {
  617. VfIrpWatermark(Irp, Flags);
  618. }
  619. }
  620. #else // NO_VERIFIER
  621. //
  622. // The code below should be built into a future stub that deadens out IO
  623. // support for the verifier.
  624. //
  625. VOID
  626. FASTCALL
  627. IovUtilInit(
  628. VOID
  629. )
  630. {
  631. }
  632. VOID
  633. FASTCALL
  634. IovUtilMarkDeviceObject(
  635. IN PDEVICE_OBJECT DeviceObject,
  636. IN MARK_TYPE MarkType
  637. )
  638. {
  639. UNREFERENCED_PARAMETER(DeviceObject);
  640. UNREFERENCED_PARAMETER(MarkType);
  641. }
  642. VOID
  643. FASTCALL
  644. IovUtilMarkStack(
  645. IN PDEVICE_OBJECT PhysicalDeviceObject,
  646. IN PDEVICE_OBJECT BottomOfFdoStack OPTIONAL,
  647. IN PDEVICE_OBJECT FunctionalDeviceObject OPTIONAL,
  648. IN BOOLEAN RawStack
  649. )
  650. {
  651. UNREFERENCED_PARAMETER(PhysicalDeviceObject);
  652. UNREFERENCED_PARAMETER(BottomOfFdoStack);
  653. UNREFERENCED_PARAMETER(FunctionalDeviceObject);
  654. UNREFERENCED_PARAMETER(RawStack);
  655. }
  656. VOID
  657. FASTCALL
  658. IovUtilWatermarkIrp(
  659. IN PIRP Irp,
  660. IN ULONG Flags
  661. )
  662. {
  663. UNREFERENCED_PARAMETER(Irp);
  664. UNREFERENCED_PARAMETER(Flags);
  665. }
  666. #endif // NO_VERIFIER