ReactOS 0.4.15-dev-6068-g8061a6f
fxiotargetapikm.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxIoTargetAPIKm.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 "FxIoTargetAPIKm.tmh"
27}
28
29//
30// Extern the entire file
31//
32extern "C" {
33
37WDFEXPORT(WdfIoTargetWdmGetTargetDeviceObject)(
38 __in
40 __in
41 WDFIOTARGET IoTarget
42 )
43/*++
44
45Routine Description:
46 Returns the PDEVICE_OBJECT. This is the device which PIRPs are sent to.
47 This is not necessarily the PDEVICE_OBJECT that WDFDEVICE is attached to.
48
49Arguments:
50 IoTarget - target whose WDM device object is being returned
51
52Return Value:
53 valid PDEVICE_OBJECT or NULL on failure
54
55 --*/
56{
60
64 (PVOID*) &pTarget,
66
68 "enter WDFIOTARGET 0x%p", IoTarget);
69
71
73 "exit WDFIOTARGET 0x%p, WDM DevObj 0x%p", IoTarget, pDevice);
74
75 return pDevice;
76}
77
81WDFEXPORT(WdfIoTargetWdmGetTargetPhysicalDevice)(
82 __in
84 __in
85 WDFIOTARGET IoTarget
86 )
87/*++
88
89Routine Description:
90 Returns the PDO for the target itself. This is not necessarily the same
91 PDO as the WDFDEVICE that owns the target. Not all targets have a PDO since
92 you can open a legacy non pnp PDEVICE_OBJECT which does not have one.
93
94Arguments:
95 IoTarget - target whose PDO is being returned
96
97Return Value:
98 A valid PDEVICE_OBJECT or NULL upon success
99
100 --*/
101{
105
107 IoTarget,
109 (PVOID*) &pTarget,
111
113 "enter WDFIOTARGET 0x%p", IoTarget);
114
116
118 "exit WDFIOTARGET 0x%p, WDM PDO 0x%p", IoTarget, pPdo);
119
120 return pPdo;
121}
122
123
127WDFEXPORT(WdfIoTargetWdmGetTargetFileObject)(
128 __in
130 __in
131 WDFIOTARGET IoTarget
132 )
133/*++
134
135Routine Description:
136 Returns the PFILE_OBJECT associated with the target. Not all targets have
137 an underlying file object so NULL is a valid and successful return value.
138
139Arguments:
140 IoTarget - the target whose fileobject is being returned
141
142Return Value:
143 a valid PFILE_OBJECT or NULL upon success
144
145 --*/
146{
150
152 IoTarget,
154 (PVOID*) &pTarget,
156
158 "enter WDFIOTARGET 0x%p", IoTarget);
159
161
163 "exit WDFIOTARGET 0x%p, WDM FileObj 0x%p", IoTarget, pFile);
164
165 return pFile;
166}
167
172WDFEXPORT(WdfIoTargetQueryForInterface)(
173 __in
175 __in
176 WDFIOTARGET IoTarget,
177 __in
179 __out
181 __in
183 __in
187 )
188/*++
189
190Routine Description:
191 Sends a query interface pnp request to the top of the target's stack.
192
193Arguments:
194 IoTarget - the target which is being queried
195
196 InterfaceType - interface type specifier
197
198 Interface - Interface block which will be filled in by the component which
199 responds to the query interface
200
201 Size - size in bytes of Interface
202
203 Version - version of InterfaceType being requested
204
205 InterfaceSpecificData - Additional data associated with Interface
206
207Return Value:
208 NTSTATUS
209
210 --*/
211{
216
218 IoTarget,
220 (PVOID*) &pTarget,
222
225
228 return status;
229 }
230
233
236 Interface,
237 Size,
238 Version,
240
242
243 return status;
244}
245
250WDFEXPORT(WdfIoTargetQueryTargetProperty)(
251 __in
253 __in
254 WDFIOTARGET IoTarget,
255 __in
257 __in
264 )
265/*++
266
267Routine Description:
268 Retrieves the requested device property for the given target
269
270Arguments:
271 IoTarget - the target whose PDO whose will be queried
272
273 DeviceProperty - the property being queried
274
275 BufferLength - length of PropertyBuffer in bytes
276
277 PropertyBuffer - Buffer which will receive the property being queried
278
279 ResultLength - if STATUS_BUFFER_TOO_SMALL is returned, then this will contain
280 the required length
281
282Return Value:
283 NTSTATUS
284
285 --*/
286{
287 DDI_ENTRY();
288
293
295 IoTarget,
297 (PVOID*) &pTarget,
298 &pGlobals);
299
301 if (BufferLength > 0) {
303 }
304
306 if (!NT_SUCCESS(status)) {
307 return status;
308 }
309
311
312 if (pPdo == NULL) {
314
316 "WDFIOTARGET 0x%p has no PDO (not opened yet?), %!STATUS!",
318
319 return status;
320 }
321
327
329 "exit WDFIOTARGET 0x%p, Property %d, %!STATUS!",
331
332
333
334 return status;
335}
336
339WDFAPI
342WDFEXPORT(WdfIoTargetAllocAndQueryTargetProperty)(
343 __in
345 __in
346 WDFIOTARGET IoTarget,
347 __in
349 __in
354 __out
355 WDFMEMORY* PropertyMemory
356 )
357/*++
358
359Routine Description:
360 Allocates and retrieves the requested device property for the given target
361
362Arguments:
363 IoTarget - the target whose PDO whose will be queried
364
365 DeviceProperty - the property being queried
366
367 PoolType - what type of pool to allocate
368
369 PropertyMemoryAttributes - attributes to associate with PropertyMemory
370
371 PropertyMemory - handle which will receive the property buffer
372
373Return Value:
374 NTSTATUS
375
376 --*/
377{
378 DDI_ENTRY();
379
384
386 IoTarget,
388 (PVOID*) &pTarget,
390
392
394
396 if (!NT_SUCCESS(status)) {
397 return status;
398 }
399
401
403 if (!NT_SUCCESS(status)) {
404 return status;
405 }
406
408
409 if (pPdo == NULL) {
411
413 "WDFIOTARGET %p has no PDO (not opened yet?), %!STATUS!",
415
416 return status;
417 }
418
419 //
420 // Worker function which does the 2 passes. First pass to query the size,
421 // the second pass w/the correctly sized buffer.
422 //
424 NULL,
425 NULL,
426 pPdo,
428 PoolType,
431
433 "exit WDFIOTARGET 0x%p, Property %d, %!STATUS!",
435
436 return status;
437}
438
439}
LONG NTSTATUS
Definition: precomp.h:26
static _Must_inspect_result_ NTSTATUS _AllocAndQueryProperty(_In_ PFX_DRIVER_GLOBALS Globals, _In_opt_ PWDFDEVICE_INIT DeviceInit, _In_opt_ FxDevice *Device, _In_opt_ MdDeviceObject RemotePdo, _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty, _In_ POOL_TYPE PoolType, _In_opt_ PWDF_OBJECT_ATTRIBUTES PropertyMemoryAttributes, _Out_ WDFMEMORY *PropertyMemory)
Definition: fxdevice.cpp:1988
static __inline NTSTATUS _GetDeviceProperty(_In_ MdDeviceObject DeviceObject, _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty, _In_ ULONG BufferLength, _Out_opt_ PVOID PropertyBuffer, _Out_ PULONG ResultLength)
__inline MdDeviceObject GetTargetPDO(VOID)
Definition: fxiotarget.hpp:281
__inline MdDeviceObject GetTargetDevice(VOID)
Definition: fxiotarget.hpp:272
__inline MdFileObject GetTargetFileObject(VOID)
Definition: fxiotarget.hpp:290
#define __out_opt
Definition: dbghelp.h:65
#define __in
Definition: dbghelp.h:35
#define __in_opt
Definition: dbghelp.h:38
#define __out
Definition: dbghelp.h:62
#define TRACINGIOTARGET
Definition: dbgtrace.h:72
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define __drv_when(cond, annotes)
Definition: driverspecs.h:335
#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 DISPATCH_LEVEL
Definition: env_spec_w32.h:696
DriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
PFX_DRIVER_GLOBALS pGlobals
__in WDFIOTARGET IoTarget
MdFileObject pFile
__in WDFIOTARGET __in LPCGUID __out PINTERFACE __in USHORT __in USHORT __in_opt PVOID InterfaceSpecificData
PDEVICE_OBJECT pTopOfStack
FxIoTarget * pTarget
__in WDFIOTARGET __in LPCGUID __out PINTERFACE __in USHORT __in USHORT Version
__in WDFIOTARGET __in LPCGUID InterfaceType
_Must_inspect_result_ __in WDFIOTARGET __in DEVICE_REGISTRY_PROPERTY __in ULONG BufferLength
__in WDFIOTARGET __in LPCGUID __out PINTERFACE __in USHORT Size
NTSTATUS status
__in WDFIOTARGET __in LPCGUID __out PINTERFACE Interface
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), IoTarget, FX_TYPE_IO_TARGET,(PVOID *) &pTarget, &pFxDriverGlobals)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIOTARGET, "enter WDFIOTARGET 0x%p", IoTarget)
_Must_inspect_result_ __in WDFIOTARGET __in DEVICE_REGISTRY_PROPERTY DeviceProperty
FxVerifierCheckNxPoolType(pFxDriverGlobals, PoolType, pFxDriverGlobals->Tag)
PDEVICE_OBJECT pPdo
PDEVICE_OBJECT pDevice
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
@ FX_TYPE_IO_TARGET
Definition: fxtypes.h:100
_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
#define ASSERT(a)
Definition: mode.c:44
#define __out_bcount_part_opt(size, length)
Definition: ms_sal.h:2726
#define _Must_inspect_result_
Definition: ms_sal.h:558
PFILE_OBJECT MdFileObject
Definition: mxgeneralkm.h:32
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1406
unsigned short USHORT
Definition: pedump.c:61
#define __deref_out_range(x, y)
Definition: sal_old.h:220
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
static _Must_inspect_result_ NTSTATUS _QueryForInterface(__in PDEVICE_OBJECT TopOfStack, __in const GUID *InterfaceType, __out PINTERFACE Interface, __in USHORT Size, __in USHORT Version, __in_opt PVOID InterfaceSpecificData)
Definition: ps.c:97
uint32_t * PULONG
Definition: typedefs.h:59
INT POOL_TYPE
Definition: typedefs.h:78
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STDCALL
Definition: wdf.h:45
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES PropertyMemoryAttributes
Definition: wdfdevice.h:3817
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFMEMORY * PropertyMemory
Definition: wdfdevice.h:3820
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
Definition: wdfdevice.h:4437
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: wdfdevice.h:3769
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT _In_opt_ PVOID InterfaceSpecificData
Definition: wdffdo.h:472
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIOTARGET * IoTarget
Definition: wdfiotarget.h:368
#define WDFAPI
Definition: wdftypes.h:53
DEVICE_REGISTRY_PROPERTY
Definition: iotypes.h:1194
* PFILE_OBJECT
Definition: iotypes.h:1998
#define ObDereferenceObject
Definition: obfuncs.h:203