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:
parent
cb555215a9
commit
62f5210364
@ -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. */
|
/* Strings are length-prefixed. Lowest nibble of resId is an index. */
|
||||||
idxString = resId & 0xf;
|
idxString = resId & 0xf;
|
||||||
while (idxString--) pString += *pString + 1;
|
while (idxString--) pString += *pString + 1;
|
||||||
|
if (!*pString) {
|
||||||
|
SetLastError(ERROR_NOT_FOUND);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
*pResString = pString + 1;
|
*pResString = pString + 1;
|
||||||
return *pString;
|
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,
|
hModule = LoadLibraryExW(file_name, NULL,
|
||||||
LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE);
|
LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE);
|
||||||
if (!hModule)
|
if (!hModule)
|
||||||
return ERROR_BADKEY;
|
return GetLastError();
|
||||||
|
|
||||||
size = load_string(hModule, res_id, &string);
|
size = load_string(hModule, res_id, &string);
|
||||||
if (!size) {
|
if (!size) {
|
||||||
result = ERROR_FILE_NOT_FOUND;
|
result = GetLastError();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
*req_chars = size + 1;
|
*req_chars = size + 1;
|
||||||
@ -3210,10 +3214,6 @@ cleanup:
|
|||||||
* RETURNS
|
* RETURNS
|
||||||
* Success: ERROR_SUCCESS,
|
* Success: ERROR_SUCCESS,
|
||||||
* Failure: nonzero error code from winerror.h
|
* 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,
|
LSTATUS WINAPI RegLoadMUIStringW(HKEY hKey, LPCWSTR pwszValue, LPWSTR pwszBuffer, DWORD cbBuffer,
|
||||||
LPDWORD pcbData, DWORD dwFlags, LPCWSTR pwszBaseDir)
|
LPDWORD pcbData, DWORD dwFlags, LPCWSTR pwszBaseDir)
|
||||||
|
@ -3854,7 +3854,6 @@ static void test_RegLoadMUIString(void)
|
|||||||
BOOL use_sysdir;
|
BOOL use_sysdir;
|
||||||
DWORD expected;
|
DWORD expected;
|
||||||
DWORD broken_ret;
|
DWORD broken_ret;
|
||||||
BOOL todo;
|
|
||||||
} test_case[] = {
|
} test_case[] = {
|
||||||
/* 0 */
|
/* 0 */
|
||||||
{ "", REG_SZ, FALSE, ERROR_INVALID_DATA },
|
{ "", REG_SZ, FALSE, ERROR_INVALID_DATA },
|
||||||
@ -3868,9 +3867,9 @@ static void test_RegLoadMUIString(void)
|
|||||||
{ "@%WineMuiTest2%", REG_EXPAND_SZ, TRUE, ERROR_SUCCESS },
|
{ "@%WineMuiTest2%", REG_EXPAND_SZ, TRUE, ERROR_SUCCESS },
|
||||||
/* 8 */
|
/* 8 */
|
||||||
{ "@%WineMuiExe%,a", REG_SZ, FALSE, ERROR_INVALID_DATA },
|
{ "@%WineMuiExe%,a", REG_SZ, FALSE, ERROR_INVALID_DATA },
|
||||||
{ "@%WineMuiExe%,-4", REG_SZ, FALSE, ERROR_NOT_FOUND, 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, 0, TRUE },
|
{ "@%WineMuiExe%,-39", REG_SZ, FALSE, ERROR_RESOURCE_NAME_NOT_FOUND },
|
||||||
{ "@%WineMuiDat%,-16", REG_EXPAND_SZ, FALSE, ERROR_BAD_EXE_FORMAT, ERROR_FILE_NOT_FOUND, TRUE },
|
{ "@%WineMuiDat%,-16", REG_EXPAND_SZ, FALSE, ERROR_BAD_EXE_FORMAT, ERROR_FILE_NOT_FOUND },
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!pRegLoadMUIStringA || !pRegLoadMUIStringW)
|
if (!pRegLoadMUIStringA || !pRegLoadMUIStringW)
|
||||||
@ -4013,7 +4012,6 @@ static void test_RegLoadMUIString(void)
|
|||||||
ret = pRegLoadMUIStringW(hkey_main, tz_valueW, bufW, ARRAY_SIZE(bufW),
|
ret = pRegLoadMUIStringW(hkey_main, tz_valueW, bufW, ARRAY_SIZE(bufW),
|
||||||
&size, 0,
|
&size, 0,
|
||||||
test_case[i].use_sysdir ? sysdirW : NULL);
|
test_case[i].use_sysdir ? sysdirW : NULL);
|
||||||
todo_wine_if(test_case[i].todo)
|
|
||||||
ok(ret == test_case[i].expected ||
|
ok(ret == test_case[i].expected ||
|
||||||
broken(test_case[i].value[0] == '%' && ret == ERROR_SUCCESS /* vista */) ||
|
broken(test_case[i].value[0] == '%' && ret == ERROR_SUCCESS /* vista */) ||
|
||||||
broken(test_case[i].broken_ret && ret == test_case[i].broken_ret /* vista */),
|
broken(test_case[i].broken_ret && ret == test_case[i].broken_ret /* vista */),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user