1 /*++ 2 3 Copyright (c) Microsoft Corporation. All rights reserved. 4 5 _WdfVersionBuild_ 6 7 Module Name: 8 9 wdfio.h 10 11 Abstract: 12 13 This module contains contains the Windows Driver Framework I/O 14 interfaces. 15 16 Environment: 17 18 kernel mode only 19 20 Revision History: 21 22 23 --*/ 24 25 // 26 // NOTE: This header is generated by stubwork. Please make any 27 // modifications to the corresponding template files 28 // (.x or .y) and use stubwork to regenerate the header 29 // 30 31 #ifndef _WDFIO_H_ 32 #define _WDFIO_H_ 33 34 #ifndef WDF_EXTERN_C 35 #ifdef __cplusplus 36 #define WDF_EXTERN_C extern "C" 37 #define WDF_EXTERN_C_START extern "C" { 38 #define WDF_EXTERN_C_END } 39 #else 40 #define WDF_EXTERN_C 41 #define WDF_EXTERN_C_START 42 #define WDF_EXTERN_C_END 43 #endif 44 #endif 45 46 WDF_EXTERN_C_START 47 48 49 50 #if (NTDDI_VERSION >= NTDDI_WIN2K) 51 52 // 53 // Types 54 // 55 56 // 57 // This defines the dispatch type of the queue. This controls how 58 // the queue raises I/O events to the driver through the registered 59 // callbacks. 60 // 61 // Sequential allows the driver to have the queue automatically dispatch 62 // one request at a time, and will hold requests until a current request 63 // is completed. 64 // 65 // Parallel has the queue dispatch requests to the driver as they arrive 66 // at the queue, and the queue is in a processing state. The driver can 67 // look at the requests in real time, and decide to service them, forward them 68 // to another queue, pend them, or return a status to have the queue held 69 // due to a hardware or other resource limit. 70 // 71 // Manual allows the driver to create multiple queues for requests, and control 72 // when it wants to retrieve requests from the queue by calling the queues 73 // WdfIoQueueRetrieveNextRequest() API. 74 // 75 76 typedef enum _WDF_IO_QUEUE_DISPATCH_TYPE { 77 WdfIoQueueDispatchInvalid = 0, 78 WdfIoQueueDispatchSequential, 79 WdfIoQueueDispatchParallel, 80 WdfIoQueueDispatchManual, 81 WdfIoQueueDispatchMax, 82 } WDF_IO_QUEUE_DISPATCH_TYPE; 83 84 // 85 // This defines the status of the queue. 86 // 87 // WdfIoQueueAcceptRequests - If TRUE, Queue will accept requests from WDM 88 // dispatch through WdfDeviceConfigureRequestDispatching, 89 // or from WdfRequestForwardToIoQueue. 90 // 91 // If FALSE, Queue will complete requests with 92 // STATUS_CANCELLED from WdfDeviceConfigureRequestDispatching, 93 // and fail WdfRequestForwardToIoQueue with 94 // STATUS_WDF_BUSY. 95 // 96 // 97 // WdfIoQueueDispatchRequests - If TRUE, and the Queue is configured for 98 // automatic dispatch as either 99 // WdfIoQueueDispatchSequential, 100 // or WdfIoQueueDispatchParallel, the Queue will 101 // present the requests to the driver according 102 // to the drivers configuration. 103 // 104 // If FALSE, requests are not automatically 105 // presented to the device driver. 106 // 107 // This has no effect on the drivers ability to 108 // retrieve requests with WdfIoQueueRetrieveNextRequest. 109 // 110 // WdfIoQueueNoRequests - If TRUE, the Queue has no requests to present 111 // or return to the device driver. 112 // 113 // WdfIoQueueDriverNoRequests - If TRUE, the device driver is not operating 114 // on any requests retrieved from or presented 115 // by this Queue. 116 // 117 // WdfIoQueuePnpHeld - The Framework PnP stage has requested that 118 // the device driver stop receiving new requests. 119 // 120 // Automatic request dispatch stops, and 121 // WdfIoQueueRetrieveNextRequest returns STATUS_WDF_BUSY. 122 // 123 124 typedef enum _WDF_IO_QUEUE_STATE { 125 WdfIoQueueAcceptRequests = 0x01, 126 WdfIoQueueDispatchRequests = 0x02, 127 WdfIoQueueNoRequests = 0x04, 128 WdfIoQueueDriverNoRequests = 0x08, 129 WdfIoQueuePnpHeld = 0x10, 130 } WDF_IO_QUEUE_STATE; 131 132 133 134 135 // 136 // These macros represent some common Queue states 137 // 138 139 // 140 // A Queue is idle if it has no requests, and the driver 141 // is not operating on any. 142 // 143 144 FORCEINLINE 145 BOOLEAN 146 WDF_IO_QUEUE_IDLE( 147 _In_ WDF_IO_QUEUE_STATE State 148 ) 149 { 150 return ((State & WdfIoQueueNoRequests) && 151 (State & WdfIoQueueDriverNoRequests)) ? TRUE: FALSE; 152 } 153 154 // 155 // A Queue is ready if it can accept and dispatch requests and 156 // queue is not held by PNP 157 // 158 FORCEINLINE 159 BOOLEAN 160 WDF_IO_QUEUE_READY( 161 _In_ WDF_IO_QUEUE_STATE State 162 ) 163 { 164 return ((State & WdfIoQueueDispatchRequests) && 165 (State & WdfIoQueueAcceptRequests) && 166 ((State & WdfIoQueuePnpHeld)==0)) ? TRUE: FALSE; 167 } 168 169 // 170 // A Queue is stopped if it can accept new requests, but 171 // is not automatically delivering them to the device driver, 172 // and the queue is idle. 173 // 174 FORCEINLINE 175 BOOLEAN 176 WDF_IO_QUEUE_STOPPED( 177 _In_ WDF_IO_QUEUE_STATE State 178 ) 179 { 180 return (((State & WdfIoQueueDispatchRequests) == 0) && 181 (State & WdfIoQueueAcceptRequests) && 182 (State & WdfIoQueueDriverNoRequests)) ? TRUE: FALSE; 183 184 } 185 186 // 187 // A Queue is drained if it can not accept new requests but 188 // can dispatch existing requests, and there are no requests 189 // either in the Queue or the device driver. 190 // 191 192 FORCEINLINE 193 BOOLEAN 194 WDF_IO_QUEUE_DRAINED( 195 _In_ WDF_IO_QUEUE_STATE State 196 ) 197 { 198 return ( ((State & WdfIoQueueAcceptRequests)==0) && 199 (State & WdfIoQueueDispatchRequests) && 200 (State & WdfIoQueueNoRequests) && 201 (State & WdfIoQueueDriverNoRequests) ) ? TRUE: FALSE; 202 203 } 204 205 // 206 // A Queue is purged if it can not accept new requests 207 // and there are no requests either in the Queue or 208 // the device driver. 209 // 210 FORCEINLINE 211 BOOLEAN 212 WDF_IO_QUEUE_PURGED( 213 _In_ WDF_IO_QUEUE_STATE State 214 ) 215 { 216 return ( ((State & WdfIoQueueAcceptRequests)==0) && 217 (State & WdfIoQueueNoRequests) && 218 (State & WdfIoQueueDriverNoRequests) ) ? TRUE: FALSE; 219 220 } 221 222 // 223 // Event callback definitions 224 // 225 226 typedef 227 _Function_class_(EVT_WDF_IO_QUEUE_IO_DEFAULT) 228 _IRQL_requires_same_ 229 _IRQL_requires_max_(DISPATCH_LEVEL) 230 VOID 231 STDCALL 232 EVT_WDF_IO_QUEUE_IO_DEFAULT( 233 _In_ 234 WDFQUEUE Queue, 235 _In_ 236 WDFREQUEST Request 237 ); 238 239 typedef EVT_WDF_IO_QUEUE_IO_DEFAULT *PFN_WDF_IO_QUEUE_IO_DEFAULT; 240 241 242 typedef 243 _Function_class_(EVT_WDF_IO_QUEUE_IO_STOP) 244 _IRQL_requires_same_ 245 _IRQL_requires_max_(DISPATCH_LEVEL) 246 VOID 247 STDCALL 248 EVT_WDF_IO_QUEUE_IO_STOP( 249 _In_ 250 WDFQUEUE Queue, 251 _In_ 252 WDFREQUEST Request, 253 _In_ 254 ULONG ActionFlags 255 ); 256 257 typedef EVT_WDF_IO_QUEUE_IO_STOP *PFN_WDF_IO_QUEUE_IO_STOP; 258 259 typedef 260 _Function_class_(EVT_WDF_IO_QUEUE_IO_RESUME) 261 _IRQL_requires_same_ 262 _IRQL_requires_max_(DISPATCH_LEVEL) 263 VOID 264 STDCALL 265 EVT_WDF_IO_QUEUE_IO_RESUME( 266 _In_ 267 WDFQUEUE Queue, 268 _In_ 269 WDFREQUEST Request 270 ); 271 272 typedef EVT_WDF_IO_QUEUE_IO_RESUME *PFN_WDF_IO_QUEUE_IO_RESUME; 273 274 typedef 275 _Function_class_(EVT_WDF_IO_QUEUE_IO_READ) 276 _IRQL_requires_same_ 277 _IRQL_requires_max_(DISPATCH_LEVEL) 278 VOID 279 STDCALL 280 EVT_WDF_IO_QUEUE_IO_READ( 281 _In_ 282 WDFQUEUE Queue, 283 _In_ 284 WDFREQUEST Request, 285 _In_ 286 size_t Length 287 ); 288 289 typedef EVT_WDF_IO_QUEUE_IO_READ *PFN_WDF_IO_QUEUE_IO_READ; 290 291 typedef 292 _Function_class_(EVT_WDF_IO_QUEUE_IO_WRITE) 293 _IRQL_requires_same_ 294 _IRQL_requires_max_(DISPATCH_LEVEL) 295 VOID 296 STDCALL 297 EVT_WDF_IO_QUEUE_IO_WRITE( 298 _In_ 299 WDFQUEUE Queue, 300 _In_ 301 WDFREQUEST Request, 302 _In_ 303 size_t Length 304 ); 305 306 typedef EVT_WDF_IO_QUEUE_IO_WRITE *PFN_WDF_IO_QUEUE_IO_WRITE; 307 308 typedef 309 _Function_class_(EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL) 310 _IRQL_requires_same_ 311 _IRQL_requires_max_(DISPATCH_LEVEL) 312 VOID 313 STDCALL 314 EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL( 315 _In_ 316 WDFQUEUE Queue, 317 _In_ 318 WDFREQUEST Request, 319 _In_ 320 size_t OutputBufferLength, 321 _In_ 322 size_t InputBufferLength, 323 _In_ 324 ULONG IoControlCode 325 ); 326 327 typedef EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL *PFN_WDF_IO_QUEUE_IO_DEVICE_CONTROL; 328 329 typedef 330 _Function_class_(EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL) 331 _IRQL_requires_same_ 332 _IRQL_requires_max_(DISPATCH_LEVEL) 333 VOID 334 STDCALL 335 EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL( 336 _In_ 337 WDFQUEUE Queue, 338 _In_ 339 WDFREQUEST Request, 340 _In_ 341 size_t OutputBufferLength, 342 _In_ 343 size_t InputBufferLength, 344 _In_ 345 ULONG IoControlCode 346 ); 347 348 typedef EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL *PFN_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL; 349 350 351 typedef 352 _Function_class_(EVT_WDF_IO_QUEUE_IO_CANCELED_ON_QUEUE) 353 _IRQL_requires_same_ 354 _IRQL_requires_max_(DISPATCH_LEVEL) 355 VOID 356 STDCALL 357 EVT_WDF_IO_QUEUE_IO_CANCELED_ON_QUEUE( 358 _In_ 359 WDFQUEUE Queue, 360 _In_ 361 WDFREQUEST Request 362 ); 363 364 typedef EVT_WDF_IO_QUEUE_IO_CANCELED_ON_QUEUE *PFN_WDF_IO_QUEUE_IO_CANCELED_ON_QUEUE; 365 366 367 typedef 368 _Function_class_(EVT_WDF_IO_QUEUE_STATE) 369 _IRQL_requires_same_ 370 _IRQL_requires_max_(DISPATCH_LEVEL) 371 VOID 372 STDCALL 373 EVT_WDF_IO_QUEUE_STATE( 374 _In_ 375 WDFQUEUE Queue, 376 _In_ 377 WDFCONTEXT Context 378 ); 379 380 typedef EVT_WDF_IO_QUEUE_STATE *PFN_WDF_IO_QUEUE_STATE; 381 382 // 383 // This is the structure used to configure an IoQueue and 384 // register callback events to it. 385 // 386 387 typedef struct _WDF_IO_QUEUE_CONFIG { 388 389 ULONG Size; 390 391 WDF_IO_QUEUE_DISPATCH_TYPE DispatchType; 392 393 WDF_TRI_STATE PowerManaged; 394 395 BOOLEAN AllowZeroLengthRequests; 396 397 BOOLEAN DefaultQueue; 398 399 PFN_WDF_IO_QUEUE_IO_DEFAULT EvtIoDefault; 400 401 PFN_WDF_IO_QUEUE_IO_READ EvtIoRead; 402 403 PFN_WDF_IO_QUEUE_IO_WRITE EvtIoWrite; 404 405 PFN_WDF_IO_QUEUE_IO_DEVICE_CONTROL EvtIoDeviceControl; 406 407 PFN_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL EvtIoInternalDeviceControl; 408 409 PFN_WDF_IO_QUEUE_IO_STOP EvtIoStop; 410 411 PFN_WDF_IO_QUEUE_IO_RESUME EvtIoResume; 412 413 PFN_WDF_IO_QUEUE_IO_CANCELED_ON_QUEUE EvtIoCanceledOnQueue; 414 415 union { 416 struct { 417 ULONG NumberOfPresentedRequests; 418 } Parallel; 419 } Settings; 420 421 WDFDRIVER Driver; 422 } WDF_IO_QUEUE_CONFIG, *PWDF_IO_QUEUE_CONFIG; 423 424 FORCEINLINE 425 VOID 426 WDF_IO_QUEUE_CONFIG_INIT( 427 _Out_ PWDF_IO_QUEUE_CONFIG Config, 428 _In_ WDF_IO_QUEUE_DISPATCH_TYPE DispatchType 429 ) 430 { 431 RtlZeroMemory(Config, sizeof(WDF_IO_QUEUE_CONFIG)); 432 433 Config->Size = sizeof(WDF_IO_QUEUE_CONFIG); 434 Config->PowerManaged = WdfUseDefault; 435 Config->DispatchType = DispatchType; 436 if (Config->DispatchType == WdfIoQueueDispatchParallel) { 437 Config->Settings.Parallel.NumberOfPresentedRequests = (ULONG)-1; 438 } 439 } 440 441 FORCEINLINE 442 VOID 443 WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE( 444 _Out_ PWDF_IO_QUEUE_CONFIG Config, 445 _In_ WDF_IO_QUEUE_DISPATCH_TYPE DispatchType 446 ) 447 { 448 RtlZeroMemory(Config, sizeof(WDF_IO_QUEUE_CONFIG)); 449 450 Config->Size = sizeof(WDF_IO_QUEUE_CONFIG); 451 Config->PowerManaged = WdfUseDefault; 452 Config->DefaultQueue = TRUE; 453 Config->DispatchType = DispatchType; 454 if (Config->DispatchType == WdfIoQueueDispatchParallel) { 455 Config->Settings.Parallel.NumberOfPresentedRequests = (ULONG)-1; 456 } 457 } 458 459 typedef enum _WDF_IO_FORWARD_PROGRESS_ACTION { 460 WdfIoForwardProgressActionInvalid = 0x0, 461 WdfIoForwardProgressActionFailRequest, 462 WdfIoForwardProgressActionUseReservedRequest 463 } WDF_IO_FORWARD_PROGRESS_ACTION; 464 465 typedef enum _WDF_IO_FORWARD_PROGRESS_RESERVED_POLICY { 466 WdfIoForwardProgressInvalidPolicy =0x0, 467 WdfIoForwardProgressReservedPolicyAlwaysUseReservedRequest, 468 WdfIoForwardProgressReservedPolicyUseExamine, 469 WdfIoForwardProgressReservedPolicyPagingIO 470 } WDF_IO_FORWARD_PROGRESS_RESERVED_POLICY; 471 472 typedef 473 _Function_class_(EVT_WDF_IO_ALLOCATE_RESOURCES_FOR_RESERVED_REQUEST) 474 _IRQL_requires_same_ 475 _IRQL_requires_max_(DISPATCH_LEVEL) 476 NTSTATUS 477 STDCALL 478 EVT_WDF_IO_ALLOCATE_RESOURCES_FOR_RESERVED_REQUEST( 479 _In_ 480 WDFQUEUE Queue, 481 _In_ 482 WDFREQUEST Request 483 ); 484 485 typedef EVT_WDF_IO_ALLOCATE_RESOURCES_FOR_RESERVED_REQUEST *PFN_WDF_IO_ALLOCATE_RESOURCES_FOR_RESERVED_REQUEST; 486 487 typedef 488 _Function_class_(EVT_WDF_IO_ALLOCATE_REQUEST_RESOURCES) 489 _IRQL_requires_same_ 490 _IRQL_requires_max_(DISPATCH_LEVEL) 491 NTSTATUS 492 STDCALL 493 EVT_WDF_IO_ALLOCATE_REQUEST_RESOURCES( 494 _In_ 495 WDFQUEUE Queue, 496 _In_ 497 WDFREQUEST Request 498 ); 499 500 typedef EVT_WDF_IO_ALLOCATE_REQUEST_RESOURCES *PFN_WDF_IO_ALLOCATE_REQUEST_RESOURCES; 501 502 typedef 503 _Function_class_(EVT_WDF_IO_WDM_IRP_FOR_FORWARD_PROGRESS) 504 _IRQL_requires_same_ 505 _IRQL_requires_max_(DISPATCH_LEVEL) 506 WDF_IO_FORWARD_PROGRESS_ACTION 507 STDCALL 508 EVT_WDF_IO_WDM_IRP_FOR_FORWARD_PROGRESS( 509 _In_ 510 WDFQUEUE Queue, 511 _In_ 512 PIRP Irp 513 ); 514 515 typedef EVT_WDF_IO_WDM_IRP_FOR_FORWARD_PROGRESS *PFN_WDF_IO_WDM_IRP_FOR_FORWARD_PROGRESS; 516 517 typedef struct _WDF_IO_FORWARD_PROGRESS_RESERVED_POLICY_SETTINGS { 518 union { 519 520 struct { 521 PFN_WDF_IO_WDM_IRP_FOR_FORWARD_PROGRESS EvtIoWdmIrpForForwardProgress; 522 } ExaminePolicy; 523 524 } Policy; 525 } WDF_IO_FORWARD_PROGRESS_RESERVED_POLICY_SETTINGS; 526 527 typedef struct _WDF_IO_QUEUE_FORWARD_PROGRESS_POLICY { 528 ULONG Size; 529 530 ULONG TotalForwardProgressRequests; 531 532 // 533 // Specify the type of the policy here. 534 // 535 WDF_IO_FORWARD_PROGRESS_RESERVED_POLICY ForwardProgressReservedPolicy; 536 537 // 538 // Structure which contains the policy specific fields 539 // 540 WDF_IO_FORWARD_PROGRESS_RESERVED_POLICY_SETTINGS ForwardProgressReservePolicySettings; 541 542 // 543 // Callback for reserved request given at initialization time 544 // 545 PFN_WDF_IO_ALLOCATE_RESOURCES_FOR_RESERVED_REQUEST EvtIoAllocateResourcesForReservedRequest; 546 547 // 548 // Callback for reserved request given at run time 549 // 550 PFN_WDF_IO_ALLOCATE_REQUEST_RESOURCES EvtIoAllocateRequestResources; 551 552 } WDF_IO_QUEUE_FORWARD_PROGRESS_POLICY, *PWDF_IO_QUEUE_FORWARD_PROGRESS_POLICY; 553 554 FORCEINLINE 555 VOID 556 WDF_IO_QUEUE_FORWARD_PROGRESS_POLICY_DEFAULT_INIT( 557 _Out_ PWDF_IO_QUEUE_FORWARD_PROGRESS_POLICY Policy, 558 _In_ ULONG TotalForwardProgressRequests 559 ) 560 { 561 RtlZeroMemory(Policy, sizeof(WDF_IO_QUEUE_FORWARD_PROGRESS_POLICY)); 562 563 Policy->Size = sizeof(WDF_IO_QUEUE_FORWARD_PROGRESS_POLICY); 564 Policy->TotalForwardProgressRequests = TotalForwardProgressRequests; 565 Policy->ForwardProgressReservedPolicy = WdfIoForwardProgressReservedPolicyAlwaysUseReservedRequest; 566 } 567 568 569 FORCEINLINE 570 VOID 571 WDF_IO_QUEUE_FORWARD_PROGRESS_POLICY_EXAMINE_INIT( 572 _Out_ PWDF_IO_QUEUE_FORWARD_PROGRESS_POLICY Policy, 573 _In_ ULONG TotalForwardProgressRequests, 574 _In_ PFN_WDF_IO_WDM_IRP_FOR_FORWARD_PROGRESS EvtIoWdmIrpForForwardProgress 575 ) 576 { 577 RtlZeroMemory(Policy, sizeof(WDF_IO_QUEUE_FORWARD_PROGRESS_POLICY)); 578 579 Policy->Size = sizeof(WDF_IO_QUEUE_FORWARD_PROGRESS_POLICY); 580 Policy->TotalForwardProgressRequests = TotalForwardProgressRequests; 581 Policy->ForwardProgressReservedPolicy = WdfIoForwardProgressReservedPolicyUseExamine; 582 Policy->ForwardProgressReservePolicySettings.Policy.ExaminePolicy.EvtIoWdmIrpForForwardProgress = 583 EvtIoWdmIrpForForwardProgress; 584 } 585 586 FORCEINLINE 587 VOID 588 WDF_IO_QUEUE_FORWARD_PROGRESS_POLICY_PAGINGIO_INIT( 589 _Out_ PWDF_IO_QUEUE_FORWARD_PROGRESS_POLICY Policy, 590 _In_ ULONG TotalForwardProgressRequests 591 ) 592 { 593 RtlZeroMemory(Policy, sizeof(WDF_IO_QUEUE_FORWARD_PROGRESS_POLICY)); 594 595 Policy->Size = sizeof(WDF_IO_QUEUE_FORWARD_PROGRESS_POLICY); 596 Policy->TotalForwardProgressRequests = TotalForwardProgressRequests; 597 Policy->ForwardProgressReservedPolicy = WdfIoForwardProgressReservedPolicyPagingIO; 598 } 599 600 601 // 602 // WDF Function: WdfIoQueueCreate 603 // 604 typedef 605 _Must_inspect_result_ 606 _IRQL_requires_max_(DISPATCH_LEVEL) 607 WDFAPI 608 NTSTATUS 609 (STDCALL *PFN_WDFIOQUEUECREATE)( 610 _In_ 611 PWDF_DRIVER_GLOBALS DriverGlobals, 612 _In_ 613 WDFDEVICE Device, 614 _In_ 615 PWDF_IO_QUEUE_CONFIG Config, 616 _In_opt_ 617 PWDF_OBJECT_ATTRIBUTES QueueAttributes, 618 _Out_opt_ 619 WDFQUEUE* Queue 620 ); 621 622 _Must_inspect_result_ 623 _IRQL_requires_max_(DISPATCH_LEVEL) 624 FORCEINLINE 625 NTSTATUS 626 WdfIoQueueCreate( 627 _In_ 628 WDFDEVICE Device, 629 _In_ 630 PWDF_IO_QUEUE_CONFIG Config, 631 _In_opt_ 632 PWDF_OBJECT_ATTRIBUTES QueueAttributes, 633 _Out_opt_ 634 WDFQUEUE* Queue 635 ) 636 { 637 return ((PFN_WDFIOQUEUECREATE) WdfFunctions[WdfIoQueueCreateTableIndex])(WdfDriverGlobals, Device, Config, QueueAttributes, Queue); 638 } 639 640 // 641 // WDF Function: WdfIoQueueGetState 642 // 643 typedef 644 _IRQL_requires_max_(DISPATCH_LEVEL) 645 WDFAPI 646 WDF_IO_QUEUE_STATE 647 (STDCALL *PFN_WDFIOQUEUEGETSTATE)( 648 _In_ 649 PWDF_DRIVER_GLOBALS DriverGlobals, 650 _In_ 651 WDFQUEUE Queue, 652 _Out_opt_ 653 PULONG QueueRequests, 654 _Out_opt_ 655 PULONG DriverRequests 656 ); 657 658 _IRQL_requires_max_(DISPATCH_LEVEL) 659 FORCEINLINE 660 WDF_IO_QUEUE_STATE 661 WdfIoQueueGetState( 662 _In_ 663 WDFQUEUE Queue, 664 _Out_opt_ 665 PULONG QueueRequests, 666 _Out_opt_ 667 PULONG DriverRequests 668 ) 669 { 670 return ((PFN_WDFIOQUEUEGETSTATE) WdfFunctions[WdfIoQueueGetStateTableIndex])(WdfDriverGlobals, Queue, QueueRequests, DriverRequests); 671 } 672 673 // 674 // WDF Function: WdfIoQueueStart 675 // 676 typedef 677 _IRQL_requires_max_(DISPATCH_LEVEL) 678 WDFAPI 679 VOID 680 (STDCALL *PFN_WDFIOQUEUESTART)( 681 _In_ 682 PWDF_DRIVER_GLOBALS DriverGlobals, 683 _In_ 684 WDFQUEUE Queue 685 ); 686 687 _IRQL_requires_max_(DISPATCH_LEVEL) 688 FORCEINLINE 689 VOID 690 WdfIoQueueStart( 691 _In_ 692 WDFQUEUE Queue 693 ) 694 { 695 ((PFN_WDFIOQUEUESTART) WdfFunctions[WdfIoQueueStartTableIndex])(WdfDriverGlobals, Queue); 696 } 697 698 // 699 // WDF Function: WdfIoQueueStop 700 // 701 typedef 702 _IRQL_requires_max_(DISPATCH_LEVEL) 703 WDFAPI 704 VOID 705 (STDCALL *PFN_WDFIOQUEUESTOP)( 706 _In_ 707 PWDF_DRIVER_GLOBALS DriverGlobals, 708 _In_ 709 WDFQUEUE Queue, 710 _When_(Context != 0, _In_) 711 _When_(Context == 0, _In_opt_) 712 PFN_WDF_IO_QUEUE_STATE StopComplete, 713 _When_(StopComplete != 0, _In_) 714 _When_(StopComplete == 0, _In_opt_) 715 WDFCONTEXT Context 716 ); 717 718 _IRQL_requires_max_(DISPATCH_LEVEL) 719 FORCEINLINE 720 VOID 721 WdfIoQueueStop( 722 _In_ 723 WDFQUEUE Queue, 724 _When_(Context != 0, _In_) 725 _When_(Context == 0, _In_opt_) 726 PFN_WDF_IO_QUEUE_STATE StopComplete, 727 _When_(StopComplete != 0, _In_) 728 _When_(StopComplete == 0, _In_opt_) 729 WDFCONTEXT Context 730 ) 731 { 732 ((PFN_WDFIOQUEUESTOP) WdfFunctions[WdfIoQueueStopTableIndex])(WdfDriverGlobals, Queue, StopComplete, Context); 733 } 734 735 // 736 // WDF Function: WdfIoQueueStopSynchronously 737 // 738 typedef 739 _IRQL_requires_max_(PASSIVE_LEVEL) 740 WDFAPI 741 VOID 742 (STDCALL *PFN_WDFIOQUEUESTOPSYNCHRONOUSLY)( 743 _In_ 744 PWDF_DRIVER_GLOBALS DriverGlobals, 745 _In_ 746 WDFQUEUE Queue 747 ); 748 749 _IRQL_requires_max_(PASSIVE_LEVEL) 750 FORCEINLINE 751 VOID 752 WdfIoQueueStopSynchronously( 753 _In_ 754 WDFQUEUE Queue 755 ) 756 { 757 ((PFN_WDFIOQUEUESTOPSYNCHRONOUSLY) WdfFunctions[WdfIoQueueStopSynchronouslyTableIndex])(WdfDriverGlobals, Queue); 758 } 759 760 // 761 // WDF Function: WdfIoQueueGetDevice 762 // 763 typedef 764 _IRQL_requires_max_(DISPATCH_LEVEL) 765 WDFAPI 766 WDFDEVICE 767 (STDCALL *PFN_WDFIOQUEUEGETDEVICE)( 768 _In_ 769 PWDF_DRIVER_GLOBALS DriverGlobals, 770 _In_ 771 WDFQUEUE Queue 772 ); 773 774 _IRQL_requires_max_(DISPATCH_LEVEL) 775 FORCEINLINE 776 WDFDEVICE 777 WdfIoQueueGetDevice( 778 _In_ 779 WDFQUEUE Queue 780 ) 781 { 782 return ((PFN_WDFIOQUEUEGETDEVICE) WdfFunctions[WdfIoQueueGetDeviceTableIndex])(WdfDriverGlobals, Queue); 783 } 784 785 // 786 // WDF Function: WdfIoQueueRetrieveNextRequest 787 // 788 typedef 789 _Must_inspect_result_ 790 _IRQL_requires_max_(DISPATCH_LEVEL) 791 WDFAPI 792 NTSTATUS 793 (STDCALL *PFN_WDFIOQUEUERETRIEVENEXTREQUEST)( 794 _In_ 795 PWDF_DRIVER_GLOBALS DriverGlobals, 796 _In_ 797 WDFQUEUE Queue, 798 _Out_ 799 WDFREQUEST* OutRequest 800 ); 801 802 _Must_inspect_result_ 803 _IRQL_requires_max_(DISPATCH_LEVEL) 804 FORCEINLINE 805 NTSTATUS 806 WdfIoQueueRetrieveNextRequest( 807 _In_ 808 WDFQUEUE Queue, 809 _Out_ 810 WDFREQUEST* OutRequest 811 ) 812 { 813 return ((PFN_WDFIOQUEUERETRIEVENEXTREQUEST) WdfFunctions[WdfIoQueueRetrieveNextRequestTableIndex])(WdfDriverGlobals, Queue, OutRequest); 814 } 815 816 // 817 // WDF Function: WdfIoQueueRetrieveRequestByFileObject 818 // 819 typedef 820 _Must_inspect_result_ 821 _IRQL_requires_max_(DISPATCH_LEVEL) 822 WDFAPI 823 NTSTATUS 824 (STDCALL *PFN_WDFIOQUEUERETRIEVEREQUESTBYFILEOBJECT)( 825 _In_ 826 PWDF_DRIVER_GLOBALS DriverGlobals, 827 _In_ 828 WDFQUEUE Queue, 829 _In_ 830 WDFFILEOBJECT FileObject, 831 _Out_ 832 WDFREQUEST* OutRequest 833 ); 834 835 _Must_inspect_result_ 836 _IRQL_requires_max_(DISPATCH_LEVEL) 837 FORCEINLINE 838 NTSTATUS 839 WdfIoQueueRetrieveRequestByFileObject( 840 _In_ 841 WDFQUEUE Queue, 842 _In_ 843 WDFFILEOBJECT FileObject, 844 _Out_ 845 WDFREQUEST* OutRequest 846 ) 847 { 848 return ((PFN_WDFIOQUEUERETRIEVEREQUESTBYFILEOBJECT) WdfFunctions[WdfIoQueueRetrieveRequestByFileObjectTableIndex])(WdfDriverGlobals, Queue, FileObject, OutRequest); 849 } 850 851 // 852 // WDF Function: WdfIoQueueFindRequest 853 // 854 typedef 855 _Must_inspect_result_ 856 _IRQL_requires_max_(DISPATCH_LEVEL) 857 WDFAPI 858 NTSTATUS 859 (STDCALL *PFN_WDFIOQUEUEFINDREQUEST)( 860 _In_ 861 PWDF_DRIVER_GLOBALS DriverGlobals, 862 _In_ 863 WDFQUEUE Queue, 864 _In_opt_ 865 WDFREQUEST FoundRequest, 866 _In_opt_ 867 WDFFILEOBJECT FileObject, 868 _Inout_opt_ 869 PWDF_REQUEST_PARAMETERS Parameters, 870 _Out_ 871 WDFREQUEST* OutRequest 872 ); 873 874 _Must_inspect_result_ 875 _IRQL_requires_max_(DISPATCH_LEVEL) 876 FORCEINLINE 877 NTSTATUS 878 WdfIoQueueFindRequest( 879 _In_ 880 WDFQUEUE Queue, 881 _In_opt_ 882 WDFREQUEST FoundRequest, 883 _In_opt_ 884 WDFFILEOBJECT FileObject, 885 _Inout_opt_ 886 PWDF_REQUEST_PARAMETERS Parameters, 887 _Out_ 888 WDFREQUEST* OutRequest 889 ) 890 { 891 return ((PFN_WDFIOQUEUEFINDREQUEST) WdfFunctions[WdfIoQueueFindRequestTableIndex])(WdfDriverGlobals, Queue, FoundRequest, FileObject, Parameters, OutRequest); 892 } 893 894 // 895 // WDF Function: WdfIoQueueRetrieveFoundRequest 896 // 897 typedef 898 _Must_inspect_result_ 899 _IRQL_requires_max_(DISPATCH_LEVEL) 900 WDFAPI 901 NTSTATUS 902 (STDCALL *PFN_WDFIOQUEUERETRIEVEFOUNDREQUEST)( 903 _In_ 904 PWDF_DRIVER_GLOBALS DriverGlobals, 905 _In_ 906 WDFQUEUE Queue, 907 _In_ 908 WDFREQUEST FoundRequest, 909 _Out_ 910 WDFREQUEST* OutRequest 911 ); 912 913 _Must_inspect_result_ 914 _IRQL_requires_max_(DISPATCH_LEVEL) 915 FORCEINLINE 916 NTSTATUS 917 WdfIoQueueRetrieveFoundRequest( 918 _In_ 919 WDFQUEUE Queue, 920 _In_ 921 WDFREQUEST FoundRequest, 922 _Out_ 923 WDFREQUEST* OutRequest 924 ) 925 { 926 return ((PFN_WDFIOQUEUERETRIEVEFOUNDREQUEST) WdfFunctions[WdfIoQueueRetrieveFoundRequestTableIndex])(WdfDriverGlobals, Queue, FoundRequest, OutRequest); 927 } 928 929 // 930 // WDF Function: WdfIoQueueDrainSynchronously 931 // 932 typedef 933 _IRQL_requires_max_(PASSIVE_LEVEL) 934 WDFAPI 935 VOID 936 (STDCALL *PFN_WDFIOQUEUEDRAINSYNCHRONOUSLY)( 937 _In_ 938 PWDF_DRIVER_GLOBALS DriverGlobals, 939 _In_ 940 WDFQUEUE Queue 941 ); 942 943 _IRQL_requires_max_(PASSIVE_LEVEL) 944 FORCEINLINE 945 VOID 946 WdfIoQueueDrainSynchronously( 947 _In_ 948 WDFQUEUE Queue 949 ) 950 { 951 ((PFN_WDFIOQUEUEDRAINSYNCHRONOUSLY) WdfFunctions[WdfIoQueueDrainSynchronouslyTableIndex])(WdfDriverGlobals, Queue); 952 } 953 954 // 955 // WDF Function: WdfIoQueueDrain 956 // 957 typedef 958 _IRQL_requires_max_(DISPATCH_LEVEL) 959 WDFAPI 960 VOID 961 (STDCALL *PFN_WDFIOQUEUEDRAIN)( 962 _In_ 963 PWDF_DRIVER_GLOBALS DriverGlobals, 964 _In_ 965 WDFQUEUE Queue, 966 _When_(Context != 0, _In_) 967 _When_(Context == 0, _In_opt_) 968 PFN_WDF_IO_QUEUE_STATE DrainComplete, 969 _When_(DrainComplete != 0, _In_) 970 _When_(DrainComplete == 0, _In_opt_) 971 WDFCONTEXT Context 972 ); 973 974 _IRQL_requires_max_(DISPATCH_LEVEL) 975 FORCEINLINE 976 VOID 977 WdfIoQueueDrain( 978 _In_ 979 WDFQUEUE Queue, 980 _When_(Context != 0, _In_) 981 _When_(Context == 0, _In_opt_) 982 PFN_WDF_IO_QUEUE_STATE DrainComplete, 983 _When_(DrainComplete != 0, _In_) 984 _When_(DrainComplete == 0, _In_opt_) 985 WDFCONTEXT Context 986 ) 987 { 988 ((PFN_WDFIOQUEUEDRAIN) WdfFunctions[WdfIoQueueDrainTableIndex])(WdfDriverGlobals, Queue, DrainComplete, Context); 989 } 990 991 // 992 // WDF Function: WdfIoQueuePurgeSynchronously 993 // 994 typedef 995 _IRQL_requires_max_(PASSIVE_LEVEL) 996 WDFAPI 997 VOID 998 (STDCALL *PFN_WDFIOQUEUEPURGESYNCHRONOUSLY)( 999 _In_ 1000 PWDF_DRIVER_GLOBALS DriverGlobals, 1001 _In_ 1002 WDFQUEUE Queue 1003 ); 1004 1005 _IRQL_requires_max_(PASSIVE_LEVEL) 1006 FORCEINLINE 1007 VOID 1008 WdfIoQueuePurgeSynchronously( 1009 _In_ 1010 WDFQUEUE Queue 1011 ) 1012 { 1013 ((PFN_WDFIOQUEUEPURGESYNCHRONOUSLY) WdfFunctions[WdfIoQueuePurgeSynchronouslyTableIndex])(WdfDriverGlobals, Queue); 1014 } 1015 1016 // 1017 // WDF Function: WdfIoQueuePurge 1018 // 1019 typedef 1020 _IRQL_requires_max_(DISPATCH_LEVEL) 1021 WDFAPI 1022 VOID 1023 (STDCALL *PFN_WDFIOQUEUEPURGE)( 1024 _In_ 1025 PWDF_DRIVER_GLOBALS DriverGlobals, 1026 _In_ 1027 WDFQUEUE Queue, 1028 _When_(Context != 0, _In_) 1029 _When_(Context == 0, _In_opt_) 1030 PFN_WDF_IO_QUEUE_STATE PurgeComplete, 1031 _When_(PurgeComplete != 0, _In_) 1032 _When_(PurgeComplete == 0, _In_opt_) 1033 WDFCONTEXT Context 1034 ); 1035 1036 _IRQL_requires_max_(DISPATCH_LEVEL) 1037 FORCEINLINE 1038 VOID 1039 WdfIoQueuePurge( 1040 _In_ 1041 WDFQUEUE Queue, 1042 _When_(Context != 0, _In_) 1043 _When_(Context == 0, _In_opt_) 1044 PFN_WDF_IO_QUEUE_STATE PurgeComplete, 1045 _When_(PurgeComplete != 0, _In_) 1046 _When_(PurgeComplete == 0, _In_opt_) 1047 WDFCONTEXT Context 1048 ) 1049 { 1050 ((PFN_WDFIOQUEUEPURGE) WdfFunctions[WdfIoQueuePurgeTableIndex])(WdfDriverGlobals, Queue, PurgeComplete, Context); 1051 } 1052 1053 // 1054 // WDF Function: WdfIoQueueReadyNotify 1055 // 1056 typedef 1057 _Must_inspect_result_ 1058 _IRQL_requires_max_(DISPATCH_LEVEL) 1059 WDFAPI 1060 NTSTATUS 1061 (STDCALL *PFN_WDFIOQUEUEREADYNOTIFY)( 1062 _In_ 1063 PWDF_DRIVER_GLOBALS DriverGlobals, 1064 _In_ 1065 WDFQUEUE Queue, 1066 _In_opt_ 1067 PFN_WDF_IO_QUEUE_STATE QueueReady, 1068 _In_opt_ 1069 WDFCONTEXT Context 1070 ); 1071 1072 _Must_inspect_result_ 1073 _IRQL_requires_max_(DISPATCH_LEVEL) 1074 FORCEINLINE 1075 NTSTATUS 1076 WdfIoQueueReadyNotify( 1077 _In_ 1078 WDFQUEUE Queue, 1079 _In_opt_ 1080 PFN_WDF_IO_QUEUE_STATE QueueReady, 1081 _In_opt_ 1082 WDFCONTEXT Context 1083 ) 1084 { 1085 return ((PFN_WDFIOQUEUEREADYNOTIFY) WdfFunctions[WdfIoQueueReadyNotifyTableIndex])(WdfDriverGlobals, Queue, QueueReady, Context); 1086 } 1087 1088 // 1089 // WDF Function: WdfIoQueueAssignForwardProgressPolicy 1090 // 1091 typedef 1092 _Must_inspect_result_ 1093 _IRQL_requires_max_(PASSIVE_LEVEL) 1094 WDFAPI 1095 NTSTATUS 1096 (STDCALL *PFN_WDFIOQUEUEASSIGNFORWARDPROGRESSPOLICY)( 1097 _In_ 1098 PWDF_DRIVER_GLOBALS DriverGlobals, 1099 _In_ 1100 WDFQUEUE Queue, 1101 _In_ 1102 PWDF_IO_QUEUE_FORWARD_PROGRESS_POLICY ForwardProgressPolicy 1103 ); 1104 1105 _Must_inspect_result_ 1106 _IRQL_requires_max_(PASSIVE_LEVEL) 1107 FORCEINLINE 1108 NTSTATUS 1109 WdfIoQueueAssignForwardProgressPolicy( 1110 _In_ 1111 WDFQUEUE Queue, 1112 _In_ 1113 PWDF_IO_QUEUE_FORWARD_PROGRESS_POLICY ForwardProgressPolicy 1114 ) 1115 { 1116 return ((PFN_WDFIOQUEUEASSIGNFORWARDPROGRESSPOLICY) WdfFunctions[WdfIoQueueAssignForwardProgressPolicyTableIndex])(WdfDriverGlobals, Queue, ForwardProgressPolicy); 1117 } 1118 1119 // 1120 // WDF Function: WdfIoQueueStopAndPurge 1121 // 1122 typedef 1123 _IRQL_requires_max_(DISPATCH_LEVEL) 1124 WDFAPI 1125 VOID 1126 (STDCALL *PFN_WDFIOQUEUESTOPANDPURGE)( 1127 _In_ 1128 PWDF_DRIVER_GLOBALS DriverGlobals, 1129 _In_ 1130 WDFQUEUE Queue, 1131 _When_(Context != 0, _In_) 1132 _When_(Context == 0, _In_opt_) 1133 PFN_WDF_IO_QUEUE_STATE StopAndPurgeComplete, 1134 _When_(StopAndPurgeComplete != 0, _In_) 1135 _When_(StopAndPurgeComplete == 0, _In_opt_) 1136 WDFCONTEXT Context 1137 ); 1138 1139 _IRQL_requires_max_(DISPATCH_LEVEL) 1140 FORCEINLINE 1141 VOID 1142 WdfIoQueueStopAndPurge( 1143 _In_ 1144 WDFQUEUE Queue, 1145 _When_(Context != 0, _In_) 1146 _When_(Context == 0, _In_opt_) 1147 PFN_WDF_IO_QUEUE_STATE StopAndPurgeComplete, 1148 _When_(StopAndPurgeComplete != 0, _In_) 1149 _When_(StopAndPurgeComplete == 0, _In_opt_) 1150 WDFCONTEXT Context 1151 ) 1152 { 1153 ((PFN_WDFIOQUEUESTOPANDPURGE) WdfFunctions[WdfIoQueueStopAndPurgeTableIndex])(WdfDriverGlobals, Queue, StopAndPurgeComplete, Context); 1154 } 1155 1156 // 1157 // WDF Function: WdfIoQueueStopAndPurgeSynchronously 1158 // 1159 typedef 1160 _IRQL_requires_max_(PASSIVE_LEVEL) 1161 WDFAPI 1162 VOID 1163 (STDCALL *PFN_WDFIOQUEUESTOPANDPURGESYNCHRONOUSLY)( 1164 _In_ 1165 PWDF_DRIVER_GLOBALS DriverGlobals, 1166 _In_ 1167 WDFQUEUE Queue 1168 ); 1169 1170 _IRQL_requires_max_(PASSIVE_LEVEL) 1171 FORCEINLINE 1172 VOID 1173 WdfIoQueueStopAndPurgeSynchronously( 1174 _In_ 1175 WDFQUEUE Queue 1176 ) 1177 { 1178 ((PFN_WDFIOQUEUESTOPANDPURGESYNCHRONOUSLY) WdfFunctions[WdfIoQueueStopAndPurgeSynchronouslyTableIndex])(WdfDriverGlobals, Queue); 1179 } 1180 1181 1182 1183 #endif // (NTDDI_VERSION >= NTDDI_WIN2K) 1184 1185 1186 WDF_EXTERN_C_END 1187 1188 #endif // _WDFIO_H_ 1189 1190