ReactOS 0.4.15-dev-7968-g24a56f8
fxqueryinterfaceapi.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxQueryInterfaceAPI.cpp
8
9Abstract:
10
11 This module implements the device interface object.
12
13Author:
14
15
16
17
18Environment:
19
20 Kernel mode only
21
22Revision History:
23
24--*/
25#include "fxsupportpch.hpp"
26
27extern "C" {
28// #include "FxQueryInterfaceAPI.tmh"
29}
30
31//
32// Extern "C" the entire file
33//
34extern "C" {
39WDFEXPORT(WdfDeviceAddQueryInterface)(
40 __in
42 __in
43 WDFDEVICE Device,
44 __in
46 )
47{
53
55 Device,
57 (PVOID*) &pDevice,
59
61
65
68 return status;
69 }
70
71 pInterface = InterfaceConfig->Interface;
72
75
78 "WDFDEVICE %p, WDF_QUERY_INTERFACE_CONFIG Size %d, expected %d, "
79 "%!STATUS!", Device, InterfaceConfig->Size,
81
82 goto Done;
83 }
84
85 //
86 // A pass through interface is only associated with PDOs
87 //
88 if (InterfaceConfig->SendQueryToParentStack && pDevice->IsPdo() == FALSE) {
90
93 "SendQueryToParentStack TRUE, but WDFDEVICE %p not a PDO, %!STATUS!",
94 Device, status);
95
96 goto Done;
97 }
98
99 //
100 // The only time we can have a NULL Interface is if the interface is
101 // passthrough or it is an import interface (since on import interfaces
102 // the callback must do the copying).
103 //
104 if (pInterface == NULL) {
105 if (InterfaceConfig->SendQueryToParentStack || InterfaceConfig->ImportInterface) {
106 //
107 // A NULL interface is valid for this config
108 //
109 DO_NOTHING();
110 }
111 else {
113
116 "WDFDEVICE %p, SendQueryToParentStack is FALSE and "
117 "InterfaceConfig->ImportInterface is FALSE, %!STATUS!",
118 Device, status);
119
120 goto Done;
121 }
122 }
123
124 //
125 // If it is an import interface, we need a callback so that the driver can
126 // modify the interface being returned.
127 //
128 if (InterfaceConfig->ImportInterface &&
129 InterfaceConfig->EvtDeviceProcessQueryInterfaceRequest == NULL) {
131
134 "WDFDEVICE %p, ImportInterface is TRUE and "
135 "EvtDeviceProcessQueryInterfaceRequest is NULL, %!STATUS!",
136 Device, status);
137
138 goto Done;
139 }
140
141 if (pInterface != NULL) {
142 //
143 // Make sure we are exposing the minimum size
144 //
145 if (pInterface->Size < sizeof(INTERFACE)) {
147
150 "WDFDEVICE %p, Interface size %d < sizeof(INTERFACE) (%d), "
151 "%!STATUS!", Device, pInterface->Size, sizeof(INTERFACE), status);
152
153 goto Done;
154 }
155 }
156
157 //
158 // Since the QI irp is only allowed to be sent at passive level and
159 // the list of FxQueryInterface's is locked by a lock which does not
160 // raise IRQL, we can allocate the structure out paged pool.
161 //
164
167
170 "WDFDEVICE %p, object creation failed, %!STATUS!", Device, status);
171
172 goto Done;
173 }
174
175 if (pInterface != NULL) {
176 //
177 // Try to allocate memory for the interface.
178 //
180 FxPoolAllocate(pFxDriverGlobals, PagedPool, pInterface->Size);
181
184
187 "WDFDEVICE %p, interface allocation failed, %!STATUS!",
188 Device, status);
189
190 goto Done;
191 }
192
196
200 }
204 }
205 }
206
208
210
211Done:
212 //
213 // Delete the query interface structure if there is an error.
214 //
216 delete pQueryInterface;
218 }
219
220 return status;
221}
222
223} // extern "C"
LONG NTSTATUS
Definition: precomp.h:26
static VOID STDCALL _InterfaceDereferenceNoOp(__in_opt PVOID Context)
Definition: fxdevice.hpp:1778
FxPkgPnp * m_PkgPnp
Definition: fxdevice.hpp:670
__inline BOOLEAN IsPdo(VOID)
Definition: fxdevice.hpp:1245
static VOID STDCALL _InterfaceReferenceNoOp(__in_opt PVOID Context)
Definition: fxdevice.hpp:1767
VOID AddQueryInterface(__in FxQueryInterface *QI, __in BOOLEAN Lock)
Definition: fxpkgpnp.cpp:5017
#define __in
Definition: dbghelp.h:35
#define TRACINGERROR
Definition: dbgtrace.h:63
#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:32
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:291
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define PagedPool
Definition: env_spec_w32.h:308
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
PFX_DRIVER_GLOBALS pFxDriverGlobals
DriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
FxQueryInterface * pQueryInterface
_Must_inspect_result_ __in WDFDEVICE __in PWDF_QUERY_INTERFACE_CONFIG InterfaceConfig
FxDevice * pDevice
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE,(PVOID *) &pDevice, &pFxDriverGlobals)
_Must_inspect_result_ __in WDFDEVICE Device
NTSTATUS status
PINTERFACE pInterface
@ FX_TYPE_DEVICE
Definition: fxtypes.h:47
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define DO_NOTHING()
Definition: mxgeneral.h:32
struct _INTERFACE * PINTERFACE
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
USHORT Size
Definition: miniport.h:121
PINTERFACE_REFERENCE InterfaceReference
Definition: miniport.h:124
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: miniport.h:125
Definition: ps.c:97
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STDCALL
Definition: wdf.h:45
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_QUERY_INTERFACE_CONFIG InterfaceConfig