wintrust: Set last error in WinVerifyTrust.

Signed-off-by: Daniel Lehman <dlehman25@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Daniel Lehman 2020-02-24 22:22:01 -08:00 committed by Alexandre Julliard
parent 690fbf64b8
commit 95a80d3585
2 changed files with 11 additions and 0 deletions

View File

@ -845,7 +845,9 @@ static void test_wintrust(void)
file.pcwszFilePath = pathW;
/* Test with an empty file */
file.hFile = create_temp_file(pathW);
SetLastError(0xdeadbeef);
r = WinVerifyTrust(INVALID_HANDLE_VALUE, &generic_action_v2, &wtd);
ok(r == GetLastError(), "expected %08x, got %08x\n", GetLastError(), r);
ok(r == TRUST_E_SUBJECT_FORM_UNKNOWN,
"expected TRUST_E_SUBJECT_FORM_UNKNOWN, got %08x\n", r);
CloseHandle(file.hFile);
@ -853,18 +855,26 @@ static void test_wintrust(void)
file.hFile = NULL;
/* Test with a known file path, which we expect not have a signature */
getNotepadPath(pathW, MAX_PATH);
SetLastError(0xdeadbeef);
r = WinVerifyTrust(INVALID_HANDLE_VALUE, &generic_action_v2, &wtd);
ok(r == GetLastError(), "expected %08x, got %08x\n", GetLastError(), r);
ok(r == TRUST_E_NOSIGNATURE || r == CRYPT_E_FILE_ERROR,
"expected TRUST_E_NOSIGNATURE or CRYPT_E_FILE_ERROR, got %08x\n", r);
wtd.dwStateAction = WTD_STATEACTION_CLOSE;
SetLastError(0xdeadbeef);
r = WinVerifyTrust(INVALID_HANDLE_VALUE, &generic_action_v2, &wtd);
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %08x\n", GetLastError());
ok(r == S_OK, "WinVerifyTrust failed: %08x\n", r);
wtd.dwStateAction = WTD_STATEACTION_VERIFY;
SetLastError(0xdeadbeef);
hr = WinVerifyTrustEx(INVALID_HANDLE_VALUE, &generic_action_v2, &wtd);
ok(hr == GetLastError(), "expected %08x, got %08x\n", GetLastError(), hr);
ok(hr == TRUST_E_NOSIGNATURE || hr == CRYPT_E_FILE_ERROR,
"expected TRUST_E_NOSIGNATURE or CRYPT_E_FILE_ERROR, got %08x\n", hr);
wtd.dwStateAction = WTD_STATEACTION_CLOSE;
SetLastError(0xdeadbeef);
r = WinVerifyTrust(INVALID_HANDLE_VALUE, &generic_action_v2, &wtd);
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %08x\n", GetLastError());
ok(r == S_OK, "WinVerifyTrust failed: %08x\n", r);
}

View File

@ -732,6 +732,7 @@ LONG WINAPI WinVerifyTrust( HWND hwnd, GUID *ActionID, LPVOID ActionData )
}
}
if (err) SetLastError(err);
TRACE("returning %08x\n", err);
return err;
}