wintrust: Implemented WintrustAddDefaultForUsage.
This commit is contained in:
parent
199c5f0ba9
commit
181574a1b4
|
@ -681,14 +681,85 @@ static void WINTRUST_RegisterGenChainVerify(void)
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* WintrustAddDefaultForUsage (WINTRUST.@)
|
* WintrustAddDefaultForUsage (WINTRUST.@)
|
||||||
|
*
|
||||||
|
* Write OID and callback functions to the registry.
|
||||||
|
*
|
||||||
|
* PARAMS
|
||||||
|
* pszUsageOID [I] Pointer to a GUID.
|
||||||
|
* psDefUsage [I] Pointer to a structure that specifies the callback functions.
|
||||||
|
*
|
||||||
|
* RETURNS
|
||||||
|
* Success: TRUE.
|
||||||
|
* Failure: FALSE.
|
||||||
|
*
|
||||||
|
* NOTES
|
||||||
|
* WintrustAddDefaultForUsage will only return TRUE or FALSE, no last
|
||||||
|
* error is set, not even when the registry cannot be written to.
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI WintrustAddDefaultForUsage(const CHAR *pszUsageOID,
|
BOOL WINAPI WintrustAddDefaultForUsage(const CHAR *pszUsageOID,
|
||||||
CRYPT_PROVIDER_REGDEFUSAGE *psDefUsage)
|
CRYPT_PROVIDER_REGDEFUSAGE *psDefUsage)
|
||||||
{
|
{
|
||||||
FIXME("(%s %p) stub\n", debugstr_a(pszUsageOID), psDefUsage);
|
static const WCHAR CBAlloc[] = {'C','a','l','l','b','a','c','k','A','l','l','o','c','F','u','n','c','t','i','o','n', 0};
|
||||||
|
static const WCHAR CBFree[] = {'C','a','l','l','b','a','c','k','F','r','e','e','F','u','n','c','t','i','o','n', 0};
|
||||||
|
LONG Res = ERROR_SUCCESS;
|
||||||
|
LONG WriteUsageError = ERROR_SUCCESS;
|
||||||
|
DWORD Len;
|
||||||
|
WCHAR GuidString[39];
|
||||||
|
|
||||||
|
TRACE("(%s %p)\n", debugstr_a(pszUsageOID), psDefUsage);
|
||||||
|
|
||||||
|
/* Some sanity checks. */
|
||||||
|
if (!pszUsageOID ||
|
||||||
|
!psDefUsage ||
|
||||||
|
!psDefUsage->pgActionID ||
|
||||||
|
(psDefUsage->cbStruct != sizeof(CRYPT_PROVIDER_REGDEFUSAGE)))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (psDefUsage->pwszDllName)
|
||||||
|
{
|
||||||
|
Res = WINTRUST_WriteSingleUsageEntry(pszUsageOID, Dll, psDefUsage->pwszDllName);
|
||||||
|
if (Res != ERROR_SUCCESS) WriteUsageError = Res;
|
||||||
|
}
|
||||||
|
if (psDefUsage->pwszLoadCallbackDataFunctionName)
|
||||||
|
{
|
||||||
|
WCHAR* CallbackW;
|
||||||
|
|
||||||
|
Len = MultiByteToWideChar( CP_ACP, 0, psDefUsage->pwszLoadCallbackDataFunctionName, -1, NULL, 0 );
|
||||||
|
CallbackW = HeapAlloc( GetProcessHeap(), 0, Len * sizeof(WCHAR) );
|
||||||
|
MultiByteToWideChar( CP_ACP, 0, psDefUsage->pwszLoadCallbackDataFunctionName, -1, CallbackW, Len );
|
||||||
|
|
||||||
|
Res = WINTRUST_WriteSingleUsageEntry(pszUsageOID, CBAlloc, CallbackW);
|
||||||
|
if (Res != ERROR_SUCCESS) WriteUsageError = Res;
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, CallbackW);
|
||||||
|
}
|
||||||
|
if (psDefUsage->pwszFreeCallbackDataFunctionName)
|
||||||
|
{
|
||||||
|
WCHAR* CallbackW;
|
||||||
|
|
||||||
|
Len = MultiByteToWideChar( CP_ACP, 0, psDefUsage->pwszFreeCallbackDataFunctionName, -1, NULL, 0 );
|
||||||
|
CallbackW = HeapAlloc( GetProcessHeap(), 0, Len * sizeof(WCHAR) );
|
||||||
|
MultiByteToWideChar( CP_ACP, 0, psDefUsage->pwszFreeCallbackDataFunctionName, -1, CallbackW, Len );
|
||||||
|
|
||||||
|
Res = WINTRUST_WriteSingleUsageEntry(pszUsageOID, CBFree, CallbackW);
|
||||||
|
if (Res != ERROR_SUCCESS) WriteUsageError = Res;
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, CallbackW);
|
||||||
|
}
|
||||||
|
|
||||||
|
WINTRUST_Guid2Wstr(psDefUsage->pgActionID, GuidString);
|
||||||
|
Res = WINTRUST_WriteSingleUsageEntry(pszUsageOID, DefaultId, GuidString);
|
||||||
|
if (Res != ERROR_SUCCESS) WriteUsageError = Res;
|
||||||
|
|
||||||
|
if (WriteUsageError != ERROR_SUCCESS)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* DllRegisterServer (WINTRUST.@)
|
* DllRegisterServer (WINTRUST.@)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -176,7 +176,6 @@ static void test_AddDefaultForUsage(void)
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = pWintrustAddDefaultForUsage(NULL, NULL);
|
ret = pWintrustAddDefaultForUsage(NULL, NULL);
|
||||||
ok (!ret, "Expected WintrustAddDefaultForUsage to fail.\n");
|
ok (!ret, "Expected WintrustAddDefaultForUsage to fail.\n");
|
||||||
todo_wine
|
|
||||||
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
"Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError());
|
"Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError());
|
||||||
|
|
||||||
|
@ -184,7 +183,6 @@ static void test_AddDefaultForUsage(void)
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = pWintrustAddDefaultForUsage(oid, NULL);
|
ret = pWintrustAddDefaultForUsage(oid, NULL);
|
||||||
ok (!ret, "Expected WintrustAddDefaultForUsage to fail.\n");
|
ok (!ret, "Expected WintrustAddDefaultForUsage to fail.\n");
|
||||||
todo_wine
|
|
||||||
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
"Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError());
|
"Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError());
|
||||||
|
|
||||||
|
@ -198,7 +196,6 @@ static void test_AddDefaultForUsage(void)
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = pWintrustAddDefaultForUsage(NULL, &DefUsage);
|
ret = pWintrustAddDefaultForUsage(NULL, &DefUsage);
|
||||||
ok (!ret, "Expected WintrustAddDefaultForUsage to fail.\n");
|
ok (!ret, "Expected WintrustAddDefaultForUsage to fail.\n");
|
||||||
todo_wine
|
|
||||||
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
"Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError());
|
"Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError());
|
||||||
|
|
||||||
|
@ -208,7 +205,6 @@ static void test_AddDefaultForUsage(void)
|
||||||
DefUsage.pgActionID = &ActionID;
|
DefUsage.pgActionID = &ActionID;
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = pWintrustAddDefaultForUsage(oid, &DefUsage);
|
ret = pWintrustAddDefaultForUsage(oid, &DefUsage);
|
||||||
todo_wine
|
|
||||||
ok ( ret, "Expected WintrustAddDefaultForUsage to succeed\n");
|
ok ( ret, "Expected WintrustAddDefaultForUsage to succeed\n");
|
||||||
ok (GetLastError() == 0xdeadbeef,
|
ok (GetLastError() == 0xdeadbeef,
|
||||||
"Last error should not have been changed: 0x%08lx\n", GetLastError());
|
"Last error should not have been changed: 0x%08lx\n", GetLastError());
|
||||||
|
@ -221,7 +217,6 @@ static void test_AddDefaultForUsage(void)
|
||||||
DefUsage.pwszFreeCallbackDataFunctionName = DummyFunction;
|
DefUsage.pwszFreeCallbackDataFunctionName = DummyFunction;
|
||||||
ret = pWintrustAddDefaultForUsage(oid, &DefUsage);
|
ret = pWintrustAddDefaultForUsage(oid, &DefUsage);
|
||||||
ok (!ret, "Expected WintrustAddDefaultForUsage to fail.\n");
|
ok (!ret, "Expected WintrustAddDefaultForUsage to fail.\n");
|
||||||
todo_wine
|
|
||||||
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
"Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError());
|
"Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError());
|
||||||
|
|
||||||
|
@ -235,7 +230,6 @@ static void test_AddDefaultForUsage(void)
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = pWintrustAddDefaultForUsage(oid, &DefUsage);
|
ret = pWintrustAddDefaultForUsage(oid, &DefUsage);
|
||||||
ok (!ret, "Expected WintrustAddDefaultForUsage to fail.\n");
|
ok (!ret, "Expected WintrustAddDefaultForUsage to fail.\n");
|
||||||
todo_wine
|
|
||||||
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
"Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError());
|
"Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError());
|
||||||
|
|
||||||
|
@ -248,7 +242,6 @@ static void test_AddDefaultForUsage(void)
|
||||||
DefUsage.pwszFreeCallbackDataFunctionName = DummyFunction;
|
DefUsage.pwszFreeCallbackDataFunctionName = DummyFunction;
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = pWintrustAddDefaultForUsage(oid, &DefUsage);
|
ret = pWintrustAddDefaultForUsage(oid, &DefUsage);
|
||||||
todo_wine
|
|
||||||
ok ( ret, "Expected WintrustAddDefaultForUsage to succeed\n");
|
ok ( ret, "Expected WintrustAddDefaultForUsage to succeed\n");
|
||||||
ok (GetLastError() == 0xdeadbeef,
|
ok (GetLastError() == 0xdeadbeef,
|
||||||
"Last error should not have been changed: 0x%08lx\n", GetLastError());
|
"Last error should not have been changed: 0x%08lx\n", GetLastError());
|
||||||
|
|
Loading…
Reference in New Issue