-
Notifications
You must be signed in to change notification settings - Fork 0
/
WDFStructs.h
1130 lines (1026 loc) · 49.6 KB
/
WDFStructs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
In KMDF, the first parameter into the pfnWdfCallbacks is the WdfDriverGlobals object (goes in RCX), so when we say:
NTSTATUS pfnWdfDriverCreate(PDRIVER_OBJECT DriverObject, PCUNICODE_STRING RegistryPath, PVOID DriverAttributes, PWDF_DRIVER_CONFIG DriverConfig, PVOID WdfDriver);
WdfDriverGlobals goes in RCX
DriverObject goes in RDX
RegistryPath goes in R8
and so on
This doesn't apply to Evt*Routines like EvtIoDeviceControl.
*/
typedef enum _MAJOR_FUNCTIONS {
DispatchCreate,
DispatchCreateNamedPipe,
DispatchCLose,
DispatchRead,
DispatchWrite,
DispatchQueryInformation,
DispatchSetInformation,
DispatchQueryEA,
DispatchSetEA,
DispatchFlushBuffers,
DispatchQueryVolumeInformation,
DispatchSetVolumeInformation,
DispatchDirectoryControl,
DispatchFileSystemControl,
DispatchDeviceIOControl,
DispatchInternalDeviceControl,
DispatchShutdown,
DispatchLockControl,
DispatchCleanup,
DispatchCreateMailslot,
DispatchQuerySecurity,
DispatchSetSecurity,
DispatchPower,
DispatchSystemControl,
DispatchDeviceChange,
DispatchQueryQuota,
DispatchSetQuota,
DispatchPNP,
} MAJOR_FUNCTIONS;
typedef struct _DRIVER_OBJECT
{
SHORT Type;
SHORT Size;
PVOID DeviceObject;
ULONG Flags;
PVOID DriverStart;
ULONG DriverSize;
PVOID DriverSection;
PVOID DriverExtension;
UNICODE_STRING DriverName;
PUNICODE_STRING HardwareDatabase;
PVOID FastIoDispatch;
PVOID DriverInit;
PVOID DriverStartIo;
PVOID DriverUnload;
PVOID DispatchCreate;
PVOID DispatchCreateNamedPipe;
PVOID DispatchClose;
PVOID DispatchRead;
PVOID DispatchWrite;
PVOID DispatchQueryInformation;
PVOID DispatchSetInformation;
PVOID DispatchQueryEA;
PVOID DispatchSetEA;
PVOID DispatchFlushBuffers;
PVOID DispatchQueryVolumeInformation;
PVOID DispatchSetVolumeInformation;
PVOID DispatchDirectoryControl;
PVOID DispatchFileSystemControl;
PVOID DispatchDeviceIOControl;
PVOID DispatchInternalDeviceControl;
PVOID DispatchShutdown;
PVOID DispatchLockControl;
PVOID DispatchCleanup;
PVOID DispatchCreateMailslot;
PVOID DispatchQuerySecurity;
PVOID DispatchSetSecurity;
PVOID DispatchPower;
PVOID DispatchSystemControl;
PVOID DispatchDeviceChange;
PVOID DispatchQueryQuota;
PVOID DispatchSetQuota;
PVOID DispatchPNP;
} DRIVER_OBJECT, *PDRIVER_OBJECT;
typedef struct _IO_STACK_LOCATION {
UCHAR MajorFunction;
UCHAR MinorFunction;
UCHAR Flags;
UCHAR Control;
PVOID OutputBufferLength;
PVOID InputBufferLength;
DWORD IOControlCode;
PVOID Type3InputBuffer;
PVOID DeviceObject;
PVOID FileObject;
PVOID CompletionRoutine;
PVOID Context;
} IO_STACK_LOCATION, *PIO_STACK_LOCATION;
typedef enum {
DevicePropertyDeviceDescription = 0x0,
DevicePropertyHardwareID = 0x1,
DevicePropertyCompatibleIDs = 0x2,
DevicePropertyBootConfiguration = 0x3,
DevicePropertyBootConfigurationTranslated = 0x4,
DevicePropertyClassName = 0x5,
DevicePropertyClassGuid = 0x6,
DevicePropertyDriverKeyName = 0x7,
DevicePropertyManufacturer = 0x8,
DevicePropertyFriendlyName = 0x9,
DevicePropertyLocationInformation = 0xa,
DevicePropertyPhysicalDeviceObjectName = 0xb,
DevicePropertyBusTypeGuid = 0xc,
DevicePropertyLegacyBusType = 0xd,
DevicePropertyBusNumber = 0xe,
DevicePropertyEnumeratorName = 0xf,
DevicePropertyAddress = 0x10,
DevicePropertyUINumber = 0x11,
DevicePropertyInstallState = 0x12,
DevicePropertyRemovalPolicy = 0x13,
DevicePropertyResourceRequirements = 0x14,
DevicePropertyAllocatedResources = 0x15,
DevicePropertyContainerID = 0x16
} DEVICE_REGISTRY_PROPERTY;
typedef struct _WDF_VERSION {
UINT Major;
UINT Minor;
UINT Build;
} WDF_VERSION;
typedef struct _WDF_BIND_INFO {
ULONG Size;
PWCHAR Component;
WDF_VERSION Version;
ULONG FuncCount;
PVOID FuncTable;
PVOID Module; // Mgmt and diagnostic use only
} WDF_BIND_INFO, * PWDF_BIND_INFO;
/*
WdfVersionBind(
__in PDRIVER_OBJECT DriverObject,
__in PUNICODE_STRING RegistryPath,
__inout PWDF_BIND_INFO BindInfo,
__out PWDF_COMPONENT_GLOBALS* ComponentGlobals
);
*/
typedef struct _WDF_PNPPOWER_EVENT_CALLBACKS {
ULONG Size;
PVOID EvtDeviceD0Entry;
PVOID EvtDeviceD0EntryPostInterruptsEnabled;
PVOID EvtDeviceD0Exit;
PVOID EvtDeviceD0ExitPreInterruptsDisabled;
PVOID EvtDevicePrepareHardware;
PVOID EvtDeviceReleaseHardware;
PVOID EvtDeviceSelfManagedIoCleanup;
PVOID EvtDeviceSelfManagedIoFlush;
PVOID EvtDeviceSelfManagedIoInit;
PVOID EvtDeviceSelfManagedIoSuspend;
PVOID EvtDeviceSelfManagedIoRestart;
PVOID EvtDeviceSurpriseRemoval;
PVOID EvtDeviceQueryRemove;
PVOID EvtDeviceQueryStop;
PVOID EvtDeviceUsageNotification;
PVOID EvtDeviceRelationsQuery;
PVOID EvtDeviceUsageNotificationEx;
} WDF_PNPPOWER_EVENT_CALLBACKS, *PWDF_PNPPOWER_EVENT_CALLBACKS;
/*
NTSTATUS EvtWdfDevicePrepareHardware(
WDFDEVICE Device,
WDFCMRESLIST ResourcesRaw,
WDFCMRESLIST ResourcesTranslated
)
The EvtDevicePrepareHardware callback function accesses the device's raw and translated hardware resources by using the ResourcesRaw and ResourcesTranslated handles that it receives. The callback function can call WdfCmResourceListGetCount and WdfCmResourceListGetDescriptor to traverse the resource lists. This callback function cannot modify the resource lists.
For more information about resource lists and the order in which the resources appear, see raw and translated hardware resources.
Typically, your driver's EvtDevicePrepareHardware callback function does the following, if necessary:
- Maps physical memory addresses to virtual addresses so the driver can access memory that is assigned to the device
- Determines the device's revision number
- Configures USB devices
- Obtains driver-defined interfaces from other drivers
Optionally, EvtDevicePrepareHardware callback function might queue a work item to complete any other time-intensive configuration tasks.
*/
// pfnWdfDeviceInitSetPnpPowerEventCallbacks
typedef struct _WDF_DRIVER_CONFIG {
ULONG Size;
PVOID EvtDriverDeviceAdd;
PVOID EvtDriverUnload;
ULONG DriverInitFlags;
ULONG DriverPoolTag;
} WDF_DRIVER_CONFIG, *PWDF_DRIVER_CONFIG;
typedef enum _WDF_SYNCHRONIZATION_SCOPE {
WdfSynchronizationScopeInvalid = 0x00,
WdfSynchronizationScopeInheritFromParent = 0x1,
WdfSynchronizationScopeDevice = 0x2,
WdfSynchronizationScopeQueue = 0x3,
WdfSynchronizationScopeNone = 0x4
} WDF_SYNCHRONIZATION_SCOPE;
typedef enum _WDF_EXECUTION_LEVEL {
WdfExecutionLevelInvalid = 0x00,
WdfExecutionLevelInheritFromParent = 0x1,
WdfExecutionLevelPassive = 0x2,
WdfExecutionLevelDispatch = 0x3
} WDF_EXECUTION_LEVEL;
typedef struct _WDF_OBJECT_CONTEXT_TYPE_INFO {
ULONG Size;
PCHAR ContextName;
UINT ContextSize;
PVOID UniqueType;
PVOID EvtDriverGetUniqueContextType;
} WDF_OBJECT_CONTEXT_TYPE_INFO, *PWDF_OBJECT_CONTEXT_TYPE_INFO;
typedef struct _WDF_OBJECT_ATTRIBUTES {
ULONG Size;
PVOID EvtCleanupCallback;
PVOID EvtDestroyCallback;
WDF_EXECUTION_LEVEL ExecutionLevel;
WDF_SYNCHRONIZATION_SCOPE SynchronizationScope;
HANDLE ParentObject;
UINT ContextSizeOverride;
PWDF_OBJECT_CONTEXT_TYPE_INFO ContextTypeInfo;
} WDF_OBJECT_ATTRIBUTES, *PWDF_OBJECT_ATTRIBUTES;
/*
pfnWdfObjectGetTypedContextWorker() -> receives a handle in RDX and returns a pointer into the private object context
*/
/*
NTSTATUS WdfIoQueueCreate(
_In_ WDFDEVICE Device,
_In_ PWDF_IO_QUEUE_CONFIG Config,
_In_opt_ PWDF_OBJECT_ATTRIBUTES QueueAttributes,
_Out_opt_ WDFQUEUE *Queue
);
void EvtWdfIoQueueIoDeviceControl(
WDFQUEUE Queue,
WDFREQUEST Request,
UINT OutputBufferLength,
UINT InputBufferLength,
ULONG IoControlCode
)
void EvtWdfIoQueueIoDeviceControl(
PVOID Queue,
PVOID Request,
UINT OutputBufferLength,
UINT InputBufferLength,
ULONG IoControlCode
)
void EvtWdfIoQueueIoRead(
WDFQUEUE Queue,
WDFREQUEST Request,
size_t Length
)
void EvtWdfIoQueueIoWrite(
WDFQUEUE Queue,
WDFREQUEST Request,
size_t Length
)
void EvtWdfIoQueueIoInternalDeviceControl(
WDFQUEUE Queue,
WDFREQUEST Request,
size_t OutputBufferLength,
size_t InputBufferLength,
ULONG IoControlCode
)
*/
typedef enum _WDF_DEVICE_IO_TYPE {
WdfDeviceIoUndefined = 0,
WdfDeviceIoNeither = 1,
WdfDeviceIoBuffered = 2,
WdfDeviceIoDirect = 3,
WdfDeviceIoBufferedOrDirect = 4
} WDF_DEVICE_IO_TYPE, *PWDF_DEVICE_IO_TYPE;
typedef enum _WDF_IO_QUEUE_DISPATCH_TYPE {
WdfIoQueueDispatchInvalid = 0,
WdfIoQueueDispatchSequential = 1,
WdfIoQueueDispatchParallel = 2,
WdfIoQueueDispatchManual = 3,
WdfIoQueueDispatchMax = 4
} WDF_IO_QUEUE_DISPATCH_TYPE;
typedef enum _WDF_TRI_STATE {
WdfFalse = FALSE,
WdfTrue = TRUE,
WdfUseDefault = 2
} WDF_TRI_STATE, *PWDF_TRI_STATE;
typedef struct _WDF_IO_QUEUE_CONFIG {
ULONG Size;
WDF_IO_QUEUE_DISPATCH_TYPE DispatchType;
WDF_TRI_STATE PowerManaged;
BOOLEAN AllowZeroLengthRequests;
BOOLEAN DefaultQueue;
PVOID EvtIoDefault;
PVOID EvtIoRead;
PVOID EvtIoWrite;
PVOID EvtIoDeviceControl;
PVOID EvtIoInternalDeviceControl;
PVOID EvtIoStop;
PVOID EvtIoResume;
PVOID EvtIoCanceledOnQueue;
union {
struct {
ULONG NumberOfPresentedRequests;
} Parallel;
} Settings;
HANDLE Driver;
} WDF_IO_QUEUE_CONFIG, *PWDF_IO_QUEUE_CONFIG;
/*
VOID WdfDeviceInitSetFileObjectConfig(
_In_ PWDFDEVICE_INIT DeviceInit,
_In_ PWDF_FILEOBJECT_CONFIG FileObjectConfig,
_In_opt_ PWDF_OBJECT_ATTRIBUTES FileObjectAttributes
);
*/
typedef enum _WDF_FILEOBJECT_CLASS {
WdfFileObjectInvalid = 0,
WdfFileObjectNotRequired = 1,
WdfFileObjectWdfCanUseFsContext = 2,
WdfFileObjectWdfCanUseFsContext2 = 3,
WdfFileObjectWdfCannotUseFsContexts = 4,
WdfFileObjectCanBeOptional = 0x80000000
} WDF_FILEOBJECT_CLASS, *PWDF_FILEOBJECT_CLASS;
typedef struct _WDF_FILEOBJECT_CONFIG {
ULONG Size;
PVOID EvtDeviceFileCreate;
PVOID EvtFileClose;
PVOID EvtFileCleanup;
WDF_TRI_STATE AutoForwardCleanupClose;
WDF_FILEOBJECT_CLASS FileObjectClass;
} WDF_FILEOBJECT_CONFIG, *PWDF_FILEOBJECT_CONFIG;
/*
NTSTATUS WdfRequestRetrieveInputBuffer(
_In_ WDFREQUEST Request,
_In_ size_t MinimumRequiredSize,
_Out_ PVOID *Buffer,
_Out_opt_ size_t *Length
);
*/
/*
WDF Request buffers (input and output) are hold in a structure like the follows
*/
typedef struct _BuffRequest {
PVOID InputBuffer;
PVOID OutputBuffer;
DWORD64 InputBuffLen;
DWORD64 OutputBuffLen;
} BuffRequest, *PBuffRequest;
typedef enum _WDF_REQUEST_TYPE {
WdfRequestTypeCreate = 0x0,
WdfRequestTypeCreateNamedPipe = 0x1,
WdfRequestTypeClose = 0x2,
WdfRequestTypeRead = 0x3,
WdfRequestTypeWrite = 0x4,
WdfRequestTypeQueryInformation = 0x5,
WdfRequestTypeSetInformation = 0x6,
WdfRequestTypeQueryEA = 0x7,
WdfRequestTypeSetEA = 0x8,
WdfRequestTypeFlushBuffers = 0x9,
WdfRequestTypeQueryVolumeInformation = 0xa,
WdfRequestTypeSetVolumeInformation = 0xb,
WdfRequestTypeDirectoryControl = 0xc,
WdfRequestTypeFileSystemControl = 0xd,
WdfRequestTypeDeviceControl = 0xe,
WdfRequestTypeDeviceControlInternal = 0xf,
WdfRequestTypeShutdown = 0x10,
WdfRequestTypeLockControl = 0x11,
WdfRequestTypeCleanup = 0x12,
WdfRequestTypeCreateMailSlot = 0x13,
WdfRequestTypeQuerySecurity = 0x14,
WdfRequestTypeSetSecurity = 0x15,
WdfRequestTypePower = 0x16,
WdfRequestTypeSystemControl = 0x17,
WdfRequestTypeDeviceChange = 0x18,
WdfRequestTypeQueryQuota = 0x19,
WdfRequestTypeSetQuota = 0x1A,
WdfRequestTypePnp = 0x1B,
WdfRequestTypeOther = 0x1C,
WdfRequestTypeUsb = 0x40,
WdfRequestTypeNoFormat = 0xFF,
WdfRequestTypeMax = 0x100
} WDF_REQUEST_TYPE;
/*
WDF_REQUEST_PARAMETERS requestParameters;
// Get the Request parameters
WDF_REQUEST_PARAMETERS_INIT(&requestParameters);
WdfRequestGetParameters(Request, &requestParameters);
*/
typedef struct _WDF_REQUEST_PARAMETERS {
USHORT Size;
UCHAR MinorFunction;
WDF_REQUEST_TYPE Type;
union {
struct {
PVOID SecurityContext;
ULONG Options;
UINT64 FileAttributes;
USHORT ShareAccess;
UINT64 EaLength;
} Create;
struct {
UINT Length;
UINT64 Key;
UINT64 DeviceOffset;
} Read;
struct {
UINT Length;
UINT64 Key;
LONGLONG DeviceOffset;
} Write;
struct {
UINT OutputBufferLength;
UINT64 InputBufferLength;
UINT64 IoControlCode;
PVOID Type3InputBuffer;
} DeviceIoControl;
struct {
PVOID Arg1;
PVOID Arg2;
UINT64 IoControlCode;
PVOID Arg4;
} Others;
} Parameters;
} WDF_REQUEST_PARAMETERS, *PWDF_REQUEST_PARAMETERS;
/*
NTSTATUS WdfDeviceAddQueryInterface(
_In_ WDFDEVICE Device,
_In_ PWDF_QUERY_INTERFACE_CONFIG InterfaceConfig
);
*/
typedef struct _INTERFACE {
USHORT Size;
USHORT Version;
PVOID Context;
PVOID InterfaceReference;
PVOID InterfaceDereference;
} INTERFACE, *PINTERFACE;
typedef struct _WDF_QUERY_INTERFACE_CONFIG {
ULONG Size;
PINTERFACE Interface;
PVOID GUIDInterfaceType;
BOOLEAN SendQueryToParentStack;
PVOID EvtDeviceProcessQueryInterfaceRequest;
BOOLEAN ImportInterface;
} WDF_QUERY_INTERFACE_CONFIG, *PWDF_QUERY_INTERFACE_CONFIG;
typedef struct _WDF_WORKITEM_CONFIG {
ULONG Size;
PVOID EvtWorkItemFunc;
BOOLEAN AutomaticSerialization;
} WDF_WORKITEM_CONFIG, *PWDF_WORKITEM_CONFIG;
/*
NTSTATUS WdfWorkItemCreate(
_In_ PWDF_WORKITEM_CONFIG Config,
_In_ PWDF_OBJECT_ATTRIBUTES Attributes,
_Out_ WDFWORKITEM *WorkItem
);
*/
/*
IO Targets:
A WDF driver can forward an I/O request or create and send a new request to another driver, called an I/O target.
The framework initializes a driver's local I/O target for a device when the driver calls WdfDeviceCreate. To retrieve a handle to a device's local I/O target, the driver calls WdfDeviceGetIoTarget.
NTSTATUS WdfDeviceCreate(
PWDFDEVICE_INIT *DeviceInit,
PWDF_OBJECT_ATTRIBUTES DeviceAttributes,
WDFDEVICE *Device
);
Most drivers send requests only to their local I/O target.
To initialize a remote I/O target for a device, the driver must:
1) Call WdfIoTargetCreate to create an I/O target object.
2) Call WdfIoTargetOpen to open an I/O target so that the driver can send requests to it.
When the driver calls WdfIoTargetOpen, it typically identifies the remote I/O target by supplying a Unicode string that represents an object name. This name can identify a device, file, or device interface.
The framework sends I/O requests to the top of the driver stack that supports the object name.
NTSTATUS WdfIoTargetOpen(
_In_ WDFIOTARGET IoTarget,
_In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams
);
*/
typedef enum _WDF_IO_TARGET_OPEN_TYPE {
WdfIoTargetOpenUndefined = 0,
WdfIoTargetOpenUseExistingDevice = 1,
WdfIoTargetOpenByName = 2,
WdfIoTargetOpenReopen = 3,
WdfIoTargetOpenLocalTargetByFile = 4
} WDF_IO_TARGET_OPEN_TYPE;
typedef struct _WDF_IO_TARGET_OPEN_PARAMS {
ULONG Size;
WDF_IO_TARGET_OPEN_TYPE Type;
PVOID EvtIoTargetQueryRemove;
PVOID EvtIoTargetRemoveCanceled;
PVOID EvtIoTargetRemoveComplete;
PDEVICE_OBJECT TargetDeviceObject;
PVOID TargetFileObject;
UNICODE_STRING TargetDeviceName;
DWORD DesiredAccess;
ULONG ShareAccess;
ULONG FileAttributes;
ULONG CreateDisposition;
ULONG CreateOptions;
PVOID EaBuffer;
ULONG EaBufferLength;
PVOID AllocationSize;
ULONG FileInformation;
UNICODE_STRING FileName;
} WDF_IO_TARGET_OPEN_PARAMS, *PWDF_IO_TARGET_OPEN_PARAMS;
typedef struct _WDF_INTERRUPT_CONFIG {
ULONG Size;
PVOID SpinLock;
WDF_TRI_STATE ShareVector;
BOOLEAN FloatingSave;
BOOLEAN AutomaticSerialization;
PVOID EvtInterruptIsr;
PVOID EvtInterruptDpc;
PVOID EvtInterruptEnable;
PVOID EvtInterruptDisable;
PVOID EvtInterruptWorkItem;
PVOID InterruptRaw;
PVOID InterruptTranslated;
PVOID WaitLock;
BOOLEAN PassiveHandling;
WDF_TRI_STATE ReportInactiveOnPowerDown;
BOOLEAN CanWakeDevice;
} WDF_INTERRUPT_CONFIG, *PWDF_INTERRUPT_CONFIG;
/*
NTSTATUS WdfInterruptCreate(
_In_ WDFDEVICE Device,
_In_ PWDF_INTERRUPT_CONFIG Configuration,
_In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes,
_Out_ WDFINTERRUPT *Interrupt
);
*/
/*
The WdfFdoInitSetDefaultChildListConfig method configures a bus driver's default child list.
VOID WdfFdoInitSetDefaultChildListConfig(
_Inout_ PWDFDEVICE_INIT DeviceInit,
_In_ PWDF_CHILD_LIST_CONFIG Config,
_In_opt_ PWDF_OBJECT_ATTRIBUTES DefaultChildListAttributes
);
*/
typedef struct _WDF_CHILD_LIST_CONFIG {
ULONG Size;
ULONG IdentificationDescriptionSize;
ULONG AddressDescriptionSize;
PVOID EvtChildListCreateDevice;
PVOID EvtChildListScanForChildren;
PVOID EvtChildListIdentificationDescriptionCopy;
PVOID EvtChildListIdentificationDescriptionDuplicate;
PVOID EvtChildListIdentificationDescriptionCleanup;
PVOID EvtChildListIdentificationDescriptionCompare;
PVOID EvtChildListAddressDescriptionCopy;
PVOID EvtChildListAddressDescriptionDuplicate;
PVOID EvtChildListAddressDescriptionCleanup;
PVOID EvtChildListDeviceReenumerated;
} WDF_CHILD_LIST_CONFIG, *PWDF_CHILD_LIST_CONFIG;
typedef struct _WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER {
//
// Size in bytes of the entire description, including this header.
//
// Same value as WDF_CHILD_LIST_CONFIG::IdentificationDescriptionSize
// Used as a sanity check.
//
ULONG IdentificationDescriptionSize;
} WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER,
*PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER;
/*
NTSTATUS EvtWdfChildListCreateDevice(
PVOID ChildList,
PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER IdentificationDescription,
PVOID ChildInit
)
NTSTATUS EvtWdfChildListIdentificationDescriptionDuplicate(
PVOID ChildList,
PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER SourceIdentificationDescription,
PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER DestinationIdentificationDescription
)
EVT_WDF_CHILD_LIST_IDENTIFICATION_DESCRIPTION_COMPARE EvtWdfChildListIdentificationDescriptionCompare;
BOOLEAN EvtWdfChildListIdentificationDescriptionCompare(
PVOID ChildList,
PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER FirstIdentificationDescription,
PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER SecondIdentificationDescription
)
void EvtWdfChildListIdentificationDescriptionCleanup(
WDFCHILDLIST ChildList,
PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER IdentificationDescription
)
*/
/*
PIRP WdfRequestWdmGetIrp(
_In_ WDFREQUEST Request
);
Returns the WDM IRP structure that is associated with a specified framework request object.
*/
// WdfDeviceInitAssignWdmIrpPreprocessCallback
/*
NTSTATUS WdfDeviceInitAssignWdmIrpPreprocessCallback(
PVOID DeviceInit,
PVOID EvtDeviceWdmIrpPreprocess,
UCHAR MajorFunction,
PUCHAR MinorFunctions,
ULONG NumMinorFunctions
);
*/
// Stripped version of this structure so it fits most binaries out there
typedef struct _WDFFUNCTIONS {
PVOID pfnWdfChildListCreate;
PVOID pfnWdfChildListGetDevice;
PVOID pfnWdfChildListRetrievePdo;
PVOID pfnWdfChildListRetrieveAddressDescription;
PVOID pfnWdfChildListBeginScan;
PVOID pfnWdfChildListEndScan;
PVOID pfnWdfChildListBeginIteration;
PVOID pfnWdfChildListRetrieveNextDevice;
PVOID pfnWdfChildListEndIteration;
PVOID pfnWdfChildListAddOrUpdateChildDescriptionAsPresent;
PVOID pfnWdfChildListUpdateChildDescriptionAsMissing;
PVOID pfnWdfChildListUpdateAllChildDescriptionsAsPresent;
PVOID pfnWdfChildListRequestChildEject;
PVOID pfnWdfCollectionCreate;
PVOID pfnWdfCollectionGetCount;
PVOID pfnWdfCollectionAdd;
PVOID pfnWdfCollectionRemove;
PVOID pfnWdfCollectionRemoveItem;
PVOID pfnWdfCollectionGetItem;
PVOID pfnWdfCollectionGetFirstItem;
PVOID pfnWdfCollectionGetLastItem;
PVOID pfnWdfCommonBufferCreate;
PVOID pfnWdfCommonBufferGetAlignedVirtualAddress;
PVOID pfnWdfCommonBufferGetAlignedLogicalAddress;
PVOID pfnWdfCommonBufferGetLength;
PVOID pfnWdfControlDeviceInitAllocate; // 0xC8
PVOID pfnWdfControlDeviceInitSetShutdownNotification;
PVOID pfnWdfControlFinishInitializing;
PVOID pfnWdfDeviceGetDeviceState;
PVOID pfnWdfDeviceSetDeviceState;
PVOID pfnWdfWdmDeviceGetWdfDeviceHandle;
PVOID pfnWdfDeviceWdmGetDeviceObject;
PVOID pfnWdfDeviceWdmGetAttachedDevice;
PVOID pfnWdfDeviceWdmGetPhysicalDevice;
PVOID pfnWdfDeviceWdmDispatchPreprocessedIrp;
PVOID pfnWdfDeviceAddDependentUsageDeviceObject;
PVOID pfnWdfDeviceAddRemovalRelationsPhysicalDevice;
PVOID pfnWdfDeviceRemoveRemovalRelationsPhysicalDevice;
PVOID pfnWdfDeviceClearRemovalRelationsDevices;
PVOID pfnWdfDeviceGetDriver;
PVOID pfnWdfDeviceRetrieveDeviceName;
PVOID pfnWdfDeviceAssignMofResourceName;
PVOID pfnWdfDeviceGetIoTarget;
PVOID pfnWdfDeviceGetDevicePnpState;
PVOID pfnWdfDeviceGetDevicePowerState;
PVOID pfnWdfDeviceGetDevicePowerPolicyState;
PVOID pfnWdfDeviceAssignS0IdleSettings;
PVOID pfnWdfDeviceAssignSxWakeSettings;
PVOID pfnWdfDeviceOpenRegistryKey;
PVOID pfnWdfDeviceSetSpecialFileSupport;
PVOID pfnWdfDeviceSetCharacteristics;
PVOID pfnWdfDeviceGetCharacteristics;
PVOID pfnWdfDeviceGetAlignmentRequirement;
PVOID pfnWdfDeviceSetAlignmentRequirement;
PVOID pfnWdfDeviceInitFree;
PVOID pfnWdfDeviceInitSetPnpPowerEventCallbacks;
PVOID pfnWdfDeviceInitSetPowerPolicyEventCallbacks;
PVOID pfnWdfDeviceInitSetPowerPolicyOwnership;
PVOID pfnWdfDeviceInitRegisterPnpStateChangeCallback;
PVOID pfnWdfDeviceInitRegisterPowerStateChangeCallback;
PVOID pfnWdfDeviceInitRegisterPowerPolicyStateChangeCallback;
PVOID pfnWdfDeviceInitSetIoType;
PVOID pfnWdfDeviceInitSetExclusive;
PVOID pfnWdfDeviceInitSetPowerNotPageable;
PVOID pfnWdfDeviceInitSetPowerPageable;
PVOID pfnWdfDeviceInitSetPowerInrush;
PVOID pfnWdfDeviceInitSetDeviceType;
PVOID pfnWdfDeviceInitAssignName;
PVOID pfnWdfDeviceInitAssignSDDLString; //0x220
PVOID pfnWdfDeviceInitSetDeviceClass;
PVOID pfnWdfDeviceInitSetCharacteristics;
PVOID pfnWdfDeviceInitSetFileObjectConfig;
PVOID pfnWdfDeviceInitSetRequestAttributes;
PVOID pfnWdfDeviceInitAssignWdmIrpPreprocessCallback; // 248h
PVOID pfnWdfDeviceInitSetIoInCallerContextCallback; // 250h
PVOID pfnWdfDeviceCreate; // 258h
PVOID pfnWdfDeviceSetStaticStopRemove;
PVOID pfnWdfDeviceCreateDeviceInterface; // 268h
PVOID pfnWdfDeviceSetDeviceInterfaceState;
PVOID pfnWdfDeviceRetrieveDeviceInterfaceString;
PVOID pfnWdfDeviceCreateSymbolicLink; // 0x280
PVOID pfnWdfDeviceQueryProperty;
PVOID pfnWdfDeviceAllocAndQueryProperty;
PVOID pfnWdfDeviceSetPnpCapabilities;
PVOID pfnWdfDeviceSetPowerCapabilities;
PVOID pfnWdfDeviceSetBusInformationForChildren;
PVOID pfnWdfDeviceIndicateWakeStatus;
PVOID pfnWdfDeviceSetFailed;
PVOID pfnWdfDeviceStopIdleNoTrack;
PVOID pfnWdfDeviceResumeIdleNoTrack;
PVOID pfnWdfDeviceGetFileObject;
PVOID pfnWdfDeviceEnqueueRequest;
PVOID pfnWdfDeviceGetDefaultQueue;
PVOID pfnWdfDeviceConfigureRequestDispatching;
PVOID pfnWdfDmaEnablerCreate;
PVOID pfnWdfDmaEnablerGetMaximumLength;
PVOID pfnWdfDmaEnablerGetMaximumScatterGatherElements;
PVOID pfnWdfDmaEnablerSetMaximumScatterGatherElements;
PVOID pfnWdfDmaTransactionCreate;
PVOID pfnWdfDmaTransactionInitialize;
PVOID pfnWdfDmaTransactionInitializeUsingRequest;
PVOID pfnWdfDmaTransactionExecute;
PVOID pfnWdfDmaTransactionRelease;
PVOID pfnWdfDmaTransactionDmaCompleted;
PVOID pfnWdfDmaTransactionDmaCompletedWithLength;
PVOID pfnWdfDmaTransactionDmaCompletedFinal;
PVOID pfnWdfDmaTransactionGetBytesTransferred;
PVOID pfnWdfDmaTransactionSetMaximumLength;
PVOID pfnWdfDmaTransactionGetRequest;
PVOID pfnWdfDmaTransactionGetCurrentDmaTransferLength;
PVOID pfnWdfDmaTransactionGetDevice;
PVOID pfnWdfDpcCreate;
PVOID pfnWdfDpcEnqueue;
PVOID pfnWdfDpcCancel;
PVOID pfnWdfDpcGetParentObject;
PVOID pfnWdfDpcWdmGetDpc;
PVOID pfnWdfDriverCreate;
PVOID pfnWdfDriverGetRegistryPath;
PVOID pfnWdfDriverWdmGetDriverObject;
PVOID pfnWdfDriverOpenParametersRegistryKey;
PVOID pfnWdfWdmDriverGetWdfDriverHandle;
PVOID pfnWdfDriverRegisterTraceInfo;
PVOID pfnWdfDriverRetrieveVersionString;
PVOID pfnWdfDriverIsVersionAvailable;
PVOID pfnWdfFdoInitWdmGetPhysicalDevice;
PVOID pfnWdfFdoInitOpenRegistryKey;
PVOID pfnWdfFdoInitQueryProperty;
PVOID pfnWdfFdoInitAllocAndQueryProperty;
PVOID pfnWdfFdoInitSetEventCallbacks;
PVOID pfnWdfFdoInitSetFilter;
PVOID pfnWdfFdoInitSetDefaultChildListConfig;
PVOID pfnWdfFdoQueryForInterface;
PVOID pfnWdfFdoGetDefaultChildList;
PVOID pfnWdfFdoAddStaticChild;
PVOID pfnWdfFdoLockStaticChildListForIteration;
PVOID pfnWdfFdoRetrieveNextStaticChild;
PVOID pfnWdfFdoUnlockStaticChildListFromIteration;
PVOID pfnWdfFileObjectGetFileName;
PVOID pfnWdfFileObjectGetFlags;
PVOID pfnWdfFileObjectGetDevice;
PVOID pfnWdfFileObjectWdmGetFileObject;
PVOID pfnWdfInterruptCreate;
PVOID pfnWdfInterruptQueueDpcForIsr;
PVOID pfnWdfInterruptSynchronize;
PVOID pfnWdfInterruptAcquireLock;
PVOID pfnWdfInterruptReleaseLock;
PVOID pfnWdfInterruptEnable;
PVOID pfnWdfInterruptDisable;
PVOID pfnWdfInterruptWdmGetInterrupt;
PVOID pfnWdfInterruptGetInfo;
PVOID pfnWdfInterruptSetPolicy;
PVOID pfnWdfInterruptGetDevice;
PVOID pfnWdfIoQueueCreate; // 4C0h
PVOID pfnWdfIoQueueGetState;
PVOID pfnWdfIoQueueStart;
PVOID pfnWdfIoQueueStop;
PVOID pfnWdfIoQueueStopSynchronously;
PVOID pfnWdfIoQueueGetDevice;
PVOID pfnWdfIoQueueRetrieveNextRequest;
PVOID pfnWdfIoQueueRetrieveRequestByFileObject;
PVOID pfnWdfIoQueueFindRequest;
PVOID pfnWdfIoQueueRetrieveFoundRequest;
PVOID pfnWdfIoQueueDrainSynchronously;
PVOID pfnWdfIoQueueDrain;
PVOID pfnWdfIoQueuePurgeSynchronously;
PVOID pfnWdfIoQueuePurge;
PVOID pfnWdfIoQueueReadyNotify;
PVOID pfnWdfIoTargetCreate;
PVOID pfnWdfIoTargetOpen;
PVOID pfnWdfIoTargetCloseForQueryRemove;
PVOID pfnWdfIoTargetClose;
PVOID pfnWdfIoTargetStart;
PVOID pfnWdfIoTargetStop;
PVOID pfnWdfIoTargetGetState;
PVOID pfnWdfIoTargetGetDevice;
PVOID pfnWdfIoTargetQueryTargetProperty;
PVOID pfnWdfIoTargetAllocAndQueryTargetProperty;
PVOID pfnWdfIoTargetQueryForInterface;
PVOID pfnWdfIoTargetWdmGetTargetDeviceObject;
PVOID pfnWdfIoTargetWdmGetTargetPhysicalDevice;
PVOID pfnWdfIoTargetWdmGetTargetFileObject;
PVOID pfnWdfIoTargetWdmGetTargetFileHandle;
PVOID pfnWdfIoTargetSendReadSynchronously;
PVOID pfnWdfIoTargetFormatRequestForRead;
PVOID pfnWdfIoTargetSendWriteSynchronously;
PVOID pfnWdfIoTargetFormatRequestForWrite;
PVOID pfnWdfIoTargetSendIoctlSynchronously;
PVOID pfnWdfIoTargetFormatRequestForIoctl;
PVOID pfnWdfIoTargetSendInternalIoctlSynchronously;
PVOID pfnWdfIoTargetFormatRequestForInternalIoctl;
PVOID pfnWdfIoTargetSendInternalIoctlOthersSynchronously;
PVOID pfnWdfIoTargetFormatRequestForInternalIoctlOthers;
PVOID pfnWdfMemoryCreate;
PVOID pfnWdfMemoryCreatePreallocated;
PVOID pfnWdfMemoryGetBuffer;
PVOID pfnWdfMemoryAssignBuffer;
PVOID pfnWdfMemoryCopyToBuffer;
PVOID pfnWdfMemoryCopyFromBuffer;
PVOID pfnWdfLookasideListCreate;
PVOID pfnWdfMemoryCreateFromLookaside;
PVOID pfnWdfDeviceMiniportCreate;
PVOID pfnWdfDriverMiniportUnload;
PVOID pfnWdfObjectGetTypedContextWorker;
PVOID pfnWdfObjectAllocateContext;
PVOID pfnWdfObjectContextGetObject;
PVOID pfnWdfObjectReferenceActual;
PVOID pfnWdfObjectDereferenceActual;
PVOID pfnWdfObjectCreate;
PVOID pfnWdfObjectDelete;
PVOID pfnWdfObjectQuery;
PVOID pfnWdfPdoInitAllocate;
PVOID pfnWdfPdoInitSetEventCallbacks;
PVOID pfnWdfPdoInitAssignDeviceID;
PVOID pfnWdfPdoInitAssignInstanceID;
PVOID pfnWdfPdoInitAddHardwareID;
PVOID pfnWdfPdoInitAddCompatibleID;
PVOID pfnWdfPdoInitAddDeviceText;
PVOID pfnWdfPdoInitSetDefaultLocale;
PVOID pfnWdfPdoInitAssignRawDevice;
PVOID pfnWdfPdoMarkMissing;
PVOID pfnWdfPdoRequestEject;
PVOID pfnWdfPdoGetParent;
PVOID pfnWdfPdoRetrieveIdentificationDescription;
PVOID pfnWdfPdoRetrieveAddressDescription;
PVOID pfnWdfPdoUpdateAddressDescription;
PVOID pfnWdfPdoAddEjectionRelationsPhysicalDevice;
PVOID pfnWdfPdoRemoveEjectionRelationsPhysicalDevice;
PVOID pfnWdfPdoClearEjectionRelationsDevices;
PVOID pfnWdfDeviceAddQueryInterface;
PVOID pfnWdfRegistryOpenKey;
PVOID pfnWdfRegistryCreateKey;
PVOID pfnWdfRegistryClose;
PVOID pfnWdfRegistryWdmGetHandle;
PVOID pfnWdfRegistryRemoveKey;
PVOID pfnWdfRegistryRemoveValue;
PVOID pfnWdfRegistryQueryValue;
PVOID pfnWdfRegistryQueryMemory;
PVOID pfnWdfRegistryQueryMultiString;
PVOID pfnWdfRegistryQueryUnicodeString;
PVOID pfnWdfRegistryQueryString;
PVOID pfnWdfRegistryQueryULong;
PVOID pfnWdfRegistryAssignValue;
PVOID pfnWdfRegistryAssignMemory;
PVOID pfnWdfRegistryAssignMultiString;
PVOID pfnWdfRegistryAssignUnicodeString;
PVOID pfnWdfRegistryAssignString;
PVOID pfnWdfRegistryAssignULong;
PVOID pfnWdfRequestCreate;
PVOID pfnWdfRequestCreateFromIrp;
PVOID pfnWdfRequestReuse;
PVOID pfnWdfRequestChangeTarget;
PVOID pfnWdfRequestFormatRequestUsingCurrentType;
PVOID pfnWdfRequestWdmFormatUsingStackLocation;
PVOID pfnWdfRequestSend;
PVOID pfnWdfRequestGetStatus;
PVOID pfnWdfRequestMarkCancelable;
PVOID pfnWdfRequestUnmarkCancelable;
PVOID pfnWdfRequestIsCanceled;
PVOID pfnWdfRequestCancelSentRequest;
PVOID pfnWdfRequestIsFrom32BitProcess;
PVOID pfnWdfRequestSetCompletionRoutine;
PVOID pfnWdfRequestGetCompletionParams;
PVOID pfnWdfRequestAllocateTimer;
PVOID pfnWdfRequestComplete;
PVOID pfnWdfRequestCompleteWithPriorityBoost;
PVOID pfnWdfRequestCompleteWithInformation;
PVOID pfnWdfRequestGetParameters;
PVOID pfnWdfRequestRetrieveInputMemory;
PVOID pfnWdfRequestRetrieveOutputMemory;
PVOID pfnWdfRequestRetrieveInputBuffer;
PVOID pfnWdfRequestRetrieveOutputBuffer;
PVOID pfnWdfRequestRetrieveInputWdmMdl;
PVOID pfnWdfRequestRetrieveOutputWdmMdl;
PVOID pfnWdfRequestRetrieveUnsafeUserInputBuffer;
PVOID pfnWdfRequestRetrieveUnsafeUserOutputBuffer;
PVOID pfnWdfRequestSetInformation;
PVOID pfnWdfRequestGetInformation;
PVOID pfnWdfRequestGetFileObject;
PVOID pfnWdfRequestProbeAndLockUserBufferForRead;
PVOID pfnWdfRequestProbeAndLockUserBufferForWrite;
PVOID pfnWdfRequestGetRequestorMode;
PVOID pfnWdfRequestForwardToIoQueue;
PVOID pfnWdfRequestGetIoQueue;
PVOID pfnWdfRequestRequeue;
PVOID pfnWdfRequestStopAcknowledge;
PVOID pfnWdfRequestWdmGetIrp;
PVOID pfnWdfIoResourceRequirementsListSetSlotNumber;
PVOID pfnWdfIoResourceRequirementsListSetInterfaceType;
PVOID pfnWdfIoResourceRequirementsListAppendIoResList;
PVOID pfnWdfIoResourceRequirementsListInsertIoResList;
PVOID pfnWdfIoResourceRequirementsListGetCount;
PVOID pfnWdfIoResourceRequirementsListGetIoResList;
PVOID pfnWdfIoResourceRequirementsListRemove;
PVOID pfnWdfIoResourceRequirementsListRemoveByIoResList;
PVOID pfnWdfIoResourceListCreate;
PVOID pfnWdfIoResourceListAppendDescriptor;
PVOID pfnWdfIoResourceListInsertDescriptor;
PVOID pfnWdfIoResourceListUpdateDescriptor;
PVOID pfnWdfIoResourceListGetCount;
PVOID pfnWdfIoResourceListGetDescriptor;
PVOID pfnWdfIoResourceListRemove;
PVOID pfnWdfIoResourceListRemoveByDescriptor;
PVOID pfnWdfCmResourceListAppendDescriptor;
PVOID pfnWdfCmResourceListInsertDescriptor;