ReactOS 0.4.16-dev-297-gc569aee
fxpkgpnpum.cpp
Go to the documentation of this file.
1//
2// Copyright (C) Microsoft. All rights reserved.
3//
4#include "../pnppriv.hpp"
5
6#include <initguid.h>
7#include <wdmguid.h>
8
9extern "C" {
10#if defined(EVENT_TRACING)
11#include "FxPkgPnpUM.tmh"
12#endif
13}
14
18 )
19{
21 ASSERTMSG("Not implemented for UMDF\n", FALSE);
22
24}
25
29 VOID
30 )
31{
32 ASSERTMSG("Not implemented for UMDF\n", FALSE);
33
35}
36
37VOID
39 __in FxDmaEnabler* Enabler
40 )
41{
43 ASSERTMSG("Not implemented for UMDF\n", FALSE);
44}
45
46VOID
48 __in FxDmaEnabler* Enabler
49 )
50{
52 ASSERTMSG("Not implemented for UMDF\n", FALSE);
53}
54
58 _In_ BOOLEAN ForS0Idle
59 )
60{
61 HRESULT hr;
63 IWudfDeviceStack* devStack;
64 WmiIdleWakeInstanceUpdate updateType;
65
66 devStack = m_Device->GetDeviceStack();
67
68 ASSERT(Action != InstanceActionInvalid);
69
70 if (Action == AddInstance) {
71 updateType = ForS0Idle ? AddS0IdleInstance : AddSxWakeInstance;
72 } else {
73 updateType = ForS0Idle ? RemoveS0IdleInstance : RemoveSxWakeInstance;
74 }
75
76 hr = devStack->UpdateIdleWakeWmiInstance(updateType);
77 if (S_OK == hr) {
79 }
80 else {
81 PUMDF_VERSION_DATA driverVersion = devStack->GetMinDriverVersion();
82 BOOL preserveCompat =
83 devStack->ShouldPreserveIrpCompletionStatusCompatibility();
84
85 status = CHostFxUtil::NtStatusFromHr(hr,
86 driverVersion->MajorNumber,
87 driverVersion->MinorNumber,
88 preserveCompat);
89 }
90
91 if (!NT_SUCCESS(status)) {
95 "failed to send ioctl to update %s WMI instance "
96 "%!STATUS!",
97 ForS0Idle ? "S0Idle" : "SxWake",
98 status);
99 }
100
101 return status;
102}
103
108 )
109{
110 DWORD err;
112 DWORD data;
114 HKEY pwrPolKey = NULL;
115 IWudfDeviceStack* devStack;
116
117 ASSERT(NULL != Value);
118 ASSERT(ValueName != NULL &&
119 ValueName->Length != 0 &&
120 ValueName->Buffer != NULL);
121
122 *Value = 0;
123 devStack = m_Device->GetDeviceStack();
124
125 err = RegOpenKeyEx(devStack->GetDeviceRegistryKey(),
127 0,
128 KEY_READ,
129 &pwrPolKey);
130 if (ERROR_SUCCESS != err) {
134 "RegOpenKeyEx returned error %d",
135 err);
136 goto Clean;
137 }
138
139 dataSize = sizeof(data);
140 err = RegQueryValueEx(pwrPolKey,
141 ValueName->Buffer,
142 NULL,
143 NULL,
144 (BYTE*) &data,
145 &dataSize);
146 if (ERROR_SUCCESS != err) {
150 "failed to read registry, "
151 "RegQueryValueEx returned error %d",
152 err);
153 goto Clean;
154 }
155
156 *Value = data;
158
159Clean:
160 if (NULL != pwrPolKey) {
161 RegCloseKey(pwrPolKey);
162 }
163
164 if (ERROR_SUCCESS == err) {
166 }
167 else {
168 PUMDF_VERSION_DATA driverVersion = devStack->GetMinDriverVersion();
169 BOOL preserveCompat =
170 devStack->ShouldPreserveIrpCompletionStatusCompatibility();
171
172 status = CHostFxUtil::NtStatusFromHr(HRESULT_FROM_WIN32(err),
173 driverVersion->MajorNumber,
174 driverVersion->MinorNumber,
175 preserveCompat);
176 }
177
178 return status;
179}
180
181VOID
183 __in HANDLE RegKey,
186 )
187{
188 DWORD err;
189 HRESULT hr;
190 HKEY hKey = NULL;
191 IWudfDeviceStack* devStack;
192 UMINT::WDF_PROPERTY_STORE_ROOT propertyStore;
193
195
196 ASSERT(ValueName != NULL &&
197 ValueName->Length != 0 &&
198 ValueName->Buffer != NULL);
199
200 devStack = m_Device->GetDeviceStack();
201
202 propertyStore.LengthCb = sizeof(UMINT::WDF_PROPERTY_STORE_ROOT);
203 propertyStore.RootClass = UMINT::WdfPropertyStoreRootClassHardwareKey;
204 propertyStore.Qualifier.HardwareKey.ServiceName = WUDF_POWER_POLICY_SETTINGS;
205
206 hr = devStack->CreateRegistryEntry(&propertyStore,
207 UMINT::WdfPropertyStoreCreateIfMissing,
209 NULL,
210 &hKey,
211 NULL);
212 if (FAILED(hr)) {
213 goto Clean;
214 }
215
216 //
217 // Failure to save the user's idle/wake settings is not critical and we
218 // will continue on regardless. Hence we ignore the return value.
219 //
221 ValueName->Buffer,
222 0,
223 REG_DWORD,
224 (BYTE *) &Value,
225 sizeof(Value));
226 if (err != ERROR_SUCCESS) {
230 "Failed to set Registry value "
231 "for S0Idle/SxWake error %d",
232 err);
233 goto Clean;
234 }
235
236Clean:
237 if (NULL != hKey) {
239 }
240}
241
245 )
246{
248
249 //
250 // Send an IOCTL to redirector
251 // to add/remove S0Idle WMI instance.
252 //
254
255 return status;
256}
257
258VOID
262 )
263{
265 ULONG value;
266
268
269 //
270 // Modify value of Enabled only if success
271 //
272 if (NT_SUCCESS(status)) {
273 //
274 // Normalize the ULONG value into a BOOLEAN
275 //
276 *Enabled = (value == FALSE) ? FALSE : TRUE;
277 }
278}
279
283 )
284{
286
287 //
288 // Send an IOCTL to redirector
289 // to add/remove SxWake WMI instance.
290 //
292
293 return status;
294}
295
296VOID
300 )
301{
303 ULONG value;
304
306
307 //
308 // Modify value of Enabled only if success
309 //
310 if (NT_SUCCESS(status)) {
311 //
312 // Normalize the ULONG value into a BOOLEAN
313 //
314 *Enabled = (value == FALSE) ? FALSE : TRUE;
315 }
316}
317
318VOID
322 __inout FxIrp* ForwardIrp
323 )
324{
327 UNREFERENCED_PARAMETER(ForwardIrp);
328 ASSERTMSG("Not implemented for UMDF\n", FALSE);
329}
330
331
332VOID
334 __in FxDmaEnabler * /* DmaEnabler */
335 )
336{
337 // Do nothing
338}
339
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define RegCloseKey(hKey)
Definition: registry.h:49
IWudfDeviceStack * GetDeviceStack(VOID)
Definition: fxdeviceum.hpp:435
Definition: fxirp.hpp:28
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
CfxDevice * m_Device
Definition: fxobject.hpp:329
VOID RevokeDmaEnablerResources(__in FxDmaEnabler *Enabler)
Definition: fxpkgpnpkm.cpp:529
NTSTATUS UpdateWmiInstance(_In_ FxWmiInstanceAction Action, _In_ BOOLEAN ForS0Idle)
Definition: fxpkgpnpum.cpp:56
VOID ReadRegistrySxWake(__in PCUNICODE_STRING ValueName, __out BOOLEAN *Enabled)
Definition: fxpkgpnpkm.cpp:469
NTSTATUS FilterResourceRequirements(__in IO_RESOURCE_REQUIREMENTS_LIST **IoList)
Definition: fxpkgpnpkm.cpp:16
VOID RemoveDmaEnabler(__in FxDmaEnabler *Enabler)
Definition: fxpkgpnpkm.cpp:289
NTSTATUS ReadStateFromRegistry(_In_ PCUNICODE_STRING ValueName, _Out_ PULONG Value)
Definition: fxpkgpnpum.cpp:105
VOID ReadRegistryS0Idle(__in PCUNICODE_STRING ValueName, __out BOOLEAN *Enabled)
Definition: fxpkgpnpkm.cpp:376
_Must_inspect_result_ NTSTATUS AllocateDmaEnablerList(VOID)
Definition: fxpkgpnpkm.cpp:241
NTSTATUS UpdateWmiInstanceForSxWake(__in FxWmiInstanceAction Action)
Definition: fxpkgpnpum.cpp:281
NTSTATUS UpdateWmiInstanceForS0Idle(__in FxWmiInstanceAction Action)
Definition: fxpkgpnpum.cpp:243
VOID AddDmaEnabler(__in FxDmaEnabler *Enabler)
Definition: fxpkgpnpkm.cpp:277
VOID WriteStateToRegistry(__in HANDLE RegKey, __in PUNICODE_STRING ValueName, __in ULONG Value)
Definition: fxpkgpnpkm.cpp:301
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define __in
Definition: dbghelp.h:35
#define __inout
Definition: dbghelp.h:50
#define __out
Definition: dbghelp.h:62
#define TRACINGPNP
Definition: dbgtrace.h:67
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WUDF_POWER_POLICY_SETTINGS
Definition: device_common.h:45
#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:33
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
FxAutoRegKey hKey
FxWmiInstanceAction
Definition: fxpkgpnp.hpp:428
@ AddInstance
Definition: fxpkgpnp.hpp:429
VOID PnpPassThroughQIWorker(__in MxDeviceObject *Device, __inout FxIrp *Irp, __inout FxIrp *ForwardIrp)
Definition: fxpkgpnpum.cpp:319
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLsizei dataSize
Definition: glext.h:11123
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define ASSERT(a)
Definition: mode.c:44
@ Enabled
Definition: mountmgr.h:179
#define _Must_inspect_result_
Definition: no_sal2.h:62
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
#define KEY_READ
Definition: nt_native.h:1023
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
#define err(...)
#define REG_DWORD
Definition: sdbapi.c:596
#define STATUS_SUCCESS
Definition: shellext.h:65
HRESULT hr
Definition: shlfolder.c:183
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
uint32_t * PULONG
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
Definition: pdh_main.c:94
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegSetValueEx
Definition: winreg.h:533
#define RegQueryValueEx
Definition: winreg.h:524
unsigned char BYTE
Definition: xxhash.c:193