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.

1478 lines
42 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. vfpnp.c
  5. Abstract:
  6. This module handles Pnp Irp verification.
  7. Author:
  8. Adrian J. Oney (adriao) 20-Apr-1998
  9. Environment:
  10. Kernel mode
  11. Revision History:
  12. AdriaO 06/15/2000 - Seperated out from ntos\io\flunkirp.c
  13. --*/
  14. #include "vfdef.h"
  15. #include "vipnp.h"
  16. #ifdef ALLOC_PRAGMA
  17. #pragma alloc_text(INIT, VfPnpInit)
  18. #pragma alloc_text(PAGEVRFY, VfPnpDumpIrpStack)
  19. #pragma alloc_text(PAGEVRFY, VfPnpVerifyNewRequest)
  20. #pragma alloc_text(PAGEVRFY, VfPnpVerifyIrpStackDownward)
  21. #pragma alloc_text(PAGEVRFY, VfPnpVerifyIrpStackUpward)
  22. #pragma alloc_text(PAGEVRFY, VfPnpIsSystemRestrictedIrp)
  23. #pragma alloc_text(PAGEVRFY, VfPnpAdvanceIrpStatus)
  24. #pragma alloc_text(PAGEVRFY, VfPnpTestStartedPdoStack)
  25. #endif
  26. #ifdef ALLOC_DATA_PRAGMA
  27. #pragma const_seg("PAGEVRFC")
  28. #endif
  29. const PCHAR PnPIrpNames[] = {
  30. "IRP_MN_START_DEVICE", // 0x00
  31. "IRP_MN_QUERY_REMOVE_DEVICE", // 0x01
  32. "IRP_MN_REMOVE_DEVICE - ", // 0x02
  33. "IRP_MN_CANCEL_REMOVE_DEVICE", // 0x03
  34. "IRP_MN_STOP_DEVICE", // 0x04
  35. "IRP_MN_QUERY_STOP_DEVICE", // 0x05
  36. "IRP_MN_CANCEL_STOP_DEVICE", // 0x06
  37. "IRP_MN_QUERY_DEVICE_RELATIONS", // 0x07
  38. "IRP_MN_QUERY_INTERFACE", // 0x08
  39. "IRP_MN_QUERY_CAPABILITIES", // 0x09
  40. "IRP_MN_QUERY_RESOURCES", // 0x0A
  41. "IRP_MN_QUERY_RESOURCE_REQUIREMENTS", // 0x0B
  42. "IRP_MN_QUERY_DEVICE_TEXT", // 0x0C
  43. "IRP_MN_FILTER_RESOURCE_REQUIREMENTS", // 0x0D
  44. "INVALID_IRP_CODE", //
  45. "IRP_MN_READ_CONFIG", // 0x0F
  46. "IRP_MN_WRITE_CONFIG", // 0x10
  47. "IRP_MN_EJECT", // 0x11
  48. "IRP_MN_SET_LOCK", // 0x12
  49. "IRP_MN_QUERY_ID", // 0x13
  50. "IRP_MN_QUERY_PNP_DEVICE_STATE", // 0x14
  51. "IRP_MN_QUERY_BUS_INFORMATION", // 0x15
  52. "IRP_MN_DEVICE_USAGE_NOTIFICATION", // 0x16
  53. "IRP_MN_SURPRISE_REMOVAL", // 0x17
  54. "IRP_MN_QUERY_LEGACY_BUS_INFORMATION", // 0x18
  55. NULL
  56. };
  57. #define MAX_NAMED_PNP_IRP 0x18
  58. #include <initguid.h>
  59. DEFINE_GUID( GUID_BOGUS_INTERFACE, 0x00000000L, 0x0000, 0x0000,
  60. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
  61. #ifdef ALLOC_DATA_PRAGMA
  62. #pragma const_seg()
  63. #endif // ALLOC_DATA_PRAGMA
  64. VOID
  65. VfPnpInit(
  66. VOID
  67. )
  68. {
  69. VfMajorRegisterHandlers(
  70. IRP_MJ_PNP,
  71. VfPnpDumpIrpStack,
  72. VfPnpVerifyNewRequest,
  73. VfPnpVerifyIrpStackDownward,
  74. VfPnpVerifyIrpStackUpward,
  75. VfPnpIsSystemRestrictedIrp,
  76. VfPnpAdvanceIrpStatus,
  77. NULL,
  78. NULL,
  79. NULL,
  80. NULL,
  81. VfPnpTestStartedPdoStack
  82. );
  83. }
  84. VOID
  85. FASTCALL
  86. VfPnpVerifyNewRequest(
  87. IN PIOV_REQUEST_PACKET IovPacket,
  88. IN PDEVICE_OBJECT DeviceObject,
  89. IN PIO_STACK_LOCATION IrpLastSp OPTIONAL,
  90. IN PIO_STACK_LOCATION IrpSp,
  91. IN PIOV_STACK_LOCATION StackLocationData,
  92. IN PVOID CallerAddress OPTIONAL
  93. )
  94. {
  95. PIRP irp;
  96. NTSTATUS currentStatus;
  97. PDEVICE_OBJECT possiblePdo;
  98. PDEVICE_CAPABILITIES deviceCapabilities;
  99. UNREFERENCED_PARAMETER (IrpLastSp);
  100. irp = IovPacket->TrackedIrp;
  101. currentStatus = irp->IoStatus.Status;
  102. //
  103. // Verify new IRPs start out life accordingly
  104. //
  105. if (currentStatus!=STATUS_NOT_SUPPORTED) {
  106. //
  107. // This is a special WDM (9x) compatibility hack.
  108. //
  109. if ((IrpSp->MinorFunction != IRP_MN_FILTER_RESOURCE_REQUIREMENTS) &&
  110. (!(IovPacket->Flags & TRACKFLAG_BOGUS))) {
  111. WDM_FAIL_ROUTINE((
  112. DCERROR_PNP_IRP_BAD_INITIAL_STATUS,
  113. DCPARAM_IRP + DCPARAM_ROUTINE,
  114. CallerAddress,
  115. irp
  116. ));
  117. }
  118. //
  119. // Don't blame anyone else for this guy's mistake.
  120. //
  121. if (!NT_SUCCESS(currentStatus)) {
  122. StackLocationData->Flags |= STACKFLAG_FAILURE_FORWARDED;
  123. }
  124. }
  125. if (IrpSp->MinorFunction == IRP_MN_QUERY_CAPABILITIES) {
  126. deviceCapabilities = IrpSp->Parameters.DeviceCapabilities.Capabilities;
  127. if (VfUtilIsMemoryRangeReadable(deviceCapabilities, sizeof(DEVICE_CAPABILITIES), VFMP_INSTANT_NONPAGED)) {
  128. //
  129. // Verify fields are initialized correctly
  130. //
  131. if (deviceCapabilities->Version < 1) {
  132. //
  133. // Whoops, it didn't initialize the version correctly!
  134. //
  135. WDM_FAIL_ROUTINE((
  136. DCERROR_PNP_QUERY_CAP_BAD_VERSION,
  137. DCPARAM_IRP + DCPARAM_ROUTINE,
  138. CallerAddress,
  139. irp
  140. ));
  141. }
  142. if (deviceCapabilities->Size < sizeof(DEVICE_CAPABILITIES)) {
  143. //
  144. // Whoops, it didn't initialize the size field correctly!
  145. //
  146. WDM_FAIL_ROUTINE((
  147. DCERROR_PNP_QUERY_CAP_BAD_SIZE,
  148. DCPARAM_IRP + DCPARAM_ROUTINE,
  149. CallerAddress,
  150. irp
  151. ));
  152. }
  153. if (deviceCapabilities->Address != (ULONG) -1) {
  154. //
  155. // Whoops, it didn't initialize the address field correctly!
  156. //
  157. WDM_FAIL_ROUTINE((
  158. DCERROR_PNP_QUERY_CAP_BAD_ADDRESS,
  159. DCPARAM_IRP + DCPARAM_ROUTINE,
  160. CallerAddress,
  161. irp
  162. ));
  163. }
  164. if (deviceCapabilities->UINumber != (ULONG) -1) {
  165. //
  166. // Whoops, it didn't initialize the UI number field correctly!
  167. //
  168. WDM_FAIL_ROUTINE((
  169. DCERROR_PNP_QUERY_CAP_BAD_UI_NUM,
  170. DCPARAM_IRP + DCPARAM_ROUTINE,
  171. CallerAddress,
  172. irp
  173. ));
  174. }
  175. }
  176. }
  177. //
  178. // If this is a target device relation IRP, verify the appropriate
  179. // object will be referenced.
  180. //
  181. if (!VfSettingsIsOptionEnabled(IovPacket->VerifierSettings, VERIFIER_OPTION_TEST_TARGET_REFCOUNT)) {
  182. return;
  183. }
  184. if ((IrpSp->MinorFunction == IRP_MN_QUERY_DEVICE_RELATIONS)&&
  185. (IrpSp->Parameters.QueryDeviceRelations.Type == TargetDeviceRelation)) {
  186. IovUtilGetBottomDeviceObject(DeviceObject, &possiblePdo);
  187. if (IovUtilIsPdo(possiblePdo)) {
  188. if (StackLocationData->ReferencingObject == NULL) {
  189. //
  190. // Got'm!
  191. //
  192. StackLocationData->Flags |= STACKFLAG_CHECK_FOR_REFERENCE;
  193. StackLocationData->ReferencingObject = possiblePdo;
  194. StackLocationData->ReferencingCount = ObvUtilStartObRefMonitoring(possiblePdo);
  195. IovPacket->RefTrackingCount++;
  196. }
  197. }
  198. //
  199. // Free our reference (we will have one if we are snapshotting anyway)
  200. //
  201. ObDereferenceObject(possiblePdo);
  202. }
  203. }
  204. VOID
  205. FASTCALL
  206. VfPnpVerifyIrpStackDownward(
  207. IN PIOV_REQUEST_PACKET IovPacket,
  208. IN PDEVICE_OBJECT DeviceObject,
  209. IN PIO_STACK_LOCATION IrpLastSp OPTIONAL,
  210. IN PIO_STACK_LOCATION IrpSp,
  211. IN PIOV_STACK_LOCATION RequestHeadLocationData,
  212. IN PIOV_STACK_LOCATION StackLocationData,
  213. IN PVOID CallerAddress OPTIONAL
  214. )
  215. {
  216. PIRP irp;
  217. NTSTATUS currentStatus, lastStatus;
  218. BOOLEAN statusChanged;
  219. PDRIVER_OBJECT driverObject;
  220. PIOV_SESSION_DATA iovSessionData;
  221. HOW_PROCESSED howProcessed;
  222. VF_DEVOBJ_TYPE devObjType;
  223. UNREFERENCED_PARAMETER (StackLocationData);
  224. if (!IovUtilIsWdmStack(DeviceObject)) {
  225. return;
  226. }
  227. irp = IovPacket->TrackedIrp;
  228. currentStatus = irp->IoStatus.Status;
  229. lastStatus = RequestHeadLocationData->LastStatusBlock.Status;
  230. statusChanged = (BOOLEAN)(currentStatus != lastStatus);
  231. iovSessionData = VfPacketGetCurrentSessionData(IovPacket);
  232. //
  233. // Verify the IRP was forwarded properly
  234. //
  235. switch(iovSessionData->ForwardMethod) {
  236. case SKIPPED_A_DO:
  237. WDM_FAIL_ROUTINE((
  238. DCERROR_SKIPPED_DEVICE_OBJECT,
  239. DCPARAM_IRP + DCPARAM_ROUTINE,
  240. CallerAddress,
  241. irp
  242. ));
  243. break;
  244. case STARTED_TOP_OF_STACK:
  245. case FORWARDED_TO_NEXT_DO:
  246. //
  247. // Perfectly normal
  248. //
  249. break;
  250. case STARTED_INSIDE_STACK:
  251. //
  252. // Probably an Internal irp (query cap's, etc)
  253. //
  254. break;
  255. case CHANGED_STACKS_MID_STACK:
  256. case CHANGED_STACKS_AT_BOTTOM:
  257. //
  258. // ADRIAO N.B. - Ensure drivers aren't rerouting certain IRPs off
  259. // PnP stacks.
  260. //
  261. #if 0
  262. ASSERT(0);
  263. #endif
  264. break ;
  265. }
  266. //
  267. // For some IRP major's going down a stack, there *must* be a handler
  268. //
  269. driverObject = DeviceObject->DriverObject;
  270. if (!IovUtilHasDispatchHandler(driverObject, IRP_MJ_PNP)) {
  271. RequestHeadLocationData->Flags |= STACKFLAG_BOGUS_IRP_TOUCHED;
  272. WDM_FAIL_ROUTINE((
  273. DCERROR_MISSING_DISPATCH_FUNCTION,
  274. DCPARAM_IRP + DCPARAM_ROUTINE,
  275. driverObject->DriverInit,
  276. irp
  277. ));
  278. StackLocationData->Flags |= STACKFLAG_NO_HANDLER;
  279. }
  280. //
  281. // The following is only executed if we are not a new IRP...
  282. //
  283. if (IrpLastSp == NULL) {
  284. return;
  285. }
  286. //
  287. // The only legit failure code to pass down is STATUS_NOT_SUPPORTED
  288. //
  289. if ((!NT_SUCCESS(currentStatus)) && (currentStatus != STATUS_NOT_SUPPORTED) &&
  290. (!(RequestHeadLocationData->Flags & STACKFLAG_FAILURE_FORWARDED))) {
  291. WDM_FAIL_ROUTINE((
  292. DCERROR_PNP_FAILURE_FORWARDED,
  293. DCPARAM_IRP + DCPARAM_ROUTINE,
  294. CallerAddress,
  295. irp
  296. ));
  297. //
  298. // Don't blame anyone else for this driver's mistakes...
  299. //
  300. RequestHeadLocationData->Flags |= STACKFLAG_FAILURE_FORWARDED;
  301. }
  302. //
  303. // Status of a PnP IRP may not be converted to
  304. // STATUS_NOT_SUPPORTED on the way down
  305. //
  306. if ((currentStatus == STATUS_NOT_SUPPORTED)&&statusChanged&&
  307. (!(RequestHeadLocationData->Flags & STACKFLAG_FAILURE_FORWARDED))) {
  308. WDM_FAIL_ROUTINE((
  309. DCERROR_PNP_IRP_STATUS_RESET,
  310. DCPARAM_IRP + DCPARAM_ROUTINE,
  311. CallerAddress,
  312. irp
  313. ));
  314. //
  315. // Don't blame anyone else for this driver's mistakes...
  316. //
  317. RequestHeadLocationData->Flags |= STACKFLAG_FAILURE_FORWARDED;
  318. }
  319. //
  320. // Some IRPs FDO's are required to handle before passing down. And some
  321. // IRPs should not be touched by the FDO. Assert it is so...
  322. //
  323. if ((!iovSessionData->DeviceLastCalled) ||
  324. (!IovUtilIsDesignatedFdo(iovSessionData->DeviceLastCalled))) {
  325. return;
  326. }
  327. if (currentStatus != STATUS_NOT_SUPPORTED) {
  328. howProcessed = DEFINITELY_PROCESSED;
  329. } else if (IrpSp->CompletionRoutine == NULL) {
  330. howProcessed = NOT_PROCESSED;
  331. } else {
  332. howProcessed = POSSIBLY_PROCESSED;
  333. }
  334. //
  335. // How could a Raw FDO (aka a PDO) get here? Well, a PDO could forward
  336. // to another stack if he's purposely reserved enough stack locations
  337. // for that eventuality.
  338. //
  339. devObjType = IovUtilIsRawPdo(iovSessionData->DeviceLastCalled) ?
  340. VF_DEVOBJ_PDO : VF_DEVOBJ_FDO;
  341. ViPnpVerifyMinorWasProcessedProperly(
  342. irp,
  343. IrpSp,
  344. devObjType,
  345. iovSessionData->VerifierSettings,
  346. howProcessed,
  347. CallerAddress
  348. );
  349. }
  350. VOID
  351. FASTCALL
  352. VfPnpVerifyIrpStackUpward(
  353. IN PIOV_REQUEST_PACKET IovPacket,
  354. IN PIO_STACK_LOCATION IrpSp,
  355. IN PIOV_STACK_LOCATION RequestHeadLocationData,
  356. IN PIOV_STACK_LOCATION StackLocationData,
  357. IN BOOLEAN IsNewlyCompleted,
  358. IN BOOLEAN RequestFinalized
  359. )
  360. {
  361. PIRP irp;
  362. NTSTATUS currentStatus;
  363. BOOLEAN mustPassDown, isBogusIrp, isPdo, touchable;
  364. PVOID routine;
  365. LONG referencesTaken;
  366. PDEVICE_RELATIONS deviceRelations;
  367. PIOV_SESSION_DATA iovSessionData;
  368. ULONG index, swapIndex;
  369. PDEVICE_OBJECT swapObject, lowerDevObj;
  370. HOW_PROCESSED howProcessed;
  371. UNREFERENCED_PARAMETER (RequestFinalized);
  372. if (!IovUtilIsWdmStack(IrpSp->DeviceObject)) {
  373. return;
  374. }
  375. isPdo = FALSE;
  376. irp = IovPacket->TrackedIrp;
  377. currentStatus = irp->IoStatus.Status;
  378. iovSessionData = VfPacketGetCurrentSessionData(IovPacket);
  379. //
  380. // Who'd we call for this one?
  381. //
  382. routine = StackLocationData->LastDispatch;
  383. ASSERT(routine) ;
  384. //
  385. // If this "Request" has been "Completed", perform some checks
  386. //
  387. if (IsNewlyCompleted) {
  388. //
  389. // Remember bogosity...
  390. //
  391. isBogusIrp = (BOOLEAN)((IovPacket->Flags&TRACKFLAG_BOGUS)!=0);
  392. //
  393. // Is this a PDO?
  394. //
  395. isPdo = (BOOLEAN)((StackLocationData->Flags&STACKFLAG_REACHED_PDO)!=0);
  396. //
  397. // Was anything completed too early?
  398. // A driver may outright fail almost anything but a bogus IRP
  399. //
  400. mustPassDown = (BOOLEAN)(!(StackLocationData->Flags&STACKFLAG_NO_HANDLER));
  401. mustPassDown &= (!isPdo);
  402. mustPassDown &= (isBogusIrp || NT_SUCCESS(currentStatus) || (currentStatus == STATUS_NOT_SUPPORTED));
  403. if (mustPassDown) {
  404. //
  405. // Print appropriate error message
  406. //
  407. if (IovPacket->Flags&TRACKFLAG_BOGUS) {
  408. WDM_FAIL_ROUTINE((
  409. DCERROR_BOGUS_PNP_IRP_COMPLETED,
  410. DCPARAM_IRP + DCPARAM_ROUTINE,
  411. routine,
  412. irp
  413. ));
  414. } else if (NT_SUCCESS(currentStatus)) {
  415. WDM_FAIL_ROUTINE((
  416. DCERROR_SUCCESSFUL_PNP_IRP_NOT_FORWARDED,
  417. DCPARAM_IRP + DCPARAM_ROUTINE,
  418. routine,
  419. irp
  420. ));
  421. } else if (currentStatus == STATUS_NOT_SUPPORTED) {
  422. WDM_FAIL_ROUTINE((
  423. DCERROR_UNTOUCHED_PNP_IRP_NOT_FORWARDED,
  424. DCPARAM_IRP + DCPARAM_ROUTINE,
  425. routine,
  426. irp
  427. ));
  428. }
  429. }
  430. }
  431. //
  432. // Did the PDO respond to it's required set of IRPs?
  433. //
  434. if (IsNewlyCompleted && isPdo) {
  435. if (currentStatus != STATUS_NOT_SUPPORTED) {
  436. howProcessed = DEFINITELY_PROCESSED;
  437. } else {
  438. howProcessed = POSSIBLY_PROCESSED;
  439. }
  440. ViPnpVerifyMinorWasProcessedProperly(
  441. irp,
  442. IrpSp,
  443. VF_DEVOBJ_PDO,
  444. iovSessionData->VerifierSettings,
  445. howProcessed,
  446. routine
  447. );
  448. }
  449. //
  450. // Was TargetDeviceRelation implemented correctly?
  451. //
  452. if (IsNewlyCompleted &&
  453. (RequestHeadLocationData->Flags&STACKFLAG_CHECK_FOR_REFERENCE)) {
  454. ASSERT ((IrpSp->MajorFunction == IRP_MJ_PNP)&&
  455. (IrpSp->MinorFunction == IRP_MN_QUERY_DEVICE_RELATIONS)&&
  456. (IrpSp->Parameters.QueryDeviceRelations.Type == TargetDeviceRelation));
  457. ASSERT(RequestHeadLocationData->ReferencingObject);
  458. ASSERT(IovPacket->RefTrackingCount);
  459. referencesTaken = ObvUtilStopObRefMonitoring(
  460. RequestHeadLocationData->ReferencingObject,
  461. RequestHeadLocationData->ReferencingCount
  462. );
  463. IovPacket->RefTrackingCount--;
  464. RequestHeadLocationData->ReferencingObject = NULL;
  465. RequestHeadLocationData->Flags &= ~STACKFLAG_CHECK_FOR_REFERENCE;
  466. if (NT_SUCCESS(currentStatus)&&(!referencesTaken)) {
  467. WDM_FAIL_ROUTINE((
  468. DCERROR_TARGET_RELATION_NEEDS_REF,
  469. DCPARAM_IRP + DCPARAM_ROUTINE,
  470. routine,
  471. irp
  472. ));
  473. }
  474. }
  475. //
  476. // Did anyone stomp the status erroneously?
  477. //
  478. if ((currentStatus == STATUS_NOT_SUPPORTED) &&
  479. (!(RequestHeadLocationData->Flags & STACKFLAG_FAILURE_FORWARDED)) &&
  480. (currentStatus != RequestHeadLocationData->LastStatusBlock.Status)) {
  481. //
  482. // Status of a PnP or Power IRP may not be converted from success to
  483. // STATUS_NOT_SUPPORTED on the way down.
  484. //
  485. WDM_FAIL_ROUTINE((
  486. DCERROR_PNP_IRP_STATUS_RESET,
  487. DCPARAM_IRP + DCPARAM_ROUTINE,
  488. routine,
  489. irp
  490. ));
  491. //
  492. // Don't blame anyone else for this driver's mistakes...
  493. //
  494. RequestHeadLocationData->Flags |= STACKFLAG_FAILURE_FORWARDED;
  495. }
  496. switch(IrpSp->MinorFunction) {
  497. case IRP_MN_QUERY_DEVICE_RELATIONS:
  498. //
  499. // Rotate device relations if so ordered.
  500. //
  501. if ((RequestHeadLocationData == StackLocationData) &&
  502. ((IrpSp->Parameters.QueryDeviceRelations.Type == BusRelations) ||
  503. (IrpSp->Parameters.QueryDeviceRelations.Type == RemovalRelations) ||
  504. (IrpSp->Parameters.QueryDeviceRelations.Type == EjectionRelations)) &&
  505. VfSettingsIsOptionEnabled(iovSessionData->VerifierSettings,
  506. VERIFIER_OPTION_SCRAMBLE_RELATIONS)) {
  507. if (NT_SUCCESS(currentStatus) && irp->IoStatus.Information) {
  508. deviceRelations = (PDEVICE_RELATIONS) irp->IoStatus.Information;
  509. touchable = VfUtilIsMemoryRangeReadable(
  510. deviceRelations,
  511. (sizeof(DEVICE_RELATIONS)-sizeof(PVOID)),
  512. VFMP_INSTANT_NONPAGED
  513. );
  514. if (!touchable) {
  515. break;
  516. }
  517. touchable = VfUtilIsMemoryRangeReadable(
  518. deviceRelations,
  519. (sizeof(DEVICE_RELATIONS)-(deviceRelations->Count-1)*sizeof(PVOID)),
  520. VFMP_INSTANT_NONPAGED
  521. );
  522. if (!touchable) {
  523. break;
  524. }
  525. if (deviceRelations->Count > 1) {
  526. //
  527. // Scramble the relation list by random swapping.
  528. //
  529. for(index = 0; index < (deviceRelations->Count+1)/2; index++) {
  530. swapIndex = VfRandomGetNumber(1, deviceRelations->Count-1);
  531. swapObject = deviceRelations->Objects[0];
  532. deviceRelations->Objects[0] = deviceRelations->Objects[swapIndex];
  533. deviceRelations->Objects[swapIndex] = swapObject;
  534. }
  535. }
  536. }
  537. }
  538. break;
  539. case IRP_MN_SURPRISE_REMOVAL:
  540. if (VfSettingsIsOptionEnabled(iovSessionData->VerifierSettings,
  541. VERIFIER_OPTION_MONITOR_REMOVES)) {
  542. //
  543. // Verify driver didn't do an IoDetachDevice upon recieving the
  544. // SURPRISE_REMOVAL IRP.
  545. //
  546. IovUtilGetLowerDeviceObject(IrpSp->DeviceObject, &lowerDevObj);
  547. if (lowerDevObj) {
  548. ObDereferenceObject(lowerDevObj);
  549. } else if (!IovUtilIsPdo(IrpSp->DeviceObject)) {
  550. WDM_FAIL_ROUTINE((
  551. DCERROR_DETACHED_IN_SURPRISE_REMOVAL,
  552. DCPARAM_IRP + DCPARAM_ROUTINE + DCPARAM_DEVOBJ,
  553. routine,
  554. iovSessionData->BestVisibleIrp,
  555. IrpSp->DeviceObject
  556. ));
  557. }
  558. //
  559. // Verify driver didn't do an IoDeleteDevice upon recieving the
  560. // SURPRISE_REMOVAL IRP.
  561. //
  562. if (IovUtilIsDeviceObjectMarked(IrpSp->DeviceObject, MARKTYPE_DELETED)) {
  563. WDM_FAIL_ROUTINE((
  564. DCERROR_DELETED_IN_SURPRISE_REMOVAL,
  565. DCPARAM_IRP + DCPARAM_ROUTINE + DCPARAM_DEVOBJ,
  566. routine,
  567. iovSessionData->BestVisibleIrp,
  568. IrpSp->DeviceObject
  569. ));
  570. }
  571. }
  572. break;
  573. default:
  574. break;
  575. }
  576. }
  577. VOID
  578. FASTCALL
  579. VfPnpDumpIrpStack(
  580. IN PIO_STACK_LOCATION IrpSp
  581. )
  582. {
  583. DbgPrint("IRP_MJ_PNP.");
  584. if (IrpSp->MinorFunction<=MAX_NAMED_PNP_IRP) {
  585. DbgPrint(PnPIrpNames[IrpSp->MinorFunction]);
  586. } else if (IrpSp->MinorFunction==0xFF) {
  587. DbgPrint("IRP_MN_BOGUS");
  588. } else {
  589. DbgPrint("(Bogus)");
  590. }
  591. switch(IrpSp->MinorFunction) {
  592. case IRP_MN_QUERY_DEVICE_RELATIONS:
  593. switch(IrpSp->Parameters.QueryDeviceRelations.Type) {
  594. case BusRelations:
  595. DbgPrint("(BusRelations)");
  596. break;
  597. case EjectionRelations:
  598. DbgPrint("(EjectionRelations)");
  599. break;
  600. case PowerRelations:
  601. DbgPrint("(PowerRelations)");
  602. break;
  603. case RemovalRelations:
  604. DbgPrint("(RemovalRelations)");
  605. break;
  606. case TargetDeviceRelation:
  607. DbgPrint("(TargetDeviceRelation)");
  608. break;
  609. default:
  610. DbgPrint("(Bogus)");
  611. break;
  612. }
  613. break;
  614. case IRP_MN_QUERY_INTERFACE:
  615. break;
  616. case IRP_MN_QUERY_DEVICE_TEXT:
  617. switch(IrpSp->Parameters.QueryId.IdType) {
  618. case DeviceTextDescription:
  619. DbgPrint("(DeviceTextDescription)");
  620. break;
  621. case DeviceTextLocationInformation:
  622. DbgPrint("(DeviceTextLocationInformation)");
  623. break;
  624. default:
  625. DbgPrint("(Bogus)");
  626. break;
  627. }
  628. break;
  629. case IRP_MN_WRITE_CONFIG:
  630. case IRP_MN_READ_CONFIG:
  631. DbgPrint("(WhichSpace=%x, Buffer=%x, Offset=%x, Length=%x)",
  632. IrpSp->Parameters.ReadWriteConfig.WhichSpace,
  633. IrpSp->Parameters.ReadWriteConfig.Buffer,
  634. IrpSp->Parameters.ReadWriteConfig.Offset,
  635. IrpSp->Parameters.ReadWriteConfig.Length
  636. );
  637. break;
  638. case IRP_MN_SET_LOCK:
  639. if (IrpSp->Parameters.SetLock.Lock) DbgPrint("(True)");
  640. else DbgPrint("(False)");
  641. break;
  642. case IRP_MN_QUERY_ID:
  643. switch(IrpSp->Parameters.QueryId.IdType) {
  644. case BusQueryDeviceID:
  645. DbgPrint("(BusQueryDeviceID)");
  646. break;
  647. case BusQueryHardwareIDs:
  648. DbgPrint("(BusQueryHardwareIDs)");
  649. break;
  650. case BusQueryCompatibleIDs:
  651. DbgPrint("(BusQueryCompatibleIDs)");
  652. break;
  653. case BusQueryInstanceID:
  654. DbgPrint("(BusQueryInstanceID)");
  655. break;
  656. default:
  657. DbgPrint("(Bogus)");
  658. break;
  659. }
  660. break;
  661. case IRP_MN_QUERY_BUS_INFORMATION:
  662. break;
  663. case IRP_MN_DEVICE_USAGE_NOTIFICATION:
  664. switch(IrpSp->Parameters.UsageNotification.Type) {
  665. case DeviceUsageTypeUndefined:
  666. DbgPrint("(DeviceUsageTypeUndefined");
  667. break;
  668. case DeviceUsageTypePaging:
  669. DbgPrint("(DeviceUsageTypePaging");
  670. break;
  671. case DeviceUsageTypeHibernation:
  672. DbgPrint("(DeviceUsageTypeHibernation");
  673. break;
  674. case DeviceUsageTypeDumpFile:
  675. DbgPrint("(DeviceUsageTypeDumpFile");
  676. break;
  677. default:
  678. DbgPrint("(Bogus)");
  679. break;
  680. }
  681. if (IrpSp->Parameters.UsageNotification.InPath) {
  682. DbgPrint(", InPath=TRUE)");
  683. } else {
  684. DbgPrint(", InPath=FALSE)");
  685. }
  686. break;
  687. case IRP_MN_QUERY_LEGACY_BUS_INFORMATION:
  688. break;
  689. default:
  690. break;
  691. }
  692. }
  693. BOOLEAN
  694. FASTCALL
  695. VfPnpIsSystemRestrictedIrp(
  696. IN PIO_STACK_LOCATION IrpSp
  697. )
  698. {
  699. switch(IrpSp->MinorFunction) {
  700. case IRP_MN_START_DEVICE:
  701. case IRP_MN_QUERY_REMOVE_DEVICE:
  702. case IRP_MN_REMOVE_DEVICE:
  703. case IRP_MN_CANCEL_REMOVE_DEVICE:
  704. case IRP_MN_STOP_DEVICE:
  705. case IRP_MN_QUERY_STOP_DEVICE:
  706. case IRP_MN_CANCEL_STOP_DEVICE:
  707. case IRP_MN_SURPRISE_REMOVAL:
  708. return TRUE;
  709. case IRP_MN_QUERY_DEVICE_RELATIONS:
  710. switch(IrpSp->Parameters.QueryDeviceRelations.Type) {
  711. case BusRelations:
  712. case PowerRelations:
  713. return TRUE;
  714. case RemovalRelations:
  715. case EjectionRelations:
  716. case TargetDeviceRelation:
  717. return FALSE;
  718. default:
  719. break;
  720. }
  721. break;
  722. case IRP_MN_QUERY_INTERFACE:
  723. case IRP_MN_QUERY_CAPABILITIES:
  724. return FALSE;
  725. case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
  726. case IRP_MN_QUERY_DEVICE_TEXT:
  727. return TRUE;
  728. case IRP_MN_READ_CONFIG:
  729. case IRP_MN_WRITE_CONFIG:
  730. return FALSE;
  731. case IRP_MN_EJECT:
  732. case IRP_MN_SET_LOCK:
  733. case IRP_MN_QUERY_RESOURCES:
  734. case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
  735. case IRP_MN_QUERY_LEGACY_BUS_INFORMATION:
  736. return TRUE;
  737. case IRP_MN_QUERY_ID:
  738. switch(IrpSp->Parameters.QueryId.IdType) {
  739. case BusQueryHardwareIDs:
  740. case BusQueryCompatibleIDs:
  741. return TRUE;
  742. case BusQueryDeviceID:
  743. case BusQueryInstanceID:
  744. return FALSE;
  745. default:
  746. break;
  747. }
  748. break;
  749. case IRP_MN_QUERY_PNP_DEVICE_STATE:
  750. case IRP_MN_QUERY_BUS_INFORMATION:
  751. return TRUE;
  752. case IRP_MN_DEVICE_USAGE_NOTIFICATION:
  753. return FALSE;
  754. default:
  755. break;
  756. }
  757. return TRUE;
  758. }
  759. BOOLEAN
  760. FASTCALL
  761. VfPnpAdvanceIrpStatus(
  762. IN PIO_STACK_LOCATION IrpSp,
  763. IN NTSTATUS OriginalStatus,
  764. IN OUT NTSTATUS *StatusToAdvance
  765. )
  766. /*++
  767. Description:
  768. Given an IRP stack pointer, is it legal to change the status for
  769. debug-ability? If so, this function determines what the new status
  770. should be. Note that for each stack location, this function is iterated
  771. over n times where n is equal to the number of drivers who IoSkip'd this
  772. location.
  773. Arguments:
  774. IrpSp - Current stack right after complete for the given stack
  775. location, but before the completion routine for the
  776. stack location above has been called.
  777. OriginalStatus - The status of the IRP at the time listed above. Does
  778. not change over iteration per skipping driver.
  779. StatusToAdvance - Pointer to the current status that should be updated.
  780. Return Value:
  781. TRUE if the status has been adjusted, FALSE otherwise (in this case
  782. StatusToAdvance is untouched).
  783. --*/
  784. {
  785. UNREFERENCED_PARAMETER (IrpSp);
  786. if (((ULONG) OriginalStatus) >= 256) {
  787. return FALSE;
  788. }
  789. (*StatusToAdvance)++;
  790. if ((*StatusToAdvance) == STATUS_PENDING) {
  791. (*StatusToAdvance)++;
  792. }
  793. return TRUE;
  794. }
  795. VOID
  796. FASTCALL
  797. VfPnpTestStartedPdoStack(
  798. IN PDEVICE_OBJECT PhysicalDeviceObject
  799. )
  800. /*++
  801. Description:
  802. As per the title, we are going to throw some IRPs at the stack to
  803. see if they are handled correctly.
  804. Returns:
  805. Nothing
  806. --*/
  807. {
  808. IO_STACK_LOCATION irpSp;
  809. PDEVICE_RELATIONS targetDeviceRelationList;
  810. INTERFACE interface;
  811. NTSTATUS status;
  812. PAGED_CODE();
  813. //
  814. // Initialize the stack location to pass to IopSynchronousCall()
  815. //
  816. RtlZeroMemory(&irpSp, sizeof(IO_STACK_LOCATION));
  817. //
  818. // send lots of bogus PNP IRPs
  819. //
  820. irpSp.MajorFunction = IRP_MJ_PNP;
  821. irpSp.MinorFunction = 0xff;
  822. VfIrpSendSynchronousIrp(
  823. PhysicalDeviceObject,
  824. &irpSp,
  825. TRUE,
  826. STATUS_NOT_SUPPORTED,
  827. 0,
  828. NULL,
  829. NULL
  830. );
  831. irpSp.MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS;
  832. irpSp.Parameters.QueryDeviceRelations.Type = (DEVICE_RELATION_TYPE) -1;
  833. VfIrpSendSynchronousIrp(
  834. PhysicalDeviceObject,
  835. &irpSp,
  836. TRUE,
  837. STATUS_NOT_SUPPORTED,
  838. 0,
  839. NULL,
  840. NULL
  841. );
  842. if (VfSettingsIsOptionEnabled(NULL, VERIFIER_OPTION_RELATION_IGNORANCE_TEST)) {
  843. irpSp.MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS;
  844. irpSp.Parameters.QueryDeviceRelations.Type = (DEVICE_RELATION_TYPE) -1;
  845. VfIrpSendSynchronousIrp(
  846. PhysicalDeviceObject,
  847. &irpSp,
  848. TRUE,
  849. STATUS_NOT_SUPPORTED,
  850. (ULONG_PTR) -1,
  851. NULL,
  852. NULL
  853. );
  854. }
  855. irpSp.MinorFunction = IRP_MN_QUERY_DEVICE_TEXT;
  856. irpSp.Parameters.QueryDeviceText.DeviceTextType = (DEVICE_TEXT_TYPE) -1;
  857. VfIrpSendSynchronousIrp(
  858. PhysicalDeviceObject,
  859. &irpSp,
  860. TRUE,
  861. STATUS_NOT_SUPPORTED,
  862. 0,
  863. NULL,
  864. NULL
  865. );
  866. irpSp.MinorFunction = IRP_MN_QUERY_ID;
  867. irpSp.Parameters.QueryId.IdType = (BUS_QUERY_ID_TYPE) -1;
  868. VfIrpSendSynchronousIrp(
  869. PhysicalDeviceObject,
  870. &irpSp,
  871. TRUE,
  872. STATUS_NOT_SUPPORTED,
  873. 0,
  874. NULL,
  875. NULL
  876. );
  877. /*
  878. irpSp.MinorFunction = IRP_MN_QUERY_ID;
  879. irpSp.Parameters.QueryId.IdType = (BUS_QUERY_ID_TYPE) -1;
  880. VfIrpSendSynchronousIrp(
  881. PhysicalDeviceObject,
  882. &irpSp,
  883. TRUE,
  884. STATUS_SUCCESS,
  885. (ULONG_PTR) -1,
  886. NULL,
  887. NULL
  888. );
  889. */
  890. //
  891. // Target device relation test...
  892. //
  893. irpSp.MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS;
  894. irpSp.Parameters.QueryDeviceRelations.Type = TargetDeviceRelation;
  895. targetDeviceRelationList = NULL;
  896. if (VfIrpSendSynchronousIrp(
  897. PhysicalDeviceObject,
  898. &irpSp,
  899. FALSE,
  900. STATUS_NOT_SUPPORTED,
  901. 0,
  902. (ULONG_PTR *) &targetDeviceRelationList,
  903. &status
  904. )) {
  905. if (NT_SUCCESS(status)) {
  906. ASSERT(targetDeviceRelationList);
  907. ASSERT(targetDeviceRelationList->Count == 1);
  908. ASSERT(targetDeviceRelationList->Objects[0]);
  909. ObDereferenceObject(targetDeviceRelationList->Objects[0]);
  910. ExFreePool(targetDeviceRelationList);
  911. } else {
  912. //
  913. // IRP was asserted in other code. We need to do nothing here...
  914. //
  915. }
  916. }
  917. RtlZeroMemory(&interface, sizeof(INTERFACE));
  918. irpSp.MinorFunction = IRP_MN_QUERY_INTERFACE;
  919. irpSp.Parameters.QueryInterface.Size = (USHORT)-1;
  920. irpSp.Parameters.QueryInterface.Version = 1;
  921. irpSp.Parameters.QueryInterface.InterfaceType = &GUID_BOGUS_INTERFACE;
  922. irpSp.Parameters.QueryInterface.Interface = &interface;
  923. irpSp.Parameters.QueryInterface.InterfaceSpecificData = (PVOID) -1;
  924. VfIrpSendSynchronousIrp(
  925. PhysicalDeviceObject,
  926. &irpSp,
  927. TRUE,
  928. STATUS_NOT_SUPPORTED,
  929. 0,
  930. NULL,
  931. NULL
  932. );
  933. RtlZeroMemory(&interface, sizeof(INTERFACE));
  934. irpSp.MinorFunction = IRP_MN_QUERY_INTERFACE;
  935. irpSp.Parameters.QueryInterface.Size = (USHORT)-1;
  936. irpSp.Parameters.QueryInterface.Version = 1;
  937. irpSp.Parameters.QueryInterface.InterfaceType = &GUID_BOGUS_INTERFACE;
  938. irpSp.Parameters.QueryInterface.Interface = &interface;
  939. irpSp.Parameters.QueryInterface.InterfaceSpecificData = (PVOID) -1;
  940. VfIrpSendSynchronousIrp(
  941. PhysicalDeviceObject,
  942. &irpSp,
  943. TRUE,
  944. STATUS_SUCCESS,
  945. 0,
  946. NULL,
  947. NULL
  948. );
  949. //
  950. // We could do more chaff here. For example, bogus device usage
  951. // notifications, etc...
  952. //
  953. }
  954. VOID
  955. ViPnpVerifyMinorWasProcessedProperly(
  956. IN PIRP Irp,
  957. IN PIO_STACK_LOCATION IrpSp,
  958. IN VF_DEVOBJ_TYPE DevObjType,
  959. IN PVERIFIER_SETTINGS_SNAPSHOT VerifierSnapshot,
  960. IN HOW_PROCESSED HowProcessed,
  961. IN PVOID CallerAddress
  962. )
  963. {
  964. PDEVICE_OBJECT relationObject, relationPdo;
  965. PDEVICE_RELATIONS deviceRelations;
  966. BOOLEAN touchable;
  967. ULONG index;
  968. switch(IrpSp->MinorFunction) {
  969. case IRP_MN_SURPRISE_REMOVAL:
  970. if ((HowProcessed != NOT_PROCESSED) ||
  971. (!VfSettingsIsOptionEnabled(VerifierSnapshot,
  972. VERIFIER_OPTION_EXTENDED_REQUIRED_IRPS))) {
  973. break;
  974. }
  975. WDM_FAIL_ROUTINE((
  976. DCERROR_PNP_IRP_NEEDS_HANDLING,
  977. DCPARAM_IRP + DCPARAM_ROUTINE,
  978. CallerAddress,
  979. Irp
  980. ));
  981. break;
  982. case IRP_MN_START_DEVICE:
  983. case IRP_MN_QUERY_REMOVE_DEVICE:
  984. case IRP_MN_REMOVE_DEVICE:
  985. case IRP_MN_STOP_DEVICE:
  986. case IRP_MN_QUERY_STOP_DEVICE:
  987. //
  988. // The driver must set the status as appropriate.
  989. //
  990. if (HowProcessed != NOT_PROCESSED) {
  991. break;
  992. }
  993. WDM_FAIL_ROUTINE((
  994. DCERROR_PNP_IRP_NEEDS_HANDLING,
  995. DCPARAM_IRP + DCPARAM_ROUTINE,
  996. CallerAddress,
  997. Irp
  998. ));
  999. break;
  1000. case IRP_MN_CANCEL_REMOVE_DEVICE:
  1001. case IRP_MN_CANCEL_STOP_DEVICE:
  1002. //
  1003. // The driver must set the status of these IRPs to something
  1004. // successful!
  1005. //
  1006. if (HowProcessed == NOT_PROCESSED) {
  1007. WDM_FAIL_ROUTINE((
  1008. DCERROR_PNP_IRP_NEEDS_HANDLING,
  1009. DCPARAM_IRP + DCPARAM_ROUTINE,
  1010. CallerAddress,
  1011. Irp
  1012. ));
  1013. } else if ((HowProcessed == DEFINITELY_PROCESSED) &&
  1014. (!NT_SUCCESS(Irp->IoStatus.Status)) &&
  1015. (VfSettingsIsOptionEnabled(VerifierSnapshot,
  1016. VERIFIER_OPTION_EXTENDED_REQUIRED_IRPS))) {
  1017. WDM_FAIL_ROUTINE((
  1018. DCERROR_NON_FAILABLE_IRP,
  1019. DCPARAM_IRP + DCPARAM_ROUTINE,
  1020. CallerAddress,
  1021. Irp
  1022. ));
  1023. }
  1024. break;
  1025. case IRP_MN_QUERY_DEVICE_RELATIONS:
  1026. switch(IrpSp->Parameters.QueryDeviceRelations.Type) {
  1027. case TargetDeviceRelation:
  1028. if (DevObjType != VF_DEVOBJ_PDO) {
  1029. if (HowProcessed != DEFINITELY_PROCESSED) {
  1030. break;
  1031. }
  1032. WDM_FAIL_ROUTINE((
  1033. DCERROR_PNP_IRP_HANDS_OFF,
  1034. DCPARAM_IRP + DCPARAM_ROUTINE,
  1035. CallerAddress,
  1036. Irp
  1037. ));
  1038. } else {
  1039. if (HowProcessed == NOT_PROCESSED) {
  1040. WDM_FAIL_ROUTINE((
  1041. DCERROR_PNP_IRP_NEEDS_PDO_HANDLING,
  1042. DCPARAM_IRP + DCPARAM_ROUTINE,
  1043. CallerAddress,
  1044. Irp
  1045. ));
  1046. } else if (NT_SUCCESS(Irp->IoStatus.Status)) {
  1047. if (Irp->IoStatus.Information == (ULONG_PTR) NULL) {
  1048. WDM_FAIL_ROUTINE((
  1049. DCERROR_TARGET_RELATION_LIST_EMPTY,
  1050. DCPARAM_IRP + DCPARAM_ROUTINE,
  1051. CallerAddress,
  1052. Irp
  1053. ));
  1054. }
  1055. //
  1056. // ADRIAO N.B. - I could also assert the Information
  1057. // matches DeviceObject.
  1058. //
  1059. }
  1060. }
  1061. break;
  1062. case BusRelations:
  1063. case PowerRelations:
  1064. case RemovalRelations:
  1065. case EjectionRelations:
  1066. //
  1067. // Ejection relations are usually a bad idea for
  1068. // FDO's - As stopping a device implies powerdown,
  1069. // RemovalRelations are usually the proper response
  1070. // for an FDO. One exception is ISAPNP, as PCI-to-ISA
  1071. // bridges can never be powered down.
  1072. //
  1073. default:
  1074. break;
  1075. }
  1076. //
  1077. // Verify we got back PDO's.
  1078. //
  1079. if (!VfSettingsIsOptionEnabled(
  1080. VerifierSnapshot,
  1081. VERIFIER_OPTION_EXAMINE_RELATION_PDOS)) {
  1082. break;
  1083. }
  1084. if ((!NT_SUCCESS(Irp->IoStatus.Status)) ||
  1085. (((PVOID) Irp->IoStatus.Information) == NULL)) {
  1086. break;
  1087. }
  1088. switch(IrpSp->Parameters.QueryDeviceRelations.Type) {
  1089. case TargetDeviceRelation:
  1090. case BusRelations:
  1091. case PowerRelations:
  1092. case RemovalRelations:
  1093. case EjectionRelations:
  1094. deviceRelations = (PDEVICE_RELATIONS) Irp->IoStatus.Information;
  1095. touchable = VfUtilIsMemoryRangeReadable(
  1096. deviceRelations,
  1097. (sizeof(DEVICE_RELATIONS)-sizeof(PVOID)),
  1098. VFMP_INSTANT_NONPAGED
  1099. );
  1100. if (!touchable) {
  1101. break;
  1102. }
  1103. touchable = VfUtilIsMemoryRangeReadable(
  1104. deviceRelations,
  1105. (sizeof(DEVICE_RELATIONS)-(deviceRelations->Count-1)*sizeof(PVOID)),
  1106. VFMP_INSTANT_NONPAGED
  1107. );
  1108. if (!touchable) {
  1109. break;
  1110. }
  1111. for(index = 0; index < deviceRelations->Count; index++) {
  1112. relationObject = deviceRelations->Objects[index];
  1113. if (IovUtilIsDeviceObjectMarked(relationObject, MARKTYPE_RELATION_PDO_EXAMINED)) {
  1114. continue;
  1115. }
  1116. IovUtilGetBottomDeviceObject(relationObject, &relationPdo);
  1117. if (relationPdo != relationObject) {
  1118. //
  1119. // Fail the appropriate driver.
  1120. //
  1121. WDM_FAIL_ROUTINE((
  1122. DCERROR_NON_PDO_RETURNED_IN_RELATION,
  1123. DCPARAM_IRP + DCPARAM_ROUTINE + DCPARAM_DEVOBJ,
  1124. CallerAddress,
  1125. Irp,
  1126. relationObject
  1127. ));
  1128. }
  1129. //
  1130. // Don't blame the next driver that handles the IRP.
  1131. //
  1132. IovUtilMarkDeviceObject(
  1133. relationObject,
  1134. MARKTYPE_RELATION_PDO_EXAMINED
  1135. );
  1136. //
  1137. // Drop ref
  1138. //
  1139. ObDereferenceObject(relationPdo);
  1140. }
  1141. break;
  1142. }
  1143. break;
  1144. case IRP_MN_QUERY_INTERFACE:
  1145. case IRP_MN_QUERY_CAPABILITIES:
  1146. case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
  1147. break;
  1148. case IRP_MN_QUERY_DEVICE_TEXT:
  1149. case IRP_MN_READ_CONFIG:
  1150. case IRP_MN_WRITE_CONFIG:
  1151. case IRP_MN_EJECT:
  1152. case IRP_MN_SET_LOCK:
  1153. case IRP_MN_QUERY_RESOURCES:
  1154. case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
  1155. case IRP_MN_QUERY_BUS_INFORMATION:
  1156. if ((DevObjType == VF_DEVOBJ_PDO) ||
  1157. (HowProcessed != DEFINITELY_PROCESSED)) {
  1158. break;
  1159. }
  1160. WDM_FAIL_ROUTINE((
  1161. DCERROR_PNP_IRP_HANDS_OFF,
  1162. DCPARAM_IRP + DCPARAM_ROUTINE,
  1163. CallerAddress,
  1164. Irp
  1165. ));
  1166. break;
  1167. case IRP_MN_QUERY_ID:
  1168. switch(IrpSp->Parameters.QueryId.IdType) {
  1169. case BusQueryDeviceID:
  1170. case BusQueryHardwareIDs:
  1171. case BusQueryCompatibleIDs:
  1172. case BusQueryInstanceID:
  1173. if ((DevObjType == VF_DEVOBJ_PDO) ||
  1174. (HowProcessed != DEFINITELY_PROCESSED)) {
  1175. break;
  1176. }
  1177. WDM_FAIL_ROUTINE((
  1178. DCERROR_PNP_IRP_HANDS_OFF,
  1179. DCPARAM_IRP + DCPARAM_ROUTINE,
  1180. CallerAddress,
  1181. Irp
  1182. ));
  1183. break;
  1184. default:
  1185. break;
  1186. }
  1187. break;
  1188. case IRP_MN_QUERY_PNP_DEVICE_STATE:
  1189. case IRP_MN_QUERY_LEGACY_BUS_INFORMATION:
  1190. break;
  1191. case IRP_MN_DEVICE_USAGE_NOTIFICATION:
  1192. if ((HowProcessed != NOT_PROCESSED) ||
  1193. (!VfSettingsIsOptionEnabled(VerifierSnapshot,
  1194. VERIFIER_OPTION_EXTENDED_REQUIRED_IRPS))) {
  1195. break;
  1196. }
  1197. WDM_FAIL_ROUTINE((
  1198. DCERROR_PNP_IRP_NEEDS_HANDLING,
  1199. DCPARAM_IRP + DCPARAM_ROUTINE,
  1200. CallerAddress,
  1201. Irp
  1202. ));
  1203. break;
  1204. default:
  1205. break;
  1206. }
  1207. }