Added partial implementation of powrprof.dll.

This commit is contained in:
Benjamin Cutler 2005-04-20 19:15:31 +00:00 committed by Alexandre Julliard
parent fc2bd2324e
commit 250a8aec08
8 changed files with 388 additions and 1 deletions

View File

@ -109,6 +109,7 @@ DLLs (under dlls/):
olepro32/ - 32 bit OLE 2.0 automation
olesvr/ - 16 bit OLE server
opengl32/ - OpenGL implementation (graphics)
powrprof/ - Power Management and Profiling
psapi/ - Process Status interface
qcap/ - DirectShow runtime
quartz/ - DirectShow runtime

3
configure vendored

File diff suppressed because one or more lines are too long

View File

@ -1628,6 +1628,7 @@ dlls/oledlg/Makefile
dlls/olepro32/Makefile
dlls/olesvr/Makefile
dlls/opengl32/Makefile
dlls/powrprof/Makefile
dlls/psapi/Makefile
dlls/psapi/tests/Makefile
dlls/qcap/Makefile

View File

@ -104,6 +104,7 @@ BASEDIRS = \
oledlg \
olepro32 \
olesvr \
powrprof \
psapi \
qcap \
quartz \
@ -348,6 +349,7 @@ SYMLINKS_SO = \
oledlg.dll.so \
olepro32.dll.so \
olesvr32.dll.so \
powrprof.dll.so \
psapi.dll.so \
qcap.dll.so \
quartz.dll.so \
@ -768,6 +770,9 @@ olesvr.dll.so : olesvr32.dll.so
opengl32.dll.so: opengl32/opengl32.dll.so
$(RM) $@ && $(LN_S) opengl32/opengl32.dll.so $@
powrprof.dll.so: powrprof/powrprof.dll.so
$(RM) $@ && $(LN_S) powrprof/powrprof.dll.so $@
psapi.dll.so: psapi/psapi.dll.so
$(RM) $@ && $(LN_S) psapi/psapi.dll.so $@
@ -1093,6 +1098,7 @@ IMPORT_LIBS = \
libolepro32.$(IMPLIBEXT) \
libolesvr32.$(IMPLIBEXT) \
libopengl32.$(IMPLIBEXT) \
libpowrprof.$(IMPLIBEXT) \
libpsapi.$(IMPLIBEXT) \
libqcap.$(IMPLIBEXT) \
libquartz.$(IMPLIBEXT) \
@ -1576,6 +1582,11 @@ libopengl32.def: opengl32/opengl32.spec.def
libopengl32.a: opengl32/opengl32.spec.def
$(DLLTOOL) -k -l $@ -d opengl32/opengl32.spec.def
libpowrprof.def: powrprof/powrprof.spec.def
$(RM) $@ && $(LN_S) powrprof/powrprof.spec.def $@
libpowrprof.a: powrprof/powrprof.spec.def
$(DLLTOOL) -k -l $@ -d powrprof/powrprof.spec.def
libpsapi.def: psapi/psapi.spec.def
$(RM) $@ && $(LN_S) psapi/psapi.spec.def $@
libpsapi.a: psapi/psapi.spec.def
@ -1887,6 +1898,7 @@ oledlg/oledlg.spec.def: $(WINEBUILD)
olepro32/olepro32.spec.def: $(WINEBUILD)
olesvr/olesvr32.spec.def: $(WINEBUILD)
opengl32/opengl32.spec.def: $(WINEBUILD)
powrprof/powrprof.spec.def: $(WINEBUILD)
psapi/psapi.spec.def: $(WINEBUILD)
qcap/qcap.spec.def: $(WINEBUILD)
quartz/quartz.spec.def: $(WINEBUILD)
@ -2040,6 +2052,7 @@ oledlg/oledlg.dll.so: oledlg
olepro32/olepro32.dll.so: olepro32
olesvr/olesvr32.dll.so: olesvr
opengl32/opengl32.dll.so: opengl32
powrprof/powrprof.dll.so: powrprof
psapi/psapi.dll.so: psapi
qcap/qcap.dll.so: qcap
quartz/quartz.dll.so: quartz

3
dlls/powrprof/.cvsignore Normal file
View File

@ -0,0 +1,3 @@
Makefile
powrprof.dll.dbg.c
powrprof.spec.def

13
dlls/powrprof/Makefile.in Normal file
View File

@ -0,0 +1,13 @@
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = powrprof.dll
IMPORTS = advapi32 kernel32 ntdll
EXTRALIBS = $(LIBUNICODE)
C_SRCS = powrprof.c
@MAKE_DLL_RULES@
### Dependencies:

336
dlls/powrprof/powrprof.c Normal file
View File

@ -0,0 +1,336 @@
/*
* Copyright (C) 2005 Benjamin Cutler
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winnt.h"
#include "winreg.h"
#include "winternl.h"
#include "ntstatus.h"
#include "powrprof.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(powrprof);
/* Notes to implementors:
* #1: The native implementation of these functions attempted to read in
* registry entries that I was unable to locate on any of the Windows
* machines I checked, but I only had desktops available, so maybe
* laptop users will have better luck. They return FNF errors because
* that's what the native DLL was returning during my tests.
* #2: These functions call NtPowerInformation but I don't know what they
* do with the results, and NtPowerInformation doesn't do much in WINE yet
* anyway.
* #3: Since I can't get several other functions working (see note #1),
* implementing these functions is going to have to wait until somebody can
* cobble together some sane test input. */
static const WCHAR szPowerCfgSubKey[] = { 'S', 'o', 'f', 't', 'w', 'a', 'r', 'e',
'\\', 'M', 'i', 'c', 'r', 'o', 's', 'o', 'f', 't', '\\', 'W', 'i',
'n', 'd', 'o', 'w', 's', '\\', 'C', 'u', 'r', 'r', 'e', 'n', 't',
'V', 'e', 'r', 's', 'i', 'o', 'n', '\\', 'C', 'o', 'n', 't', 'r',
'o', 'l', 's', ' ', 'F', 'o', 'l', 'd', 'e', 'r', '\\', 'P', 'o',
'w', 'e', 'r', 'C', 'f', 'g', 0 };
static const WCHAR szSemaphoreName[] = { 'P', 'o', 'w', 'e', 'r', 'P', 'r', 'o',
'f', 'i', 'l', 'e', 'R', 'e', 'g', 'i', 's', 't', 'r', 'y', 'S',
'e', 'm', 'a', 'p', 'h', 'o', 'r', 'e', 0 };
static const WCHAR szDiskMax[] = { 'D', 'i', 's', 'k', 'S', 'p', 'i', 'n', 'd',
'o', 'w', 'n', 'M', 'a', 'x', 0 };
static const WCHAR szDiskMin[] = { 'D', 'i', 's', 'k', 'S', 'p', 'i', 'n', 'd',
'o', 'w', 'n', 'M', 'i', 'n', 0 };
static const WCHAR szLastID[] = { 'L', 'a', 's', 't', 'I', 'D', 0 };
static HANDLE PPRegSemaphore = NULL;
NTSTATUS WINAPI CallNtPowerInformation(
POWER_INFORMATION_LEVEL InformationLevel,
PVOID lpInputBuffer, ULONG nInputBufferSize,
PVOID lpOutputBuffer, ULONG nOutputBufferSize)
{
return NtPowerInformation(InformationLevel, lpInputBuffer,
nInputBufferSize, lpOutputBuffer, nOutputBufferSize);
}
BOOLEAN WINAPI CanUserWritePwrScheme(VOID)
{
HKEY hKey = NULL;
LONG r;
BOOLEAN bSuccess = TRUE;
TRACE("()\n");
r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szPowerCfgSubKey, 0, KEY_READ | KEY_WRITE, &hKey);
if (r != ERROR_SUCCESS) {
TRACE("RegOpenKeyEx failed: %ld\n", r);
bSuccess = FALSE;
}
SetLastError(r);
RegCloseKey(hKey);
return bSuccess;
}
BOOLEAN WINAPI DeletePwrScheme(UINT uiIndex)
{
/* FIXME: See note #1 */
FIXME("(%d) stub!\n", uiIndex);
SetLastError(ERROR_FILE_NOT_FOUND);
return FALSE;
}
BOOLEAN WINAPI EnumPwrSchemes(PWRSCHEMESENUMPROC lpfnPwrSchemesEnumProc,
LPARAM lParam)
{
/* FIXME: See note #1 */
FIXME("(%p, %ld) stub!\n", lpfnPwrSchemesEnumProc, lParam);
SetLastError(ERROR_FILE_NOT_FOUND);
return FALSE;
}
BOOLEAN WINAPI GetActivePwrScheme(PUINT puiID)
{
/* FIXME: See note #1 */
FIXME("(%p) stub!\n", puiID);
SetLastError(ERROR_FILE_NOT_FOUND);
return FALSE;
}
BOOLEAN WINAPI GetCurrentPowerPolicies(
PGLOBAL_POWER_POLICY pGlobalPowerPolicy,
PPOWER_POLICY pPowerPolicy)
{
/* FIXME: See note #2 */
SYSTEM_POWER_POLICY ACPower, DCPower;
FIXME("(%p, %p) stub!\n", pGlobalPowerPolicy, pPowerPolicy);
NtPowerInformation(SystemPowerPolicyAc, 0, 0, &ACPower, sizeof(SYSTEM_POWER_POLICY));
NtPowerInformation(SystemPowerPolicyDc, 0, 0, &DCPower, sizeof(SYSTEM_POWER_POLICY));
return FALSE;
}
BOOLEAN WINAPI GetPwrCapabilities(
PSYSTEM_POWER_CAPABILITIES lpSystemPowerCapabilities)
{
NTSTATUS r;
TRACE("(%p)\n", lpSystemPowerCapabilities);
r = NtPowerInformation(SystemPowerCapabilities, 0, 0, lpSystemPowerCapabilities, sizeof(SYSTEM_POWER_CAPABILITIES));
SetLastError(RtlNtStatusToDosError(r));
return r == STATUS_SUCCESS;
}
BOOLEAN WINAPI GetPwrDiskSpindownRange(PUINT RangeMax, PUINT RangeMin)
{
HKEY hKey;
BYTE lpValue[40];
LONG cbValue = 40, r;
TRACE("(%p, %p)\n", RangeMax, RangeMin);
if (RangeMax == NULL || RangeMin == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
SetLastError(ERROR_SUCCESS);
WaitForSingleObject(PPRegSemaphore, INFINITE);
r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szPowerCfgSubKey, 0, KEY_READ, &hKey);
if (r != ERROR_SUCCESS) {
TRACE("RegOpenKeyEx failed: %ld\n", r);
TRACE("Using defaults: 3600, 3\n");
*RangeMax = 3600;
*RangeMin = 3;
ReleaseSemaphore(PPRegSemaphore, 1, NULL);
return TRUE;
}
r = RegQueryValueExW(hKey, szDiskMax, 0, 0, lpValue, &cbValue);
if (r != ERROR_SUCCESS) {
TRACE("Couldn't open DiskSpinDownMax: %ld\n", r);
TRACE("Using default: 3600\n");
*RangeMax = 3600;
} else {
*RangeMax = atoiW((LPCWSTR)lpValue);
}
cbValue = 40;
r = RegQueryValueExW(hKey, szDiskMin, 0, 0, lpValue, &cbValue);
if (r != ERROR_SUCCESS) {
TRACE("Couldn't open DiskSpinDownMin: %ld\n", r);
TRACE("Using default: 3\n");
*RangeMin = 3;
} else {
*RangeMin = atoiW((LPCWSTR)lpValue);
}
RegCloseKey(hKey);
ReleaseSemaphore(PPRegSemaphore, 1, NULL);
return TRUE;
}
BOOLEAN WINAPI IsPwrHibernateAllowed(VOID)
{
/* FIXME: See note #2 */
SYSTEM_POWER_CAPABILITIES PowerCaps;
FIXME("() stub!\n");
NtPowerInformation(SystemPowerCapabilities, NULL, 0, &PowerCaps, sizeof(PowerCaps));
return FALSE;
}
BOOLEAN WINAPI IsPwrShutdownAllowed(VOID)
{
/* FIXME: See note #2 */
SYSTEM_POWER_CAPABILITIES PowerCaps;
FIXME("() stub!\n");
NtPowerInformation(SystemPowerCapabilities, NULL, 0, &PowerCaps, sizeof(PowerCaps));
return FALSE;
}
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
{
/* FIXME: See note #2 */
SYSTEM_POWER_CAPABILITIES PowerCaps;
FIXME("() stub!\n");
NtPowerInformation(SystemPowerCapabilities, NULL, 0, &PowerCaps, sizeof(PowerCaps));
return FALSE;
}
BOOLEAN WINAPI ReadGlobalPwrPolicy(PGLOBAL_POWER_POLICY pGlobalPowerPolicy)
{
/* FIXME: See note #1 */
FIXME("(%p) stub!\n", pGlobalPowerPolicy);
SetLastError(ERROR_FILE_NOT_FOUND);
return FALSE;
}
BOOLEAN WINAPI ReadProcessorPwrScheme(UINT uiID,
PMACHINE_PROCESSOR_POWER_POLICY pMachineProcessorPowerPolicy)
{
/* FIXME: See note #1 */
FIXME("(%d, %p) stub!\n", uiID, pMachineProcessorPowerPolicy);
SetLastError(ERROR_FILE_NOT_FOUND);
return FALSE;
}
BOOLEAN WINAPI ReadPwrScheme(UINT uiID,
PPOWER_POLICY pPowerPolicy)
{
/* FIXME: See note #1 */
FIXME("(%d, %p) stub!\n", uiID, pPowerPolicy);
SetLastError(ERROR_FILE_NOT_FOUND);
return FALSE;
}
BOOLEAN WINAPI SetActivePwrScheme(UINT uiID,
PGLOBAL_POWER_POLICY lpGlobalPowerPolicy,
PPOWER_POLICY lpPowerPolicy)
{
/* FIXME: See note #1 */
FIXME("(%d, %p, %p) stub!\n", uiID, lpGlobalPowerPolicy, lpPowerPolicy);
SetLastError(ERROR_FILE_NOT_FOUND);
return FALSE;
}
BOOLEAN WINAPI SetSuspendState(BOOLEAN Hibernate, BOOLEAN ForceCritical,
BOOLEAN DisableWakeEvent)
{
/* FIXME: I have NO idea how you're supposed to call NtInitiatePowerAction
* here, because it's not a documented function that I can find */
FIXME("(%d, %d, %d) stub!\n", Hibernate, ForceCritical, DisableWakeEvent);
return TRUE;
}
BOOLEAN WINAPI WriteGlobalPwrPolicy(PGLOBAL_POWER_POLICY pGlobalPowerPolicy)
{
/* FIXME: See note #3 */
FIXME("(%p) stub!\n", pGlobalPowerPolicy);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
BOOLEAN WINAPI WriteProcessorPwrScheme(UINT ID,
PMACHINE_PROCESSOR_POWER_POLICY pMachineProcessorPowerPolicy)
{
/* FIXME: See note #3 */
FIXME("(%d, %p) stub!\n", ID, pMachineProcessorPowerPolicy);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
BOOLEAN WINAPI WritePwrScheme(PUINT puiID, LPWSTR lpszName, LPWSTR lpszDescription,
PPOWER_POLICY pPowerPolicy)
{
/* FIXME: See note #3 */
FIXME("(%p, %s, %s, %p) stub!\n", puiID, debugstr_w(lpszName), debugstr_w(lpszDescription), pPowerPolicy);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
FIXME("(%p, %ld, %p) not fully implemented\n", hinstDLL, fdwReason, lpvReserved);
switch(fdwReason) {
case DLL_PROCESS_ATTACH: {
HKEY hKey;
LONG r;
DisableThreadLibraryCalls(hinstDLL);
r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szPowerCfgSubKey, 0, KEY_READ | KEY_WRITE, &hKey);
if (r != ERROR_SUCCESS) {
TRACE("Couldn't open registry key HKLM\\%s, using some sane(?) defaults\n", debugstr_w(szPowerCfgSubKey));
} else {
BYTE lpValue[40];
LONG cbValue = 40;
r = RegQueryValueExW(hKey, szLastID, 0, 0, lpValue, &cbValue);
if (r != ERROR_SUCCESS) {
TRACE("Couldn't open registry entry HKLM\\%s\\LastID, using some sane(?) defaults\n", debugstr_w(szPowerCfgSubKey));
}
RegCloseKey(hKey);
}
PPRegSemaphore = CreateSemaphoreW(NULL, 1, 1, szSemaphoreName);
if (PPRegSemaphore == NULL) {
ERR("Couldn't create Semaphore: %ld\n", GetLastError());
return FALSE;
}
break;
}
case DLL_PROCESS_DETACH:
CloseHandle(PPRegSemaphore);
break;
}
return TRUE;
}

View File

@ -0,0 +1,19 @@
@ stdcall CallNtPowerInformation (long ptr long ptr long)
@ stdcall CanUserWritePwrScheme ()
@ stdcall DeletePwrScheme (long)
@ stdcall EnumPwrSchemes (ptr long)
@ stdcall GetActivePwrScheme (ptr)
@ stdcall GetCurrentPowerPolicies (ptr ptr)
@ stdcall GetPwrCapabilities (ptr)
@ stdcall GetPwrDiskSpindownRange (ptr ptr)
@ stdcall IsPwrHibernateAllowed ()
@ stdcall IsPwrShutdownAllowed ()
@ stdcall IsPwrSuspendAllowed ()
@ stdcall ReadGlobalPwrPolicy (ptr)
@ stdcall ReadProcessorPwrScheme (long ptr)
@ stdcall ReadPwrScheme (long ptr)
@ stdcall SetActivePwrScheme (long ptr ptr)
@ stdcall SetSuspendState (long long long)
@ stdcall WriteGlobalPwrPolicy (ptr)
@ stdcall WriteProcessorPwrScheme (long ptr)
@ stdcall WritePwrScheme (ptr str str ptr)