ReactOS 0.4.16-dev-329-g9223134
fxiotargetapi.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxIoTargetAPI.cpp
8
9Abstract:
10
11 This module implements the IO Target APIs
12
13Author:
14
15Environment:
16
17 kernel mode only
18
19Revision History:
20
21--*/
22
23#include "../fxtargetsshared.hpp"
24
25extern "C" {
26// #include "FxIoTargetAPI.tmh"
27}
28
29//
30// Extern the entire file
31//
32extern "C" {
33
38WDFEXPORT(WdfIoTargetStart)(
39 __in
41 __in
42 WDFIOTARGET IoTarget
43 )
44/*++
45
46Routine Description:
47 Changes the target's state to started. In the started state, the target
48 can send I/O.
49
50Arguments:
51 IoTarget - the target whose state will change
52
53Return Value:
54 NTSTATUS
55
56 --*/
57{
58 DDI_ENTRY();
59
61
65 (PVOID*) &pTarget);
66
67 return pTarget->Start();
68}
69
72VOID
74WDFEXPORT(WdfIoTargetStop)(
75 __in
77 __in
78 WDFIOTARGET IoTarget,
79 __in
80 __drv_strictTypeMatch(__drv_typeConst)
82 )
83/*++
84
85Routine Description:
86 This function puts the target into the stopped state. Depending on the value
87 of Action, this function may not return until sent I/O has been canceled and/or
88 completed.
89
90Arguments:
91 IoTarget - the target whose state is being changed
92
93 Action - what to do with the I/O that is pending in the target already
94
95Return Value:
96 None
97
98 --*/
99{
100 DDI_ENTRY();
101
105
107 IoTarget,
109 (PVOID*) &pTarget,
111
115 "Action %d undefined or out of range", Action);
116 return;
117 }
118
122 if (!NT_SUCCESS(status)) {
123 return;
124 }
125 }
126
128}
129
132VOID
134WDFEXPORT(WdfIoTargetPurge)(
135 __in
137 __in
138 WDFIOTARGET IoTarget,
139 __in
140 __drv_strictTypeMatch(__drv_typeConst)
142 )
143/*++
144
145Routine Description:
146 This function puts the target into the purged state. Depending on the value
147 of Action, this function may not return until pending and sent I/O has been
148 canceled and completed.
149
150Arguments:
151 IoTarget - the target whose state is being changed
152
153 Action - purge action: wait or not for I/O to complete after doing the purge.
154
155Return Value:
156 None
157
158 --*/
159{
160 DDI_ENTRY();
161
165
167 IoTarget,
169 (PVOID*) &pTarget,
171
175 "Action %d undefined or out of range", Action);
176 return;
177 }
178
181 if (!NT_SUCCESS(status)) {
182 return;
183 }
184 }
185
187}
188
192WDFEXPORT(WdfIoTargetGetState)(
193 __in
195 __in
196 WDFIOTARGET IoTarget
197 )
198/*++
199
200Routine Description:
201 Returns the current state of the target
202
203Arguments:
204 IoTarget - target whose state is being returned
205
206Return Value:
207 current target state
208
209 --*/
210{
211 DDI_ENTRY();
212
214
216 IoTarget,
218 (PVOID*) &pTarget);
219
220 return pTarget->GetState();
221}
222
226 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
228 )
229/*++
230
231Routine Description:
232 Validates the target open parameters structure.
233
234Arguments:
235 FxDriverGlobals - driver globals
236
237 OpenParams - the structure to validate
238
239Return Value:
240 NTSTATUS
241
242 --*/
243
244{
246
247 //
248 // Check specific fields based on Type
249 //
250 switch (OpenParams->Type) {
252 if (OpenParams->TargetDeviceObject == NULL) {
255 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
256 "Expected non NULL TargetDeviceObject in OpenParams, %!STATUS!",
257 status);
258 return status;
259 }
260
261 //
262 // This type is supported only in KMDF.
263 //
264 if (FxDriverGlobals->IsUserModeDriver) {
267 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
268 "The open type WdfIoTargetOpenUseExistingDevice is not "
269 "supported in UMDF drivers. It is supported in KMDF "
270 "drivers only, %!STATUS!",
271 status);
272 return status;
273 }
274
275 if (OpenParams->TargetFileObject == NULL &&
276 (OpenParams->EvtIoTargetQueryRemove != NULL ||
277 OpenParams->EvtIoTargetRemoveCanceled != NULL ||
278 OpenParams->EvtIoTargetRemoveComplete != NULL)) {
280
282 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
283 "OpenParams %p TargetFileObject is NULL but a state callback "
284 "(query remove %p, remove canceled %p, remove complete %p)"
285 " was specified, %!STATUS!",
286 OpenParams, OpenParams->EvtIoTargetQueryRemove,
287 OpenParams->EvtIoTargetRemoveCanceled,
288 OpenParams->EvtIoTargetRemoveComplete, status);
289
290 return status;
291 }
292 break;
293
295 if (OpenParams->TargetDeviceName.Buffer == NULL ||
296 OpenParams->TargetDeviceName.Length == 0 ||
297 OpenParams->TargetDeviceName.MaximumLength == 0) {
300 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
301 "Expected valid OpenParams TargetDeviceName string, %!STATUS!",
302 status);
303 return status;
304 }
305 break;
306
308 //
309 // This type is supported only in UMDF.
310 //
311 if (FxDriverGlobals->IsUserModeDriver == FALSE) {
314 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
315 "The open type WdfIoTargetOpenLocalTargetByFile is not "
316 "supported in KMDF drivers. It is supported in UMDF "
317 "drivers only, %!STATUS!",
318 status);
319 return status;
320 }
321
322 if ((OpenParams->EvtIoTargetQueryRemove != NULL ||
323 OpenParams->EvtIoTargetRemoveCanceled != NULL ||
324 OpenParams->EvtIoTargetRemoveComplete != NULL)) {
326
328 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIOTARGET,
329 "The open type is WdfIoTargetOpenLocalTargetByFile but a state"
330 " callback (query remove %p, remove canceled %p, remove"
331 " complete %p) was specified, %!STATUS!",
332 OpenParams->EvtIoTargetQueryRemove,
333 OpenParams->EvtIoTargetRemoveCanceled,
334 OpenParams->EvtIoTargetRemoveComplete, status);
335
336 return status;
337 }
338
339 if (OpenParams->FileName.Buffer != NULL ||
340 OpenParams->FileName.Length != 0 ||
341 OpenParams->FileName.MaximumLength != 0) {
342 status = FxValidateUnicodeString(FxDriverGlobals,
343 &OpenParams->FileName);
344 if (!NT_SUCCESS(status)) {
345 return status;
346 }
347 }
348
349
350 break;
351
353 break;
354
355 default:
358 "OpenParams Type (%d) incorrect, %!STATUS!",
359 OpenParams->Type, status);
360
361 return status;
362 }
363
364 return STATUS_SUCCESS;
365}
366
367
372WDFEXPORT(WdfIoTargetCreate)(
373 __in
375 __in
376 WDFDEVICE Device,
379 __out
380 WDFIOTARGET* IoTarget
381 )
382/*++
383
384Routine Description:
385 Creates a WDFIOTARGET which can be opened upon success.
386
387Arguments:
388 Device - the device which will own the target. The target will be parented
389 by the owning device
390
391 IoTargetAttributes - optional attributes to apply to the target
392
393 IoTarget - pointer which will receive the created target handle
394
395Return Value:
396 NTSTATUS
397
398 --*/
399{
400 DDI_ENTRY();
401
406
408 Device,
412
414
416 "WDFDEVICE 0x%p", Device);
417
420 return status;
421 }
422
423 //
424 // Since the target is auto parented to the Device, we don't allow the client
425 // to specify a parent.
426 //
428 if (!NT_SUCCESS(status)) {
429 return status;
430 }
431
434
437 }
438
439 return status;
440}
441
446WDFEXPORT(WdfIoTargetOpen)(
447 __in
449 __in
450 WDFIOTARGET IoTarget,
451 __in
453 )
454/*++
455
456Routine Description:
457 Opens a target. The target must be in the closed state for an open to
458 succeed. Open is either wrapping an existing PDEVICE_OBJECT + PFILE_OBJECT
459 that the client provides or opening a PDEVICE_OBJECT by name.
460
461Arguments:
462 IoTarget - Target to be opened
463
464 OpenParams - structure which describes how to open the target
465
466Return Value:
467 NTSTATUS
468
469 --*/
470{
471 //
472 // UMDF only, noop for KMDF.
473 // It's ok to be impersonated here, because it can be required in order for
474 // the CreateFile() call to succeed.
475 //
477
483
485 IoTarget,
487 (PVOID*) &pTarget,
489
491 "enter WDFIOTARGET 0x%p", IoTarget);
492
494
496 if (!NT_SUCCESS(status)) {
497 return status;
498 }
499
503
504 //
505 // Check Size
506 //
507 if (OpenParams->Size != sizeof(WDF_IO_TARGET_OPEN_PARAMS) &&
511 "OpenParams size (%d) incorrect, expected %d, %!STATUS!",
513 return status;
514 }
515
516 //
517 // Normalize WDF_IO_TARGET_OPEN_PARAMS structure.
518 //
521
522 //
523 // Copy over existing fields and readjust the struct size.
524 //
526 openParams.Size = sizeof(openParams);
527
528 //
529 // Use new open params structure from now on.
530 //
532 }
533
535 if (!NT_SUCCESS(status)) {
536 //
537 // FxIoTargetValidateCreateParams traces the error
538 //
539 return status;
540 }
541
542 status = pTarget->Open(OpenParams);
543
545 "exit WDFIOTARGET 0x%p, %!STATUS!", IoTarget, status);
546
547 return status;
548}
549
551VOID
553WDFEXPORT(WdfIoTargetCloseForQueryRemove)(
554 __in
556 __in
557 WDFIOTARGET IoTarget
558 )
559/*++
560
561Routine Description:
562 Closes a target in response to a query remove notification callback. This
563 will pend all i/o sent after the call returns.
564
565Arguments:
566 IoTarget - Target to be closed
567
568Return Value:
569 None
570
571 --*/
572{
573 DDI_ENTRY();
574
578
580 IoTarget,
582 (PVOID*) &pTarget,
584
586
589 "enter WDFIOTARGET 0x%p", IoTarget);
590
592 if (!NT_SUCCESS(status)) {
593 return;
594 }
595
597}
598
600VOID
602WDFEXPORT(WdfIoTargetClose)(
603 __in
605 __in
606 WDFIOTARGET IoTarget
607 )
608/*++
609
610Routine Description:
611 Closes the target for good. The target can be in either a query removed or
612 opened state.
613
614Arguments:
615 IoTarget - target to close
616
617Return Value:
618 None
619
620 --*/
621{
622 DDI_ENTRY();
623
627
629 IoTarget,
631 (PVOID*) &pTarget,
633
635 "enter WDFIOTARGET 0x%p", IoTarget);
636
638 if (!NT_SUCCESS(status)) {
639 return;
640 }
641
643}
644
646WDFDEVICE
648WDFEXPORT(WdfIoTargetGetDevice)(
649 __in
651 __in
652 WDFIOTARGET IoTarget
653 )
654/*++
655
656Routine Description:
657 Returns the owning WDFDEVICE for the WDFIOTARGET, this is not necessarily
658 the PDEVICE_OBJECT of the target itself.
659
660Arguments:
661 IoTarget - the target being retrieved
662
663Return Value:
664 a valid WDFDEVICE handle , NULL if there are any problems
665
666 --*/
667
668{
669 DDI_ENTRY();
670
673 WDFDEVICE device;
674
676 IoTarget,
678 (PVOID*) &pTarget,
680
682 "enter WDFIOTARGET 0x%p", IoTarget);
683
685
687 "exit WDFIOTARGET 0x%p, WDFDEVICE 0x%p", IoTarget, device);
688
689 return device;
690}
691
692static
696 __in
697 PFX_DRIVER_GLOBALS FxDriverGlobals,
698 __in
699 WDFIOTARGET IoTarget,
701 WDFREQUEST Request,
702 __in
703 UCHAR MajorCode,
705 PWDF_MEMORY_DESCRIPTOR IoBuffer,
712 )
713/*++
714
715Routine Description:
716 This routine sends a read or write synchronously to the target. If Request
717 is not NULL, the PIRP it contains will be used to send the IO.
718
719Arguments:
720 IoTarget - target to where the IO is going to be sent
721
722 Request - optional. If specified, the PIRP it contains will be used
723 to send the I/O
724
725 MajorCode - read or write major code
726
727 IoBuffer - Buffer which will be used in the I/O. The buffer can be a PMDL,
728 buffer, or WDFMEMORY
729
730 DeviceOffset - offset into the target (and not the memory) in which the I/O
731 will start
732
733 RequestOptions - optional. If specified, the timeout value is used to cancel
734 the sent i/o if the timeout is exceeded
735
736 BytesReturned - upon success, the number of bytes transferred in the I/O
737 request
738
739Return Value:
740 NTSTATUS
741
742 --*/
743
744{
746 FxRequestBuffer ioBuf;
748
749 FxObjectHandleGetPtrAndGlobals(FxDriverGlobals,
750 IoTarget,
752 (PVOID*) &pTarget,
753 &FxDriverGlobals);
754
755 //
756 // Minimize the points of failure by using the stack instead of allocating
757 // out of pool. For UMDF, request initialization can fail so we still need
758 // to call initialize for FxSyncRequest. Initialization always succeeds for
759 // KM.
760 //
762 FxSyncRequest request(FxDriverGlobals, &context, Request);
763
764 status = request.Initialize();
765 if (!NT_SUCCESS(status)) {
767 "Failed to initialize FxSyncRequest for WDFIOTARGET "
768 "0x%p", IoTarget);
769 return status;
770 }
771
773 "enter: WDFIOTARGET 0x%p, WDFREQUEST 0x%p, MJ code 0x%x",
774 IoTarget, Request, MajorCode);
775
776 //
777 // Since we are synchronously waiting, we must be at passive level
778 //
780 if (!NT_SUCCESS(status)) {
781 return status;
782 }
783
785 if (!NT_SUCCESS(status)) {
787 "invalid options, %!STATUS!", status);
788 return status;
789 }
790
791 if (IoBuffer != NULL) {
792 //
793 // This transcribes the client union into a local structure which we
794 // can change w/out altering the client's buffer.
795 //
796 status = ioBuf.ValidateMemoryDescriptor(FxDriverGlobals, IoBuffer);
797 if (!NT_SUCCESS(status)) {
799 "invalid input buffer descriptor 0x%p, %!STATUS!",
800 IoBuffer, status);
801 return status;
802 }
803 }
804
805 //
806 // Format the next stack location in the PIRP
807 //
809 request.m_TrueRequest, MajorCode, &ioBuf, DeviceOffset, NULL);
810
811 if (NT_SUCCESS(status)) {
812 //
813 // And send it
814 //
816 "WDFIOTARGET 0x%p, WDFREQUEST 0x%p being submitted",
817 IoTarget, request.m_TrueRequest->GetTraceObjectHandle());
818
820
821 if (BytesReturned != NULL) {
822 *BytesReturned = request.m_TrueRequest->GetSubmitFxIrp()->GetInformation();
823
824 }
825 }
826 else {
828 "could not format MJ 0x%x request, %!STATUS!",
829 MajorCode, status);
830 }
831
832 return status;
833}
834
835static
839 __in
840 PFX_DRIVER_GLOBALS FxDriverGlobals,
841 __in
842 WDFIOTARGET IoTarget,
843 __inout
844 WDFREQUEST Request,
845 __in
846 UCHAR MajorCode,
848 WDFMEMORY IoBuffer,
850 PWDFMEMORY_OFFSET IoBufferOffsets,
853 )
854/*++
855
856Routine Description:
857 Formats a Request for a read or write. The request can later be sent to the
858 target using WdfRequestSend. Upon success, this will take a reference on the
859 Iobuffer handle if it is not NULL. This reference will be released when
860 one of the following occurs:
861 1) the request is completed through WdfRequestComplete
862 2) the request is reused through WdfRequestReuse
863 3) the request is reformatted through any target format DDI
864
865Arguments:
866 IoTarget - the request that the read or write will later be sent to
867
868 Request - the request that will be formatted
869
870 MajorCode - read or write major code
871
872 IoBuffer - optional reference counted memory handle
873
874 IoBufferOffset - optional offset into the IoBuffer. This can specify the
875 starting offset and/or length of the transfer
876
877 DeviceOffset - offset into the target in which the i/o will start
878
879Return Value:
880 NTSTATUS
881
882 --*/
883{
886 IFxMemory* pIoMemory;
887 FxRequestBuffer ioBuf;
889
890 FxObjectHandleGetPtrAndGlobals(FxDriverGlobals,
891 IoTarget,
893 (PVOID*) &pTarget,
894 &FxDriverGlobals);
895
896 DoTraceLevelMessage(FxDriverGlobals,
898 "enter: WDFIOTARGET 0x%p, WDFREQUEST 0x%p, MJ code 0x%x, WDFMEMORY 0x%p",
899 IoTarget, Request, MajorCode, IoBuffer);
900
901 FxObjectHandleGetPtr(FxDriverGlobals,
902 Request,
904 (PVOID*) &pRequest);
905
906 if (IoBuffer != NULL) {
907 FxObjectHandleGetPtr(FxDriverGlobals,
908 IoBuffer,
910 (PVOID*) &pIoMemory);
911
912 status = pIoMemory->ValidateMemoryOffsets(IoBufferOffsets);
913 if (!NT_SUCCESS(status)) {
915 "invalid memory offsets, %!STATUS!",
916 status);
917 return status;
918 }
919
920 //
921 // This transcribes the client union into a local structure which we
922 // can change w/out altering the client's buffer.
923 //
924 ioBuf.SetMemory(pIoMemory, IoBufferOffsets);
925 }
926 else {
927 pIoMemory = NULL;
928 }
929
930 //
931 // Format the next stack locaiton in the PIRP
932 //
934 pRequest, MajorCode, &ioBuf, DeviceOffset, NULL);
935
936 if (NT_SUCCESS(status)) {
937 if (MajorCode == IRP_MJ_WRITE) {
938 pRequest->GetContext()->FormatWriteParams(pIoMemory, IoBufferOffsets);
939 }
940 else if (MajorCode == IRP_MJ_READ) {
941 pRequest->GetContext()->FormatReadParams(pIoMemory, IoBufferOffsets);
942 }
943 }
944
946 "exit WDFIOTARGET 0x%p, WDFREQUEST 0x%p, %!STATUS!",
948
949 return status;
950}
951
956WDFEXPORT(WdfIoTargetSendReadSynchronously)(
957 __in
959 __in
960 WDFIOTARGET IoTarget,
962 WDFREQUEST Request,
971 )
972{
973 DDI_ENTRY();
974
976 IoTarget,
977 Request,
982 BytesRead);
983}
984
989WDFEXPORT(WdfIoTargetFormatRequestForRead)(
990 __in
992 __in
993 WDFIOTARGET IoTarget,
994 __in
995 WDFREQUEST Request,
997 WDFMEMORY OutputBuffer,
1000 __in_opt
1002 )
1003{
1004 DDI_ENTRY();
1005
1007 IoTarget,
1008 Request,
1012 DeviceOffset);
1013}
1014
1015
1019STDCALL
1020WDFEXPORT(WdfIoTargetSendWriteSynchronously)(
1021 __in
1023 __in
1024 WDFIOTARGET IoTarget,
1025 __in_opt
1026 WDFREQUEST Request,
1027 __in_opt
1029 __in_opt
1031 __in_opt
1033 __out_opt
1035 )
1036{
1037 DDI_ENTRY();
1038
1040 IoTarget,
1041 Request,
1046 BytesWritten);
1047}
1048
1052STDCALL
1053WDFEXPORT(WdfIoTargetFormatRequestForWrite)(
1054 __in
1056 __in
1057 WDFIOTARGET IoTarget,
1058 __in
1059 WDFREQUEST Request,
1060 __in_opt
1061 WDFMEMORY InputBuffer,
1062 __in_opt
1064 __in_opt
1066 )
1067{
1068 DDI_ENTRY();
1069
1071 IoTarget,
1072 Request,
1076 DeviceOffset);
1077}
1078
1082 __in
1083 PFX_DRIVER_GLOBALS FxDriverGlobals,
1084 __in
1085 WDFIOTARGET IoTarget,
1086 __in_opt
1087 WDFREQUEST Request,
1088 __in
1089 ULONG Ioctl,
1090 __in
1092 __in_opt
1094 __in_opt
1096 __in_opt
1098 __out_opt
1100 )
1101/*++
1102
1103Routine Description:
1104 Sends an external or internal IOCTL to the target. If the optional request
1105 is specified, this function will use it's PIRP to send the request to the
1106 target. Both buffers are optional.
1107
1108Arguments:
1109 IoTarget - the target to which the IOCTL is being sent
1110
1111 IOCTL - the device io control value
1112
1113 Internal - if TRUE, an internal IOCTL, if FALSE, a normal IOCTL
1114
1115 InputBuffer - optional. Can be one of the following: PMDL, PVOID, or WDFMEMORY
1116
1117 OutputBuffer - optional. Can be one of the following: PMDL, PVOID, or WDFMEMORY
1118
1119 RequestOptions - optional. Specifies a timeout to be used if the sent IO
1120 does not return within the time specified.
1121
1122 BytesReturned - number of bytes transfered
1123
1124Return Value:
1125 NTSTATUS
1126
1127 --*/
1128{
1130 FxRequestBuffer inputBuf, outputBuf;
1132
1133 FxObjectHandleGetPtrAndGlobals(FxDriverGlobals,
1134 IoTarget,
1136 (PVOID*) &pTarget,
1137 &FxDriverGlobals);
1138
1139 //
1140 // Minimize the points of failure by using the stack instead of allocating
1141 // out of pool. For UMDF, request initialization can fail so we still need
1142 // to call initialize for FxSyncRequest. Initialization always succeeds for
1143 // KM.
1144 //
1146 FxSyncRequest request(FxDriverGlobals, &context, Request);
1147
1148 status = request.Initialize();
1149 if (!NT_SUCCESS(status)) {
1151 "Failed to initialize FxSyncRequest for WDFIOTARGET "
1152 "0x%p", IoTarget);
1153 return status;
1154 }
1155
1157 "enter: WDFIOTARGET 0x%p, WDFREQUEST 0x%p, IOCTL 0x%x, "
1158 "internal %d", IoTarget, Request, Ioctl, Internal);
1159
1160 //
1161 // Since we are synchronously waiting, we must be at passive
1162 //
1163 status = FxVerifierCheckIrqlLevel(FxDriverGlobals, PASSIVE_LEVEL);
1164 if (!NT_SUCCESS(status)) {
1165 return status;
1166 }
1167
1169 if (!NT_SUCCESS(status)) {
1171 "invalid options, %!STATUS!", status);
1172 return status;
1173 }
1174
1175 if (InputBuffer != NULL) {
1176 //
1177 // This transcribes the client union into a local structure which we
1178 // can change w/out altering the client's buffer.
1179 //
1180 status = inputBuf.ValidateMemoryDescriptor(FxDriverGlobals, InputBuffer);
1181 if (!NT_SUCCESS(status)) {
1183 "invalid input buffer descriptor 0x%p, %!STATUS!",
1185 return status;
1186 }
1187 }
1188
1189 if (OutputBuffer != NULL) {
1190 //
1191 // This transcribes the client union into a local structure which we
1192 // can change w/out altering the client's buffer.
1193 //
1194 status = outputBuf.ValidateMemoryDescriptor(FxDriverGlobals, OutputBuffer);
1195 if (!NT_SUCCESS(status)) {
1197 "invalid output buffer descriptor 0x%p, %!STATUS!",
1199 return status;
1200 }
1201 }
1202
1203 //
1204 // Format the next stack location
1205 //
1207 request.m_TrueRequest, Ioctl, Internal, &inputBuf, &outputBuf, NULL);
1208
1209 if (NT_SUCCESS(status)) {
1211 "WDFIOTARGET 0x%p, WDFREQUEST 0x%p being submitted",
1212 IoTarget,
1213 request.m_TrueRequest->GetTraceObjectHandle());
1214
1215 status = pTarget->SubmitSync(request.m_TrueRequest, RequestOptions);
1216
1217 if (BytesReturned != NULL) {
1218 *BytesReturned = request.m_TrueRequest->GetSubmitFxIrp()->GetInformation();
1219 }
1220 }
1221 else {
1223 "could not format IOCTL 0x%x request, %!STATUS!",
1224 Ioctl, status);
1225 }
1226
1227 return status;
1228}
1229
1230static
1234 __in
1235 PFX_DRIVER_GLOBALS FxDriverGlobals,
1236 __in
1237 WDFIOTARGET IoTarget,
1238 __in
1239 WDFREQUEST Request,
1240 __in
1241 ULONG Ioctl,
1242 __in
1244 __in_opt
1245 WDFMEMORY InputBuffer,
1246 __in_opt
1248 __in_opt
1249 WDFMEMORY OutputBuffer,
1250 __in_opt
1252 )
1253/*++
1254
1255Routine Description:
1256 Formats a request as an IOCTL to be sent to the specified target. Upon
1257 success, this will take a reference on each of the WDFMEMORY handles that
1258 are passed in. This reference will be released when one of the following
1259 occurs:
1260 1) the request is completed through WdfRequestComplete
1261 2) the request is reused through WdfRequestReuse
1262 3) the request is reformatted through any target format DDI
1263
1264Arguments:
1265 IoTarget - the target to which the IOCTL will be formatted for
1266
1267 Request - the request which will be formatted
1268
1269 IOCTL - the device IO control itself to be used
1270
1271 Internal - if TRUE, an internal IOCTL, if FALSE, a normal IOCTL
1272
1273 InputBuffer - optional. If specified, a reference counted memory handle to
1274 be placed in the next stack location.
1275
1276 InputBufferOffsets - optional. If specified, it can override the starting
1277 offset of the buffer and the length of the buffer used
1278
1279 OutputBuffer - optional. If specified, a reference counted memory handle to
1280 be placed in the next stack location.
1281
1282 OutputBufferOffsets - optional. If specified, it can override the starting
1283 offset of the buffer and the length of the buffer used
1284
1285Return Value:
1286 NTSTATUS
1287
1288 --*/
1289{
1292 IFxMemory *pInputMemory, *pOutputMemory;
1293 FxRequestBuffer inputBuf, outputBuf;
1295
1296 FxObjectHandleGetPtrAndGlobals(FxDriverGlobals,
1297 IoTarget,
1299 (PVOID*) &pTarget,
1300 &FxDriverGlobals);
1301
1303 FxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIOTARGET,
1304 "enter: WDFIOTARGET 0x%p, WDFREQUEST 0x%p, IOCTL 0x%x, internal %d, input "
1305 "WDFMEMORY 0x%p, output WDFMEMORY 0x%p",
1307
1308 FxObjectHandleGetPtr(FxDriverGlobals,
1309 Request,
1311 (PVOID*) &pRequest);
1312
1313 if (InputBuffer != NULL) {
1314 FxObjectHandleGetPtr(FxDriverGlobals,
1317 (PVOID*) &pInputMemory);
1318
1319 status = pInputMemory->ValidateMemoryOffsets(InputBufferOffsets);
1320 if (!NT_SUCCESS(status)) {
1322 "Invalid input memory offsets, %!STATUS!",
1323 status);
1324 return status;
1325 }
1326
1327 //
1328 // This transcribes the client union into a local structure which we
1329 // can change w/out altering the client's buffer.
1330 //
1331 inputBuf.SetMemory(pInputMemory, InputBufferOffsets);
1332 }
1333
1334 if (OutputBuffer != NULL) {
1335 FxObjectHandleGetPtr(FxDriverGlobals,
1338 (PVOID*) &pOutputMemory);
1339
1340 status = pOutputMemory->ValidateMemoryOffsets(OutputBufferOffsets);
1341 if (!NT_SUCCESS(status)) {
1343 "Invalid output memory offsets, %!STATUS!",
1344 status);
1345 return status;
1346 }
1347
1348 //
1349 // This transcribes the client union into a local structure which we
1350 // can change w/out altering the client's buffer.
1351 //
1352 outputBuf.SetMemory(pOutputMemory, OutputBufferOffsets);
1353 }
1354
1355 //
1356 // format the next stack location
1357 //
1359 pRequest, Ioctl, Internal, &inputBuf, &outputBuf, NULL);
1360
1361 if (NT_SUCCESS(status)) {
1362 FxRequestContext* pContext;
1363
1364 //
1365 // Upon a successful format, a FxRequestContext will have been
1366 // associated with the FxRequest
1367 //
1368 pContext = pRequest->GetContext();
1369
1370 pContext->m_CompletionParams.Parameters.Ioctl.IoControlCode = Ioctl;
1371
1372 if (Internal) {
1374 }
1375 else {
1377 }
1378
1379 pContext->m_CompletionParams.Parameters.Ioctl.Input.Buffer = InputBuffer;
1380 if (InputBufferOffsets != NULL) {
1381 pContext->m_CompletionParams.Parameters.Ioctl.Input.Offset =
1383 }
1384
1385 pContext->m_CompletionParams.Parameters.Ioctl.Output.Buffer = OutputBuffer;
1386 if (OutputBufferOffsets != NULL) {
1387 pContext->m_CompletionParams.Parameters.Ioctl.Output.Offset =
1389 }
1390 }
1391
1393 "Exit WDFIOTARGET 0x%p, WDFREQUEST 0x%p, %!STATUS!",
1395
1396 return status;
1397}
1398
1402STDCALL
1403WDFEXPORT(WdfIoTargetSendIoctlSynchronously)(
1404 __in
1406 __in
1407 WDFIOTARGET IoTarget,
1408 __in_opt
1409 WDFREQUEST Request,
1410 __in
1412 __in_opt
1414 __in_opt
1416 __in_opt
1418 __out_opt
1420 )
1421{
1422 DDI_ENTRY();
1423
1426 IoTarget,
1427 Request,
1428 Ioctl,
1429 FALSE,
1434 );
1435}
1436
1440STDCALL
1441WDFEXPORT(WdfIoTargetFormatRequestForIoctl)(
1442 __in
1444 __in
1445 WDFIOTARGET IoTarget,
1446 __in
1447 WDFREQUEST Request,
1448 __in
1449 ULONG Ioctl,
1450 __in_opt
1451 WDFMEMORY InputBuffer,
1452 __in_opt
1454 __in_opt
1455 WDFMEMORY OutputBuffer,
1456 __in_opt
1458 )
1459{
1460 DDI_ENTRY();
1461
1463 IoTarget,
1464 Request,
1465 Ioctl,
1466 FALSE,
1471}
1472
1476STDCALL
1477WDFEXPORT(WdfIoTargetSendInternalIoctlSynchronously)(
1478 __in
1480 __in
1481 WDFIOTARGET IoTarget,
1482 __in_opt
1483 WDFREQUEST Request,
1484 __in
1485 ULONG Ioctl,
1486 __in_opt
1488 __in_opt
1490 __in_opt
1492 __out_opt
1494 )
1495{
1496 DDI_ENTRY();
1497
1500 IoTarget,
1501 Request,
1502 Ioctl,
1503 TRUE,
1508 );
1509}
1510
1514STDCALL
1515WDFEXPORT(WdfIoTargetFormatRequestForInternalIoctl)(
1516 __in
1518 __in
1519 WDFIOTARGET IoTarget,
1520 __in
1521 WDFREQUEST Request,
1522 __in
1523 ULONG Ioctl,
1524 __in_opt
1525 WDFMEMORY InputBuffer,
1526 __in_opt
1528 __in_opt
1529 WDFMEMORY OutputBuffer,
1530 __in_opt
1532 )
1533{
1534 DDI_ENTRY();
1535
1537 IoTarget,
1538 Request,
1539 Ioctl,
1540 TRUE,
1545}
1546
1550STDCALL
1551WDFEXPORT(WdfIoTargetSendInternalIoctlOthersSynchronously)(
1552 __in
1554 __in
1555 WDFIOTARGET IoTarget,
1556 __in_opt
1557 WDFREQUEST Request,
1558 __in
1559 ULONG Ioctl,
1560 __in_opt
1562 __in_opt
1564 __in_opt
1566 __in_opt
1568 __out_opt
1570 )
1571/*++
1572
1573Routine Description:
1574 Sends an internal IOCTL to the target synchronously. Since all 3 buffers can
1575 be used, we cannot overload WdfIoTargetSendInternalIoctlSynchronously since
1576 it can only take 2 buffers.
1577
1578Arguments:
1579 IoTarget - the target to which the request will be sent
1580
1581 Request - optional. If specified, the request's PIRP will be used to send
1582 the i/o to the target.
1583
1584 Ioctl - internal ioctl value to send
1585
1586 OtherArg1
1587 OtherArg2
1588 OtherArg4 - arguments to use in the stack locations's Others field. There
1589 is no OtherArg3 because 3 is where the IOCTL value is written.
1590 All buffers are optional.
1591
1592 RequestOptions - optional. If specified, the timeout indicated will be used
1593 if the request exceeds the timeout.
1594
1595 BytesReturned - the number of bytes returned by the target
1596
1597Return Value:
1598 NTSTATUS
1599
1600 --*/
1601{
1602 DDI_ENTRY();
1603
1608
1610 IoTarget,
1612 (PVOID*) &pTarget,
1614
1615 //
1616 // Minimize the points of failure by using the stack instead of allocating
1617 // out of pool. For UMDF, request initialization can fail so we still need
1618 // to call initialize for FxSyncRequest. Initialization always succeeds for
1619 // KM.
1620 //
1623
1624 status = request.Initialize();
1625 if (!NT_SUCCESS(status)) {
1627 "Failed to initialize FxSyncRequest for WDFIOTARGET "
1628 "0x%p", IoTarget);
1629 return status;
1630 }
1631
1633 "enter: WDFIOTARGET 0x%p, WDFREQUEST 0x%p, IOCTL 0x%x, Args %p %p %p",
1635
1636 //
1637 // Since we are waiting synchronously, we must be at pasisve
1638 //
1640 if (!NT_SUCCESS(status)) {
1641 return status;
1642 }
1643
1645 if (!NT_SUCCESS(status)) {
1647 "Invalid options, %!STATUS!", status);
1648 return status;
1649 }
1650
1652
1653 i = 0;
1654 if (OtherArg1 != NULL) {
1655 //
1656 // This transcribes the client union into a local structure which we
1657 // can change w/out altering the client's buffer.
1658 //
1659 status = args[i].ValidateMemoryDescriptor(pFxDriverGlobals, OtherArg1);
1660 if (!NT_SUCCESS(status)) {
1662 "invalid OtherArg1 buffer descriptor 0x%p, %!STATUS!",
1663 OtherArg1, status);
1664 return status;
1665 }
1666 }
1667
1668 i++;
1669 if (OtherArg2 != NULL) {
1670 //
1671 // This transcribes the client union into a local structure which we
1672 // can change w/out altering the client's buffer.
1673 //
1674 status = args[i].ValidateMemoryDescriptor(pFxDriverGlobals, OtherArg2);
1675 if (!NT_SUCCESS(status)) {
1677 "invalid OtherArg2 buffer descriptor 0x%p, %!STATUS!",
1678 OtherArg2, status);
1679 return status;
1680 }
1681 }
1682
1683 i++;
1684 if (OtherArg4 != NULL) {
1685 //
1686 // This transcribes the client union into a local structure which we
1687 // can change w/out altering the client's buffer.
1688 //
1689 status = args[i].ValidateMemoryDescriptor(pFxDriverGlobals, OtherArg4);
1690 if (!NT_SUCCESS(status)) {
1692 "invalid OtherArg4 buffer descriptor 0x%p, %!STATUS!",
1693 OtherArg4, status);
1694 return status;
1695 }
1696 }
1697
1698 //
1699 // Format the next stack location
1700 //
1702 Ioctl,
1703 args);
1704
1705 if (NT_SUCCESS(status)) {
1707 "WDFIOTARGET 0x%p, WDFREQUEST 0x%p being submitted",
1708 IoTarget,
1709 request.m_TrueRequest->GetTraceObjectHandle());
1710
1711 status = pTarget->SubmitSync(request.m_TrueRequest, RequestOptions);
1712
1713 if (BytesReturned != NULL) {
1714 *BytesReturned = request.m_TrueRequest->GetSubmitFxIrp()->GetInformation();
1715 }
1716 }
1717 else {
1719 "Could not format IOCTL 0x%x request, %!STATUS!",
1720 Ioctl, status);
1721 }
1722
1723 return status;
1724}
1725
1729STDCALL
1730WDFEXPORT(WdfIoTargetFormatRequestForInternalIoctlOthers)(
1731 __in
1733 __in
1734 WDFIOTARGET IoTarget,
1735 __in
1736 WDFREQUEST Request,
1737 __in
1738 ULONG Ioctl,
1739 __in_opt
1740 WDFMEMORY OtherArg1,
1741 __in_opt
1743 __in_opt
1744 WDFMEMORY OtherArg2,
1745 __in_opt
1747 __in_opt
1748 WDFMEMORY OtherArg4,
1749 __in_opt
1751 )
1752/*++
1753
1754Routine Description:
1755 Formats an internal IOCTL so that it can sent to the target. Since all 3
1756 buffers can be used, we cannot overload
1757 WdfIoTargetFormatRequestForInternalIoctlOthers since it can only take 2 buffers.
1758
1759 Upon success, this will take a reference on each of the WDFMEMORY handles that
1760 are passed in. This reference will be released when one of the following
1761 occurs:
1762 1) the request is completed through WdfRequestComplete
1763 2) the request is reused through WdfRequestReuse
1764 3) the request is reformatted through any target format DDI
1765
1766Arguments:
1767 IoTarget - the target to which the request will be sent
1768
1769 Request - the request to be formatted
1770
1771 Ioctl - internal ioctl value to send
1772
1773 OtherArg1
1774 OtherArg2
1775 OtherArg4 - arguments to use in the stack locations's Others field. There
1776 is no OtherArg3 because 3 is where the IOCTL value is written.
1777 All buffers are optional
1778
1779 OterhArgXOffsets - offset into each buffer which can override the starting
1780 offset of the buffer. Length does not matter since
1781 there is no way of generically describing the length of
1782 each of the 3 buffers in the PIRP
1783
1784Return Value:
1785 NTSTATUS
1786
1787 --*/
1788{
1789 DDI_ENTRY();
1790
1799 ULONG i;
1801
1803 IoTarget,
1805 (PVOID*) &pTarget,
1807
1809 "Enter: WDFIOTARGET 0x%p, WDFREQUEST 0x%p, IOCTL 0x%x, "
1810 "WDFMEMORY 1 0x%p, 2 0x%p, 3 0x%p",
1812 OtherArg4);
1813
1815 Request,
1817 (PVOID*) &pRequest);
1818
1819 i = 0;
1822
1825
1828
1830 if (memoryHandles[i] != NULL) {
1831
1835 (PVOID*) &pMemory[i]);
1836
1838 if (!NT_SUCCESS(status)) {
1840 "Invalid OtherArg%d memory offsets, %!STATUS!",
1841 i+1, status);
1842 return status;
1843 }
1844
1845 //
1846 // This transcribes the client union into a local structure which we
1847 // can change w/out altering the client's buffer.
1848 //
1849 args[i].SetMemory(pMemory[i], offsets[i]);
1850 }
1851 }
1852
1854 if (NT_SUCCESS(status)) {
1856 }
1858 "Exit: WDFIOTARGET %p, WDFREQUEST %p, IOCTL 0x%x, "
1859 "Arg Handles %p %p %p, status %!STATUS!",
1861 OtherArg4, status);
1862
1863 return status;
1864}
1865
1869STDCALL
1870WDFEXPORT(WdfIoTargetSelfAssignDefaultIoQueue)(
1871 _In_
1873 _In_
1874 WDFIOTARGET IoTarget,
1875 _In_
1876 WDFQUEUE Queue
1877 )
1878
1879/*++
1880
1881Routine Description:
1882
1883 Assigns a default queue for the Self IO Target.
1884
1885 By default the IO sent to the Self IO Target is dispatched ot the
1886 client's default / top level queue.
1887
1888 This routine assigns a default queue for the Intenral I/O target.
1889 If a client calls this API, all the I/O directed to the Self IO target
1890 is dispatched to the queue specified.
1891
1892Arguments:
1893
1894 IoTarget - Handle to the Self Io Target.
1895
1896 Queue - Handle to a queue that is being assigned as the default queue for
1897 the Self io target.
1898
1899Returns:
1900
1901 NTSTATUS
1902
1903--*/
1904
1905{
1906 DDI_ENTRY();
1907
1913
1914 pDevice = NULL;
1915 pFxIoQueue = NULL;
1916
1918 IoTarget,
1920 (PVOID *) &pTargetSelf,
1921 &pGlobals);
1922
1924
1925 //
1926 // Validate the Queue handle
1927 //
1929 Queue,
1931 (PVOID*)&pFxIoQueue);
1932
1935
1938 "Input WDFQUEUE 0x%p belongs to WDFDEVICE 0x%p, but "
1939 "Self Io Target 0x%p corresponds to the WDFDEVICE 0x%p, %!STATUS!",
1942
1943 return status;
1944 }
1945
1946 if (pDevice->IsLegacy()) {
1947 //
1948 // This is a controldevice. Make sure the create is called after the device
1949 // is initialized and ready to accept I/O.
1950 //
1952 if ((deviceObject.GetFlags() & DO_DEVICE_INITIALIZING) == 0x0) {
1953
1957 "Queue cannot be configured for automatic dispatching"
1958 " after WdfControlDeviceFinishInitializing"
1959 "is called on the WDFDEVICE %p is called %!STATUS!",
1960 pDevice->GetHandle(),
1961 status);
1962 return status;
1963 }
1964 }
1965 else {
1966 //
1967 // This is either FDO or PDO. Make sure it's not started yet.
1968 //
1969 if (pDevice->GetDevicePnpState() != WdfDevStatePnpInit) {
1973 "Queue cannot be configured for automatic dispatching"
1974 "after the WDFDEVICE %p is started, %!STATUS!",
1976 return status;
1977 }
1978 }
1979
1981
1983}
1984
1986HANDLE
1987STDCALL
1988WDFEXPORT(WdfIoTargetWdmGetTargetFileHandle)(
1989 __in
1991 __in
1992 WDFIOTARGET IoTarget
1993 )
1994/*++
1995
1996Routine Description:
1997 Returns the file handle that the target represents. For KMDF, the handle is a kernel
1998 handle, so it is not tied to any process context. For UMDF it is a Win32 handle opened
1999 in the host process context. Not all targets have a file handle associated with them,
2000 so NULL is a valid return value that does not indicate error.
2001
2002Arguments:
2003 IoTarget - target whose file handle is being returned
2004
2005Return Value:
2006 A valid kernel/win32 handle or NULL
2007
2008 --*/
2009{
2013
2015 IoTarget,
2017 (PVOID*) &pTarget,
2019
2021 "enter WDFIOTARGET 0x%p", IoTarget);
2022
2023 handle = pTarget->GetTargetHandle();
2024
2026 "exit WDFIOTARGET 0x%p, WDM file handle 0x%p",
2027 IoTarget, handle);
2028
2029 return handle;
2030}
2031
2032
2033} // extern "C"
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
__inline CfxDevice * GetDevice(VOID)
Definition: fxioqueue.hpp:773
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in FxDeviceBase *Device, __out FxIoTargetRemote **Target)
VOID SetDispatchQueue(_In_ FxIoQueue *DispatchQueue)
virtual VOID Stop(__in WDF_IO_TARGET_SENT_IO_ACTION Action)
Definition: fxiotarget.cpp:748
WDFIOTARGET GetHandle(VOID)
Definition: fxiotarget.hpp:307
_Must_inspect_result_ NTSTATUS SubmitSync(__in FxRequestBase *Request, __in_opt PWDF_REQUEST_SEND_OPTIONS Options=NULL, __out_opt PULONG Action=NULL)
__inline WDF_IO_TARGET_STATE GetState(VOID)
Definition: fxiotarget.hpp:263
__inline WDFDEVICE GetDeviceHandle(VOID)
Definition: fxiotarget.hpp:299
_Must_inspect_result_ NTSTATUS FormatInternalIoctlOthersRequest(__in FxRequestBase *Request, __in ULONG Ioctl, __in FxRequestBuffer *Buffers)
_Must_inspect_result_ NTSTATUS FormatIoctlRequest(__in FxRequestBase *Request, __in ULONG Ioctl, __in BOOLEAN Internal, __in FxRequestBuffer *InputBuffer, __in FxRequestBuffer *OutputBuffer, __in_opt FxFileObject *FileObject=NULL)
virtual VOID Purge(__in WDF_IO_TARGET_PURGE_IO_ACTION Action)
Definition: fxiotarget.cpp:918
virtual _Must_inspect_result_ NTSTATUS Start(VOID)
Definition: fxiotarget.cpp:282
_Must_inspect_result_ NTSTATUS FormatIoRequest(__inout FxRequestBase *Request, __in UCHAR MajorCode, __in FxRequestBuffer *IoBuffer, __in_opt PLONGLONG StartingOffset, __in_opt FxFileObject *FileObject=NULL)
CfxDevice * GetDevice(VOID)
Definition: fxobject.hpp:781
__inline FxRequestContext * GetContext(VOID)
_Must_inspect_result_ NTSTATUS ValidateMemoryOffsets(__in_opt PWDFMEMORY_OFFSET Offsets)
Definition: ifxmemory.hpp:105
ULONG GetFlags(VOID)
#define __out_opt
Definition: dbghelp.h:65
#define __inout_opt
Definition: dbghelp.h:53
#define __in
Definition: dbghelp.h:35
#define __inout
Definition: dbghelp.h:50
#define __in_opt
Definition: dbghelp.h:38
#define __out
Definition: dbghelp.h:62
#define TRACINGIOTARGET
Definition: dbgtrace.h:72
#define TRACINGIO
Definition: dbgtrace.h:66
#define TRACINGPNP
Definition: dbgtrace.h:67
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define __drv_when(cond, annotes)
Definition: driverspecs.h:335
#define _IRQL_requires_max_(irql)
Definition: driverspecs.h:230
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:291
#define __drv_strictTypeMatch(mode)
Definition: driverspecs.h:330
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
MxDeviceObject deviceObject
DriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define DDI_ENTRY_IMPERSONATION_OK()
Definition: fxglobalskm.h:55
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
WDFMEMORY memoryHandles[FX_REQUEST_NUM_OTHER_PARAMS]
_Must_inspect_result_ __in WDFIOTARGET __in_opt WDFREQUEST __in ULONG __in_opt PWDF_MEMORY_DESCRIPTOR __in_opt PWDF_MEMORY_DESCRIPTOR OtherArg2
_Must_inspect_result_ __in WDFDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES IoTargetAttributes
_Must_inspect_result_ _In_ WDFIOTARGET _In_ WDFQUEUE Queue
PWDFMEMORY_OFFSET offsets[FX_REQUEST_NUM_OTHER_PARAMS]
_Must_inspect_result_ __in WDFIOTARGET __in_opt WDFREQUEST __in ULONG __in_opt PWDF_MEMORY_DESCRIPTOR __in_opt PWDF_MEMORY_DESCRIPTOR __in_opt PWDF_REQUEST_SEND_OPTIONS __out_opt PULONG_PTR BytesReturned
_Must_inspect_result_ __in WDFIOTARGET __in_opt WDFREQUEST __in_opt PWDF_MEMORY_DESCRIPTOR __in_opt PLONGLONG DeviceOffset
PFX_DRIVER_GLOBALS pGlobals
PVOID handle
_Must_inspect_result_ NTSTATUS FxIoTargetSendIoctl(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in WDFIOTARGET IoTarget, __in_opt WDFREQUEST Request, __in ULONG Ioctl, __in BOOLEAN Internal, __in_opt PWDF_MEMORY_DESCRIPTOR InputBuffer, __in_opt PWDF_MEMORY_DESCRIPTOR OutputBuffer, __in_opt PWDF_REQUEST_SEND_OPTIONS RequestOptions, __out_opt PULONG_PTR BytesReturned)
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE_BASE,(PWDFOBJECT) &pDevice, &pFxDriverGlobals)
FxIoTarget * pTarget
static _Must_inspect_result_ NTSTATUS FxIoTargetFormatIoctl(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in WDFIOTARGET IoTarget, __in WDFREQUEST Request, __in ULONG Ioctl, __in BOOLEAN Internal, __in_opt WDFMEMORY InputBuffer, __in_opt PWDFMEMORY_OFFSET InputBufferOffsets, __in_opt WDFMEMORY OutputBuffer, __in_opt PWDFMEMORY_OFFSET OutputBufferOffsets)
_Must_inspect_result_ __in WDFIOTARGET __in_opt WDFREQUEST __in_opt PWDF_MEMORY_DESCRIPTOR __in_opt PLONGLONG __in_opt PWDF_REQUEST_SEND_OPTIONS __out_opt PULONG_PTR BytesWritten
NTSTATUS status
FxInternalIoctlOthersContext context
_Must_inspect_result_ __in WDFIOTARGET __in PWDF_IO_TARGET_OPEN_PARAMS OpenParams
_Must_inspect_result_ __in WDFIOTARGET __in WDFREQUEST __in_opt WDFMEMORY __in_opt PWDFMEMORY_OFFSET InputBufferOffsets
_Must_inspect_result_ __in WDFIOTARGET __in_opt WDFREQUEST __in_opt PWDF_MEMORY_DESCRIPTOR InputBuffer
_Must_inspect_result_ __in WDFIOTARGET __in_opt WDFREQUEST __in_opt PWDF_MEMORY_DESCRIPTOR OutputBuffer
_Must_inspect_result_ NTSTATUS FxIoTargetValidateOpenParams(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_IO_TARGET_OPEN_PARAMS OpenParams)
_Must_inspect_result_ __in WDFIOTARGET __in_opt WDFREQUEST Request
return STATUS_SUCCESS
FxIoQueue * pFxIoQueue
ULONG i
FxInternalIoctlParams InternalIoctlParams
_Must_inspect_result_ __in WDFDEVICE Device
FxDeviceBase * pDevice
WDFDEVICE device
ULONG expectedConfigSize
_Must_inspect_result_ __in WDFIOTARGET __in WDFREQUEST __in ULONG __in_opt WDFMEMORY __in_opt PWDFMEMORY_OFFSET __in_opt WDFMEMORY __in_opt PWDFMEMORY_OFFSET __in_opt WDFMEMORY __in_opt PWDFMEMORY_OFFSET OtherArg4Offsets
_Must_inspect_result_ __in WDFIOTARGET __in_opt WDFREQUEST __in ULONG __in_opt PWDF_MEMORY_DESCRIPTOR OtherArg1
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIOTARGET, "WDFDEVICE 0x%p", Device)
FxRequest * pRequest
_Must_inspect_result_ __in WDFIOTARGET __in_opt WDFREQUEST __in ULONG Ioctl
static _Must_inspect_result_ NTSTATUS FxIoTargetFormatIo(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in WDFIOTARGET IoTarget, __inout WDFREQUEST Request, __in UCHAR MajorCode, __inout_opt WDFMEMORY IoBuffer, __in_opt PWDFMEMORY_OFFSET IoBufferOffsets, __in_opt PLONGLONG DeviceOffset)
_Must_inspect_result_ __in WDFIOTARGET __in_opt WDFREQUEST __in ULONG __in_opt PWDF_MEMORY_DESCRIPTOR __in_opt PWDF_MEMORY_DESCRIPTOR __in_opt PWDF_MEMORY_DESCRIPTOR OtherArg4
IFxMemory * pMemory[FX_REQUEST_NUM_OTHER_PARAMS]
FxIoTargetSelf * pTargetSelf
_Must_inspect_result_ __in WDFIOTARGET __in_opt WDFREQUEST __in_opt PWDF_MEMORY_DESCRIPTOR __in_opt PLONGLONG __in_opt PWDF_REQUEST_SEND_OPTIONS RequestOptions
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), IoTarget, FX_TYPE_IO_TARGET,(PVOID *) &pTarget)
WDF_IO_TARGET_OPEN_PARAMS openParams
static _Must_inspect_result_ NTSTATUS FxIoTargetSendIo(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in WDFIOTARGET IoTarget, __inout_opt WDFREQUEST Request, __in UCHAR MajorCode, __inout_opt PWDF_MEMORY_DESCRIPTOR IoBuffer, __in_opt PLONGLONG DeviceOffset, __in_opt PWDF_REQUEST_SEND_OPTIONS RequestOptions, __out_opt PULONG_PTR BytesReturned)
_Must_inspect_result_ __in WDFIOTARGET __in_opt WDFREQUEST __in_opt PWDF_MEMORY_DESCRIPTOR __in_opt PLONGLONG __in_opt PWDF_REQUEST_SEND_OPTIONS __out_opt PULONG_PTR BytesRead
_Must_inspect_result_ __in WDFIOTARGET __in WDFREQUEST __in_opt WDFMEMORY __in_opt PWDFMEMORY_OFFSET OutputBufferOffsets
_Must_inspect_result_ __in WDFIOTARGET __in WDFREQUEST __in ULONG __in_opt WDFMEMORY __in_opt PWDFMEMORY_OFFSET OtherArg1Offsets
_Must_inspect_result_ __in WDFIOTARGET __in WDFREQUEST __in ULONG __in_opt WDFMEMORY __in_opt PWDFMEMORY_OFFSET __in_opt WDFMEMORY __in_opt PWDFMEMORY_OFFSET OtherArg2Offsets
_Must_inspect_result_ __in WDFIOTARGET IoTarget
PFX_DRIVER_GLOBALS pFxDriverGlobals
@ FxIoTargetRemoteCloseReasonPlainClose
@ FxIoTargetRemoteCloseReasonQueryRemove
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
#define FX_REQUEST_NUM_OTHER_PARAMS
NTSTATUS __inline FxValidateRequestOptions(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_ PWDF_REQUEST_SEND_OPTIONS Options, _In_opt_ FxRequestBase *Request=NULL)
@ FX_TYPE_IO_TARGET_SELF
Definition: fxtypes.h:105
@ FX_TYPE_QUEUE
Definition: fxtypes.h:48
@ FX_TYPE_IO_TARGET
Definition: fxtypes.h:100
@ IFX_TYPE_MEMORY
Definition: fxtypes.h:55
@ FX_TYPE_REQUEST
Definition: fxtypes.h:53
@ FX_TYPE_IO_TARGET_REMOTE
Definition: fxtypes.h:101
@ FX_TYPE_DEVICE_BASE
Definition: fxtypes.h:83
_Must_inspect_result_ NTSTATUS __inline FxValidateUnicodeString(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PCUNICODE_STRING String)
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
@ Internal
Definition: hwresource.cpp:137
#define _Must_inspect_result_
Definition: no_sal2.h:62
#define _In_
Definition: no_sal2.h:158
__GNU_EXTENSION typedef __int64 * PLONGLONG
Definition: ntbasedef.h:390
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
VOID SetMemory(__in IFxMemory *Memory, __in PWDFMEMORY_OFFSET Offsets)
NTSTATUS ValidateMemoryDescriptor(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_MEMORY_DESCRIPTOR Descriptor, __in ULONG Flags=0x0)
WDF_REQUEST_COMPLETION_PARAMS m_CompletionParams
VOID FormatReadParams(__in_opt IFxMemory *ReadMemory, __in_opt PWDFMEMORY_OFFSET ReadOffsets)
VOID FormatOtherParams(__in FxInternalIoctlParams *InternalIoctlParams)
VOID FormatWriteParams(__in_opt IFxMemory *WriteMemory, __in_opt PWDFMEMORY_OFFSET WriteOffsets)
_Must_inspect_result_ BOOLEAN IsVersionGreaterThanOrEqualTo(__in ULONG Major, __in ULONG Minor)
Definition: globalskm.cpp:92
size_t BufferOffset
Definition: wdfmemory.h:65
struct _WDF_REQUEST_COMPLETION_PARAMS::@3889::@3892 Ioctl
union _WDF_REQUEST_COMPLETION_PARAMS::@3889 Parameters
Definition: match.c:390
Definition: http.c:7252
Definition: devices.h:37
Definition: tftpd.h:86
Definition: ps.c:97
uint32_t * PULONG_PTR
Definition: typedefs.h:65
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
struct _WDF_IO_TARGET_OPEN_PARAMS_V1_11 WDF_IO_TARGET_OPEN_PARAMS_V1_11
#define STDCALL
Definition: wdf.h:45
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
@ WdfDevStatePnpInit
Definition: wdfdevice.h:69
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2225
@ WdfRequestTypeDeviceControlInternal
Definition: wdfdevice.h:518
@ WdfRequestTypeDeviceControl
Definition: wdfdevice.h:517
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
enum _WDF_IO_TARGET_PURGE_IO_ACTION WDF_IO_TARGET_PURGE_IO_ACTION
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_MEMORY_DESCRIPTOR OtherArg2
Definition: wdfiotarget.h:1251
@ WdfIoTargetOpenLocalTargetByFile
Definition: wdfiotarget.h:66
@ WdfIoTargetOpenReopen
Definition: wdfiotarget.h:65
@ WdfIoTargetOpenUseExistingDevice
Definition: wdfiotarget.h:63
@ WdfIoTargetOpenByName
Definition: wdfiotarget.h:64
_Must_inspect_result_ _In_ WDFIOTARGET _In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams
Definition: wdfiotarget.h:401
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesReturned
Definition: wdfiotarget.h:1052
struct _WDF_IO_TARGET_OPEN_PARAMS WDF_IO_TARGET_OPEN_PARAMS
@ WdfIoTargetCancelSentIo
Definition: wdfiotarget.h:71
@ WdfIoTargetWaitForSentIoToComplete
Definition: wdfiotarget.h:72
@ WdfIoTargetSentIoUndefined
Definition: wdfiotarget.h:70
@ WdfIoTargetLeaveSentIoPending
Definition: wdfiotarget.h:73
enum _WDF_IO_TARGET_SENT_IO_ACTION WDF_IO_TARGET_SENT_IO_ACTION
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES IoTargetAttributes
Definition: wdfiotarget.h:365
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIOTARGET * IoTarget
Definition: wdfiotarget.h:368
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510
@ WdfIoTargetPurgeIo
Definition: wdfiotarget.h:79
@ WdfIoTargetPurgeIoUndefined
Definition: wdfiotarget.h:77
@ WdfIoTargetPurgeIoAndWait
Definition: wdfiotarget.h:78
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960
WDF_EXTERN_C_START enum _WDF_IO_TARGET_STATE WDF_IO_TARGET_STATE
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG _In_opt_ PWDF_MEMORY_DESCRIPTOR OtherArg1
Definition: wdfiotarget.h:1249
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG DeviceOffset
Definition: wdfiotarget.h:865
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_MEMORY_DESCRIPTOR OtherArg4
Definition: wdfiotarget.h:1253
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS RequestOptions
Definition: wdfiotarget.h:867
unsigned char UCHAR
Definition: xmlstorage.h:181