2006-08-29 10:25:47 +02:00
|
|
|
/* Unit test suite for wintrust API functions
|
|
|
|
*
|
|
|
|
* Copyright 2006 Paul Vriens
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "windows.h"
|
|
|
|
#include "softpub.h"
|
|
|
|
#include "wintrust.h"
|
2006-09-12 13:18:48 +02:00
|
|
|
#include "winreg.h"
|
2006-08-29 10:25:47 +02:00
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
static BOOL (WINAPI * pWintrustAddActionID)(GUID*, DWORD, CRYPT_REGISTER_ACTIONID*);
|
2006-09-12 13:18:48 +02:00
|
|
|
static BOOL (WINAPI * pWintrustAddDefaultForUsage)(const CHAR*,CRYPT_PROVIDER_REGDEFUSAGE*);
|
2006-08-29 10:25:47 +02:00
|
|
|
static BOOL (WINAPI * pWintrustRemoveActionID)(GUID*);
|
2007-05-02 16:43:08 +02:00
|
|
|
static BOOL (WINAPI * pWintrustLoadFunctionPointers)(GUID *, CRYPT_PROVIDER_FUNCTIONS *);
|
2006-08-29 10:25:47 +02:00
|
|
|
|
|
|
|
static HMODULE hWintrust = 0;
|
|
|
|
|
|
|
|
#define WINTRUST_GET_PROC(func) \
|
|
|
|
p ## func = (void*)GetProcAddress(hWintrust, #func); \
|
|
|
|
if(!p ## func) { \
|
|
|
|
trace("GetProcAddress(%s) failed\n", #func); \
|
|
|
|
FreeLibrary(hWintrust); \
|
|
|
|
return FALSE; \
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL InitFunctionPtrs(void)
|
|
|
|
{
|
|
|
|
hWintrust = LoadLibraryA("wintrust.dll");
|
|
|
|
|
|
|
|
if(!hWintrust)
|
|
|
|
{
|
|
|
|
trace("Could not load wintrust.dll\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
WINTRUST_GET_PROC(WintrustAddActionID)
|
2006-09-12 13:18:48 +02:00
|
|
|
WINTRUST_GET_PROC(WintrustAddDefaultForUsage)
|
2006-08-29 10:25:47 +02:00
|
|
|
WINTRUST_GET_PROC(WintrustRemoveActionID)
|
2007-05-02 16:43:08 +02:00
|
|
|
WINTRUST_GET_PROC(WintrustLoadFunctionPointers)
|
2006-08-29 10:25:47 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_AddRem_ActionID(void)
|
|
|
|
{
|
|
|
|
static WCHAR DummyDllW[] = {'d','e','a','d','b','e','e','f','.','d','l','l',0 };
|
|
|
|
static WCHAR DummyFunctionW[] = {'d','u','m','m','y','f','u','n','c','t','i','o','n',0 };
|
2006-09-12 13:18:48 +02:00
|
|
|
GUID ActionID = { 0xdeadbeef, 0xdead, 0xbeef, { 0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef }};
|
2006-08-29 10:25:47 +02:00
|
|
|
CRYPT_REGISTER_ACTIONID ActionIDFunctions;
|
|
|
|
CRYPT_TRUST_REG_ENTRY EmptyProvider = { 0, NULL, NULL };
|
|
|
|
CRYPT_TRUST_REG_ENTRY DummyProvider = { sizeof(CRYPT_TRUST_REG_ENTRY), DummyDllW, DummyFunctionW };
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
/* All NULL */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pWintrustAddActionID(NULL, 0, NULL);
|
|
|
|
ok (!ret, "Expected WintrustAddActionID to fail.\n");
|
2006-08-31 16:37:19 +02:00
|
|
|
ok (GetLastError() == ERROR_INVALID_PARAMETER /* XP/W2K3 */ ||
|
|
|
|
GetLastError() == 0xdeadbeef /* Win98/NT4/W2K */,
|
2007-01-09 12:21:57 +01:00
|
|
|
"Expected ERROR_INVALID_PARAMETER(W2K3) or 0xdeadbeef(Win98/NT4/W2K), got %u.\n", GetLastError());
|
2006-08-29 10:25:47 +02:00
|
|
|
|
|
|
|
/* NULL functions */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pWintrustAddActionID(&ActionID, 0, NULL);
|
|
|
|
ok (!ret, "Expected WintrustAddActionID to fail.\n");
|
2006-08-31 16:37:19 +02:00
|
|
|
ok (GetLastError() == ERROR_INVALID_PARAMETER /* XP/W2K3 */ ||
|
|
|
|
GetLastError() == 0xdeadbeef /* Win98/NT4/W2K */,
|
2007-01-09 12:21:57 +01:00
|
|
|
"Expected ERROR_INVALID_PARAMETER(W2K3) or 0xdeadbeef(Win98/NT4/W2K), got %u.\n", GetLastError());
|
2006-08-29 10:25:47 +02:00
|
|
|
|
|
|
|
/* All OK (although no functions defined), except cbStruct is not set in ActionIDFunctions */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
memset(&ActionIDFunctions, 0, sizeof(CRYPT_REGISTER_ACTIONID));
|
|
|
|
ret = pWintrustAddActionID(&ActionID, 0, &ActionIDFunctions);
|
|
|
|
ok (!ret, "Expected WintrustAddActionID to fail.\n");
|
2006-08-31 16:37:19 +02:00
|
|
|
ok (GetLastError() == ERROR_INVALID_PARAMETER /* XP/W2K3 */ ||
|
|
|
|
GetLastError() == 0xdeadbeef /* Win98/NT4/W2K */,
|
2007-01-09 12:21:57 +01:00
|
|
|
"Expected ERROR_INVALID_PARAMETER(W2K3) or 0xdeadbeef(Win98/NT4/W2K), got %u.\n", GetLastError());
|
2006-08-29 10:25:47 +02:00
|
|
|
|
|
|
|
/* All OK (although no functions defined) and cbStruct is set now */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
memset(&ActionIDFunctions, 0, sizeof(CRYPT_REGISTER_ACTIONID));
|
|
|
|
ActionIDFunctions.cbStruct = sizeof(CRYPT_REGISTER_ACTIONID);
|
|
|
|
ret = pWintrustAddActionID(&ActionID, 0, &ActionIDFunctions);
|
2006-08-31 16:37:19 +02:00
|
|
|
ok (ret, "Expected WintrustAddActionID to succeed.\n");
|
|
|
|
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
2007-01-09 12:21:57 +01:00
|
|
|
"Expected ERROR_INVALID_PARAMETER, got %u.\n", GetLastError());
|
2006-08-29 10:25:47 +02:00
|
|
|
|
|
|
|
/* All OK and all (but 1) functions are correctly defined. The DLL and entrypoints
|
|
|
|
* are not present.
|
|
|
|
*/
|
|
|
|
memset(&ActionIDFunctions, 0, sizeof(CRYPT_REGISTER_ACTIONID));
|
|
|
|
ActionIDFunctions.cbStruct = sizeof(CRYPT_REGISTER_ACTIONID);
|
|
|
|
ActionIDFunctions.sInitProvider = DummyProvider;
|
|
|
|
ActionIDFunctions.sObjectProvider = DummyProvider;
|
|
|
|
ActionIDFunctions.sSignatureProvider = EmptyProvider;
|
|
|
|
ActionIDFunctions.sCertificateProvider = DummyProvider;
|
|
|
|
ActionIDFunctions.sCertificatePolicyProvider = DummyProvider;
|
|
|
|
ActionIDFunctions.sFinalPolicyProvider = DummyProvider;
|
|
|
|
ActionIDFunctions.sTestPolicyProvider = DummyProvider;
|
|
|
|
ActionIDFunctions.sCleanupProvider = DummyProvider;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pWintrustAddActionID(&ActionID, 0, &ActionIDFunctions);
|
2006-08-31 16:37:19 +02:00
|
|
|
ok (ret, "Expected WintrustAddActionID to succeed.\n");
|
|
|
|
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
2007-01-09 12:21:57 +01:00
|
|
|
"Expected ERROR_INVALID_PARAMETER, got %u.\n", GetLastError());
|
2006-08-29 10:25:47 +02:00
|
|
|
|
|
|
|
/* All OK and all functions are correctly defined. The DLL and entrypoints
|
|
|
|
* are not present.
|
|
|
|
*/
|
|
|
|
memset(&ActionIDFunctions, 0, sizeof(CRYPT_REGISTER_ACTIONID));
|
|
|
|
ActionIDFunctions.cbStruct = sizeof(CRYPT_REGISTER_ACTIONID);
|
|
|
|
ActionIDFunctions.sInitProvider = DummyProvider;
|
|
|
|
ActionIDFunctions.sObjectProvider = DummyProvider;
|
|
|
|
ActionIDFunctions.sSignatureProvider = DummyProvider;
|
|
|
|
ActionIDFunctions.sCertificateProvider = DummyProvider;
|
|
|
|
ActionIDFunctions.sCertificatePolicyProvider = DummyProvider;
|
|
|
|
ActionIDFunctions.sFinalPolicyProvider = DummyProvider;
|
|
|
|
ActionIDFunctions.sTestPolicyProvider = DummyProvider;
|
|
|
|
ActionIDFunctions.sCleanupProvider = DummyProvider;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pWintrustAddActionID(&ActionID, 0, &ActionIDFunctions);
|
2006-08-31 16:37:19 +02:00
|
|
|
ok (ret, "Expected WintrustAddActionID to succeed.\n");
|
|
|
|
ok (GetLastError() == 0xdeadbeef,
|
2007-01-09 12:21:57 +01:00
|
|
|
"Expected 0xdeadbeef, got %u.\n", GetLastError());
|
2006-08-29 10:25:47 +02:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pWintrustRemoveActionID(&ActionID);
|
2007-01-09 12:21:57 +01:00
|
|
|
ok ( ret, "WintrustRemoveActionID failed : %d\n", GetLastError());
|
|
|
|
ok ( GetLastError() == 0xdeadbeef, "Last error should not have been changed: %u\n", GetLastError());
|
2006-08-29 17:57:35 +02:00
|
|
|
|
|
|
|
/* NULL input */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pWintrustRemoveActionID(NULL);
|
2006-08-30 19:36:54 +02:00
|
|
|
ok (ret, "Expected WintrustRemoveActionID to succeed.\n");
|
|
|
|
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
2007-01-09 12:21:57 +01:00
|
|
|
"Expected ERROR_INVALID_PARAMETER, got %u.\n", GetLastError());
|
2006-08-29 17:57:35 +02:00
|
|
|
|
2006-09-07 20:01:50 +02:00
|
|
|
/* The passed GUID is removed by a previous call, so it's basically a test with a nonexistent Trust provider */
|
2006-08-29 17:57:35 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pWintrustRemoveActionID(&ActionID);
|
2006-08-30 19:36:54 +02:00
|
|
|
ok (ret, "Expected WintrustRemoveActionID to succeed.\n");
|
|
|
|
ok (GetLastError() == 0xdeadbeef,
|
2007-01-09 12:21:57 +01:00
|
|
|
"Expected 0xdeadbeef, got %u.\n", GetLastError());
|
2006-08-29 10:25:47 +02:00
|
|
|
}
|
|
|
|
|
2006-09-12 13:18:48 +02:00
|
|
|
static void test_AddDefaultForUsage(void)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
LONG res;
|
|
|
|
static GUID ActionID = { 0xdeadbeef, 0xdead, 0xbeef, { 0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef }};
|
|
|
|
static WCHAR DummyDllW[] = {'d','e','a','d','b','e','e','f','.','d','l','l',0 };
|
|
|
|
static CHAR DummyFunction[] = "dummyfunction";
|
|
|
|
static const CHAR oid[] = "1.2.3.4.5.6.7.8.9.10";
|
|
|
|
static const CHAR Usages[] = "SOFTWARE\\Microsoft\\Cryptography\\Providers\\Trust\\Usages\\1.2.3.4.5.6.7.8.9.10";
|
|
|
|
static CRYPT_PROVIDER_REGDEFUSAGE DefUsage;
|
|
|
|
|
|
|
|
/* All NULL */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pWintrustAddDefaultForUsage(NULL, NULL);
|
|
|
|
ok (!ret, "Expected WintrustAddDefaultForUsage to fail.\n");
|
2006-09-12 14:28:05 +02:00
|
|
|
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
2007-01-09 12:21:57 +01:00
|
|
|
"Expected ERROR_INVALID_PARAMETER, got %u.\n", GetLastError());
|
2006-09-12 13:18:48 +02:00
|
|
|
|
|
|
|
/* NULL defusage */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pWintrustAddDefaultForUsage(oid, NULL);
|
|
|
|
ok (!ret, "Expected WintrustAddDefaultForUsage to fail.\n");
|
2006-09-12 14:28:05 +02:00
|
|
|
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
2007-01-09 12:21:57 +01:00
|
|
|
"Expected ERROR_INVALID_PARAMETER, got %u.\n", GetLastError());
|
2006-09-12 13:18:48 +02:00
|
|
|
|
|
|
|
/* NULL oid and proper defusage */
|
|
|
|
memset(&DefUsage, 0 , sizeof(CRYPT_PROVIDER_REGDEFUSAGE));
|
|
|
|
DefUsage.cbStruct = sizeof(CRYPT_PROVIDER_REGDEFUSAGE);
|
|
|
|
DefUsage.pgActionID = &ActionID;
|
|
|
|
DefUsage.pwszDllName = DummyDllW;
|
|
|
|
DefUsage.pwszLoadCallbackDataFunctionName = DummyFunction;
|
|
|
|
DefUsage.pwszFreeCallbackDataFunctionName = DummyFunction;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pWintrustAddDefaultForUsage(NULL, &DefUsage);
|
|
|
|
ok (!ret, "Expected WintrustAddDefaultForUsage to fail.\n");
|
2006-09-12 14:28:05 +02:00
|
|
|
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
2007-01-09 12:21:57 +01:00
|
|
|
"Expected ERROR_INVALID_PARAMETER, got %u.\n", GetLastError());
|
2006-09-12 13:18:48 +02:00
|
|
|
|
|
|
|
/* Just the ActionID */
|
|
|
|
memset(&DefUsage, 0 , sizeof(CRYPT_PROVIDER_REGDEFUSAGE));
|
|
|
|
DefUsage.cbStruct = sizeof(CRYPT_PROVIDER_REGDEFUSAGE);
|
|
|
|
DefUsage.pgActionID = &ActionID;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pWintrustAddDefaultForUsage(oid, &DefUsage);
|
2006-09-12 14:28:05 +02:00
|
|
|
ok ( ret, "Expected WintrustAddDefaultForUsage to succeed\n");
|
2006-09-12 13:18:48 +02:00
|
|
|
ok (GetLastError() == 0xdeadbeef,
|
2007-01-09 12:21:57 +01:00
|
|
|
"Last error should not have been changed: %u\n", GetLastError());
|
2006-09-12 13:18:48 +02:00
|
|
|
|
|
|
|
/* No ActionID */
|
|
|
|
memset(&DefUsage, 0 , sizeof(CRYPT_PROVIDER_REGDEFUSAGE));
|
|
|
|
DefUsage.cbStruct = sizeof(CRYPT_PROVIDER_REGDEFUSAGE);
|
|
|
|
DefUsage.pwszDllName = DummyDllW;
|
|
|
|
DefUsage.pwszLoadCallbackDataFunctionName = DummyFunction;
|
|
|
|
DefUsage.pwszFreeCallbackDataFunctionName = DummyFunction;
|
|
|
|
ret = pWintrustAddDefaultForUsage(oid, &DefUsage);
|
|
|
|
ok (!ret, "Expected WintrustAddDefaultForUsage to fail.\n");
|
2006-09-12 14:28:05 +02:00
|
|
|
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
2007-01-09 12:21:57 +01:00
|
|
|
"Expected ERROR_INVALID_PARAMETER, got %u.\n", GetLastError());
|
2006-09-12 13:18:48 +02:00
|
|
|
|
|
|
|
/* cbStruct set to 0 */
|
|
|
|
memset(&DefUsage, 0 , sizeof(CRYPT_PROVIDER_REGDEFUSAGE));
|
|
|
|
DefUsage.cbStruct = 0;
|
|
|
|
DefUsage.pgActionID = &ActionID;
|
|
|
|
DefUsage.pwszDllName = DummyDllW;
|
|
|
|
DefUsage.pwszLoadCallbackDataFunctionName = DummyFunction;
|
|
|
|
DefUsage.pwszFreeCallbackDataFunctionName = DummyFunction;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pWintrustAddDefaultForUsage(oid, &DefUsage);
|
|
|
|
ok (!ret, "Expected WintrustAddDefaultForUsage to fail.\n");
|
2006-09-12 14:28:05 +02:00
|
|
|
ok (GetLastError() == ERROR_INVALID_PARAMETER,
|
2007-01-09 12:21:57 +01:00
|
|
|
"Expected ERROR_INVALID_PARAMETER, got %u.\n", GetLastError());
|
2006-09-12 13:18:48 +02:00
|
|
|
|
|
|
|
/* All OK */
|
|
|
|
memset(&DefUsage, 0 , sizeof(CRYPT_PROVIDER_REGDEFUSAGE));
|
|
|
|
DefUsage.cbStruct = sizeof(CRYPT_PROVIDER_REGDEFUSAGE);
|
|
|
|
DefUsage.pgActionID = &ActionID;
|
|
|
|
DefUsage.pwszDllName = DummyDllW;
|
|
|
|
DefUsage.pwszLoadCallbackDataFunctionName = DummyFunction;
|
|
|
|
DefUsage.pwszFreeCallbackDataFunctionName = DummyFunction;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pWintrustAddDefaultForUsage(oid, &DefUsage);
|
2006-09-12 14:28:05 +02:00
|
|
|
ok ( ret, "Expected WintrustAddDefaultForUsage to succeed\n");
|
2006-09-12 13:18:48 +02:00
|
|
|
ok (GetLastError() == 0xdeadbeef,
|
2007-01-09 12:21:57 +01:00
|
|
|
"Last error should not have been changed: %u\n", GetLastError());
|
2006-09-12 13:18:48 +02:00
|
|
|
|
|
|
|
/* There is no corresponding remove for WintrustAddDefaultForUsage
|
|
|
|
* so we delete the registry key manually.
|
|
|
|
*/
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
res = RegDeleteKeyA(HKEY_LOCAL_MACHINE, Usages);
|
2006-10-03 17:06:01 +02:00
|
|
|
ok (res == ERROR_SUCCESS, "Key delete failed : 0x%08x\n", res);
|
2006-09-12 13:18:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-02 16:43:08 +02:00
|
|
|
static void test_LoadFunctionPointers(void)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
CRYPT_PROVIDER_FUNCTIONS funcs;
|
|
|
|
GUID action = WINTRUST_ACTION_GENERIC_VERIFY_V2;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pWintrustLoadFunctionPointers(NULL, NULL);
|
|
|
|
ok(!ret && GetLastError() == 0xdeadbeef, "Expected failure\n");
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pWintrustLoadFunctionPointers(&action, NULL);
|
|
|
|
ok(!ret && GetLastError() == 0xdeadbeef, "Expected failure\n");
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pWintrustLoadFunctionPointers(NULL, &funcs);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
funcs.cbStruct = 0;
|
|
|
|
ret = pWintrustLoadFunctionPointers(&action, &funcs);
|
|
|
|
ok(!ret && GetLastError() == 0xdeadbeef, "Expected failure\n");
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
funcs.cbStruct = sizeof(funcs);
|
|
|
|
ret = pWintrustLoadFunctionPointers(&action, &funcs);
|
|
|
|
ok(ret, "WintrustLoadFunctionPointers failed: %d\n", GetLastError());
|
|
|
|
}
|
|
|
|
|
2007-05-15 03:15:09 +02:00
|
|
|
static void test_RegPolicyFlags(void)
|
|
|
|
{
|
|
|
|
/* Default state value 0x00023c00, which is
|
|
|
|
* WTPF_IGNOREREVOCATIONONTS |
|
|
|
|
* WTPF_OFFLINEOKNBU_COM |
|
|
|
|
* WTPF_OFFLINEOKNBU_IND |
|
|
|
|
* WTPF_OFFLINEOK_COM |
|
|
|
|
* WTPF_OFFLINEOK_IND
|
|
|
|
*/
|
2007-06-06 15:47:36 +02:00
|
|
|
static const CHAR Software_Publishing[] =
|
|
|
|
"Software\\Microsoft\\Windows\\CurrentVersion\\Wintrust\\"
|
|
|
|
"Trust Providers\\Software Publishing";
|
|
|
|
static const CHAR State[] = "State";
|
2007-06-12 17:58:03 +02:00
|
|
|
void (WINAPI *pGetFlags)(DWORD *);
|
|
|
|
BOOL (WINAPI *pSetFlags)(DWORD);
|
2007-05-15 03:15:09 +02:00
|
|
|
HKEY key;
|
|
|
|
LONG r;
|
|
|
|
DWORD flags1, flags2, flags3, size;
|
|
|
|
BOOL ret;
|
|
|
|
|
2007-06-12 17:58:03 +02:00
|
|
|
pGetFlags = (void*)GetProcAddress(hWintrust, "WintrustGetRegPolicyFlags");
|
|
|
|
pSetFlags = (void*)GetProcAddress(hWintrust, "WintrustSetRegPolicyFlags");
|
2007-05-15 03:15:09 +02:00
|
|
|
if (!pGetFlags || !pSetFlags)
|
|
|
|
skip("Policy flags functions not present\n");
|
|
|
|
|
2007-06-13 12:05:55 +02:00
|
|
|
pGetFlags(&flags2);
|
|
|
|
|
2007-06-06 15:47:36 +02:00
|
|
|
r = RegOpenKeyExA(HKEY_CURRENT_USER, Software_Publishing, 0, KEY_ALL_ACCESS,
|
2007-05-15 03:15:09 +02:00
|
|
|
&key);
|
|
|
|
ok(!r, "RegOpenKeyEx failed: %d\n", r);
|
|
|
|
|
|
|
|
size = sizeof(flags1);
|
2007-06-06 15:47:36 +02:00
|
|
|
r = RegQueryValueExA(key, State, NULL, NULL, (LPBYTE)&flags1, &size);
|
2007-05-15 03:15:09 +02:00
|
|
|
ok(!r, "RegQueryValueEx failed: %d\n", r);
|
|
|
|
|
2007-06-12 17:58:44 +02:00
|
|
|
ok(flags1 == flags2, "Got %08x flags instead of %08x\n", flags1, flags2);
|
2007-05-15 03:15:09 +02:00
|
|
|
|
|
|
|
flags3 = flags2 | 1;
|
|
|
|
ret = pSetFlags(flags3);
|
|
|
|
ok(ret, "pSetFlags failed: %d\n", GetLastError());
|
|
|
|
size = sizeof(flags1);
|
2007-06-06 15:47:36 +02:00
|
|
|
r = RegQueryValueExA(key, State, NULL, NULL, (LPBYTE)&flags1, &size);
|
2007-06-12 17:58:44 +02:00
|
|
|
ok(flags1 == flags3, "Got %08x flags instead of %08x\n", flags1, flags3);
|
2007-05-15 03:15:09 +02:00
|
|
|
|
|
|
|
pSetFlags(flags2);
|
|
|
|
|
|
|
|
RegCloseKey(key);
|
|
|
|
}
|
|
|
|
|
2006-08-29 10:25:47 +02:00
|
|
|
START_TEST(register)
|
|
|
|
{
|
|
|
|
if(!InitFunctionPtrs())
|
|
|
|
return;
|
|
|
|
|
|
|
|
test_AddRem_ActionID();
|
2006-09-12 13:18:48 +02:00
|
|
|
test_AddDefaultForUsage();
|
2007-05-02 16:43:08 +02:00
|
|
|
test_LoadFunctionPointers();
|
2007-05-15 03:15:09 +02:00
|
|
|
test_RegPolicyFlags();
|
2006-08-29 10:25:47 +02:00
|
|
|
|
|
|
|
FreeLibrary(hWintrust);
|
|
|
|
}
|