fix function GetAllUsersProfileDirectoryW
From: 纯真的电灯泡1011726441@qq.com
--- dlls/userenv/userenv_main.c | 62 +++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-)
diff --git a/dlls/userenv/userenv_main.c b/dlls/userenv/userenv_main.c index cadb45c1a74..3e71a88771f 100644 --- a/dlls/userenv/userenv_main.c +++ b/dlls/userenv/userenv_main.c @@ -587,10 +587,66 @@ BOOL WINAPI GetAllUsersProfileDirectoryA( LPSTR lpProfileDir, LPDWORD lpcchSize return FALSE; }
-BOOL WINAPI GetAllUsersProfileDirectoryW( LPWSTR lpProfileDir, LPDWORD lpcchSize ) +BOOL WINAPI GetAllUsersProfileDirectoryW(LPWSTR lpProfileDir, LPDWORD lpcchSize) { - FIXME("%p %p\n", lpProfileDir, lpcchSize); - return FALSE; + LONG l; + HKEY key; + BOOL ret = FALSE; + DWORD len = 0, expanded_len; + LPWSTR unexpanded_profiles_dir = NULL; + + TRACE("%p %p\n", lpProfilesDir, lpcchSize); + + if (!lpcchSize) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + l = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"Software\Microsoft\Windows NT\CurrentVersion\ProfileList", + 0, KEY_READ, &key); + if (l) + { + SetLastError(l); + return FALSE; + } + l = RegQueryValueExW(key, L"ProgramData", NULL, NULL, NULL, &len); + if (l) + { + SetLastError(l); + goto end; + } + unexpanded_profiles_dir = HeapAlloc(GetProcessHeap(), 0, len); + if (!unexpanded_profiles_dir) + { + SetLastError(ERROR_OUTOFMEMORY); + goto end; + } + l = RegQueryValueExW(key, L"ProgramData", NULL, NULL, + (BYTE *)unexpanded_profiles_dir, &len); + if (l) + { + SetLastError(l); + goto end; + } + expanded_len = ExpandEnvironmentStringsW(unexpanded_profiles_dir, NULL, 0); + /* The returned length doesn't include the NULL terminator. */ + if (*lpcchSize < expanded_len - 1 || !lpProfilesDir) + { + *lpcchSize = expanded_len - 1; + SetLastError(ERROR_INSUFFICIENT_BUFFER); + goto end; + } + *lpcchSize = expanded_len - 1; + /* The return value is also the expected length. */ + ret = ExpandEnvironmentStringsW(unexpanded_profiles_dir, lpProfilesDir, + expanded_len) - + 1; +end: + HeapFree(GetProcessHeap(), 0, unexpanded_profiles_dir); + RegCloseKey(key); + return ret; }
BOOL WINAPI GetProfileType( DWORD *pdwFlags )
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=141519
Your paranoid android.
=== debian11 (build log) ===
../wine/dlls/userenv/userenv_main.c:598:22: error: ���lpProfilesDir��� undeclared (first use in this function); did you mean ���lpProfileDir���? Task: The win32 Wine build failed
=== debian11b (build log) ===
../wine/dlls/userenv/userenv_main.c:598:22: error: ���lpProfilesDir��� undeclared (first use in this function); did you mean ���lpProfileDir���? Task: The wow64 Wine build failed