Akihiro Sagawa : advapi32: Return required buffer size in RegLoadMUIString.
Alexandre Julliard
julliard at winehq.org
Mon May 13 16:24:17 CDT 2019
Module: wine
Branch: master
Commit: 4fe6460a3047806309c9b7bbedeb98b3f9fb5eb2
URL: https://source.winehq.org/git/wine.git/?a=commit;h=4fe6460a3047806309c9b7bbedeb98b3f9fb5eb2
Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date: Thu May 9 22:07:34 2019 +0900
advapi32: Return required buffer size in RegLoadMUIString.
Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/advapi32/registry.c | 10 ++++++++--
dlls/advapi32/tests/registry.c | 14 ++++++--------
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c
index 97561e2..7cf9ed1 100644
--- a/dlls/advapi32/registry.c
+++ b/dlls/advapi32/registry.c
@@ -3112,7 +3112,7 @@ LSTATUS WINAPI RegOpenUserClassesRoot(
* avoid importing user32, which is higher level than advapi32. Helper for
* RegLoadMUIString.
*/
-static LONG load_string(HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cMaxChars)
+static LONG load_string(HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cMaxChars, UINT *reqChars)
{
HGLOBAL hMemory;
HRSRC hResource;
@@ -3133,6 +3133,7 @@ static LONG load_string(HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cM
/* Strings are length-prefixed. Lowest nibble of resId is an index. */
idxString = resId & 0xf;
while (idxString--) pString += *pString + 1;
+ *reqChars = *pString + 1;
/* If no buffer is given, return here. */
if (!pwszBuffer) return ERROR_MORE_DATA;
@@ -3221,6 +3222,8 @@ LSTATUS WINAPI RegLoadMUIStringW(HKEY hKey, LPCWSTR pwszValue, LPWSTR pwszBuffer
result = ERROR_SUCCESS;
if (*pwszExpandedBuffer != '@') { /* '@' is the prefix for resource based string entries. */
lstrcpynW(pwszBuffer, pwszExpandedBuffer, cbBuffer / sizeof(WCHAR));
+ if (pcbData)
+ *pcbData = (strlenW(pwszExpandedBuffer) + 1) * sizeof(WCHAR);
} else {
WCHAR *pComma = strrchrW(pwszExpandedBuffer, ','), *pNewBuffer;
const WCHAR backslashW[] = {'\\',0};
@@ -3264,7 +3267,10 @@ LSTATUS WINAPI RegLoadMUIStringW(HKEY hKey, LPCWSTR pwszValue, LPWSTR pwszBuffer
hModule = LoadLibraryExW(pwszTempBuffer, NULL,
LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE);
if (hModule) {
- result = load_string(hModule, uiStringId, pwszBuffer, cbBuffer/sizeof(WCHAR));
+ DWORD reqChars;
+ result = load_string(hModule, uiStringId, pwszBuffer, cbBuffer/sizeof(WCHAR), &reqChars);
+ if (pcbData && (result == ERROR_SUCCESS || result == ERROR_MORE_DATA))
+ *pcbData = reqChars * sizeof(WCHAR);
FreeLibrary(hModule);
}
else
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index a1fcb5e..b8974f2 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -3892,7 +3892,7 @@ static void test_RegLoadMUIString(void)
size = 0xdeadbeef;
ret = pRegLoadMUIStringW(hkey, tz_valueW, NULL, 0, &size, 0, NULL);
ok(ret == ERROR_MORE_DATA, "got %d, expected ERROR_MORE_DATA\n", ret);
- todo_wine ok(size == text_size, "got %u, expected %u\n", size, text_size);
+ ok(size == text_size, "got %u, expected %u\n", size, text_size);
memset(bufW, 0xff, sizeof(bufW));
ret = pRegLoadMUIStringW(hkey, tz_valueW, bufW, sizeof(WCHAR)+1, &size, 0, NULL);
@@ -3903,7 +3903,7 @@ static void test_RegLoadMUIString(void)
memset(bufW, 0xff, sizeof(bufW));
ret = pRegLoadMUIStringW(hkey, tz_valueW, bufW, sizeof(WCHAR)*2, &size, 0, NULL);
todo_wine ok(ret == ERROR_MORE_DATA, "got %d, expected ERROR_MORE_DATA\n", ret);
- todo_wine ok(size == text_size || broken(size == text_size + sizeof(WCHAR) /* vista */),
+ ok(size == text_size || broken(size == text_size + sizeof(WCHAR) /* vista */),
"got %u, expected %u\n", size, text_size);
todo_wine ok(bufW[0] == 0xffff, "got 0x%04x, expected 0xffff\n", bufW[0]);
@@ -3911,9 +3911,8 @@ static void test_RegLoadMUIString(void)
memset(bufW, 0xff, sizeof(bufW));
ret = pRegLoadMUIStringW(hkey, tz_valueW, bufW, ARRAY_SIZE(bufW), &size, 0, NULL);
ok(ret == ERROR_SUCCESS, "got %d, expected ERROR_SUCCESS\n", ret);
- todo_wine ok(size == text_size, "got %u, expected %u\n", size, text_size);
- size = min(size, sizeof(bufW));
- todo_wine ok(!memcmp(textW, bufW, size), "got %s, expected %s\n",
+ ok(size == text_size, "got %u, expected %u\n", size, text_size);
+ ok(!memcmp(textW, bufW, size), "got %s, expected %s\n",
wine_dbgstr_wn(bufW, size / sizeof(WCHAR)), wine_dbgstr_wn(textW, text_size / sizeof(WCHAR)));
ret = pRegLoadMUIStringA(hkey, tz_value, buf, ARRAY_SIZE(buf), &size, 0, NULL);
@@ -3926,9 +3925,8 @@ static void test_RegLoadMUIString(void)
memset(bufW, 0xff, sizeof(bufW));
ret = pRegLoadMUIStringW(hkey, tz_valueW, bufW, ARRAY_SIZE(bufW), &size, 0, sysdirW);
ok(ret == ERROR_SUCCESS, "got %d, expected ERROR_SUCCESS\n", ret);
- todo_wine ok(size == text_size, "got %u, expected %u\n", size, text_size);
- size = min(size, sizeof(bufW));
- todo_wine ok(!memcmp(textW, bufW, size), "got %s, expected %s\n",
+ ok(size == text_size, "got %u, expected %u\n", size, text_size);
+ ok(!memcmp(textW, bufW, size), "got %s, expected %s\n",
wine_dbgstr_wn(bufW, size / sizeof(WCHAR)), wine_dbgstr_wn(textW, text_size / sizeof(WCHAR)));
ret = pRegLoadMUIStringA(hkey, tz_value, buf, ARRAY_SIZE(buf), &size, 0, sysdir);
More information about the wine-cvs
mailing list