ReactOS 0.4.15-dev-8058-ga7cbb60
fxdeviceinit.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxDeviceInit.cpp
8
9Abstract:
10 Internals for WDFDEVICE_INIT
11
12Author:
13
14
15
16Environment:
17
18 Both kernel and user mode
19
20Revision History:
21
22--*/
23
24#include "coreprivshared.hpp"
25
26extern "C" {
27// #include "FxDeviceInit.tmh"
28}
29
32 ) :
34{
35 DriverGlobals = Driver->GetDriverGlobals();
36
39 Inrush = FALSE;
42
44 FileObject.AutoForwardCleanupClose = WdfUseDefault;
45
48
51
53
55
61
63
65
66 RtlZeroMemory(&Fdo.EventCallbacks, sizeof(Fdo.EventCallbacks));
67 RtlZeroMemory(&Fdo.ListConfig, sizeof(Fdo.ListConfig));
68 RtlZeroMemory(&Fdo.ListConfigAttributes, sizeof(Fdo.ListConfigAttributes));
69 Fdo.Filter = FALSE;
70
72 Pdo.Raw = FALSE;
77 Pdo.DefaultLocale = 0x0;
80
82
84
86
88
90
92
93#if (FX_CORE_MODE == FX_CORE_USER_MODE)
94
97
98 DevStack = NULL;
99
101
102 PdoKey = NULL;
103
105
106 DriverID = 0;
107#endif
108}
109
111{
113
116 }
117
120 }
121
124 }
125
126 if (DeviceName != NULL) {
127 DeviceName->DeleteObject();
128 }
129 if (Pdo.DeviceID != NULL) {
131 }
132 if (Pdo.InstanceID != NULL) {
134 }
135 if (Pdo.ContainerID != NULL) {
137 }
138
140
141 if (Security.Sddl != NULL) {
143 }
144 if (PreprocessInfo != NULL) {
145 delete PreprocessInfo;
146 }
147
150 PWDFCXDEVICE_INIT cxInit;
151 cxInit = CONTAINING_RECORD(next, WDFCXDEVICE_INIT, ListEntry);
153 delete cxInit;
154 }
155
156#if (FX_CORE_MODE == FX_CORE_USER_MODE)
157 delete [] KernelDeviceName;
158 delete [] ConfigRegistryPath;
159 delete [] DevInstanceID;
160
161 if (PdoKey != NULL) {
163 PdoKey = NULL;
164 }
165#endif
166
167}
168
172 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
174 )
175{
176 if (DeviceName == NULL) {
177 DeviceName = new(FxDriverGlobals, WDF_NO_OBJECT_ATTRIBUTES)
178 FxString(FxDriverGlobals);
179
180 if (DeviceName == NULL) {
182
184
186 "DeviceName is NULL, %!STATUS!", status);
187
188 return status;
189 }
190
191 //
192 // Clear out the autogenerate flag since we have a specific name
193 //
194 Characteristics &= ~FILE_AUTOGENERATED_DEVICE_NAME;
195 }
196
197 return DeviceName->Assign(Name);
198}
199
205 )
206{
210
211 pFxDriverGlobals = Driver->GetDriverGlobals();
212
214
215 if (pInit == NULL) {
217 "WDFDRIVER 0x%p couldn't allocate WDFDEVICE_INIT",
218 Driver);
219 return NULL;
220 }
221
223
224 //
225 // Since we require and SDLL string, initialize to autogenerated device
226 // name so the driver doesn't have to worry about creating a name if they
227 // don't want it (useful if creating a DO for WMI tracing for instance).
228 //
230
233
234 if (pInit->Security.Sddl != NULL) {
236 }
237 else {
241 "WDFDRIVER 0x%p couldn't create Security String object %!STATUS!",
242 Driver, status);
243 }
244
245 if (!NT_SUCCESS(status)) {
246 delete pInit;
247 pInit = NULL;
248 }
249
250 return pInit;
251}
252
255 VOID
256 )
257{
258 //
259 // Driver explicitly set a class or SDDL, we have to create a secure
260 // device. This will be true for all control devices (SDDL required)
261 // and raw PDOs (class required), could be true for FDOs or filters as
262 // well.
263 //
265 return TRUE;
266 }
267
268 //
269 // See if there is a name for the device
270 //
271 if (HasName()) {
272 if (IsPdoInit()) {
273
274
275
276
277
278
279
280
281
282
283
284
285
286 ASSERT(Pdo.Raw == FALSE);
287
292 "WDFDRIVER 0x%p asked for a named device object, but the PDO "
293 "will be created without a name because an SDDL string has not "
294 "been specified for the PDO.",
295 Driver
296 );
297 return FALSE;
298 }
299 else {
300 //
301 // We are creating a named FDO or filter
302 //
303 ASSERT(IsFdoInit());
304 return TRUE;
305 }
306 }
307
308 //
309 // No name involved (FDO or filter)
310 //
311 ASSERT(IsFdoInit());
312
313 return FALSE;
314}
315
316VOID
319 )
320{
322}
323
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define RegCloseKey(hKey)
Definition: registry.h:49
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
virtual VOID DeleteObject(VOID)
_Must_inspect_result_ NTSTATUS Assign(__in PCWSTR SourceString)
Definition: fxstring.cpp:57
#define __in
Definition: dbghelp.h:35
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#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 InsertHeadList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
PFX_DRIVER_GLOBALS pFxDriverGlobals
@ FxDeviceInitTypeControlDevice
@ FxDeviceInitTypeFdo
PWDFDEVICE_INIT pInit
_Must_inspect_result_ _In_ PWDFCXDEVICE_INIT CxDeviceInit
Definition: fxdynamics.h:1012
DeviceType
Definition: mmdrv.h:42
#define ASSERT(a)
Definition: mode.c:44
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:138
#define FILE_DEVICE_UNKNOWN
Definition: winioctl.h:140
static unsigned __int64 next
Definition: rand_nt.c:6
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
static void _CleanupList(__inout PSINGLE_LIST_ENTRY Head)
FxString * InstanceID
FxString * ContainerID
BOOLEAN ForwardRequestToParent
SINGLE_LIST_ENTRY DeviceText
FxDeviceDescriptionEntry * DescriptionEntry
WDF_PDO_EVENT_CALLBACKS EventCallbacks
FxString * DeviceID
WDF_POWER_POLICY_EVENT_CALLBACKS PolicyEventCallbacks
WDF_PNPPOWER_EVENT_CALLBACKS PnpPowerEventCallbacks
WDF_TRI_STATE PowerPolicyOwner
FxPowerPolicyStateCallback * PowerPolicyStateCallbacks
FxPowerStateCallback * PowerStateCallbacks
FxPnpStateCallback * PnpStateCallbacks
BOOLEAN DeviceClassSet
FxString * Sddl
LIST_ENTRY ListEntry
PWSTR ConfigRegistryPath
BOOLEAN PowerPageable
SecurityInit Security
FxDeviceInitType InitType
LIST_ENTRY CxDeviceInitListHead
PFX_DRIVER_GLOBALS DriverGlobals
BOOLEAN ShouldCreateSecure(VOID)
PFN_WDF_IO_IN_CALLER_CONTEXT IoInCallerContextCallback
WDF_DEVICE_IO_TYPE DeviceControlIoType
IWudfDeviceStack * DevStack
VOID AddCxDeviceInit(__in PWDFCXDEVICE_INIT CxDeviceInit)
WDF_DEVICE_IO_TYPE ReadWriteIoType
_Must_inspect_result_ NTSTATUS AssignName(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in const UNICODE_STRING *Name)
PnpPowerInit PnpPower
BOOLEAN CreatedOnStack
FxIrpPreprocessInfo * PreprocessInfo
static _Must_inspect_result_ PWDFDEVICE_INIT _AllocateControlDeviceInit(__in FxDriver *Driver, __in const UNICODE_STRING *SDDLString)
WDFDEVICE_INIT(__in FxDriver *Driver)
ULONG RemoveLockOptionFlags
ULONG DirectTransferThreshold
FxDevice * CreatedDevice
BOOLEAN IsPdoInit(VOID)
BOOLEAN RequiresSelfIoTarget
BOOLEAN HasName(VOID)
BOOLEAN IsFdoInit(VOID)
Definition: typedefs.h:120
Definition: ps.c:97
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDRIVER Driver
Definition: wdfcontrol.h:83
_Must_inspect_result_ _In_ WDFDRIVER _In_ CONST UNICODE_STRING * SDDLString
Definition: wdfcontrol.h:86
_In_ PWDFDEVICE_INIT _In_ PWDF_OBJECT_ATTRIBUTES RequestAttributes
Definition: wdfdevice.h:3431
@ WdfReleaseHardwareOrderOnFailureEarly
Definition: wdfdevice.h:475
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
@ WdfDeviceIoBuffered
Definition: wdfdevice.h:452
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_In_ PWDFDEVICE_INIT _In_ WDF_RELEASE_HARDWARE_ORDER_ON_FAILURE ReleaseHardwareOrderOnFailure
Definition: wdfdevice.h:4365
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
@ WdfUseDefault
Definition: wdftypes.h:89
#define WDF_NO_OBJECT_ATTRIBUTES
Definition: wdftypes.h:105