ReactOS  0.4.15-dev-2701-g34593d9
fxdriverapium.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  User 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 "FxDriverApiUm.tmh"
31 }
32 
33 //
34 // extern the whole file
35 //
36 extern "C" {
37 
41 WDFEXPORT(WdfDriverOpenParametersRegistryKey)(
42  __in
44  __in
45  WDFDRIVER Driver,
46  __in
48  __in_opt
50  __out
51  WDFKEY* Key
52  )
53 {
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  if (pKey == NULL) {
86  }
87 
91  //
92  // These access rights are not allowed. This restriction is
93  // imposed by the host process and the reflector driver.
94  //
95  // Even though the maximum-permissions handle is already opened,
96  // we fail so that the caller knows not to assume it has the
97  // GENERIC_WRITE, KEY_CREATE_SUB_KEY, or WRITE_DAC permissions.
98  //
102  "Could not open '%s' service parameters key "
103  "with access rights 0x%x, %!STATUS!",
104  pFxDriverGlobals->Public.DriverName,
106  } else if ((DesiredAccess & ~(KEY_READ | GENERIC_READ)) == 0) {
107  //
108  // If caller requested read-only access, open a new handle
109  // to the parameters key, no reason to give more privileges
110  // than needed.
111  //
112  result = RegOpenKeyEx(pDriver->GetDriverParametersKey(),
113  L"",
114  0,
116  &hKey);
118  if (!NT_SUCCESS(status)) {
121  "Could not open '%s' service parameters key "
122  "with access rights 0x%x, %!STATUS!",
123  pFxDriverGlobals->Public.DriverName,
125  }
126  } else {
127  //
128  // If caller requested write access, give it the pre-opened
129  // handle, since we do not have permission to open this key
130  // with write access rights from user mode.
131  //
132  hKey = pDriver->GetDriverParametersKey();
133 
134  //
135  // Mark the registry key handle such that it won't be closed
136  // when this FxRegKey is deleted. We might need the handle again
137  // for future calls to WdfDriverOpenParametersRegistryKey.
138  //
140  }
141 
142  if (NT_SUCCESS(status)) {
144  *Key = keyHandle;
145  }
146  }
147 
148  if (!NT_SUCCESS(status)) {
150  }
151 
152  return status;
153 }
154 
157 WDFEXPORT(WdfDriverWdmGetDriverObject)(
158  __in
160  __in
161  WDFDRIVER Driver
162  )
163 {
164  DDI_ENTRY();
165 
168 
169  ASSERTMSG("Not implemented for UMDF\n", FALSE);
170 
171  return NULL;
172 }
173 
175 WDFDRIVER
176 WDFEXPORT(WdfWdmDriverGetWdfDriverHandle)(
177  __in
179  __in
181  )
182 {
183  DDI_ENTRY();
184 
187 
188  ASSERTMSG("Not implemented for UMDF\n", FALSE);
189 
190  return NULL;
191 }
192 
193 VOID
195  __in
197  __in
198  WDFDRIVER Driver
199  )
200 {
201  DDI_ENTRY();
202 
205 
206  ASSERTMSG("Not implemented for UMDF\n", FALSE);
207 }
208 
211 NTSTATUS
212 WDFEXPORT(WdfDeviceMiniportCreate)(
213  __in
215  __in
216  WDFDRIVER Driver,
217  __in_opt
219  __in
221  __in_opt
223  __in_opt
225  __out
226  WDFDEVICE* Device
227  )
228 {
229  DDI_ENTRY();
230 
238 
239  ASSERTMSG("Not implemented for UMDF\n", FALSE);
240 
242 }
243 
244 } // extern "C"
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
_Must_inspect_result_ __in WDFDRIVER __in_opt PWDF_OBJECT_ATTRIBUTES __in PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
#define _Must_inspect_result_
Definition: no_sal2.h:62
PFX_DRIVER_GLOBALS pFxDriverGlobals
NTSTATUS WinErrorToNtStatus(__in ULONG WinError)
Definition: errtostatus.cpp:60
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_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
GLuint64EXT * result
Definition: glext.h:11304
#define __in_opt
Definition: dbghelp.h:38
#define KEY_READ
Definition: nt_native.h:1023
WDFKEY keyHandle
LONG NTSTATUS
Definition: precomp.h:26
VOID WDFEXPORT() WdfDriverMiniportUnload(__in PWDF_DRIVER_GLOBALS DriverGlobals, __in WDFDRIVER Driver)
#define TRACINGDRIVER
Definition: dbgtrace.h:68
DriverGlobals
ASSERTMSG("Not implemented for UMDF\n", FALSE)
_Must_inspect_result_ __in WDFDRIVER Driver
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
#define FALSE
Definition: types.h:117
return NULL
long LONG
Definition: pedump.c:60
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define GENERIC_WRITE
Definition: nt_native.h:90
#define __out
Definition: dbghelp.h:62
UNREFERENCED_PARAMETER(DriverGlobals)
VOID __inline SetCanCloseHandle(BOOLEAN CanCloseHandle)
Definition: fxregkey.hpp:277
_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
_Must_inspect_result_ __in WDFDRIVER __in ACCESS_MASK __in_opt PWDF_OBJECT_ATTRIBUTES KeyAttributes
_Must_inspect_result_ __in WDFDRIVER __in ACCESS_MASK DesiredAccess
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
_Must_inspect_result_ __in WDFDRIVER __in_opt PWDF_OBJECT_ATTRIBUTES __in PDEVICE_OBJECT __in_opt PDEVICE_OBJECT AttachedDeviceObject
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ __in WDFDRIVER __in_opt PWDF_OBJECT_ATTRIBUTES __in PDEVICE_OBJECT __in_opt PDEVICE_OBJECT __in_opt PDEVICE_OBJECT __out WDFDEVICE * Device
_Must_inspect_result_ __in WDFDRIVER __in_opt PWDF_OBJECT_ATTRIBUTES __in PDEVICE_OBJECT __in_opt PDEVICE_OBJECT __in_opt PDEVICE_OBJECT Pdo
#define WRITE_DAC
Definition: nt_native.h:59
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
__in PDRIVER_OBJECT DriverObject
_Must_inspect_result_ __in WDFDRIVER __in ACCESS_MASK __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFKEY * Key
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)
HKEY hKey
FxRegKey * pKey
_Must_inspect_result_ __in WDFDRIVER __in_opt PWDF_OBJECT_ATTRIBUTES Attributes
__inline VOID SetHandle(__in HANDLE Key)
Definition: fxregkey.hpp:94
#define GENERIC_READ
Definition: compat.h:135
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define RegOpenKeyEx
Definition: winreg.h:520
status
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
FxDriver * pDriver
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
_Must_inspect_result_ __drv_maxIRQL(PASSIVE_LEVEL) NTSTATUS WDFEXPORT(WdfDriverOpenParametersRegistryKey)(__in PWDF_DRIVER_GLOBALS DriverGlobals
FxObjectHandleGetPtr(pFxDriverGlobals, Driver, FX_TYPE_DRIVER,(PVOID *) &pDriver)
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
LONG result
#define __in
Definition: dbghelp.h:35
_Must_inspect_result_ _In_ WDFDRIVER Driver
Definition: wdfcontrol.h:83
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
ULONG ACCESS_MASK
Definition: nt_native.h:40
FxPointerNotNull(pFxDriverGlobals, Key)
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
Definition: ps.c:97