add Wine's powrprof to build
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Tue, 6 Jun 2006 23:14:09 +0000 (23:14 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Tue, 6 Jun 2006 23:14:09 +0000 (23:14 +0000)
svn path=/trunk/; revision=22258

reactos/baseaddress.rbuild
reactos/dll/win32/powrprof/powrprof.c
reactos/dll/win32/powrprof/powrprof.rbuild [new file with mode: 0644]
reactos/dll/win32/powrprof/powrprof.rc [new file with mode: 0644]
reactos/dll/win32/powrprof/powrprof_gcc.def [new file with mode: 0644]
reactos/dll/win32/win32.rbuild
reactos/media/doc/README.WINE

index a426870..1ce6adc 100644 (file)
@@ -62,6 +62,7 @@
   <property name="BASEADDRESS_ICMP" value="0x741F0000" />
   <property name="BASEADDRESS_USERENV" value="0x74850000" />
   <property name="BASEADDRESS_SYSSETUP" value="0x74a30000" />
+  <property name="BASEADDRESS_POWRPROF" value="0x74ad0000" />
   <property name="BASEADDRESS_OLEDLG" value="0x74d00000" />
   <property name="BASEADDRESS_SAMSRV" value="0x74f30000" />
   <property name="BASEADDRESS_SAMLIB" value="0x750C0000" />
index 730246d..6005bee 100644 (file)
-/*\r
- * Copyright (C) 2005 Benjamin Cutler\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2.1 of the License, or (at your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA\r
- */\r
-\r
-\r
-#include <stdarg.h>\r
-\r
-#include "ntstatus.h"\r
-#define WIN32_NO_STATUS\r
-#include "windef.h"\r
-#include "winbase.h"\r
-#include "winnt.h"\r
-#include "winreg.h"\r
-#include "winternl.h"\r
-#include "powrprof.h"\r
-#include "wine/debug.h"\r
-#include "wine/unicode.h"\r
-\r
-WINE_DEFAULT_DEBUG_CHANNEL(powrprof);\r
-\r
-/* Notes to implementors:\r
- * #1: The native implementation of these functions attempted to read in\r
- * registry entries that I was unable to locate on any of the Windows\r
- * machines I checked, but I only had desktops available, so maybe\r
- * laptop users will have better luck. They return FNF errors because\r
- * that's what the native DLL was returning during my tests.\r
- * #2: These functions call NtPowerInformation but I don't know what they\r
- * do with the results, and NtPowerInformation doesn't do much in WINE yet\r
- * anyway.\r
- * #3: Since I can't get several other functions working (see note #1),\r
- * implementing these functions is going to have to wait until somebody can\r
- * cobble together some sane test input. */\r
-\r
-static const WCHAR szPowerCfgSubKey[] = { 'S', 'o', 'f', 't', 'w', 'a', 'r', 'e',\r
-       '\\', 'M', 'i', 'c', 'r', 'o', 's', 'o', 'f', 't', '\\', 'W', 'i',\r
-       'n', 'd', 'o', 'w', 's', '\\', 'C', 'u', 'r', 'r', 'e', 'n', 't',\r
-       'V', 'e', 'r', 's', 'i', 'o', 'n', '\\', 'C', 'o', 'n', 't', 'r',\r
-       'o', 'l', 's', ' ', 'F', 'o', 'l', 'd', 'e', 'r', '\\', 'P', 'o',\r
-       'w', 'e', 'r', 'C', 'f', 'g', 0 };\r
-static const WCHAR szSemaphoreName[] = { 'P', 'o', 'w', 'e', 'r', 'P', 'r', 'o',\r
-       'f', 'i', 'l', 'e', 'R', 'e', 'g', 'i', 's', 't', 'r', 'y', 'S',\r
-       'e', 'm', 'a', 'p', 'h', 'o', 'r', 'e', 0 };\r
-static const WCHAR szDiskMax[] = { 'D', 'i', 's', 'k', 'S', 'p', 'i', 'n', 'd',\r
-       'o', 'w', 'n', 'M', 'a', 'x', 0 };\r
-static const WCHAR szDiskMin[] = { 'D', 'i', 's', 'k', 'S', 'p', 'i', 'n', 'd',\r
-       'o', 'w', 'n', 'M', 'i', 'n', 0 };\r
-static const WCHAR szLastID[] = { 'L', 'a', 's', 't', 'I', 'D', 0 };\r
-static HANDLE PPRegSemaphore = NULL;\r
-\r
-NTSTATUS WINAPI CallNtPowerInformation(\r
-       POWER_INFORMATION_LEVEL InformationLevel,\r
-       PVOID lpInputBuffer, ULONG nInputBufferSize,\r
-       PVOID lpOutputBuffer, ULONG nOutputBufferSize)\r
-{\r
-   return NtPowerInformation(InformationLevel, lpInputBuffer,\r
-      nInputBufferSize, lpOutputBuffer, nOutputBufferSize);\r
-}\r
-\r
-BOOLEAN WINAPI CanUserWritePwrScheme(VOID)\r
-{\r
-   HKEY hKey = NULL;\r
-   LONG r;\r
-   BOOLEAN bSuccess = TRUE;\r
-\r
-   TRACE("()\n");\r
-\r
-   r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szPowerCfgSubKey, 0, KEY_READ | KEY_WRITE, &hKey);\r
-\r
-   if (r != ERROR_SUCCESS) {\r
-      TRACE("RegOpenKeyEx failed: %ld\n", r);\r
-      bSuccess = FALSE;\r
-   }\r
-\r
-   SetLastError(r);\r
-   RegCloseKey(hKey);\r
-   return bSuccess;\r
-}\r
-\r
-BOOLEAN WINAPI DeletePwrScheme(UINT uiIndex)\r
-{\r
-   /* FIXME: See note #1 */\r
-   FIXME("(%d) stub!\n", uiIndex);\r
-   SetLastError(ERROR_FILE_NOT_FOUND);\r
-   return FALSE;\r
-}\r
-\r
-BOOLEAN WINAPI EnumPwrSchemes(PWRSCHEMESENUMPROC lpfnPwrSchemesEnumProc,\r
-                       LPARAM lParam)\r
-{\r
-   /* FIXME: See note #1 */\r
-   FIXME("(%p, %ld) stub!\n", lpfnPwrSchemesEnumProc, lParam);\r
-   SetLastError(ERROR_FILE_NOT_FOUND);\r
-   return FALSE;\r
-}\r
-\r
-BOOLEAN WINAPI GetActivePwrScheme(PUINT puiID)\r
-{\r
-   /* FIXME: See note #1 */\r
-   FIXME("(%p) stub!\n", puiID);\r
-   SetLastError(ERROR_FILE_NOT_FOUND);\r
-   return FALSE;\r
-}\r
-\r
-BOOLEAN WINAPI GetCurrentPowerPolicies(\r
-       PGLOBAL_POWER_POLICY pGlobalPowerPolicy,\r
-       PPOWER_POLICY pPowerPolicy)\r
-{\r
-   /* FIXME: See note #2 */\r
-   SYSTEM_POWER_POLICY ACPower, DCPower;\r
-\r
-   FIXME("(%p, %p) stub!\n", pGlobalPowerPolicy, pPowerPolicy);\r
-\r
-   NtPowerInformation(SystemPowerPolicyAc, 0, 0, &ACPower, sizeof(SYSTEM_POWER_POLICY));\r
-   NtPowerInformation(SystemPowerPolicyDc, 0, 0, &DCPower, sizeof(SYSTEM_POWER_POLICY));\r
-\r
-   return FALSE;\r
-}\r
-\r
-BOOLEAN WINAPI GetPwrCapabilities(\r
-       PSYSTEM_POWER_CAPABILITIES lpSystemPowerCapabilities)\r
-{\r
-   NTSTATUS r;\r
-\r
-   TRACE("(%p)\n", lpSystemPowerCapabilities);\r
-\r
-   r = NtPowerInformation(SystemPowerCapabilities, 0, 0, lpSystemPowerCapabilities, sizeof(SYSTEM_POWER_CAPABILITIES));\r
-\r
-   SetLastError(RtlNtStatusToDosError(r));\r
-\r
-   return r == STATUS_SUCCESS;\r
-}\r
-\r
-BOOLEAN WINAPI GetPwrDiskSpindownRange(PUINT RangeMax, PUINT RangeMin)\r
-{\r
-   HKEY hKey;\r
-   BYTE lpValue[40];\r
-   LONG r;\r
-   DWORD cbValue = sizeof(lpValue);\r
-\r
-   TRACE("(%p, %p)\n", RangeMax, RangeMin);\r
-\r
-   if (RangeMax == NULL || RangeMin == NULL) {\r
-      SetLastError(ERROR_INVALID_PARAMETER);\r
-      return FALSE;\r
-   }\r
-\r
-   SetLastError(ERROR_SUCCESS);\r
-\r
-   WaitForSingleObject(PPRegSemaphore, INFINITE);\r
-\r
-   r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szPowerCfgSubKey, 0, KEY_READ, &hKey);\r
-   if (r != ERROR_SUCCESS) {\r
-      TRACE("RegOpenKeyEx failed: %ld\n", r);\r
-      TRACE("Using defaults: 3600, 3\n");\r
-      *RangeMax = 3600;\r
-      *RangeMin = 3;\r
-      ReleaseSemaphore(PPRegSemaphore, 1, NULL);\r
-      return TRUE;\r
-   }\r
-\r
-   r = RegQueryValueExW(hKey, szDiskMax, 0, 0, lpValue, &cbValue);\r
-   if (r != ERROR_SUCCESS) {\r
-      TRACE("Couldn't open DiskSpinDownMax: %ld\n", r);\r
-      TRACE("Using default: 3600\n");\r
-      *RangeMax = 3600;\r
-   } else {\r
-      *RangeMax = atoiW((LPCWSTR)lpValue);\r
-   }\r
-\r
-   cbValue = sizeof(lpValue);\r
-\r
-   r = RegQueryValueExW(hKey, szDiskMin, 0, 0, lpValue, &cbValue);\r
-   if (r != ERROR_SUCCESS) {\r
-      TRACE("Couldn't open DiskSpinDownMin: %ld\n", r);\r
-      TRACE("Using default: 3\n");\r
-      *RangeMin = 3;\r
-   } else {\r
-      *RangeMin = atoiW((LPCWSTR)lpValue);\r
-   }\r
-\r
-   RegCloseKey(hKey);\r
-\r
-   ReleaseSemaphore(PPRegSemaphore, 1, NULL);\r
-\r
-   return TRUE;\r
-}\r
-\r
-BOOLEAN WINAPI IsAdminOverrideActive(PADMINISTRATOR_POWER_POLICY p)\r
-{\r
-   FIXME("( %p) stub!\n", p);\r
-   return FALSE;\r
-}\r
-\r
-BOOLEAN WINAPI IsPwrHibernateAllowed(VOID)\r
-{\r
-   /* FIXME: See note #2 */\r
-   SYSTEM_POWER_CAPABILITIES PowerCaps;\r
-   FIXME("() stub!\n");\r
-   NtPowerInformation(SystemPowerCapabilities, NULL, 0, &PowerCaps, sizeof(PowerCaps));\r
-   return FALSE;\r
-}\r
-\r
-BOOLEAN WINAPI IsPwrShutdownAllowed(VOID)\r
-{\r
-   /* FIXME: See note #2 */\r
-   SYSTEM_POWER_CAPABILITIES PowerCaps;\r
-   FIXME("() stub!\n");\r
-   NtPowerInformation(SystemPowerCapabilities, NULL, 0, &PowerCaps, sizeof(PowerCaps));\r
-   return FALSE;\r
-}\r
-\r
-BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)\r
-{\r
-   /* FIXME: See note #2 */\r
-   SYSTEM_POWER_CAPABILITIES PowerCaps;\r
-   FIXME("() stub!\n");\r
-   NtPowerInformation(SystemPowerCapabilities, NULL, 0, &PowerCaps, sizeof(PowerCaps));\r
-   return FALSE;\r
-}\r
-\r
-BOOLEAN WINAPI ReadGlobalPwrPolicy(PGLOBAL_POWER_POLICY pGlobalPowerPolicy)\r
-{\r
-   /* FIXME: See note #1 */\r
-   FIXME("(%p) stub!\n", pGlobalPowerPolicy);\r
-   SetLastError(ERROR_FILE_NOT_FOUND);\r
-   return FALSE;\r
-}\r
-\r
-BOOLEAN WINAPI ReadProcessorPwrScheme(UINT uiID,\r
-                       PMACHINE_PROCESSOR_POWER_POLICY pMachineProcessorPowerPolicy)\r
-{\r
-   /* FIXME: See note #1 */\r
-   FIXME("(%d, %p) stub!\n", uiID, pMachineProcessorPowerPolicy);\r
-   SetLastError(ERROR_FILE_NOT_FOUND);\r
-   return FALSE;\r
-}\r
-\r
-BOOLEAN WINAPI ReadPwrScheme(UINT uiID,\r
-       PPOWER_POLICY pPowerPolicy)\r
-{\r
-   /* FIXME: See note #1 */\r
-   FIXME("(%d, %p) stub!\n", uiID, pPowerPolicy);\r
-   SetLastError(ERROR_FILE_NOT_FOUND);\r
-   return FALSE;\r
-}\r
-\r
-BOOLEAN WINAPI SetActivePwrScheme(UINT uiID,\r
-       PGLOBAL_POWER_POLICY lpGlobalPowerPolicy,\r
-       PPOWER_POLICY lpPowerPolicy)\r
-{\r
-   /* FIXME: See note #1 */\r
-   FIXME("(%d, %p, %p) stub!\n", uiID, lpGlobalPowerPolicy, lpPowerPolicy);\r
-   SetLastError(ERROR_FILE_NOT_FOUND);\r
-   return FALSE;\r
-}\r
-\r
-BOOLEAN WINAPI SetSuspendState(BOOLEAN Hibernate, BOOLEAN ForceCritical,\r
-       BOOLEAN DisableWakeEvent)\r
-{\r
-   /* FIXME: I have NO idea how you're supposed to call NtInitiatePowerAction\r
-    * here, because it's not a documented function that I can find */\r
-   FIXME("(%d, %d, %d) stub!\n", Hibernate, ForceCritical, DisableWakeEvent);\r
-   return TRUE;\r
-}\r
-\r
-BOOLEAN WINAPI WriteGlobalPwrPolicy(PGLOBAL_POWER_POLICY pGlobalPowerPolicy)\r
-{\r
-   /* FIXME: See note #3 */\r
-   FIXME("(%p) stub!\n", pGlobalPowerPolicy);\r
-   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);\r
-   return FALSE;\r
-}\r
-\r
-BOOLEAN WINAPI WriteProcessorPwrScheme(UINT ID,\r
-       PMACHINE_PROCESSOR_POWER_POLICY pMachineProcessorPowerPolicy)\r
-{\r
-   /* FIXME: See note #3 */\r
-   FIXME("(%d, %p) stub!\n", ID, pMachineProcessorPowerPolicy);\r
-   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);\r
-   return FALSE;\r
-}\r
-\r
-BOOLEAN WINAPI WritePwrScheme(PUINT puiID, LPWSTR lpszName, LPWSTR lpszDescription,\r
-       PPOWER_POLICY pPowerPolicy)\r
-{\r
-   /* FIXME: See note #3 */\r
-   FIXME("(%p, %s, %s, %p) stub!\n", puiID, debugstr_w(lpszName), debugstr_w(lpszDescription), pPowerPolicy);\r
-   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);\r
-   return FALSE;\r
-}\r
-\r
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)\r
-{\r
-   FIXME("(%p, %ld, %p) not fully implemented\n", hinstDLL, fdwReason, lpvReserved);\r
-\r
-   switch(fdwReason) {\r
-      case DLL_PROCESS_ATTACH: {\r
-\r
-         HKEY hKey;\r
-         LONG r;\r
-\r
-         DisableThreadLibraryCalls(hinstDLL);\r
-\r
-         r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szPowerCfgSubKey, 0, KEY_READ | KEY_WRITE, &hKey);\r
-\r
-         if (r != ERROR_SUCCESS) {\r
-            TRACE("Couldn't open registry key HKLM\\%s, using some sane(?) defaults\n", debugstr_w(szPowerCfgSubKey));\r
-         } else {\r
-            BYTE lpValue[40];\r
-            DWORD cbValue = sizeof(lpValue);\r
-            r = RegQueryValueExW(hKey, szLastID, 0, 0, lpValue, &cbValue);\r
-            if (r != ERROR_SUCCESS) {\r
-               TRACE("Couldn't open registry entry HKLM\\%s\\LastID, using some sane(?) defaults\n", debugstr_w(szPowerCfgSubKey));\r
-            }\r
-            RegCloseKey(hKey);\r
-         }\r
-\r
-         PPRegSemaphore = CreateSemaphoreW(NULL, 1, 1, szSemaphoreName);\r
-         if (PPRegSemaphore == NULL) {\r
-            ERR("Couldn't create Semaphore: %ld\n", GetLastError());\r
-            return FALSE;\r
-         }\r
-         break;\r
-      }\r
-      case DLL_PROCESS_DETACH:\r
-         CloseHandle(PPRegSemaphore);\r
-         break;\r
-    }\r
-    return TRUE;\r
-}\r
+/*
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+
+#include <stdarg.h>
+
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
+#include "windef.h"
+#include "winbase.h"
+#include "winnt.h"
+#include "winreg.h"
+#include "winternl.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 r;
+   DWORD cbValue = sizeof(lpValue);
+
+   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 = sizeof(lpValue);
+
+   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 IsAdminOverrideActive(PADMINISTRATOR_POWER_POLICY p)
+{
+   FIXME("( %p) stub!\n", p);
+   return FALSE;
+}
+
+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];
+            DWORD cbValue = sizeof(lpValue);
+            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/reactos/dll/win32/powrprof/powrprof.rbuild b/reactos/dll/win32/powrprof/powrprof.rbuild
new file mode 100644 (file)
index 0000000..144615c
--- /dev/null
@@ -0,0 +1,19 @@
+<module name="powrprof" type="win32dll" baseaddress="${BASEADDRESS_POWRPROF}" installbase="system32" installname="powrprof.dll" allowwarnings="true">
+       <importlibrary definition="powrprof_gcc.def" />
+       <include base="ReactOS">include/wine</include>
+       <define name="_DISABLE_TIDENTS" />
+       <define name="__REACTOS__" />
+       <define name="__USE_W32API" />
+       <define name="UNICODE" />
+       <define name="_UNICODE" />
+       <define name="_WIN32_IE">0x600</define>
+       <define name="_WIN32_WINNT">0x501</define>
+       <define name="WINVER">0x501</define>
+       <library>wine</library>
+       <library>ntdll</library>
+       <library>rtl</library>
+       <library>kernel32</library>
+       <library>ntoskrnl</library>
+       <file>powrprof.c</file>
+       <file>powrprof.rc</file>
+</module>
diff --git a/reactos/dll/win32/powrprof/powrprof.rc b/reactos/dll/win32/powrprof/powrprof.rc
new file mode 100644 (file)
index 0000000..0249dc8
--- /dev/null
@@ -0,0 +1,10 @@
+/* $Id: version.rc 12852 2005-01-06 13:58:04Z mf $ */
+
+#include "powrprof.h"
+//#include "misc.h"
+//#include "type.h"
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION   "Power Profile Helper DLL\0"
+#define REACTOS_STR_INTERNAL_NAME      "powerprof\0"
+#define REACTOS_STR_ORIGINAL_FILENAME  "powerprof.dll\0"
+#include <reactos/version.rc>
diff --git a/reactos/dll/win32/powrprof/powrprof_gcc.def b/reactos/dll/win32/powrprof/powrprof_gcc.def
new file mode 100644 (file)
index 0000000..b4d8413
--- /dev/null
@@ -0,0 +1,36 @@
+
+; $Id: version.def 12852 2005-01-06 13:58:04Z mf $
+; ReactOS Operating System
+;
+LIBRARY powrprof.dll
+EXPORTS
+CallNtPowerInformation@20
+;NtPowerInformation@20=ntokrnl._NtPowerInformation@20
+CanUserWritePwrScheme@0
+;DebugPrintA
+;DllInitialize
+DeletePwrScheme@4
+;DevicePowerClose
+;DevicePowerEnumDevices
+;DevicePowerOpen
+;DevicePowerSetDeviceState
+EnumPwrSchemes@8
+GetActivePwrScheme@4
+GetCurrentPowerPolicies@8
+GetPwrCapabilities@4
+GetPwrDiskSpindownRange@8
+IsAdminOverrideActive@4
+IsPwrHibernateAllowed@0
+IsPwrShutdownAllowed@0
+IsPwrSuspendAllowed@0
+;LoadCurrentPwrScheme
+;MergeLegacyPwrScheme
+ReadGlobalPwrPolicy@4
+ReadProcessorPwrScheme@8
+ReadPwrScheme@8
+SetActivePwrScheme@12
+SetSuspendState@12
+;ValidatePowerPolicies@8
+WriteGlobalPwrPolicy@4
+WriteProcessorPwrScheme@8
+WritePwrScheme@16
\ No newline at end of file
index 7079112..a6a946b 100644 (file)
 <directory name="opengl32">
        <xi:include href="opengl32/opengl32.rbuild" />
 </directory>
+<directory name="powrprof">
+       <xi:include href="powrprof/powrprof.rbuild" />
+</directory>
 <directory name="psapi">
        <xi:include href="psapi/psapi.rbuild" />
 </directory>
index 5c5565e..137707b 100644 (file)
@@ -62,6 +62,7 @@ reactos/dll/win32/oleacc          # Synced to Wine-0_9_10
 reactos/dll/win32/oleaut32        # Synced to Wine-0_9_10
 reactos/dll/win32/oledlg          # Synced to Wine-0_9_5
 reactos/dll/win32/olepro32        # Synced to Wine-0_9_10
+reactos/dll/win32/powrprof        # Synced to Wine-0_9_14
 reactos/dll/win32/riched20        # Synced to Wine-0_9_5
 reactos/dll/win32/richedit        # Synced to Wine-0_9_10
 reactos/dll/win32/rpcrt4          # Synced to Wine-0_9_10