From 250a8aec083f96e4ca37b8f593340a9fdd85bcb8 Mon Sep 17 00:00:00 2001 From: Benjamin Cutler <cutler@cs.colostate.edu> Date: Wed, 20 Apr 2005 19:15:31 +0000 Subject: [PATCH] Added partial implementation of powrprof.dll. --- DEVELOPERS-HINTS | 1 + configure | 3 +- configure.ac | 1 + dlls/Makefile.in | 13 ++ dlls/powrprof/.cvsignore | 3 + dlls/powrprof/Makefile.in | 13 ++ dlls/powrprof/powrprof.c | 336 ++++++++++++++++++++++++++++++++++++ dlls/powrprof/powrprof.spec | 19 ++ 8 files changed, 388 insertions(+), 1 deletion(-) create mode 100644 dlls/powrprof/.cvsignore create mode 100644 dlls/powrprof/Makefile.in create mode 100644 dlls/powrprof/powrprof.c create mode 100644 dlls/powrprof/powrprof.spec diff --git a/DEVELOPERS-HINTS b/DEVELOPERS-HINTS index 3dacadf7605..7a2e405d21d 100644 --- a/DEVELOPERS-HINTS +++ b/DEVELOPERS-HINTS @@ -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 diff --git a/configure b/configure index a62ac7af448..fb45f1713b9 100755 --- a/configure +++ b/configure @@ -20052,7 +20052,7 @@ MAKE_LIB_RULES=libs/Makelib.rules MAKE_PROG_RULES=programs/Makeprog.rules - ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/advpack/Makefile dlls/advpack/tests/Makefile dlls/amstream/Makefile dlls/atl/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/capi2032/Makefile dlls/cards/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/cryptdll/Makefile dlls/ctl3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3dim/Makefile dlls/d3drm/Makefile dlls/d3dx8/Makefile dlls/d3dxof/Makefile dlls/dbghelp/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnet/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/dxdiagn/Makefile dlls/dxerr8/Makefile dlls/dxerr9/Makefile dlls/dxguid/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/hhctrl.ocx/Makefile dlls/iccvid/Makefile dlls/icmp/Makefile dlls/ifsmgr.vxd/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/itss/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/lzexpand/tests/Makefile dlls/mapi32/Makefile dlls/mapi32/tests/Makefile dlls/mlang/Makefile dlls/mlang/tests/Makefile dlls/mmdevldr.vxd/Makefile dlls/monodebg.vxd/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msacm/tests/Makefile dlls/mscms/Makefile dlls/mscms/tests/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/msi/Makefile dlls/msi/tests/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile dlls/msvcrtd/Makefile dlls/msvcrtd/tests/Makefile dlls/msvidc32/Makefile dlls/msvideo/Makefile dlls/mswsock/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/ole32/tests/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/psapi/tests/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/quartz/tests/Makefile dlls/rasapi32/Makefile dlls/riched20/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/rsabase/Makefile dlls/rsabase/tests/Makefile dlls/rsaenh/Makefile dlls/rsaenh/tests/Makefile dlls/secur32/Makefile dlls/sensapi/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/stdole32.tlb/Makefile dlls/sti/Makefile dlls/strmiids/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/uuid/Makefile dlls/uxtheme/Makefile dlls/vdhcp.vxd/Makefile dlls/vdmdbg/Makefile dlls/version/Makefile dlls/version/tests/Makefile dlls/vmm.vxd/Makefile dlls/vnbt.vxd/Makefile dlls/vnetbios.vxd/Makefile dlls/vtdapi.vxd/Makefile dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winejack/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/wtsapi32/Makefile dlls/x11drv/Makefile documentation/Makefile fonts/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/msiexec/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/taskmgr/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile" + ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/advpack/Makefile dlls/advpack/tests/Makefile dlls/amstream/Makefile dlls/atl/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/capi2032/Makefile dlls/cards/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/cryptdll/Makefile dlls/ctl3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3dim/Makefile dlls/d3drm/Makefile dlls/d3dx8/Makefile dlls/d3dxof/Makefile dlls/dbghelp/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnet/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/dxdiagn/Makefile dlls/dxerr8/Makefile dlls/dxerr9/Makefile dlls/dxguid/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/hhctrl.ocx/Makefile dlls/iccvid/Makefile dlls/icmp/Makefile dlls/ifsmgr.vxd/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/itss/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/lzexpand/tests/Makefile dlls/mapi32/Makefile dlls/mapi32/tests/Makefile dlls/mlang/Makefile dlls/mlang/tests/Makefile dlls/mmdevldr.vxd/Makefile dlls/monodebg.vxd/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msacm/tests/Makefile dlls/mscms/Makefile dlls/mscms/tests/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/msi/Makefile dlls/msi/tests/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile dlls/msvcrtd/Makefile dlls/msvcrtd/tests/Makefile dlls/msvidc32/Makefile dlls/msvideo/Makefile dlls/mswsock/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/ole32/tests/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile 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 dlls/quartz/Makefile dlls/quartz/tests/Makefile dlls/rasapi32/Makefile dlls/riched20/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/rsabase/Makefile dlls/rsabase/tests/Makefile dlls/rsaenh/Makefile dlls/rsaenh/tests/Makefile dlls/secur32/Makefile dlls/sensapi/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/stdole32.tlb/Makefile dlls/sti/Makefile dlls/strmiids/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/uuid/Makefile dlls/uxtheme/Makefile dlls/vdhcp.vxd/Makefile dlls/vdmdbg/Makefile dlls/version/Makefile dlls/version/tests/Makefile dlls/vmm.vxd/Makefile dlls/vnbt.vxd/Makefile dlls/vnetbios.vxd/Makefile dlls/vtdapi.vxd/Makefile dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winejack/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/wtsapi32/Makefile dlls/x11drv/Makefile documentation/Makefile fonts/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/msiexec/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/taskmgr/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile" cat >confcache <<\_ACEOF @@ -20708,6 +20708,7 @@ do "dlls/olepro32/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/olepro32/Makefile" ;; "dlls/olesvr/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/olesvr/Makefile" ;; "dlls/opengl32/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/opengl32/Makefile" ;; + "dlls/powrprof/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/powrprof/Makefile" ;; "dlls/psapi/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/psapi/Makefile" ;; "dlls/psapi/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/psapi/tests/Makefile" ;; "dlls/qcap/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/qcap/Makefile" ;; diff --git a/configure.ac b/configure.ac index 6e77d69562b..2df8318d0c9 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/dlls/Makefile.in b/dlls/Makefile.in index 812889126f1..8657ca896e9 100644 --- a/dlls/Makefile.in +++ b/dlls/Makefile.in @@ -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 diff --git a/dlls/powrprof/.cvsignore b/dlls/powrprof/.cvsignore new file mode 100644 index 00000000000..e583e462134 --- /dev/null +++ b/dlls/powrprof/.cvsignore @@ -0,0 +1,3 @@ +Makefile +powrprof.dll.dbg.c +powrprof.spec.def diff --git a/dlls/powrprof/Makefile.in b/dlls/powrprof/Makefile.in new file mode 100644 index 00000000000..100e3fd8af2 --- /dev/null +++ b/dlls/powrprof/Makefile.in @@ -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: diff --git a/dlls/powrprof/powrprof.c b/dlls/powrprof/powrprof.c new file mode 100644 index 00000000000..974b017eced --- /dev/null +++ b/dlls/powrprof/powrprof.c @@ -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; +} diff --git a/dlls/powrprof/powrprof.spec b/dlls/powrprof/powrprof.spec new file mode 100644 index 00000000000..3a461baff40 --- /dev/null +++ b/dlls/powrprof/powrprof.spec @@ -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) -- GitLab