advapi32: Return required buffer size in RegLoadMUIString.
Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2d9a7cd39d
commit
4fe6460a30
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue