ReactOS  0.4.15-dev-3175-g222acf5
fxqueryinterface.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxQueryInterface.cpp
8 
9 Abstract:
10 
11  This module implements the device interface object.
12 
13 Author:
14 
15 
16 
17 Environment:
18 
19  Kernel mode only
20 
21 Revision History:
22 
23 --*/
24 
25 #include "fxsupportpch.hpp"
26 
27 extern "C" {
28 // #include "FxQueryInterface.tmh"
29 }
30 
34  ) :
35  m_Device(Device),
36  m_Interface(NULL)
37 {
38  m_Entry.Next = NULL;
39 
41 
42  if (Config != NULL) {
43  m_SendQueryToParentStack = Config->SendQueryToParentStack;
44  m_ImportInterface = Config->ImportInterface;
45  m_ProcessRequest.m_Method = Config->EvtDeviceProcessQueryInterfaceRequest;
46  RtlCopyMemory(&m_InterfaceType, Config->InterfaceType, sizeof(GUID));
47  }
48 }
49 
51 {
52  //
53  // Should not in any list
54  //
55  ASSERT(m_Entry.Next == NULL);
56 
59  }
60 }
61 
62 VOID
64  __in PIRP Irp,
65  __in const GUID* InterfaceGuid,
67  __in USHORT InterfaceSize,
68  __in USHORT InterfaceVersion,
70  )
71 {
73 
74  Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
75 
77 
78  stack->MajorFunction = IRP_MJ_PNP;
79  stack->MinorFunction = IRP_MN_QUERY_INTERFACE;
80 
81  stack->Parameters.QueryInterface.Interface = Interface;
82  stack->Parameters.QueryInterface.InterfaceSpecificData = InterfaceSpecificData;
83  stack->Parameters.QueryInterface.Size = InterfaceSize;
84  stack->Parameters.QueryInterface.Version = InterfaceVersion;
85  stack->Parameters.QueryInterface.InterfaceType = InterfaceGuid;
86 }
87 
91  __in PDEVICE_OBJECT TopOfStack,
92  __in const GUID* InterfaceType,
97  )
98 /*++
99 
100 Routine Description:
101  Send an IRP_MJPNP/IRP_MN_QUERY_INTERFACE irp to a device object and its
102  attached stack.
103 
104 Arguments:
105  TargetDevice - device to send the query to.
106 
107  InterfaceType - The type of interface to query for
108 
109  Interface - The interface to fill out
110 
111  Size - Size of Interface in bytes
112 
113  Version - Version of the interface to be queried
114 
115  InterfaceSpecificData - Addtional interface data to be queried
116 
117 
118 Return Value:
119  NTSTATUS as indicated by the handler of the QI with in the device stack,
120  STATUS_NOT_SUPPORTED if the QI is not handled.
121 
122  --*/
123 {
124  PIRP pIrp;
126 
127  pIrp = IoAllocateIrp(TopOfStack->StackSize, FALSE);
128 
129  if (pIrp != NULL) {
130  FxAutoIrp irp(pIrp);
131 
132  _FormatIrp(
133  pIrp,
135  Interface,
136  Size,
137  Version,
139  );
140 
141  status = irp.SendIrpSynchronously(TopOfStack);
142  }
143  else {
145  }
146 
147  return status;
148 }
149 
150 VOID
154  )
155 /*++
156 
157 Routine Description:
158  Marks the structure as embedded and sets the configuration. This is used
159  for FxQueryInterface structs which are embedded in other structures because
160  at contruction time the Config is not available yet.
161 
162  By marking as embedded, FxPkgPnp will not free the structure when it deletes
163  the query interface chain.
164 
165 Arguments:
166  Config - how the interface behaves
167 
168  Interface - the interface that is exported
169 
170 Return Value:
171  None
172 
173  --*/
174 {
177 
178  m_SendQueryToParentStack = Config->SendQueryToParentStack;
179  m_ImportInterface = Config->ImportInterface;
180  m_ProcessRequest.m_Method = Config->EvtDeviceProcessQueryInterfaceRequest;
181  RtlCopyMemory(&m_InterfaceType, Config->InterfaceType, sizeof(GUID));
182 }
return STATUS_NOT_SUPPORTED
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT _In_opt_ PVOID InterfaceSpecificData
Definition: wdffdo.h:461
PFN_WDF_DEVICE_PROCESS_QUERY_INTERFACE_REQUEST m_Method
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define __in_opt
Definition: dbghelp.h:38
#define TRUE
Definition: types.h:120
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
static stack_node_t * stack
Definition: rpn_ieee.c:37
FxIrp * pIrp
SINGLE_LIST_ENTRY m_Entry
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
CHECK_RETURN_IF_USER_MODE NTSTATUS SendIrpSynchronously(__in MdDeviceObject DeviceObject)
Definition: fxirpum.cpp:151
#define __out
Definition: dbghelp.h:62
Definition: _stack.h:47
#define ASSERT(a)
Definition: mode.c:44
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:361
#define IRP_MN_QUERY_INTERFACE
VOID SetEmbedded(__in PWDF_QUERY_INTERFACE_CONFIG Config, __in PINTERFACE Interface)
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
static const GUID InterfaceGuid
Definition: wlanapi.c:25
FxDeviceProcessQueryInterfaceRequest m_ProcessRequest
#define _Must_inspect_result_
Definition: ms_sal.h:558
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2695
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:474
FxQueryInterface(__in CfxDevice *Device, __in PWDF_QUERY_INTERFACE_CONFIG Config)
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:361
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)
unsigned short USHORT
Definition: pedump.c:61
#define NULL
Definition: types.h:112
static VOID _FormatIrp(__in PIRP Irp, __in const GUID *InterfaceGuid, __out PINTERFACE Interface, __in USHORT InterfaceSize, __in USHORT InterfaceVersion, __in_opt PVOID InterfaceSpecificData=NULL)
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361
#define __in
Definition: dbghelp.h:35
static SERVICE_STATUS status
Definition: service.c:31
FxIrp * irp
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:461
BOOLEAN m_SendQueryToParentStack
Definition: ps.c:97