From: Robert Lippmann robert.lippmann.development@gmail.com
--- dlls/powrprof/powrprof.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/dlls/powrprof/powrprof.c b/dlls/powrprof/powrprof.c index c3078decc87..c6a9bf8c56c 100644 --- a/dlls/powrprof/powrprof.c +++ b/dlls/powrprof/powrprof.c @@ -305,8 +305,8 @@ DWORD WINAPI PowerGetActiveScheme(HKEY UserRootPowerKey, GUID **polguid) FIXME("should use registry\n"); /* Windows throws an access violation if **polguid is NULL, so I guess we will too. */ - TRACE("*polguid %p, active_power_scheme %s\n", wine_dbgstr_point(*polguid), - debugstr_guid(*active_power_scheme)); + TRACE("*polguid %p, active_power_scheme %s\n",*polguid, + debugstr_guid(active_power_scheme)); /* Windows SDK docs say use LocalFree to free this */ *polguid = LocalAlloc(LMEM_FIXED, sizeof(GUID)); if (*polguid == NULL) @@ -322,7 +322,7 @@ DWORD WINAPI PowerSetActiveScheme(HKEY UserRootPowerKey, GUID *polguid) size_t i;
FIXME("should use registry\n"); - TRACE("polguid %s\n", debugstr_guid(*polguid)); + TRACE("polguid %s\n", debugstr_guid((const GUID *)polguid)); for (i = 0; i < ARRAYSIZE(valid_power_schemes); i++) { if (IsEqualGUID(polguid, valid_power_schemes[i].guid)) @@ -346,7 +346,7 @@ DWORD WINAPI PowerReadFriendlyName(HKEY RootPowerKey, const GUID *Scheme, { size_t i; const WCHAR *name; - DWORD name_len, result; + DWORD buffer_size = sizeof(GUID), result; GUID current_guid;
FIXME("should use registry\n"); @@ -358,9 +358,10 @@ DWORD WINAPI PowerReadFriendlyName(HKEY RootPowerKey, const GUID *Scheme, } for (i = 0; ; i++) { - result = PowerEnumerate(NULL, NULL, NULL, ACCESS_SCHEME, i, (UCHAR *)¤t_guid, sizeof(GUID)); + result = PowerEnumerate(NULL, NULL, NULL, ACCESS_SCHEME, i, (UCHAR *)¤t_guid, &buffer_size); if (result != ERROR_SUCCESS) { + ERR("PowerEnumerate failed: %lu\n", result); return result; } if (result == ERROR_NO_MORE_ITEMS) @@ -370,14 +371,14 @@ DWORD WINAPI PowerReadFriendlyName(HKEY RootPowerKey, const GUID *Scheme, if (IsEqualGUID(Scheme, ¤t_guid)) { name = valid_power_schemes[i].name; - name_len = (wcslen(name) + 1) * sizeof(WCHAR); - if (*BufferSize < name_len) + buffer_size = (wcslen(name) + 1) * sizeof(WCHAR); + if (*BufferSize < buffer_size) { - *BufferSize = name_len; + *BufferSize = buffer_size; return ERROR_MORE_DATA; } - memcpy(Buffer, name, name_len); - *BufferSize = name_len; + memcpy(Buffer, name, buffer_size); + *BufferSize = buffer_size; return ERROR_SUCCESS; } }