1 /*++ 2 3 Copyright (c) Microsoft Corporation. All rights reserved. 4 5 Module Name: 6 7 VfEventHooks.cpp 8 9 Abstract: 10 Generated implementation of verifier event callback hooks 11 12 Environment: 13 User and Kernel 14 15 ** Warning ** : manual changes to this file will be lost. 16 17 --*/ 18 19 #include "vfpriv.hpp" 20 21 22 extern "C" { 23 extern WDFVERSION WdfVersion; 24 } 25 26 #ifdef ALLOC_PRAGMA 27 #pragma alloc_text(FX_ENHANCED_VERIFIER_SECTION_NAME, \ 28 VfEvtDeviceD0Entry, \ 29 VfEvtDeviceD0EntryPostInterruptsEnabled, \ 30 VfEvtDeviceD0Exit, \ 31 VfEvtDeviceD0ExitPreInterruptsDisabled, \ 32 VfEvtDevicePrepareHardware, \ 33 VfEvtDeviceReleaseHardware, \ 34 VfEvtDeviceSelfManagedIoCleanup, \ 35 VfEvtDeviceSelfManagedIoFlush, \ 36 VfEvtDeviceSelfManagedIoInit, \ 37 VfEvtDeviceSelfManagedIoSuspend, \ 38 VfEvtDeviceSelfManagedIoRestart, \ 39 VfEvtDeviceQueryStop, \ 40 VfEvtDeviceQueryRemove, \ 41 VfEvtDeviceSurpriseRemoval, \ 42 VfEvtDeviceUsageNotification, \ 43 VfEvtDeviceUsageNotificationEx, \ 44 VfEvtDeviceRelationsQuery, \ 45 VfEvtIoDefault, \ 46 VfEvtIoStop, \ 47 VfEvtIoResume, \ 48 VfEvtIoRead, \ 49 VfEvtIoWrite, \ 50 VfEvtIoDeviceControl, \ 51 VfEvtIoInternalDeviceControl, \ 52 VfEvtIoCanceledOnQueue \ 53 ) 54 #endif 55 56 NTSTATUS 57 VfEvtDeviceD0Entry( 58 WDFDEVICE Device, 59 WDF_POWER_DEVICE_STATE PreviousState 60 ) 61 { 62 NTSTATUS returnVal = STATUS_SUCCESS; 63 PFN_WDF_DEVICE_D0_ENTRY pfn = NULL; 64 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 65 66 PAGED_CODE_LOCKED(); 67 68 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 69 ASSERT(context != NULL); 70 71 pfn = context->PnpPowerEventCallbacksOriginal.EvtDeviceD0Entry; 72 if (pfn != NULL) { 73 GUID activityId = { 0 }; 74 if (PerfEvtDeviceD0EntryStart(Device, &activityId)) { 75 returnVal = (pfn)( 76 Device, 77 PreviousState 78 ); 79 80 PerfEvtDeviceD0EntryStop(Device, &activityId); 81 } else { 82 KIRQL irql = PASSIVE_LEVEL; 83 BOOLEAN critRegion = FALSE; 84 85 VerifyIrqlEntry(&irql); 86 VerifyCriticalRegionEntry(&critRegion); 87 88 returnVal = (pfn)( 89 Device, 90 PreviousState 91 ); 92 93 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 94 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 95 } 96 } 97 98 return returnVal; 99 } 100 101 NTSTATUS 102 VfEvtDeviceD0EntryPostInterruptsEnabled( 103 WDFDEVICE Device, 104 WDF_POWER_DEVICE_STATE PreviousState 105 ) 106 { 107 NTSTATUS returnVal = STATUS_SUCCESS; 108 PFN_WDF_DEVICE_D0_ENTRY_POST_INTERRUPTS_ENABLED pfn = NULL; 109 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 110 111 PAGED_CODE_LOCKED(); 112 113 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 114 ASSERT(context != NULL); 115 116 pfn = context->PnpPowerEventCallbacksOriginal.EvtDeviceD0EntryPostInterruptsEnabled; 117 if (pfn != NULL) { 118 KIRQL irql = PASSIVE_LEVEL; 119 BOOLEAN critRegion = FALSE; 120 121 VerifyIrqlEntry(&irql); 122 VerifyCriticalRegionEntry(&critRegion); 123 124 returnVal = (pfn)( 125 Device, 126 PreviousState 127 ); 128 129 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 130 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 131 } 132 133 return returnVal; 134 } 135 136 NTSTATUS 137 VfEvtDeviceD0Exit( 138 WDFDEVICE Device, 139 WDF_POWER_DEVICE_STATE TargetState 140 ) 141 { 142 NTSTATUS returnVal = STATUS_SUCCESS; 143 PFN_WDF_DEVICE_D0_EXIT pfn = NULL; 144 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 145 146 PAGED_CODE_LOCKED(); 147 148 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 149 ASSERT(context != NULL); 150 151 pfn = context->PnpPowerEventCallbacksOriginal.EvtDeviceD0Exit; 152 if (pfn != NULL) { 153 GUID activityId = { 0 }; 154 if (PerfEvtDeviceD0ExitStart(Device, &activityId)) { 155 returnVal = (pfn)( 156 Device, 157 TargetState 158 ); 159 160 PerfEvtDeviceD0ExitStop(Device, &activityId); 161 } else { 162 KIRQL irql = PASSIVE_LEVEL; 163 BOOLEAN critRegion = FALSE; 164 165 VerifyIrqlEntry(&irql); 166 VerifyCriticalRegionEntry(&critRegion); 167 168 returnVal = (pfn)( 169 Device, 170 TargetState 171 ); 172 173 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 174 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 175 } 176 } 177 178 return returnVal; 179 } 180 181 NTSTATUS 182 VfEvtDeviceD0ExitPreInterruptsDisabled( 183 WDFDEVICE Device, 184 WDF_POWER_DEVICE_STATE TargetState 185 ) 186 { 187 NTSTATUS returnVal = STATUS_SUCCESS; 188 PFN_WDF_DEVICE_D0_EXIT_PRE_INTERRUPTS_DISABLED pfn = NULL; 189 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 190 191 PAGED_CODE_LOCKED(); 192 193 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 194 ASSERT(context != NULL); 195 196 pfn = context->PnpPowerEventCallbacksOriginal.EvtDeviceD0ExitPreInterruptsDisabled; 197 if (pfn != NULL) { 198 KIRQL irql = PASSIVE_LEVEL; 199 BOOLEAN critRegion = FALSE; 200 201 VerifyIrqlEntry(&irql); 202 VerifyCriticalRegionEntry(&critRegion); 203 204 returnVal = (pfn)( 205 Device, 206 TargetState 207 ); 208 209 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 210 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 211 } 212 213 return returnVal; 214 } 215 216 NTSTATUS 217 VfEvtDevicePrepareHardware( 218 WDFDEVICE Device, 219 WDFCMRESLIST ResourcesRaw, 220 WDFCMRESLIST ResourcesTranslated 221 ) 222 { 223 NTSTATUS returnVal = STATUS_SUCCESS; 224 PFN_WDF_DEVICE_PREPARE_HARDWARE pfn = NULL; 225 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 226 227 PAGED_CODE_LOCKED(); 228 229 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 230 ASSERT(context != NULL); 231 232 pfn = context->PnpPowerEventCallbacksOriginal.EvtDevicePrepareHardware; 233 if (pfn != NULL) { 234 GUID activityId = { 0 }; 235 if (PerfEvtDevicePrepareHardwareStart(Device, &activityId)) { 236 returnVal = (pfn)( 237 Device, 238 ResourcesRaw, 239 ResourcesTranslated 240 ); 241 242 PerfEvtDevicePrepareHardwareStop(Device, &activityId); 243 } else { 244 KIRQL irql = PASSIVE_LEVEL; 245 BOOLEAN critRegion = FALSE; 246 247 VerifyIrqlEntry(&irql); 248 VerifyCriticalRegionEntry(&critRegion); 249 250 returnVal = (pfn)( 251 Device, 252 ResourcesRaw, 253 ResourcesTranslated 254 ); 255 256 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 257 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 258 } 259 } 260 261 return returnVal; 262 } 263 264 NTSTATUS 265 VfEvtDeviceReleaseHardware( 266 WDFDEVICE Device, 267 WDFCMRESLIST ResourcesTranslated 268 ) 269 { 270 NTSTATUS returnVal = STATUS_SUCCESS; 271 PFN_WDF_DEVICE_RELEASE_HARDWARE pfn = NULL; 272 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 273 274 PAGED_CODE_LOCKED(); 275 276 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 277 ASSERT(context != NULL); 278 279 pfn = context->PnpPowerEventCallbacksOriginal.EvtDeviceReleaseHardware; 280 if (pfn != NULL) { 281 GUID activityId = { 0 }; 282 if (PerfEvtDeviceReleaseHardwareStart(Device, &activityId)) { 283 returnVal = (pfn)( 284 Device, 285 ResourcesTranslated 286 ); 287 288 PerfEvtDeviceReleaseHardwareStop(Device, &activityId); 289 } else { 290 KIRQL irql = PASSIVE_LEVEL; 291 BOOLEAN critRegion = FALSE; 292 293 VerifyIrqlEntry(&irql); 294 VerifyCriticalRegionEntry(&critRegion); 295 296 returnVal = (pfn)( 297 Device, 298 ResourcesTranslated 299 ); 300 301 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 302 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 303 } 304 } 305 306 return returnVal; 307 } 308 309 VOID 310 VfEvtDeviceSelfManagedIoCleanup( 311 WDFDEVICE Device 312 ) 313 { 314 PFN_WDF_DEVICE_SELF_MANAGED_IO_CLEANUP pfn = NULL; 315 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 316 317 PAGED_CODE_LOCKED(); 318 319 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 320 ASSERT(context != NULL); 321 322 pfn = context->PnpPowerEventCallbacksOriginal.EvtDeviceSelfManagedIoCleanup; 323 if (pfn != NULL) { 324 KIRQL irql = PASSIVE_LEVEL; 325 BOOLEAN critRegion = FALSE; 326 327 VerifyIrqlEntry(&irql); 328 VerifyCriticalRegionEntry(&critRegion); 329 330 (pfn)( 331 Device 332 ); 333 334 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 335 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 336 } 337 338 return; 339 } 340 341 VOID 342 VfEvtDeviceSelfManagedIoFlush( 343 WDFDEVICE Device 344 ) 345 { 346 PFN_WDF_DEVICE_SELF_MANAGED_IO_FLUSH pfn = NULL; 347 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 348 349 PAGED_CODE_LOCKED(); 350 351 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 352 ASSERT(context != NULL); 353 354 pfn = context->PnpPowerEventCallbacksOriginal.EvtDeviceSelfManagedIoFlush; 355 if (pfn != NULL) { 356 KIRQL irql = PASSIVE_LEVEL; 357 BOOLEAN critRegion = FALSE; 358 359 VerifyIrqlEntry(&irql); 360 VerifyCriticalRegionEntry(&critRegion); 361 362 (pfn)( 363 Device 364 ); 365 366 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 367 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 368 } 369 370 return; 371 } 372 373 NTSTATUS 374 VfEvtDeviceSelfManagedIoInit( 375 WDFDEVICE Device 376 ) 377 { 378 NTSTATUS returnVal = STATUS_SUCCESS; 379 PFN_WDF_DEVICE_SELF_MANAGED_IO_INIT pfn = NULL; 380 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 381 382 PAGED_CODE_LOCKED(); 383 384 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 385 ASSERT(context != NULL); 386 387 pfn = context->PnpPowerEventCallbacksOriginal.EvtDeviceSelfManagedIoInit; 388 if (pfn != NULL) { 389 KIRQL irql = PASSIVE_LEVEL; 390 BOOLEAN critRegion = FALSE; 391 392 VerifyIrqlEntry(&irql); 393 VerifyCriticalRegionEntry(&critRegion); 394 395 returnVal = (pfn)( 396 Device 397 ); 398 399 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 400 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 401 } 402 403 return returnVal; 404 } 405 406 NTSTATUS 407 VfEvtDeviceSelfManagedIoSuspend( 408 WDFDEVICE Device 409 ) 410 { 411 NTSTATUS returnVal = STATUS_SUCCESS; 412 PFN_WDF_DEVICE_SELF_MANAGED_IO_SUSPEND pfn = NULL; 413 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 414 415 PAGED_CODE_LOCKED(); 416 417 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 418 ASSERT(context != NULL); 419 420 pfn = context->PnpPowerEventCallbacksOriginal.EvtDeviceSelfManagedIoSuspend; 421 if (pfn != NULL) { 422 KIRQL irql = PASSIVE_LEVEL; 423 BOOLEAN critRegion = FALSE; 424 425 VerifyIrqlEntry(&irql); 426 VerifyCriticalRegionEntry(&critRegion); 427 428 returnVal = (pfn)( 429 Device 430 ); 431 432 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 433 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 434 } 435 436 return returnVal; 437 } 438 439 NTSTATUS 440 VfEvtDeviceSelfManagedIoRestart( 441 WDFDEVICE Device 442 ) 443 { 444 NTSTATUS returnVal = STATUS_SUCCESS; 445 PFN_WDF_DEVICE_SELF_MANAGED_IO_RESTART pfn = NULL; 446 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 447 448 PAGED_CODE_LOCKED(); 449 450 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 451 ASSERT(context != NULL); 452 453 pfn = context->PnpPowerEventCallbacksOriginal.EvtDeviceSelfManagedIoRestart; 454 if (pfn != NULL) { 455 KIRQL irql = PASSIVE_LEVEL; 456 BOOLEAN critRegion = FALSE; 457 458 VerifyIrqlEntry(&irql); 459 VerifyCriticalRegionEntry(&critRegion); 460 461 returnVal = (pfn)( 462 Device 463 ); 464 465 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 466 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 467 } 468 469 return returnVal; 470 } 471 472 NTSTATUS 473 VfEvtDeviceQueryStop( 474 WDFDEVICE Device 475 ) 476 { 477 NTSTATUS returnVal = STATUS_SUCCESS; 478 PFN_WDF_DEVICE_QUERY_STOP pfn = NULL; 479 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 480 481 PAGED_CODE_LOCKED(); 482 483 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 484 ASSERT(context != NULL); 485 486 pfn = context->PnpPowerEventCallbacksOriginal.EvtDeviceQueryStop; 487 if (pfn != NULL) { 488 KIRQL irql = PASSIVE_LEVEL; 489 BOOLEAN critRegion = FALSE; 490 491 VerifyIrqlEntry(&irql); 492 VerifyCriticalRegionEntry(&critRegion); 493 494 returnVal = (pfn)( 495 Device 496 ); 497 498 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 499 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 500 } 501 502 return returnVal; 503 } 504 505 NTSTATUS 506 VfEvtDeviceQueryRemove( 507 WDFDEVICE Device 508 ) 509 { 510 NTSTATUS returnVal = STATUS_SUCCESS; 511 PFN_WDF_DEVICE_QUERY_REMOVE pfn = NULL; 512 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 513 514 PAGED_CODE_LOCKED(); 515 516 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 517 ASSERT(context != NULL); 518 519 pfn = context->PnpPowerEventCallbacksOriginal.EvtDeviceQueryRemove; 520 if (pfn != NULL) { 521 KIRQL irql = PASSIVE_LEVEL; 522 BOOLEAN critRegion = FALSE; 523 524 VerifyIrqlEntry(&irql); 525 VerifyCriticalRegionEntry(&critRegion); 526 527 returnVal = (pfn)( 528 Device 529 ); 530 531 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 532 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 533 } 534 535 return returnVal; 536 } 537 538 VOID 539 VfEvtDeviceSurpriseRemoval( 540 WDFDEVICE Device 541 ) 542 { 543 PFN_WDF_DEVICE_SURPRISE_REMOVAL pfn = NULL; 544 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 545 546 PAGED_CODE_LOCKED(); 547 548 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 549 ASSERT(context != NULL); 550 551 pfn = context->PnpPowerEventCallbacksOriginal.EvtDeviceSurpriseRemoval; 552 if (pfn != NULL) { 553 KIRQL irql = PASSIVE_LEVEL; 554 BOOLEAN critRegion = FALSE; 555 556 VerifyIrqlEntry(&irql); 557 VerifyCriticalRegionEntry(&critRegion); 558 559 (pfn)( 560 Device 561 ); 562 563 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 564 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 565 } 566 567 return; 568 } 569 570 VOID 571 VfEvtDeviceUsageNotification( 572 WDFDEVICE Device, 573 WDF_SPECIAL_FILE_TYPE NotificationType, 574 BOOLEAN IsInNotificationPath 575 ) 576 { 577 PFN_WDF_DEVICE_USAGE_NOTIFICATION pfn = NULL; 578 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 579 580 PAGED_CODE_LOCKED(); 581 582 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 583 ASSERT(context != NULL); 584 585 pfn = context->PnpPowerEventCallbacksOriginal.EvtDeviceUsageNotification; 586 if (pfn != NULL) { 587 KIRQL irql = PASSIVE_LEVEL; 588 BOOLEAN critRegion = FALSE; 589 590 VerifyIrqlEntry(&irql); 591 VerifyCriticalRegionEntry(&critRegion); 592 593 (pfn)( 594 Device, 595 NotificationType, 596 IsInNotificationPath 597 ); 598 599 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 600 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 601 } 602 603 return; 604 } 605 606 NTSTATUS 607 VfEvtDeviceUsageNotificationEx( 608 WDFDEVICE Device, 609 WDF_SPECIAL_FILE_TYPE NotificationType, 610 BOOLEAN IsInNotificationPath 611 ) 612 { 613 NTSTATUS returnVal = STATUS_SUCCESS; 614 PFN_WDF_DEVICE_USAGE_NOTIFICATION_EX pfn = NULL; 615 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 616 617 PAGED_CODE_LOCKED(); 618 619 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 620 ASSERT(context != NULL); 621 622 pfn = context->PnpPowerEventCallbacksOriginal.EvtDeviceUsageNotificationEx; 623 if (pfn != NULL) { 624 KIRQL irql = PASSIVE_LEVEL; 625 BOOLEAN critRegion = FALSE; 626 627 VerifyIrqlEntry(&irql); 628 VerifyCriticalRegionEntry(&critRegion); 629 630 returnVal = (pfn)( 631 Device, 632 NotificationType, 633 IsInNotificationPath 634 ); 635 636 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 637 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 638 } 639 640 return returnVal; 641 } 642 643 VOID 644 VfEvtDeviceRelationsQuery( 645 WDFDEVICE Device, 646 DEVICE_RELATION_TYPE RelationType 647 ) 648 { 649 PFN_WDF_DEVICE_RELATIONS_QUERY pfn = NULL; 650 PVF_WDFDEVICECREATE_CONTEXT context = NULL; 651 652 PAGED_CODE_LOCKED(); 653 654 context = GET_CONTEXT(Device, VF_WDFDEVICECREATE_CONTEXT); 655 ASSERT(context != NULL); 656 657 pfn = context->PnpPowerEventCallbacksOriginal.EvtDeviceRelationsQuery; 658 if (pfn != NULL) { 659 KIRQL irql = PASSIVE_LEVEL; 660 BOOLEAN critRegion = FALSE; 661 662 VerifyIrqlEntry(&irql); 663 VerifyCriticalRegionEntry(&critRegion); 664 665 (pfn)( 666 Device, 667 RelationType 668 ); 669 670 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 671 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 672 } 673 674 return; 675 } 676 677 VOID 678 VfEvtIoDefault( 679 WDFQUEUE Queue, 680 WDFREQUEST Request 681 ) 682 { 683 PFN_WDF_IO_QUEUE_IO_DEFAULT pfn = NULL; 684 PVF_WDFIOQUEUECREATE_CONTEXT context = NULL; 685 686 PAGED_CODE_LOCKED(); 687 688 context = GET_CONTEXT(Queue, VF_WDFIOQUEUECREATE_CONTEXT); 689 ASSERT(context != NULL); 690 691 pfn = context->IoQueueConfigOriginal.EvtIoDefault; 692 if (pfn != NULL) { 693 if (PerfIoStart(Request)) { 694 (pfn)( 695 Queue, 696 Request 697 ); 698 } else { 699 KIRQL irql = PASSIVE_LEVEL; 700 BOOLEAN critRegion = FALSE; 701 702 VerifyIrqlEntry(&irql); 703 VerifyCriticalRegionEntry(&critRegion); 704 705 (pfn)( 706 Queue, 707 Request 708 ); 709 710 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 711 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 712 } 713 } 714 715 return; 716 } 717 718 VOID 719 VfEvtIoStop( 720 WDFQUEUE Queue, 721 WDFREQUEST Request, 722 ULONG ActionFlags 723 ) 724 { 725 PFN_WDF_IO_QUEUE_IO_STOP pfn = NULL; 726 PVF_WDFIOQUEUECREATE_CONTEXT context = NULL; 727 728 PAGED_CODE_LOCKED(); 729 730 context = GET_CONTEXT(Queue, VF_WDFIOQUEUECREATE_CONTEXT); 731 ASSERT(context != NULL); 732 733 pfn = context->IoQueueConfigOriginal.EvtIoStop; 734 if (pfn != NULL) { 735 GUID activityId = { 0 }; 736 if (PerfEvtIoStopStart(Queue, &activityId)) { 737 (pfn)( 738 Queue, 739 Request, 740 ActionFlags 741 ); 742 743 PerfEvtIoStopStop(Queue, &activityId); 744 } else { 745 KIRQL irql = PASSIVE_LEVEL; 746 BOOLEAN critRegion = FALSE; 747 748 VerifyIrqlEntry(&irql); 749 VerifyCriticalRegionEntry(&critRegion); 750 751 (pfn)( 752 Queue, 753 Request, 754 ActionFlags 755 ); 756 757 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 758 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 759 } 760 } 761 762 return; 763 } 764 765 VOID 766 VfEvtIoResume( 767 WDFQUEUE Queue, 768 WDFREQUEST Request 769 ) 770 { 771 PFN_WDF_IO_QUEUE_IO_RESUME pfn = NULL; 772 PVF_WDFIOQUEUECREATE_CONTEXT context = NULL; 773 774 PAGED_CODE_LOCKED(); 775 776 context = GET_CONTEXT(Queue, VF_WDFIOQUEUECREATE_CONTEXT); 777 ASSERT(context != NULL); 778 779 pfn = context->IoQueueConfigOriginal.EvtIoResume; 780 if (pfn != NULL) { 781 KIRQL irql = PASSIVE_LEVEL; 782 BOOLEAN critRegion = FALSE; 783 784 VerifyIrqlEntry(&irql); 785 VerifyCriticalRegionEntry(&critRegion); 786 787 (pfn)( 788 Queue, 789 Request 790 ); 791 792 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 793 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 794 } 795 796 return; 797 } 798 799 VOID 800 VfEvtIoRead( 801 WDFQUEUE Queue, 802 WDFREQUEST Request, 803 size_t Length 804 ) 805 { 806 PFN_WDF_IO_QUEUE_IO_READ pfn = NULL; 807 PVF_WDFIOQUEUECREATE_CONTEXT context = NULL; 808 809 PAGED_CODE_LOCKED(); 810 811 context = GET_CONTEXT(Queue, VF_WDFIOQUEUECREATE_CONTEXT); 812 ASSERT(context != NULL); 813 814 pfn = context->IoQueueConfigOriginal.EvtIoRead; 815 if (pfn != NULL) { 816 if (PerfIoStart(Request)) { 817 (pfn)( 818 Queue, 819 Request, 820 Length 821 ); 822 } else { 823 KIRQL irql = PASSIVE_LEVEL; 824 BOOLEAN critRegion = FALSE; 825 826 VerifyIrqlEntry(&irql); 827 VerifyCriticalRegionEntry(&critRegion); 828 829 (pfn)( 830 Queue, 831 Request, 832 Length 833 ); 834 835 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 836 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 837 } 838 } 839 840 return; 841 } 842 843 VOID 844 VfEvtIoWrite( 845 WDFQUEUE Queue, 846 WDFREQUEST Request, 847 size_t Length 848 ) 849 { 850 PFN_WDF_IO_QUEUE_IO_WRITE pfn = NULL; 851 PVF_WDFIOQUEUECREATE_CONTEXT context = NULL; 852 853 PAGED_CODE_LOCKED(); 854 855 context = GET_CONTEXT(Queue, VF_WDFIOQUEUECREATE_CONTEXT); 856 ASSERT(context != NULL); 857 858 pfn = context->IoQueueConfigOriginal.EvtIoWrite; 859 if (pfn != NULL) { 860 if (PerfIoStart(Request)) { 861 (pfn)( 862 Queue, 863 Request, 864 Length 865 ); 866 } else { 867 KIRQL irql = PASSIVE_LEVEL; 868 BOOLEAN critRegion = FALSE; 869 870 VerifyIrqlEntry(&irql); 871 VerifyCriticalRegionEntry(&critRegion); 872 873 (pfn)( 874 Queue, 875 Request, 876 Length 877 ); 878 879 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 880 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 881 } 882 } 883 884 return; 885 } 886 887 VOID 888 VfEvtIoDeviceControl( 889 WDFQUEUE Queue, 890 WDFREQUEST Request, 891 size_t OutputBufferLength, 892 size_t InputBufferLength, 893 ULONG IoControlCode 894 ) 895 { 896 PFN_WDF_IO_QUEUE_IO_DEVICE_CONTROL pfn = NULL; 897 PVF_WDFIOQUEUECREATE_CONTEXT context = NULL; 898 899 PAGED_CODE_LOCKED(); 900 901 context = GET_CONTEXT(Queue, VF_WDFIOQUEUECREATE_CONTEXT); 902 ASSERT(context != NULL); 903 904 pfn = context->IoQueueConfigOriginal.EvtIoDeviceControl; 905 if (pfn != NULL) { 906 if (PerfIoStart(Request)) { 907 (pfn)( 908 Queue, 909 Request, 910 OutputBufferLength, 911 InputBufferLength, 912 IoControlCode 913 ); 914 } else { 915 KIRQL irql = PASSIVE_LEVEL; 916 BOOLEAN critRegion = FALSE; 917 918 VerifyIrqlEntry(&irql); 919 VerifyCriticalRegionEntry(&critRegion); 920 921 (pfn)( 922 Queue, 923 Request, 924 OutputBufferLength, 925 InputBufferLength, 926 IoControlCode 927 ); 928 929 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 930 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 931 } 932 } 933 934 return; 935 } 936 937 VOID 938 VfEvtIoInternalDeviceControl( 939 WDFQUEUE Queue, 940 WDFREQUEST Request, 941 size_t OutputBufferLength, 942 size_t InputBufferLength, 943 ULONG IoControlCode 944 ) 945 { 946 PFN_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL pfn = NULL; 947 PVF_WDFIOQUEUECREATE_CONTEXT context = NULL; 948 949 PAGED_CODE_LOCKED(); 950 951 context = GET_CONTEXT(Queue, VF_WDFIOQUEUECREATE_CONTEXT); 952 ASSERT(context != NULL); 953 954 pfn = context->IoQueueConfigOriginal.EvtIoInternalDeviceControl; 955 if (pfn != NULL) { 956 if (PerfIoStart(Request)) { 957 (pfn)( 958 Queue, 959 Request, 960 OutputBufferLength, 961 InputBufferLength, 962 IoControlCode 963 ); 964 } else { 965 KIRQL irql = PASSIVE_LEVEL; 966 BOOLEAN critRegion = FALSE; 967 968 VerifyIrqlEntry(&irql); 969 VerifyCriticalRegionEntry(&critRegion); 970 971 (pfn)( 972 Queue, 973 Request, 974 OutputBufferLength, 975 InputBufferLength, 976 IoControlCode 977 ); 978 979 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 980 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 981 } 982 } 983 984 return; 985 } 986 987 VOID 988 VfEvtIoCanceledOnQueue( 989 WDFQUEUE Queue, 990 WDFREQUEST Request 991 ) 992 { 993 PFN_WDF_IO_QUEUE_IO_CANCELED_ON_QUEUE pfn = NULL; 994 PVF_WDFIOQUEUECREATE_CONTEXT context = NULL; 995 996 PAGED_CODE_LOCKED(); 997 998 context = GET_CONTEXT(Queue, VF_WDFIOQUEUECREATE_CONTEXT); 999 ASSERT(context != NULL); 1000 1001 pfn = context->IoQueueConfigOriginal.EvtIoCanceledOnQueue; 1002 if (pfn != NULL) { 1003 KIRQL irql = PASSIVE_LEVEL; 1004 BOOLEAN critRegion = FALSE; 1005 1006 VerifyIrqlEntry(&irql); 1007 VerifyCriticalRegionEntry(&critRegion); 1008 1009 (pfn)( 1010 Queue, 1011 Request 1012 ); 1013 1014 VerifyIrqlExit(context->CommonHeader.DriverGlobals, irql); 1015 VerifyCriticalRegionExit(context->CommonHeader.DriverGlobals, critRegion, (PVOID)pfn); 1016 } 1017 1018 return; 1019 } 1020 1021