advapi32: Fix the error code on load failure.

Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Akihiro Sagawa 2019-05-26 21:15:09 +09:00 committed by Alexandre Julliard
parent cb555215a9
commit 62f5210364
2 changed files with 9 additions and 11 deletions

View File

@ -3133,6 +3133,10 @@ static INT load_string(HINSTANCE hModule, UINT resId, LPWSTR *pResString)
/* Strings are length-prefixed. Lowest nibble of resId is an index. */
idxString = resId & 0xf;
while (idxString--) pString += *pString + 1;
if (!*pString) {
SetLastError(ERROR_NOT_FOUND);
return 0;
}
*pResString = pString + 1;
return *pString;
@ -3153,11 +3157,11 @@ static LONG load_mui_string(const WCHAR *file_name, UINT res_id, WCHAR *buffer,
hModule = LoadLibraryExW(file_name, NULL,
LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE);
if (!hModule)
return ERROR_BADKEY;
return GetLastError();
size = load_string(hModule, res_id, &string);
if (!size) {
result = ERROR_FILE_NOT_FOUND;
result = GetLastError();
goto cleanup;
}
*req_chars = size + 1;
@ -3210,10 +3214,6 @@ cleanup:
* RETURNS
* Success: ERROR_SUCCESS,
* Failure: nonzero error code from winerror.h
*
* NOTES
* This is an API of Windows Vista, which wasn't available at the time this code
* was written. We have to check for the correct behaviour once it's available.
*/
LSTATUS WINAPI RegLoadMUIStringW(HKEY hKey, LPCWSTR pwszValue, LPWSTR pwszBuffer, DWORD cbBuffer,
LPDWORD pcbData, DWORD dwFlags, LPCWSTR pwszBaseDir)

View File

@ -3854,7 +3854,6 @@ static void test_RegLoadMUIString(void)
BOOL use_sysdir;
DWORD expected;
DWORD broken_ret;
BOOL todo;
} test_case[] = {
/* 0 */
{ "", REG_SZ, FALSE, ERROR_INVALID_DATA },
@ -3868,9 +3867,9 @@ static void test_RegLoadMUIString(void)
{ "@%WineMuiTest2%", REG_EXPAND_SZ, TRUE, ERROR_SUCCESS },
/* 8 */
{ "@%WineMuiExe%,a", REG_SZ, FALSE, ERROR_INVALID_DATA },
{ "@%WineMuiExe%,-4", REG_SZ, FALSE, ERROR_NOT_FOUND, ERROR_FILE_NOT_FOUND, TRUE },
{ "@%WineMuiExe%,-39", REG_SZ, FALSE, ERROR_RESOURCE_NAME_NOT_FOUND, 0, TRUE },
{ "@%WineMuiDat%,-16", REG_EXPAND_SZ, FALSE, ERROR_BAD_EXE_FORMAT, ERROR_FILE_NOT_FOUND, TRUE },
{ "@%WineMuiExe%,-4", REG_SZ, FALSE, ERROR_NOT_FOUND, ERROR_FILE_NOT_FOUND },
{ "@%WineMuiExe%,-39", REG_SZ, FALSE, ERROR_RESOURCE_NAME_NOT_FOUND },
{ "@%WineMuiDat%,-16", REG_EXPAND_SZ, FALSE, ERROR_BAD_EXE_FORMAT, ERROR_FILE_NOT_FOUND },
};
if (!pRegLoadMUIStringA || !pRegLoadMUIStringW)
@ -4013,7 +4012,6 @@ static void test_RegLoadMUIString(void)
ret = pRegLoadMUIStringW(hkey_main, tz_valueW, bufW, ARRAY_SIZE(bufW),
&size, 0,
test_case[i].use_sysdir ? sysdirW : NULL);
todo_wine_if(test_case[i].todo)
ok(ret == test_case[i].expected ||
broken(test_case[i].value[0] == '%' && ret == ERROR_SUCCESS /* vista */) ||
broken(test_case[i].broken_ret && ret == test_case[i].broken_ret /* vista */),