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
|
/*++
Copyright (c) 1990-2010 Microsoft Corporation
Module Name:
SimpleDevice.c
Abstract:
This is a simple device driver that consumes GPIO pins for I/O and interrupt.
Environment:
Kernel mode
--*/
//
// ------------------------------------------------------------------- Includes
//
#include "common.h"
#include <gpio.h>
#define RESHUB_USE_HELPER_ROUTINES
#include <reshub.h>
//
// -------------------------------------------------------------------- Defines
//
#define MAX_NUMBER_IO_RESOURCES 2
//
// -------------------------------------------------------------------- Types
//
typedef struct _SAMPLE_DRV_DEVICE_EXTENSION {
ULONG IoResourceCount;
ULONG InterruptCount;
LARGE_INTEGER ConnectionIds[MAX_NUMBER_IO_RESOURCES];
} SAMPLE_DRV_DEVICE_EXTENSION, *PSAMPLE_DRV_DEVICE_EXTENSION;
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(SAMPLE_DRV_DEVICE_EXTENSION, SampleDrvGetDeviceExtension)
//
// ----------------------------------------------------------------- Prototypes
//
DRIVER_INITIALIZE DriverEntry;
EVT_WDF_DRIVER_DEVICE_ADD SampleDrvEvtDeviceAdd;
EVT_WDF_DEVICE_D0_ENTRY SampleDrvEvtDeviceD0Entry;
EVT_WDF_DEVICE_PREPARE_HARDWARE SampleDrvEvtDevicePrepareHardware;
EVT_WDF_INTERRUPT_DPC SampleDrvInterruptDpc;
EVT_WDF_INTERRUPT_ISR SampleDrvInterruptIsr;
EVT_WDF_INTERRUPT_ISR SampleDrvInterruptPassiveCallback;
NTSTATUS
TestReadWrite (
_In_ WDFDEVICE Device,
_In_ PCUNICODE_STRING RequestString,
_In_ BOOLEAN ReadOperation,
_Inout_ PUCHAR Data,
_In_ _In_range_(>, 0) ULONG Size,
_Out_ WDFIOTARGET *IoTargetOut
);
//
// -------------------------------------------------------------------- Pragmas
//
#pragma alloc_text(PAGE, SampleDrvEvtDeviceAdd)
#pragma alloc_text(PAGE, SampleDrvEvtDevicePrepareHardware)
//
// ------------------------------------------------------------------ Functions
//
NTSTATUS
DriverEntry (
_In_ PDRIVER_OBJECT DriverObject,
_In_ PUNICODE_STRING RegistryPath
)
/*++
Routine Description:
This routine is the driver initialization entry point.
Arguments:
DriverObject - Pointer to the driver object created by the I/O manager.
RegistryPath - Pointer to the driver specific registry key.
Return Value:
NTSTATUS code.
--*/
{
WDFDRIVER Driver;
WDF_DRIVER_CONFIG DriverConfig;
NTSTATUS Status;
//
// Initialize the driver configuration structure.
//
WDF_DRIVER_CONFIG_INIT(&DriverConfig, SampleDrvEvtDeviceAdd);
//
// Create a framework driver object to represent our driver.
//
Status = WdfDriverCreate(DriverObject,
RegistryPath,
WDF_NO_OBJECT_ATTRIBUTES,
&DriverConfig,
&Driver);
if (!NT_SUCCESS(Status)) {
goto DriverEntryEnd;
}
DriverEntryEnd:
return Status;
}
BOOLEAN
SampleDrvInterruptIsr (
_In_ WDFINTERRUPT Interrupt,
_In_ ULONG MessageID
)
/*++
Routine Description:
This routine is the interrupt service routine for the sample device
N.B. This driver assumes that the interrupt line is not shared with any
other device. Hence it always claims the interrupt.
Arguments:
Interupt - Supplies a handle to interrupt object (WDFINTERRUPT) for this
device.
MessageID - Supplies the MSI message ID for MSI-based interrupts.
Return Value:
Always TRUE.
--*/
{
UNREFERENCED_PARAMETER(Interrupt);
UNREFERENCED_PARAMETER(MessageID);
//
// The sample driver always returns TRUE (e.g. claiming the interrupt)
// from its ISR. In reality, the driver needs to do whatever necessary to
// quiesce the interrupt before claiming the interrupt. In case of spurious
// interrupts, the ISR returns FALSE. If additional work needs to be done
// at a lower IRQL, schedule a DPC.
//
return TRUE;
}
#if 0
BOOLEAN
SampleDrvInterruptPassiveCallback (
_In_ WDFINTERRUPT Interrupt,
_In_ ULONG MessageID
)
/*++
Routine Description:
This routine is the passive interrupt callback routine for the sample device.
As its name suggests, this routine is always invoked at PASSIVE_LEVEL.
This is useful in scenarios where the device is located behind a slow serial
peripheral bus(SPB) and requires communication (possible only at PASSIVE_LEVEL)
over the bus in quiescing the interrupt source.
N.B. It is possible for passive interrupt callback and DIRQL ISRs to
coexist for the same device and/or IDT entry. Interrupt objects chained to a
given IDT entry are always ordered (at interrupt connect time) by the OS such
that the DIRQL ISR interrupt objects are located before the passive callback
ones. Consequently, during interrupt dispatching, the OS would walk the list
in that order until the first ISR/passive callback returns TRUE to claim the
interrupt.
Arguments:
Interupt - Supplies a handle to interrupt object (WDFINTERRUPT) for this
device.
MessageID - Supplies the MSI message ID for MSI-based interrupts.
Return Value:
Always TRUE.
--*/
{
UNREFERENCED_PARAMETER(Interrupt);
UNREFERENCED_PARAMETER(MessageID);
//
// The sample driver always returns TRUE (e.g. claiming the interrupt)
// from its passive callback. In reality, the driver needs to do whatever necessary to
// quiesce the interrupt before claiming the interrupt.
//
return TRUE;
}
#endif
VOID
SampleDrvInterruptDpc (
_In_ WDFINTERRUPT WdfInterrupt,
_In_ WDFOBJECT WdfDevice
)
/*++
Routine Description:
This routine is the DPC callback for the ISR. This routine is unused.
Arguments:
Interupt - Supplies a handle to interrupt object (WDFINTERRUPT) for this
device.
Device - Supplies a handle to the framework device object.
Return Value:
None.
--*/
{
UNREFERENCED_PARAMETER(WdfInterrupt);
UNREFERENCED_PARAMETER(WdfDevice);
return;
}
_Use_decl_annotations_
NTSTATUS
SampleDrvEvtDeviceAdd (
WDFDRIVER Driver,
PWDFDEVICE_INIT DeviceInit
)
/*++
Routine Description:
This routine is the AddDevice entry point for the sample device driver.
It sets the ISR and DPC routine handlers for the interrupt and the passive
level callback for the passive interrupt
N.B. The sample device expects two interrupt resources in connecting its
DIRQL ISR and PASSIVE_LEVEL callback.
Arguments:
Driver - Supplies a handle to the driver object created in DriverEntry.
DeviceInit - Supplies a pointer to a framework-allocated WDFDEVICE_INIT
structure.
Return Value:
NTSTATUS code.
--*/
{
WDF_PNPPOWER_EVENT_CALLBACKS Callbacks;
WDFDEVICE Device;
WDF_OBJECT_ATTRIBUTES FdoAttributes;
WDF_INTERRUPT_CONFIG InterruptConfiguration;
NTSTATUS Status;
WDFINTERRUPT WdfInterrupt;
UNREFERENCED_PARAMETER(Driver);
PAGED_CODE();
//
// Set PnP callbacks for prepare/release hardware and D0 entry/exit. All
// callbacks not overriden here will be handled by the framework in the
// default manner.
//
WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&Callbacks);
Callbacks.EvtDevicePrepareHardware = SampleDrvEvtDevicePrepareHardware;
Callbacks.EvtDeviceD0Entry = SampleDrvEvtDeviceD0Entry;
//
// Register the PnP callbacks with the framework.
//
WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit, &Callbacks);
//
// Initialize FDO attributes with the sample device extension.
//
WDF_OBJECT_ATTRIBUTES_INIT(&FdoAttributes);
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&FdoAttributes, SAMPLE_DRV_DEVICE_EXTENSION);
//
// Call the framework to create the device and attach it to the lower stack.
//
Status = WdfDeviceCreate(&DeviceInit, &FdoAttributes, &Device);
if (!NT_SUCCESS(Status)) {
goto EvtDeviceAddEnd;
}
//
// Create an interrupt object. For the KMDF driver, the ISR will be run at
// DIRQL. For UMDF(v2), it will be run at PASSIVE_LEVEL, hence the DPC is
// only defined in the KMDF case.
//
WDF_INTERRUPT_CONFIG_INIT(&InterruptConfiguration,
SampleDrvInterruptIsr,
#ifdef _KERNEL_MODE
SampleDrvInterruptDpc
#else
NULL
#endif
);
Status = WdfInterruptCreate(Device,
&InterruptConfiguration,
WDF_NO_OBJECT_ATTRIBUTES,
&WdfInterrupt);
if (!NT_SUCCESS(Status)) {
goto EvtDeviceAddEnd;
}
#if 0
//
// Create an interrupt object for the passive interrupt callback. Note that
// the interrupt object is chained to the same interrupt line/IDT as the
// DIRQL one.
//
WDF_INTERRUPT_CONFIG_INIT(&InterruptConfiguration,
SampleDrvInterruptIsr,
NULL);
//
// Set passive handling to true
//
InterruptConfiguration.PassiveHandling = TRUE;
Status = WdfInterruptCreate(Device,
&InterruptConfiguration,
WDF_NO_OBJECT_ATTRIBUTES,
&WdfInterrupt);
#endif
EvtDeviceAddEnd:
return Status;
}
NTSTATUS
SampleDrvEvtDevicePrepareHardware (
_In_ WDFDEVICE Device,
_In_ WDFCMRESLIST ResourcesRaw,
_In_ WDFCMRESLIST ResourcesTranslated
)
/*++
Routine Description:
This routine is called by the framework when the PnP manager sends an
IRP_MN_START_DEVICE request to the driver stack.
Arguments:
Device - Supplies a handle to a framework device object.
ResourcesRaw - Supplies a handle to a collection of framework resource
objects. This collection identifies the raw (bus-relative) hardware
resources that have been assigned to the device.
ResourcesTranslated - Supplies a handle to a collection of framework
resource objects. This collection identifies the translated
(system-physical) hardware resources that have been assigned to the
device. The resources appear from the CPU's point of view.
Return Value:
NT status code.
--*/
{
PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor;
PSAMPLE_DRV_DEVICE_EXTENSION SampleDrvExtension;
ULONG Index;
ULONG ResourceCount;
NTSTATUS Status;
ULONG IoResourceIndex;
UNREFERENCED_PARAMETER(Device);
UNREFERENCED_PARAMETER(ResourcesRaw);
PAGED_CODE();
SampleDrvExtension = SampleDrvGetDeviceExtension(Device);
Status = STATUS_SUCCESS;
IoResourceIndex = 0;
SampleDrvExtension->InterruptCount = 0;
//
// Walk through the resource list and map all the resources. Only one
// memory resource and one interrupt is expected.
//
ResourceCount = WdfCmResourceListGetCount(ResourcesTranslated);
for (Index = 0; Index < ResourceCount; Index += 1) {
Descriptor = WdfCmResourceListGetDescriptor(ResourcesTranslated, Index);
switch(Descriptor->Type) {
//
// This memory resource supplies the base of the device registers.
//
case CmResourceTypeConnection:
//
// Check against expected connection type
//
if ((Descriptor->u.Connection.Class ==
CM_RESOURCE_CONNECTION_CLASS_GPIO) &&
(Descriptor->u.Connection.Type ==
CM_RESOURCE_CONNECTION_TYPE_GPIO_IO)) {
SampleDrvExtension->ConnectionIds[IoResourceIndex].LowPart =
Descriptor->u.Connection.IdLowPart;
SampleDrvExtension->ConnectionIds[IoResourceIndex].HighPart =
Descriptor->u.Connection.IdHighPart;
IoResourceIndex++;
} else {
Status = STATUS_UNSUCCESSFUL;
}
break;
//
// Interrupt resource
//
case CmResourceTypeInterrupt:
SampleDrvExtension->InterruptCount++;
default:
break;
}
if (!NT_SUCCESS(Status)) {
goto DevicePrepareHardwareEnd;
}
}
//
// Ensure that at least one interrupt resource is defined.
//
#ifdef _KERNEL_MODE
NT_ASSERT(SampleDrvExtension->InterruptCount > 0);
#endif
if (SampleDrvExtension->InterruptCount < 1) {
Status = STATUS_UNSUCCESSFUL;
goto DevicePrepareHardwareEnd;
}
//
// Store the number of GPIO IO connection strings
//
SampleDrvExtension->IoResourceCount = IoResourceIndex;
DevicePrepareHardwareEnd:
return Status;
}
NTSTATUS
SampleDrvEvtDeviceD0Entry (
_In_ WDFDEVICE Device,
_In_ WDF_POWER_DEVICE_STATE PreviousPowerState
)
/*++
Routine Description:
This routine is invoked by the framework to program the device to goto
D0, which is the working state. The framework invokes callback every
time the hardware needs to be (re-)initialized. This includes after
IRP_MN_START_DEVICE, IRP_MN_CANCEL_STOP_DEVICE, IRP_MN_CANCEL_REMOVE_DEVICE,
and IRP_MN_SET_POWER-D0.
N.B. This function is not marked pageable because this function is in
the device power up path. When a function is marked pagable and the
code section is paged out, it will generate a page fault which could
impact the fast resume behavior because the client driver will have
to wait until the system drivers can service this page fault.
Arguments:
Device - Supplies a handle to the framework device object.
PreviousPowerState - WDF_POWER_DEVICE_STATE-typed enumerator that identifies
the device power state that the device was in before this transition
to D0.
Return Value:
NTSTATUS code. A failure here will indicate a fatal error and cause the
framework to tear down the stack.
--*/
{
BYTE Data;
NTSTATUS Status;
WDFIOTARGET ReadTarget;
WDFIOTARGET WriteTarget;
PSAMPLE_DRV_DEVICE_EXTENSION SampleDrvExtension;
UNICODE_STRING ReadString;
WCHAR ReadStringBuffer[100];
UNICODE_STRING WriteString;
WCHAR WriteStringBuffer[100];
UNREFERENCED_PARAMETER(PreviousPowerState);
ReadTarget = NULL;
WriteTarget = NULL;
SampleDrvExtension = SampleDrvGetDeviceExtension(Device);
//
// For demonstration purporses, the sample device consumes two IO resources,
// the first of which will be used for input, and the second for output.
//
RtlInitEmptyUnicodeString(&ReadString,
ReadStringBuffer,
sizeof(ReadStringBuffer));
RtlInitEmptyUnicodeString(&WriteString,
WriteStringBuffer,
sizeof(WriteStringBuffer));
//
// Construct full-path string for GPIO read operation
//
Status = RESOURCE_HUB_CREATE_PATH_FROM_ID(&ReadString,
SampleDrvExtension->ConnectionIds[0].LowPart,
SampleDrvExtension->ConnectionIds[0].HighPart);
if (!NT_SUCCESS(Status)) {
goto Cleanup;
}
//
// Construct full-path string for GPIO write operation
//
Status = RESOURCE_HUB_CREATE_PATH_FROM_ID(&WriteString,
SampleDrvExtension->ConnectionIds[1].LowPart,
SampleDrvExtension->ConnectionIds[1].HighPart);
if (!NT_SUCCESS(Status)) {
goto Cleanup;
}
//
// Perform the read operation
//
Data = 0x0;
Status = TestReadWrite(Device, &ReadString, TRUE, &Data, sizeof(Data), &ReadTarget);
if (!NT_SUCCESS(Status)) {
goto Cleanup;
}
//
// Perform the write operation
//
Status = TestReadWrite(Device, &WriteString, FALSE, &Data, sizeof(Data), &WriteTarget);
if (!NT_SUCCESS(Status)) {
goto Cleanup;
}
Cleanup:
if (ReadTarget != NULL) {
WdfIoTargetClose(ReadTarget);
WdfObjectDelete(ReadTarget);
}
if (WriteTarget != NULL) {
WdfIoTargetClose(WriteTarget);
WdfObjectDelete(WriteTarget);
}
return Status;
}
NTSTATUS
TestReadWrite (
_In_ WDFDEVICE Device,
_In_ PCUNICODE_STRING RequestString,
_In_ BOOLEAN ReadOperation,
_Inout_ PUCHAR Data,
_In_ _In_range_(>, 0) ULONG Size,
_Out_ WDFIOTARGET *IoTargetOut
)
/*++
Routine Description:
This is a utility routine to test read or write on a set of GPIO pins.
Arguments:
Device - Supplies a handle to the framework device object.
RequestString - Supplies a pointer to the unicode string to be opened.
ReadOperation - Supplies a boolean that identifies whether read (TRUE) or
write (FALSE) should be performed.
Data - Supplies a pointer containing the buffer that should be read from
or written to.
Size - Supplies the size of the data buffer in bytes.
IoTargetOut - Supplies a pointer that receives the IOTARGET created by
WDF.
Return Value:
None.
--*/
{
WDF_OBJECT_ATTRIBUTES Attributes;
WDFREQUEST IoctlRequest;
WDFIOTARGET IoTarget;
ULONG DesiredAccess;
WDFMEMORY WdfMemory;
WDF_OBJECT_ATTRIBUTES RequestAttributes;
WDF_REQUEST_SEND_OPTIONS SendOptions;
NTSTATUS Status;
WDF_OBJECT_ATTRIBUTES ObjectAttributes;
WDF_IO_TARGET_OPEN_PARAMS OpenParams;
WDF_OBJECT_ATTRIBUTES_INIT(&ObjectAttributes);
ObjectAttributes.ParentObject = Device;
IoctlRequest = NULL;
IoTarget = NULL;
if ((Data == NULL) || (Size == 0)) {
Status = STATUS_INVALID_PARAMETER;
goto TestReadWriteEnd;
}
Status = WdfIoTargetCreate(Device,
&ObjectAttributes,
&IoTarget);
if (!NT_SUCCESS(Status)) {
goto TestReadWriteEnd;
}
//
// Specify desired file access
//
if (ReadOperation != FALSE) {
DesiredAccess = FILE_GENERIC_READ;
} else {
DesiredAccess = FILE_GENERIC_WRITE;
}
WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(&OpenParams,
RequestString,
DesiredAccess);
//
// Open the IoTarget for I/O operation
//
Status = WdfIoTargetOpen(IoTarget, &OpenParams);
if (!NT_SUCCESS(Status)) {
goto TestReadWriteEnd;
}
WDF_OBJECT_ATTRIBUTES_INIT(&RequestAttributes);
Status = WdfRequestCreate(&RequestAttributes, IoTarget, &IoctlRequest);
if (!NT_SUCCESS(Status)) {
goto TestReadWriteEnd;
}
//
// Set up a WDF memory object for the IOCTL request
//
WDF_OBJECT_ATTRIBUTES_INIT(&Attributes);
Attributes.ParentObject = IoctlRequest;
Status = WdfMemoryCreatePreallocated(&Attributes, Data, Size, &WdfMemory);
if (!NT_SUCCESS(Status)) {
goto TestReadWriteEnd;
}
//
// Format the request as read or write operation
//
if (ReadOperation != FALSE) {
Status = WdfIoTargetFormatRequestForIoctl(IoTarget,
IoctlRequest,
IOCTL_GPIO_READ_PINS,
NULL,
0,
WdfMemory,
0);
} else {
Status = WdfIoTargetFormatRequestForIoctl(IoTarget,
IoctlRequest,
IOCTL_GPIO_WRITE_PINS,
WdfMemory,
0,
WdfMemory,
0);
}
if (!NT_SUCCESS(Status)) {
goto TestReadWriteEnd;
}
//
// Send the request synchronously with an arbitrary timeout of 60 seconds
//
WDF_REQUEST_SEND_OPTIONS_INIT(&SendOptions,
WDF_REQUEST_SEND_OPTION_SYNCHRONOUS);
WDF_REQUEST_SEND_OPTIONS_SET_TIMEOUT(&SendOptions,
WDF_REL_TIMEOUT_IN_SEC(60));
Status = WdfRequestAllocateTimer(IoctlRequest);
if (!NT_SUCCESS(Status)) {
goto TestReadWriteEnd;
}
if (!WdfRequestSend(IoctlRequest, IoTarget, &SendOptions)) {
Status = WdfRequestGetStatus(IoctlRequest);
}
if (NT_SUCCESS(Status)) {
*IoTargetOut = IoTarget;
}
TestReadWriteEnd:
if (IoctlRequest != NULL) {
WdfObjectDelete(IoctlRequest);
}
if (!NT_SUCCESS(Status) && (IoTarget != NULL)) {
WdfIoTargetClose(IoTarget);
WdfObjectDelete(IoTarget);
}
return Status;
}
|