1 /*++ 2 3 Copyright (c) Microsoft Corporation 4 5 Module Name: 6 7 FxPnpCallbacks.hpp 8 9 Abstract: 10 11 This module implements the PnP/Power callback objects. 12 13 Author: 14 15 16 17 Environment: 18 19 Both kernel and user mode 20 21 Revision History: 22 23 --*/ 24 25 #ifndef _FXPNPCALLBACKS_H_ 26 #define _FXPNPCALLBACKS_H_ 27 28 class FxPnpDeviceFilterResourceRequirements : public FxCallback { 29 30 public: 31 PFN_WDF_DEVICE_FILTER_RESOURCE_REQUIREMENTS m_Method; 32 33 FxPnpDeviceFilterResourceRequirements( 34 VOID 35 ) : FxCallback(), m_Method(NULL) 36 { 37 } 38 39 _Must_inspect_result_ 40 NTSTATUS 41 Invoke( 42 __in WDFDEVICE Device, 43 __in WDFIORESREQLIST Collection 44 ) 45 { 46 if (m_Method != NULL) { 47 NTSTATUS status; 48 49 CallbackStart(); 50 status = m_Method(Device, Collection); 51 CallbackEnd(); 52 53 return status; 54 } 55 else { 56 return STATUS_SUCCESS; 57 } 58 } 59 }; 60 61 class FxPnpDeviceD0Entry : public FxCallback { 62 63 public: 64 PFN_WDF_DEVICE_D0_ENTRY m_Method; 65 66 FxPnpDeviceD0Entry( 67 VOID 68 ) : FxCallback(), m_Method(NULL) 69 { 70 } 71 72 _Must_inspect_result_ 73 NTSTATUS 74 Invoke( 75 __in WDFDEVICE Device, 76 __in WDF_POWER_DEVICE_STATE PreviousState 77 ) 78 { 79 if (m_Method != NULL) { 80 NTSTATUS status; 81 82 CallbackStart(); 83 status = m_Method(Device, PreviousState); 84 CallbackEnd(); 85 86 return status; 87 } 88 else { 89 return STATUS_SUCCESS; 90 } 91 } 92 }; 93 94 class FxPnpDeviceD0EntryPostInterruptsEnabled : public FxCallback { 95 96 public: 97 PFN_WDF_DEVICE_D0_ENTRY_POST_INTERRUPTS_ENABLED m_Method; 98 99 FxPnpDeviceD0EntryPostInterruptsEnabled( 100 VOID 101 ) : FxCallback(), m_Method(NULL) 102 { 103 } 104 105 _Must_inspect_result_ 106 NTSTATUS 107 Invoke( 108 __in WDFDEVICE Device, 109 __in WDF_POWER_DEVICE_STATE PreviousState 110 ) 111 { 112 if (m_Method != NULL) { 113 NTSTATUS status; 114 115 CallbackStart(); 116 status = m_Method(Device, PreviousState); 117 CallbackEnd(); 118 119 return status; 120 } 121 else { 122 return STATUS_SUCCESS; 123 } 124 } 125 }; 126 127 class FxPnpDeviceD0Exit : public FxCallback { 128 129 public: 130 PFN_WDF_DEVICE_D0_EXIT m_Method; 131 132 FxPnpDeviceD0Exit( 133 VOID 134 ) : FxCallback(), m_Method(NULL) 135 { 136 } 137 138 _Must_inspect_result_ 139 NTSTATUS 140 Invoke( 141 __in WDFDEVICE Device, 142 __in WDF_POWER_DEVICE_STATE TargetState 143 ) 144 { 145 if (m_Method != NULL) { 146 NTSTATUS status; 147 148 CallbackStart(); 149 status = m_Method(Device, TargetState); 150 CallbackEnd(); 151 152 return status; 153 } 154 else { 155 return STATUS_SUCCESS; 156 } 157 } 158 }; 159 160 class FxPnpDeviceD0ExitPreInterruptsDisabled : public FxCallback { 161 162 public: 163 PFN_WDF_DEVICE_D0_EXIT_PRE_INTERRUPTS_DISABLED m_Method; 164 165 FxPnpDeviceD0ExitPreInterruptsDisabled( 166 VOID 167 ) : FxCallback(), m_Method(NULL) 168 { 169 } 170 171 _Must_inspect_result_ 172 NTSTATUS 173 Invoke( 174 __in WDFDEVICE Device, 175 __in WDF_POWER_DEVICE_STATE TargetState 176 ) 177 { 178 if (m_Method != NULL) { 179 NTSTATUS status; 180 181 CallbackStart(); 182 status = m_Method(Device, TargetState); 183 CallbackEnd(); 184 185 return status; 186 } 187 else { 188 return STATUS_SUCCESS; 189 } 190 } 191 }; 192 193 class FxPnpDevicePrepareHardware : public FxCallback { 194 195 public: 196 PFN_WDF_DEVICE_PREPARE_HARDWARE m_Method; 197 198 FxPnpDevicePrepareHardware( 199 VOID 200 ) : FxCallback(), m_Method(NULL) 201 { 202 } 203 204 _Must_inspect_result_ 205 NTSTATUS 206 Invoke( 207 __in WDFDEVICE Device, 208 __in WDFCMRESLIST ResourcesRaw, 209 __in WDFCMRESLIST ResourcesTranslated 210 ) 211 { 212 if (m_Method != NULL) { 213 NTSTATUS status; 214 215 CallbackStart(); 216 status = m_Method(Device, ResourcesRaw, ResourcesTranslated); 217 CallbackEnd(); 218 219 return status; 220 } 221 else { 222 return STATUS_SUCCESS; 223 } 224 } 225 }; 226 227 class FxPnpDeviceReleaseHardware : public FxCallback { 228 229 public: 230 PFN_WDF_DEVICE_RELEASE_HARDWARE m_Method; 231 232 FxPnpDeviceReleaseHardware( 233 VOID 234 ) : FxCallback(), m_Method(NULL) 235 { 236 } 237 238 _Must_inspect_result_ 239 NTSTATUS 240 Invoke( 241 __in WDFDEVICE Device, 242 __in WDFCMRESLIST ResourcesTranslated 243 ) 244 { 245 if (m_Method != NULL) { 246 NTSTATUS status; 247 248 CallbackStart(); 249 status = m_Method(Device, ResourcesTranslated); 250 CallbackEnd(); 251 252 return status; 253 } 254 else { 255 return STATUS_SUCCESS; 256 } 257 } 258 }; 259 260 class FxPnpDeviceRemoveAddedResources : public FxCallback { 261 public: 262 PFN_WDF_DEVICE_REMOVE_ADDED_RESOURCES m_Method; 263 264 public: 265 FxPnpDeviceRemoveAddedResources( 266 VOID 267 ) : FxCallback(), m_Method(NULL) 268 { 269 } 270 271 _Must_inspect_result_ 272 NTSTATUS 273 Invoke( 274 __in WDFDEVICE Device, 275 __in WDFCMRESLIST ResourcesRaw, 276 __in WDFCMRESLIST ResourcesTranslated 277 ) 278 { 279 if (m_Method != NULL) { 280 NTSTATUS status; 281 282 CallbackStart(); 283 status = m_Method(Device, ResourcesRaw, ResourcesTranslated); 284 CallbackEnd(); 285 286 return status; 287 } 288 else { 289 return STATUS_SUCCESS; 290 } 291 } 292 }; 293 294 class FxPnpDeviceSelfManagedIoCleanup : public FxCallback { 295 296 public: 297 PFN_WDF_DEVICE_SELF_MANAGED_IO_CLEANUP m_Method; 298 299 FxPnpDeviceSelfManagedIoCleanup( 300 VOID 301 ) : m_Method(NULL) 302 { 303 } 304 305 VOID 306 Invoke( 307 __in WDFDEVICE Device 308 ) 309 { 310 if (m_Method != NULL) { 311 CallbackStart(); 312 m_Method(Device); 313 CallbackEnd(); 314 } 315 } 316 }; 317 318 class FxPnpDeviceSelfManagedIoFlush : public FxCallback { 319 320 public: 321 PFN_WDF_DEVICE_SELF_MANAGED_IO_FLUSH m_Method; 322 323 FxPnpDeviceSelfManagedIoFlush( 324 VOID 325 ) : m_Method(NULL) 326 { 327 } 328 329 VOID 330 Invoke( 331 __in WDFDEVICE Device 332 ) 333 { 334 if (m_Method != NULL) { 335 CallbackStart(); 336 m_Method(Device); 337 CallbackEnd(); 338 } 339 } 340 }; 341 342 class FxPnpDeviceSelfManagedIoInit : public FxCallback { 343 344 public: 345 PFN_WDF_DEVICE_SELF_MANAGED_IO_INIT m_Method; 346 347 FxPnpDeviceSelfManagedIoInit( 348 VOID 349 ) : m_Method(NULL) 350 { 351 } 352 353 _Must_inspect_result_ 354 NTSTATUS 355 Invoke( 356 __in WDFDEVICE Device 357 ) 358 { 359 if (m_Method != NULL) { 360 NTSTATUS status; 361 362 CallbackStart(); 363 status = m_Method(Device); 364 CallbackEnd(); 365 366 return status; 367 } 368 else { 369 return STATUS_SUCCESS; 370 } 371 } 372 }; 373 374 class FxPnpDeviceSelfManagedIoSuspend : public FxCallback { 375 376 public: 377 PFN_WDF_DEVICE_SELF_MANAGED_IO_SUSPEND m_Method; 378 379 FxPnpDeviceSelfManagedIoSuspend( 380 VOID 381 ) : m_Method(NULL) 382 { 383 } 384 385 _Must_inspect_result_ 386 NTSTATUS 387 Invoke( 388 __in WDFDEVICE Device 389 ) 390 { 391 if (m_Method != NULL) { 392 NTSTATUS status; 393 394 CallbackStart(); 395 status = m_Method(Device); 396 CallbackEnd(); 397 398 return status; 399 } 400 else { 401 return STATUS_SUCCESS; 402 } 403 } 404 }; 405 406 class FxPnpDeviceSelfManagedIoRestart : public FxCallback { 407 408 public: 409 PFN_WDF_DEVICE_SELF_MANAGED_IO_RESTART m_Method; 410 411 FxPnpDeviceSelfManagedIoRestart( 412 VOID 413 ) : m_Method(NULL) 414 { 415 } 416 417 _Must_inspect_result_ 418 NTSTATUS 419 Invoke( 420 __in WDFDEVICE Device 421 ) 422 { 423 if (m_Method != NULL) { 424 NTSTATUS status; 425 426 CallbackStart(); 427 status = m_Method(Device); 428 CallbackEnd(); 429 430 return status; 431 } 432 else { 433 return STATUS_SUCCESS; 434 } 435 } 436 }; 437 438 class FxPnpDeviceQueryStop : public FxCallback { 439 440 public: 441 PFN_WDF_DEVICE_QUERY_STOP m_Method; 442 443 FxPnpDeviceQueryStop( 444 VOID 445 ) : FxCallback(), m_Method(NULL) 446 { 447 } 448 449 _Must_inspect_result_ 450 NTSTATUS 451 Invoke( 452 __in WDFDEVICE Device 453 ) 454 { 455 if (m_Method != NULL) { 456 NTSTATUS status; 457 458 CallbackStart(); 459 status = m_Method(Device); 460 CallbackEnd(); 461 462 return status; 463 } 464 else { 465 return STATUS_SUCCESS; 466 } 467 } 468 }; 469 470 class FxPnpDeviceQueryRemove : public FxCallback { 471 472 public: 473 PFN_WDF_DEVICE_QUERY_REMOVE m_Method; 474 475 FxPnpDeviceQueryRemove( 476 VOID 477 ) : FxCallback(), m_Method(NULL) 478 { 479 } 480 481 _Must_inspect_result_ 482 NTSTATUS 483 Invoke( 484 __in WDFDEVICE Device 485 ) 486 { 487 if (m_Method != NULL) { 488 NTSTATUS status; 489 490 CallbackStart(); 491 status = m_Method(Device); 492 CallbackEnd(); 493 494 return status; 495 } 496 else { 497 return STATUS_SUCCESS; 498 } 499 } 500 }; 501 502 class FxPnpDeviceResourcesQuery : public FxCallback { 503 504 public: 505 PFN_WDF_DEVICE_RESOURCES_QUERY m_Method; 506 507 FxPnpDeviceResourcesQuery( 508 VOID 509 ) : FxCallback(), m_Method(NULL) 510 { 511 } 512 513 _Must_inspect_result_ 514 NTSTATUS 515 Invoke( 516 __in WDFDEVICE Device, 517 __in WDFCMRESLIST Collection 518 ) 519 { 520 if (m_Method != NULL) { 521 NTSTATUS status; 522 523 CallbackStart(); 524 status = m_Method(Device, Collection); 525 CallbackEnd(); 526 527 return status; 528 } 529 else { 530 return STATUS_SUCCESS; 531 } 532 } 533 }; 534 535 class FxPnpDeviceResourceRequirementsQuery : public FxCallback { 536 537 public: 538 PFN_WDF_DEVICE_RESOURCE_REQUIREMENTS_QUERY m_Method; 539 540 FxPnpDeviceResourceRequirementsQuery( 541 VOID 542 ) : FxCallback(), m_Method(NULL) 543 { 544 } 545 546 _Must_inspect_result_ 547 NTSTATUS 548 Invoke( 549 __in WDFDEVICE Device, 550 __in WDFIORESREQLIST Collection 551 ) 552 { 553 if (m_Method != NULL) { 554 NTSTATUS status; 555 556 CallbackStart(); 557 status = m_Method(Device, Collection); 558 CallbackEnd(); 559 560 return status; 561 } 562 else { 563 return STATUS_SUCCESS; 564 } 565 } 566 }; 567 568 class FxPnpDeviceEject : public FxCallback { 569 570 public: 571 PFN_WDF_DEVICE_EJECT m_Method; 572 573 FxPnpDeviceEject( 574 VOID 575 ) : FxCallback(), m_Method(NULL) 576 { 577 } 578 579 _Must_inspect_result_ 580 NTSTATUS 581 Invoke( 582 __in WDFDEVICE Device 583 ) 584 { 585 if (m_Method != NULL) { 586 NTSTATUS status; 587 588 CallbackStart(); 589 status = m_Method(Device); 590 CallbackEnd(); 591 592 return status; 593 } 594 else { 595 return STATUS_SUCCESS; 596 } 597 } 598 }; 599 600 class FxPnpDeviceSurpriseRemoval : public FxCallback { 601 602 public: 603 PFN_WDF_DEVICE_SURPRISE_REMOVAL m_Method; 604 605 FxPnpDeviceSurpriseRemoval( 606 VOID 607 ) : FxCallback(), m_Method(NULL) 608 { 609 } 610 611 VOID 612 Invoke( 613 __in WDFDEVICE Device 614 ) 615 { 616 if (m_Method != NULL) { 617 CallbackStart(); 618 m_Method(Device); 619 CallbackEnd(); 620 } 621 } 622 }; 623 624 class FxPnpDeviceUsageNotification : public FxCallback { 625 626 public: 627 PFN_WDF_DEVICE_USAGE_NOTIFICATION m_Method; 628 629 FxPnpDeviceUsageNotification( 630 VOID 631 ) : FxCallback(), m_Method(NULL) 632 { 633 } 634 635 VOID 636 Invoke( 637 __in WDFDEVICE Device, 638 __in WDF_SPECIAL_FILE_TYPE NotificationType, 639 __in BOOLEAN InPath 640 ) 641 { 642 if (m_Method != NULL) { 643 CallbackStart(); 644 m_Method(Device, NotificationType, InPath); 645 CallbackEnd(); 646 } 647 } 648 }; 649 650 class FxPnpDeviceUsageNotificationEx : public FxCallback { 651 652 public: 653 PFN_WDF_DEVICE_USAGE_NOTIFICATION_EX m_Method; 654 655 FxPnpDeviceUsageNotificationEx( 656 VOID 657 ) : FxCallback(), m_Method(NULL) 658 { 659 } 660 661 _Must_inspect_result_ 662 NTSTATUS 663 Invoke( 664 __in WDFDEVICE Device, 665 __in WDF_SPECIAL_FILE_TYPE NotificationType, 666 __in BOOLEAN InPath 667 ) 668 { 669 if (m_Method != NULL) { 670 NTSTATUS status; 671 672 CallbackStart(); 673 status = m_Method(Device, NotificationType, InPath); 674 CallbackEnd(); 675 676 return status; 677 } 678 else { 679 return STATUS_SUCCESS; 680 } 681 } 682 }; 683 684 class FxPnpDeviceRelationsQuery : public FxCallback { 685 686 public: 687 PFN_WDF_DEVICE_RELATIONS_QUERY m_Method; 688 689 FxPnpDeviceRelationsQuery( 690 VOID 691 ) : FxCallback(), m_Method(NULL) 692 { 693 } 694 695 VOID 696 Invoke( 697 __in WDFDEVICE Device, 698 __in DEVICE_RELATION_TYPE RelationType 699 ) 700 { 701 if (m_Method != NULL) { 702 CallbackStart(); 703 m_Method(Device, RelationType); 704 CallbackEnd(); 705 } 706 } 707 }; 708 709 class FxPnpDeviceSetLock : public FxCallback { 710 711 public: 712 PFN_WDF_DEVICE_SET_LOCK m_Method; 713 714 FxPnpDeviceSetLock( 715 VOID 716 ) : FxCallback(), m_Method(NULL) 717 { 718 } 719 720 _Must_inspect_result_ 721 NTSTATUS 722 Invoke( 723 __in WDFDEVICE Device, 724 __in BOOLEAN Lock 725 ) 726 { 727 if (m_Method != NULL) { 728 NTSTATUS status; 729 730 CallbackStart(); 731 status = m_Method(Device, Lock); 732 CallbackEnd(); 733 734 return status; 735 } 736 else { 737 return STATUS_UNSUCCESSFUL; 738 } 739 } 740 }; 741 742 class FxPnpDeviceReportedMissing : public FxCallback { 743 744 public: 745 PFN_WDF_DEVICE_REPORTED_MISSING m_Method; 746 747 FxPnpDeviceReportedMissing( 748 VOID 749 ) : FxCallback(), m_Method(NULL) 750 { 751 } 752 753 VOID 754 Invoke( 755 __in WDFDEVICE Device 756 ) 757 { 758 if (m_Method != NULL) { 759 CallbackStart(); 760 m_Method(Device); 761 CallbackEnd(); 762 } 763 } 764 }; 765 766 class FxPowerDeviceEnableWakeAtBus : public FxCallback { 767 768 public: 769 PFN_WDF_DEVICE_ENABLE_WAKE_AT_BUS m_Method; 770 771 FxPowerDeviceEnableWakeAtBus( 772 VOID 773 ) : FxCallback(), m_Method(NULL) 774 { 775 } 776 777 _Must_inspect_result_ 778 NTSTATUS 779 Invoke( 780 __in WDFDEVICE Device, 781 __in SYSTEM_POWER_STATE PowerState 782 ) 783 { 784 NTSTATUS status; 785 786 if (m_Method != NULL) { 787 CallbackStart(); 788 status = m_Method(Device, PowerState); 789 CallbackEnd(); 790 791 return status; 792 } 793 else { 794 return STATUS_SUCCESS; 795 } 796 } 797 }; 798 799 class FxPowerDeviceDisableWakeAtBus : public FxCallback { 800 801 public: 802 PFN_WDF_DEVICE_DISABLE_WAKE_AT_BUS m_Method; 803 804 FxPowerDeviceDisableWakeAtBus( 805 VOID 806 ) : FxCallback(), m_Method(NULL) 807 { 808 } 809 810 VOID 811 Invoke( 812 __in WDFDEVICE Device 813 ) 814 { 815 if (m_Method != NULL) { 816 CallbackStart(); 817 m_Method(Device); 818 CallbackEnd(); 819 } 820 } 821 }; 822 823 class FxPowerDeviceArmWakeFromS0 : public FxCallback { 824 825 public: 826 PFN_WDF_DEVICE_ARM_WAKE_FROM_S0 m_Method; 827 828 FxPowerDeviceArmWakeFromS0( 829 VOID 830 ) : m_Method(NULL) 831 { 832 } 833 834 _Must_inspect_result_ 835 NTSTATUS 836 Invoke( 837 __in WDFDEVICE Device 838 ) 839 { 840 if (m_Method != NULL) { 841 NTSTATUS status; 842 843 CallbackStart(); 844 status = m_Method(Device); 845 CallbackEnd(); 846 847 return status; 848 } 849 else { 850 return STATUS_SUCCESS; 851 } 852 } 853 }; 854 855 class FxPowerDeviceArmWakeFromSx : public FxCallback { 856 857 public: 858 PFN_WDF_DEVICE_ARM_WAKE_FROM_SX m_Method; 859 PFN_WDF_DEVICE_ARM_WAKE_FROM_SX_WITH_REASON m_MethodWithReason; 860 861 FxPowerDeviceArmWakeFromSx( 862 VOID 863 ) : m_Method(NULL), 864 m_MethodWithReason(NULL) 865 { 866 } 867 868 _Must_inspect_result_ 869 NTSTATUS 870 Invoke( 871 __in WDFDEVICE Device, 872 __in BOOLEAN DeviceWakeEnabled, 873 __in BOOLEAN ChildrenArmedForWake 874 ) 875 { 876 if (m_MethodWithReason != NULL) { 877 NTSTATUS status; 878 879 CallbackStart(); 880 status = m_MethodWithReason(Device, 881 DeviceWakeEnabled, 882 ChildrenArmedForWake); 883 CallbackEnd(); 884 885 return status; 886 } 887 else if (m_Method != NULL) { 888 NTSTATUS status; 889 890 CallbackStart(); 891 status = m_Method(Device); 892 CallbackEnd(); 893 894 return status; 895 } 896 else { 897 return STATUS_SUCCESS; 898 } 899 } 900 }; 901 902 class FxPowerDeviceDisarmWakeFromS0 : public FxCallback { 903 904 public: 905 PFN_WDF_DEVICE_DISARM_WAKE_FROM_S0 m_Method; 906 907 FxPowerDeviceDisarmWakeFromS0( 908 VOID 909 ) : m_Method(NULL) 910 { 911 } 912 913 VOID 914 Invoke( 915 __in WDFDEVICE Device 916 ) 917 { 918 if (m_Method != NULL) { 919 CallbackStart(); 920 m_Method(Device); 921 CallbackEnd(); 922 } 923 } 924 }; 925 926 class FxPowerDeviceDisarmWakeFromSx : public FxCallback { 927 928 public: 929 PFN_WDF_DEVICE_DISARM_WAKE_FROM_SX m_Method; 930 931 FxPowerDeviceDisarmWakeFromSx( 932 VOID 933 ) : m_Method(NULL) 934 { 935 } 936 937 VOID 938 Invoke( 939 __in WDFDEVICE Device 940 ) 941 { 942 if (m_Method != NULL) { 943 CallbackStart(); 944 m_Method(Device); 945 CallbackEnd(); 946 } 947 } 948 }; 949 950 class FxPowerDeviceWakeFromSxTriggered : public FxCallback { 951 952 public: 953 PFN_WDF_DEVICE_WAKE_FROM_SX_TRIGGERED m_Method; 954 955 FxPowerDeviceWakeFromSxTriggered( 956 VOID 957 ) : m_Method(NULL) 958 { 959 } 960 961 VOID 962 Invoke( 963 __in WDFDEVICE Device 964 ) 965 { 966 if (m_Method != NULL) { 967 CallbackStart(); 968 m_Method(Device); 969 CallbackEnd(); 970 } 971 } 972 }; 973 974 class FxPowerDeviceWakeFromS0Triggered : public FxCallback { 975 976 public: 977 PFN_WDF_DEVICE_WAKE_FROM_S0_TRIGGERED m_Method; 978 979 FxPowerDeviceWakeFromS0Triggered( 980 VOID 981 ) : m_Method(NULL) 982 { 983 } 984 985 VOID 986 Invoke( 987 __in WDFDEVICE Device 988 ) 989 { 990 if (m_Method != NULL) { 991 CallbackStart(); 992 m_Method(Device); 993 CallbackEnd(); 994 } 995 } 996 }; 997 998 struct FxPnpStateCallbackInfo { 999 // 1000 // Bit field of WDF_STATE_NOTIFICATION_TYPE defined values 1001 // 1002 ULONG Types; 1003 1004 // 1005 // Function to call 1006 // 1007 PFN_WDF_DEVICE_PNP_STATE_CHANGE_NOTIFICATION Callback; 1008 }; 1009 1010 struct FxPnpStateCallback : public FxCallback { 1011 1012 FxPnpStateCallback( 1013 VOID 1014 ) : FxCallback() 1015 { 1016 RtlZeroMemory(&m_Methods[0], sizeof(m_Methods)); 1017 } 1018 1019 VOID 1020 Invoke( 1021 __in WDF_DEVICE_PNP_STATE State, 1022 __in WDF_STATE_NOTIFICATION_TYPE Type, 1023 __in WDFDEVICE Device, 1024 __in PCWDF_DEVICE_PNP_NOTIFICATION_DATA NotificationData 1025 ) 1026 { 1027 FxPnpStateCallbackInfo* pInfo; 1028 1029 pInfo = &m_Methods[WdfDevStateNormalize(State)-WdfDevStatePnpObjectCreated]; 1030 1031 if (pInfo->Callback != NULL && (pInfo->Types & Type)) { 1032 CallbackStart(); 1033 pInfo->Callback(Device, NotificationData); 1034 CallbackEnd(); 1035 } 1036 } 1037 1038 FxPnpStateCallbackInfo m_Methods[WdfDevStatePnpNull - WdfDevStatePnpObjectCreated]; 1039 }; 1040 1041 struct FxPowerStateCallbackInfo { 1042 // 1043 // Bit field of WDF_STATE_NOTIFICATION_TYPE defined values 1044 // 1045 ULONG Types; 1046 1047 // 1048 // Function to call 1049 // 1050 PFN_WDF_DEVICE_POWER_STATE_CHANGE_NOTIFICATION Callback; 1051 }; 1052 1053 struct FxPowerStateCallback : public FxCallback { 1054 FxPowerStateCallback( 1055 VOID 1056 ) : FxCallback() 1057 { 1058 RtlZeroMemory(&m_Methods[0], sizeof(m_Methods)); 1059 } 1060 1061 VOID 1062 Invoke( 1063 __in WDF_DEVICE_POWER_STATE State, 1064 __in WDF_STATE_NOTIFICATION_TYPE Type, 1065 __in WDFDEVICE Device, 1066 __in PCWDF_DEVICE_POWER_NOTIFICATION_DATA NotificationData 1067 ) 1068 { 1069 FxPowerStateCallbackInfo *pInfo; 1070 1071 pInfo = &m_Methods[WdfDevStateNormalize(State)-WdfDevStatePowerObjectCreated]; 1072 1073 if (pInfo->Callback != NULL && (pInfo->Types & Type)) { 1074 CallbackStart(); 1075 pInfo->Callback(Device, NotificationData); 1076 CallbackEnd(); 1077 } 1078 } 1079 1080 FxPowerStateCallbackInfo m_Methods[WdfDevStatePowerNull-WdfDevStatePowerObjectCreated]; 1081 }; 1082 1083 struct FxPowerPolicyStateCallbackInfo { 1084 // 1085 // Bit field of WDF_STATE_NOTIFICATION_TYPE defined values 1086 // 1087 ULONG Types; 1088 1089 // 1090 // Function to call 1091 // 1092 PFN_WDF_DEVICE_POWER_POLICY_STATE_CHANGE_NOTIFICATION Callback; 1093 }; 1094 1095 struct FxPowerPolicyStateCallback : public FxCallback { 1096 FxPowerPolicyStateCallback( 1097 VOID 1098 ) : FxCallback() 1099 { 1100 RtlZeroMemory(&m_Methods[0], sizeof(m_Methods)); 1101 } 1102 1103 VOID 1104 Invoke( 1105 __in WDF_DEVICE_POWER_POLICY_STATE State, 1106 __in WDF_STATE_NOTIFICATION_TYPE Type, 1107 __in WDFDEVICE Device, 1108 __in PCWDF_DEVICE_POWER_POLICY_NOTIFICATION_DATA NotificationData 1109 ) 1110 { 1111 FxPowerPolicyStateCallbackInfo *pInfo; 1112 1113 pInfo = &m_Methods[WdfDevStateNormalize(State)-WdfDevStatePwrPolObjectCreated]; 1114 1115 if (pInfo->Callback != NULL && (pInfo->Types & Type)) { 1116 CallbackStart(); 1117 pInfo->Callback(Device, NotificationData); 1118 CallbackEnd(); 1119 } 1120 } 1121 1122 FxPowerPolicyStateCallbackInfo m_Methods[WdfDevStatePwrPolNull-WdfDevStatePwrPolObjectCreated]; 1123 }; 1124 1125 1126 1127 #endif // _FXPNPCALLBACKS_H_ 1128