ReactOS 0.4.15-dev-7958-gcd0bb1a
fxdeviceinterfacekm.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxDeviceInterfaceKM.cpp
8
9Abstract:
10
11 This module implements the device interface object.
12
13Author:
14
15
16
17Environment:
18
19 Kernel mode only
20
21Revision History:
22
23--*/
24
25#include "fxsupportpch.hpp"
26
27extern "C" {
28// #include "FxDeviceInterfaceKM.tmh"
29}
30
32 )
33/*++
34
35Routine Description:
36 Constructor for the object. Initializes all fields
37
38Arguments:
39 None
40
41Return Value:
42 None
43
44 --*/
45{
47
50
52
53 m_State = FALSE;
54}
55
57/*++
58
59Routine Description:
60 Destructor for FxDeviceInterface. Cleans up any allocations previously
61 allocated.
62
63Arguments:
64 None
65
66Return Value:
67 None
68
69 --*/
70{
71 // the device interface should be off now
73
74 // should no longer be in any list
76
80 }
81
84 }
85}
86
90 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
91 __in CONST GUID* InterfaceGUID,
93 )
94/*++
95
96Routine Description:
97 Initializes the object with the interface GUID and optional reference string
98
99Arguments:
100 InterfaceGUID - GUID describing the interface
101
102 ReferenceString - string used to differentiate between 2 interfaces on the
103 same PDO
104
105Return Value:
106 STATUS_SUCCESS or STATUS_INSUFFICIENT_RESOURCES
107
108 --*/
109{
110 RtlCopyMemory(&m_InterfaceClassGUID, InterfaceGUID, sizeof(GUID));
111
112 if (ReferenceString != NULL) {
113 return FxDuplicateUnicodeString(FxDriverGlobals,
116 }
117 else {
118 return STATUS_SUCCESS;
119 }
120}
121
122
123VOID
126 )
127/*++
128
129Routine Description:
130 Sets the state of the device interface
131
132Arguments:
133 State - the state to set
134
135
136Return Value:
137 None.
138
139 --*/
140{
141 m_State = State;
142
143 //
144 // Only set the state if the interface has been registered
145 //
148 }
149}
150
155 )
156/*++
157
158Routine Description:
159 Registers the device interface for a given PDO
160
161Arguments:
162 Pdo - PDO for the device stack
163
164
165Return Value:
166 returned by IoRegisterDeviceInterface
167
168 --*/
169{
171
172 if (m_ReferenceString.Length > 0) {
174 }
175 else {
176 pString = NULL;
177 }
178
181}
182
187 )
188{
190 MdDeviceObject pdo;
191
192 pdo = Device->GetSafePhysicalDevice();
193
194 if (pdo != NULL) {
195 status = Register(pdo);
196 }
197 else {
198 //
199 // Leave the device interface unregistered. When we are in hardware
200 // available, we will register there once we know for sure we have a
201 // real live PDO that the system has acknowledged.
202 //
203 DO_NOTHING();
204
206 }
207
208 return status;
209}
210
213 _In_ FxString* LinkString
214 )
215{
217
219 //
220 // The device interface has not yet been registered b/c it
221 // belongs to a PDO and the PDO has not been recognized by
222 // pnp yet.
223 //
225 UNREFERENCED_PARAMETER(LinkString);
226 }
227 else {
228 //
229 // Attempt a copy
230 //
231 status = LinkString->Assign(&m_SymbolicLinkName);
232 }
233
234 return status;
235}
236
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ NTSTATUS Initialize(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in CONST GUID *InterfaceGUID, __in_opt PCUNICODE_STRING ReferenceString)
VOID SetState(__in BOOLEAN State)
UNICODE_STRING m_SymbolicLinkName
UNICODE_STRING m_ReferenceString
NTSTATUS GetSymbolicLinkName(_In_ FxString *LinkString)
_Must_inspect_result_ NTSTATUS Register(__in MdDeviceObject Pdo)
SINGLE_LIST_ENTRY m_Entry
static __inline NTSTATUS MxRegisterDeviceInterface(_In_ PDEVICE_OBJECT PhysicalDeviceObject, _In_ const GUID *InterfaceClassGuid, _In_opt_ PUNICODE_STRING ReferenceString, _Out_ PUNICODE_STRING SymbolicLinkName)
Definition: mxgeneralkm.h:619
static __inline NTSTATUS MxSetDeviceInterfaceState(_In_ PUNICODE_STRING SymbolicLinkName, _In_ BOOLEAN Enable)
Definition: mxgeneralkm.h:608
#define __in
Definition: dbghelp.h:35
#define __in_opt
Definition: dbghelp.h:38
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
FxString * pString
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361
#define ASSERT(a)
Definition: mode.c:44
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define _In_
Definition: ms_sal.h:308
#define DO_NOTHING()
Definition: mxgeneral.h:32
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define CONST
Definition: pedump.c:81
#define STATUS_SUCCESS
Definition: shellext.h:65
_Must_inspect_result_ NTSTATUS FxDuplicateUnicodeString(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in const UNICODE_STRING *Source, __out PUNICODE_STRING Destination)
Definition: stringutil.cpp:180
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
Definition: ps.c:97
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_ WDFDEVICE _In_ CONST GUID _In_opt_ PCUNICODE_STRING ReferenceString
Definition: wdfdevice.h:3630
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT Pdo
Definition: wdfminiport.h:72