1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7     FxQueryInterface.hpp
8 
9 Abstract:
10 
11     This module implements the "query" interface object.
12 
13 Author:
14 
15 
16 
17 Environment:
18 
19     Both kernel and user mode
20 
21 Revision History:
22 
23 --*/
24 
25 #ifndef _FXQUERYINTERFACE_H_
26 #define _FXQUERYINTERFACE_H_
27 
28 class FxDeviceProcessQueryInterfaceRequest : public FxCallback {
29 
30 public:
31 
FxDeviceProcessQueryInterfaceRequest(VOID)32     FxDeviceProcessQueryInterfaceRequest(
33         VOID
34         ) :
35         m_Method(NULL)
36     {
37     }
38 
39     _Must_inspect_result_
40     NTSTATUS
Invoke(__in WDFDEVICE Device,__in LPGUID InterfacType,__out PINTERFACE ExposedInterface,__in_opt PVOID ExposedInterfaceSpecificData)41     Invoke(
42         __in WDFDEVICE Device,
43         __in LPGUID InterfacType,
44         __out PINTERFACE ExposedInterface,
45         __in_opt PVOID ExposedInterfaceSpecificData
46         )
47     {
48         if (m_Method != NULL) {
49             NTSTATUS status;
50 
51             CallbackStart();
52             status = m_Method(Device,
53                               InterfacType,
54                               ExposedInterface,
55                               ExposedInterfaceSpecificData);
56             CallbackEnd();
57 
58             return status;
59         }
60         else {
61             return STATUS_SUCCESS;
62         }
63     }
64 
65 public:
66     PFN_WDF_DEVICE_PROCESS_QUERY_INTERFACE_REQUEST m_Method;
67 };
68 
69 struct FxQueryInterface : public FxStump {
70 
71 public:
72     FxQueryInterface(
73         __in CfxDevice* Device,
74         __in PWDF_QUERY_INTERFACE_CONFIG Config
75         );
76 
77     ~FxQueryInterface(
78         VOID
79         );
80 
81     VOID
82     SetEmbedded(
83         __in PWDF_QUERY_INTERFACE_CONFIG Config,
84         __in PINTERFACE Interface
85         );
86 
87     static
88     FxQueryInterface*
_FromEntryFxQueryInterface89     _FromEntry(
90         __in PSINGLE_LIST_ENTRY Entry
91         )
92     {
93         return CONTAINING_RECORD(Entry, FxQueryInterface, m_Entry);
94     }
95 
96     static
97     VOID
98     _FormatIrp(
99         __in PIRP Irp,
100         __in const GUID* InterfaceGuid,
101         __out PINTERFACE Interface,
102         __in USHORT InterfaceSize,
103         __in USHORT InterfaceVersion,
104         __in_opt PVOID InterfaceSpecificData = NULL
105         );
106 
107     _Must_inspect_result_
108     static
109     NTSTATUS
110     _QueryForInterface(
111         __in PDEVICE_OBJECT TopOfStack,
112         __in const GUID* InterfaceType,
113         __out PINTERFACE Interface,
114         __in USHORT Size,
115         __in USHORT Version,
116         __in_opt PVOID InterfaceSpecificData
117         );
118 
119 public:
120     GUID m_InterfaceType;
121 
122     PINTERFACE m_Interface;
123 
124     CfxDevice *m_Device;
125 
126     FxDeviceProcessQueryInterfaceRequest m_ProcessRequest;
127 
128     SINGLE_LIST_ENTRY m_Entry;
129 
130     BOOLEAN m_ImportInterface;
131 
132     BOOLEAN m_SendQueryToParentStack;
133 
134     BOOLEAN m_EmbeddedInterface;
135 };
136 
137 #endif // _FXQUERYINTERFACE_H_
138