ReactOS  0.4.15-dev-1638-gc0caa5c
fxdriverapikm.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxDriverApiKm.cpp
8 
9 Abstract:
10 
11  This module contains the "C" interface for the FxDriver object.
12 
13 Author:
14 
15 
16 
17 Environment:
18 
19  Kernel mode only
20 
21 Revision History:
22 
23 --*/
24 
25 #include "coreprivshared.hpp"
26 
27 // Tracing support
28 extern "C" {
29 #include <ntverp.h>
30 // #include "FxDriverApiKm.tmh"
31 }
32 
33 //
34 // extern the whole file
35 //
36 extern "C" {
37 
41 STDCALL
42 WDFEXPORT(WdfDriverOpenParametersRegistryKey)(
43  __in
45  __in
46  WDFDRIVER Driver,
47  __in
49  __in_opt
51  __out
52  WDFKEY* Key
53  )
54 {
60  WDFKEY keyHandle;
61 
63 
65 
66  *Key = NULL;
67 
69  if (!NT_SUCCESS(status)) {
70  return status;
71  }
72 
74  if (!NT_SUCCESS(status)) {
75  return status;
76  }
77 
79  Driver,
81  (PVOID*) &pDriver);
82 
84 
85  if (pKey == NULL) {
87  }
88 
90 
92  //
93  // Static worker function (no object assignment for opened handled)
94  //
95  status = FxRegKey::_OpenKey(
97 
98  if (NT_SUCCESS(status)) {
99  DECLARE_CONST_UNICODE_STRING(parameters, L"Parameters");
100 
101  //
102  // This will store the resulting handle in pKey
103  //
104  status = pKey->Create(hKey.m_Key, &parameters, DesiredAccess);
105 
106  if (NT_SUCCESS(status)) {
107  *Key = keyHandle;
108  }
109  }
110  }
111 
112  if (!NT_SUCCESS(status)) {
114  }
115 
116  return status;
117 }
118 
121 STDCALL
122 WDFEXPORT(WdfDriverWdmGetDriverObject)(
123  __in
125  __in
126  WDFDRIVER Driver
127  )
128 {
129  FxDriver *pDriver;
130 
132  Driver,
134  (PVOID*) &pDriver);
135 
136  return pDriver->GetDriverObject();
137 }
138 
140 WDFDRIVER
141 STDCALL
142 WDFEXPORT(WdfWdmDriverGetWdfDriverHandle)(
143  __in
145  __in
147  )
148 {
150 
152 }
153 
154 VOID
155 STDCALL
157  __in
159  __in
160  WDFDRIVER Driver
161  )
162 {
163  FxDriver *pDriver;
164 
166  Driver,
168  (PVOID *)&pDriver);
169 
171 }
172 
175 NTSTATUS
176 STDCALL
177 WDFEXPORT(WdfDeviceMiniportCreate)(
178  __in
180  __in
181  WDFDRIVER Driver,
182  __in_opt
184  __in
186  __in_opt
188  __in_opt
190  __out
191  WDFDEVICE* Device
192  )
193 {
195  FxDriver* pDriver;
198 
200  Driver,
202  (PVOID *)&pDriver,
204 
206 
209  }
210  else if (AttachedDeviceObject != NULL && Pdo == NULL) {
212  }
213 
215  if (!NT_SUCCESS(status)) {
216  return status;
217  }
218 
220  if (!NT_SUCCESS(status)) {
221  return status;
222  }
223 
226  pDriver,
227  DeviceObject,
229  Pdo);
230 
231  if (pMpDevice == NULL) {
233  }
234 
235  if (AttachedDeviceObject != NULL) {
237  FALSE /*SelfTarget=FALSE*/);
238  if (!NT_SUCCESS(status)) {
239  goto Done;
240  }
241  }
242 
246  if (!NT_SUCCESS(status)) {
247  goto Done;
248  }
249 
251  if (!NT_SUCCESS(status)) {
252  goto Done;
253  }
254 
256  if (!NT_SUCCESS(status)) { // follow the same error pattern as above.
257  goto Done;
258  }
259 
260 Done:
261  if (!NT_SUCCESS(status)) {
263  }
264 
265  return status;
266 }
267 
268 } // extern "C"
FxDriver * pDriver
NTSTATUS ConfigureConstraints(__in_opt PWDF_OBJECT_ATTRIBUTES ObjectAttributes)
static MdDriverUnloadType Unload
Definition: fxdriver.hpp:369
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
#define _Must_inspect_result_
Definition: no_sal2.h:62
_Must_inspect_result_ __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS STDCALL WDFEXPORT(WdfDriverOpenParametersRegistryKey)(__in PWDF_DRIVER_GLOBALS DriverGlobals
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
_Must_inspect_result_ NTSTATUS Commit(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
Definition: fxobject.cpp:904
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Driver, FX_TYPE_DRIVER,(PVOID *)&pDriver, &pFxDriverGlobals)
#define __in_opt
Definition: dbghelp.h:38
FxIoTarget * m_DefaultTarget
Definition: fxdevice.hpp:2291
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ NTSTATUS AllocateTarget(_Out_ FxIoTarget **Target, _In_ BOOLEAN SelfTarget)
DriverGlobals
_Must_inspect_result_ __in WDFDRIVER __in ACCESS_MASK __in_opt PWDF_OBJECT_ATTRIBUTES KeyAttributes
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
WDFKEY keyHandle
_Must_inspect_result_ __in WDFDRIVER __in_opt PWDF_OBJECT_ATTRIBUTES __in PDEVICE_OBJECT __in_opt PDEVICE_OBJECT AttachedDeviceObject
#define FALSE
Definition: types.h:117
_Must_inspect_result_ __in WDFDRIVER __in_opt PWDF_OBJECT_ATTRIBUTES __in PDEVICE_OBJECT __in_opt PDEVICE_OBJECT __in_opt PDEVICE_OBJECT __out WDFDEVICE * Device
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define __out
Definition: dbghelp.h:62
static FxDriver * GetFxDriver(__in MdDriverObject DriverObject)
Definition: fxdriverkm.cpp:158
_Must_inspect_result_ __in WDFDRIVER Driver
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK _In_opt_ PWDF_OBJECT_ATTRIBUTES KeyAttributes
Definition: wdfdevice.h:2654
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
FxRegKey * pKey
PUNICODE_STRING GetRegistryPathUnicodeString(VOID)
Definition: fxdriver.hpp:243
__inline WDFDRIVER GetHandle(VOID)
Definition: fxdriver.hpp:202
FxDisposeList * m_DisposeList
Definition: fxdevice.hpp:466
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
#define STDCALL
Definition: wdf.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DECLARE_CONST_UNICODE_STRING(_variablename, _string)
Definition: wdfcore.h:161
NTSTATUS status
FxMpDevice * pMpDevice
static const WCHAR L[]
Definition: oid.c:1250
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ __in WDFDRIVER __in ACCESS_MASK DesiredAccess
FxObjectHandleGetPtr(pFxDriverGlobals, Driver, FX_TYPE_DRIVER,(PVOID *) &pDriver)
VOID STDCALL WDFEXPORT() WdfDriverMiniportUnload(__in PWDF_DRIVER_GLOBALS DriverGlobals, __in WDFDRIVER Driver)
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
__inline MdDriverObject GetDriverObject(VOID)
Definition: fxdriver.hpp:252
static NTSTATUS _Create(PFX_DRIVER_GLOBALS FxDriverGlobals, PVOID WdmObject, FxDisposeList **pObject)
_Must_inspect_result_ __in WDFDRIVER __in_opt PWDF_OBJECT_ATTRIBUTES __in PDEVICE_OBJECT __in_opt PDEVICE_OBJECT __in_opt PDEVICE_OBJECT Pdo
FxAutoRegKey hKey
__in PDRIVER_OBJECT DriverObject
_Must_inspect_result_ __in WDFDRIVER __in ACCESS_MASK __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFKEY * Key
FxPointerNotNull(pFxDriverGlobals, Key)
#define NULL
Definition: types.h:112
_Must_inspect_result_ __in WDFDRIVER __in_opt PWDF_OBJECT_ATTRIBUTES Attributes
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
_Must_inspect_result_ __in WDFDRIVER __in_opt PWDF_OBJECT_ATTRIBUTES __in PDEVICE_OBJECT DeviceObject
pFxDriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define __in
Definition: dbghelp.h:35
_Must_inspect_result_ _In_ WDFDRIVER Driver
Definition: wdfcontrol.h:83
ULONG ACCESS_MASK
Definition: nt_native.h:40
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
Definition: ps.c:97