ReactOS 0.4.15-dev-8109-gd7be748
fxdriverkm.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxDriverKm.cpp
8
9Abstract:
10
11 This is the main driver framework.
12
13Author:
14
15
16
17Environment:
18
19 Kernel mode only
20
21Revision History:
22
23
24
25--*/
26
27#include "coreprivshared.hpp"
28#include "fxiotarget.hpp"
29
30// Tracing support
31extern "C" {
32// #include "FxDriverKm.tmh"
33}
34
41 )
42{
44
46
47 if (pDriver != NULL) {
49 }
50
52}
53
58 )
59{
60 WDFDEVICE_INIT init(this);
63
65 "Enter AddDevice PDO %p", PhysicalDeviceObject);
66
67 pDevice = NULL;
68 init.CreatedOnStack = TRUE;
69
70 init.InitType = FxDeviceInitTypeFdo;
71 init.Fdo.PhysicalDevice = PhysicalDeviceObject;
72
74
75 //
76 // Caller returned w/out creating a device, we are done. Returning
77 // STATUS_SUCCESS w/out creating a device and attaching to the stack is OK,
78 // especially for filter drivers which selectively attach to devices.
79 //
80 if (init.CreatedDevice == NULL) {
82 "Driver did not create a device in "
83 "EvtDriverAddDevice, status %!STATUS!", status);
84
85 //
86 // We do not let filters affect the building of the rest of the stack.
87 // If they return error, we convert it to STATUS_SUCCESS.
88 //
89 if (init.Fdo.Filter && !NT_SUCCESS(status)) {
92 "Filter returned %!STATUS! without creating a WDFDEVICE, "
93 "converting to STATUS_SUCCESS", status);
95 }
96
97 return status;
98 }
99
100 pDevice = init.CreatedDevice;
101
102 if (NT_SUCCESS(status)) {
103 //
104 // Make sure that DO_DEVICE_INITIALIZING is cleared.
105 // FxDevice::FdoInitialize does not do this b/c the driver writer may
106 // want the bit set until sometime after WdfDeviceCreate returns
107 //
109 }
110 else {
111 //
112 // Created a device, but returned error.
113 //
114 ASSERT(pDevice->IsPnp());
116
118 pDevice = NULL;
119 }
120
122 "Exit, status %!STATUS!", status);
123
124 return status;
125}
126
127
131 VOID
132 )
133{
135 FxDriver** ppDriver;
136
137 //
138 // Prefast is much happier if we take the size of the type rather then
139 // the size of the variable.
140 //
143 sizeof(FxDriver**),
144 (PVOID*)&ppDriver);
145 if (!NT_SUCCESS(status)) {
146 return status;
147 }
148
149 //
150 // If we succeeded in creating the driver object extension,
151 // then store our FxDriver pointer in the DriverObjectExtension.
152 //
153 *ppDriver = this;
154
155 return STATUS_SUCCESS;
156}
157
161 )
162{
163 FxDriver* objExt;
166 ASSERT(objExt != NULL);
167
168 return objExt;
169}
170
171
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
__inline BOOLEAN IsPnp(VOID)
Definition: fxdevice.hpp:1200
WDF_DEVICE_PNP_STATE m_CurrentPnpState
Definition: fxdevice.hpp:507
VOID FinishInitializing(VOID)
Definition: fxdevice.cpp:1109
_Must_inspect_result_ NTSTATUS DeleteDeviceFromFailedCreate(__in NTSTATUS FailedStatus, __in BOOLEAN UseStateMachine)
Definition: fxdevice.cpp:644
_Must_inspect_result_ NTSTATUS Invoke(__in WDFDRIVER Driver, __in PWDFDEVICE_INIT DeviceInit)
_Must_inspect_result_ NTSTATUS AllocateDriverObjectExtensionAndStoreFxDriver(VOID)
Definition: fxdriverkm.cpp:130
static MdDriverAddDeviceType AddDevice
Definition: fxdriver.hpp:125
FxDriverDeviceAdd m_DriverDeviceAdd
Definition: fxdriver.hpp:70
static FxDriver * GetFxDriver(__in MdDriverObject DriverObject)
Definition: fxdriverkm.cpp:159
MxDriverObject m_DriverObject
Definition: fxdriver.hpp:62
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
__inline MdDriverObject GetObject(VOID)
static __inline PVOID MxGetDriverObjectExtension(__in MdDriverObject DriverObject, __in PVOID ClientIdentificationAddress)
Definition: mxgeneralkm.h:385
static __inline NTSTATUS MxAllocateDriverObjectExtension(_In_ MdDriverObject DriverObject, _In_ PVOID ClientIdentificationAddress, _In_ ULONG DriverObjectExtensionSize, _Post_ _At_(*DriverObjectExtension, _When_(return==0, __drv_aliasesMem __drv_allocatesMem(Mem) _Post_notnull_)) _When_(return==0, _Outptr_result_bytebuffer_(DriverObjectExtensionSize)) PVOID *DriverObjectExtension)
Definition: mxgeneralkm.h:396
#define __in
Definition: dbghelp.h:35
#define TRACINGPNP
Definition: dbgtrace.h:67
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
FxDevice * pDevice
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
@ FxDeviceInitTypeFdo
FxDriver * pDriver
#define FX_DRIVER_ID
Definition: fxdriver.hpp:49
#define ASSERT(a)
Definition: mode.c:44
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define _In_
Definition: ms_sal.h:308
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
Definition: ps.c:97
#define GetHandle(h)
Definition: treelist.c:116
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STDCALL
Definition: wdf.h:45
@ WdfDevStatePnpInit
Definition: wdfdevice.h:69
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
static int init
Definition: wintirpc.c:33