Commit 33b6ad7f authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi/tests: Skip tests if UAC is enabled and the process is not running elevated.

parent deb1c552
......@@ -36,6 +36,8 @@ char CURR_DIR[MAX_PATH];
static UINT (WINAPI *pMsiApplyMultiplePatchesA)(LPCSTR, LPCSTR, LPCSTR);
static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
static BOOL (WINAPI *pGetTokenInformation)( HANDLE, TOKEN_INFORMATION_CLASS, LPVOID, DWORD, PDWORD );
static BOOL (WINAPI *pOpenProcessToken)( HANDLE, DWORD, PHANDLE );
static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD);
static LONG (WINAPI *pRegDeleteKeyExW)(HKEY, LPCWSTR, REGSAM, DWORD);
static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
......@@ -56,6 +58,8 @@ static void init_functionpointers(void)
GET_PROC(hmsi, MsiApplyMultiplePatchesA);
GET_PROC(hadvapi32, ConvertSidToStringSidA);
GET_PROC(hadvapi32, GetTokenInformation);
GET_PROC(hadvapi32, OpenProcessToken);
GET_PROC(hadvapi32, RegDeleteKeyExA)
GET_PROC(hadvapi32, RegDeleteKeyExW)
GET_PROC(hkernel32, IsWow64Process)
......@@ -66,6 +70,25 @@ static void init_functionpointers(void)
#undef GET_PROC
}
static BOOL is_process_limited(void)
{
HANDLE token;
if (!pOpenProcessToken || !pGetTokenInformation) return FALSE;
if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
{
BOOL ret;
TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
DWORD size;
ret = pGetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
CloseHandle(token);
return (ret && type == TokenElevationTypeLimited);
}
return FALSE;
}
static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access )
{
if (pRegDeleteKeyExA)
......@@ -2440,6 +2463,12 @@ static void test_states(void)
static const CHAR msifile3[] = "winetest3-package.msi";
static const CHAR msifile4[] = "winetest4-package.msi";
if (is_process_limited())
{
skip("process is limited\n");
return;
}
hdb = create_package_db();
ok ( hdb, "failed to create package database\n" );
......@@ -7538,6 +7567,12 @@ static void test_appsearch_complocator(void)
if (!get_user_sid(&usersid))
return;
if (is_process_limited())
{
skip("process is limited\n");
return;
}
create_test_file("FileName1");
create_test_file("FileName4");
set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE,
......
......@@ -35,6 +35,8 @@ static UINT (WINAPI *pMsiGetPatchInfoExA)( LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCON
LPCSTR, LPSTR, DWORD * );
static UINT (WINAPI *pMsiEnumPatchesExA)( LPCSTR, LPCSTR, DWORD, DWORD, DWORD, LPSTR,
LPSTR, MSIINSTALLCONTEXT *, LPSTR, LPDWORD );
static BOOL (WINAPI *pGetTokenInformation)( HANDLE, TOKEN_INFORMATION_CLASS, LPVOID, DWORD, PDWORD );
static BOOL (WINAPI *pOpenProcessToken)( HANDLE, DWORD, PHANDLE );
static const char *msifile = "winetest-patch.msi";
static const char *mspfile = "winetest-patch.msp";
......@@ -138,6 +140,7 @@ static const struct msi_table tables[] =
static void init_function_pointers( void )
{
HMODULE hmsi = GetModuleHandleA( "msi.dll" );
HMODULE hadvapi32 = GetModuleHandleA( "advapi32.dll" );
#define GET_PROC( mod, func ) \
p ## func = (void *)GetProcAddress( mod, #func ); \
......@@ -147,9 +150,31 @@ static void init_function_pointers( void )
GET_PROC( hmsi, MsiApplyPatchA );
GET_PROC( hmsi, MsiGetPatchInfoExA );
GET_PROC( hmsi, MsiEnumPatchesExA );
GET_PROC( hadvapi32, GetTokenInformation );
GET_PROC( hadvapi32, OpenProcessToken );
#undef GET_PROC
}
static BOOL is_process_limited(void)
{
HANDLE token;
if (!pOpenProcessToken || !pGetTokenInformation) return FALSE;
if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
{
BOOL ret;
TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
DWORD size;
ret = pGetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
CloseHandle(token);
return (ret && type == TokenElevationTypeLimited);
}
return FALSE;
}
static BOOL get_program_files_dir( char *buf, char *buf2 )
{
HKEY hkey;
......@@ -690,6 +715,11 @@ static void test_simple_patch( void )
win_skip("MsiApplyPatchA is not available\n");
return;
}
if (is_process_limited())
{
skip("process is limited\n");
return;
}
CreateDirectoryA( "msitest", NULL );
create_file( "msitest\\patch.txt", 1000 );
......@@ -937,6 +967,11 @@ static void test_system_tables( void )
win_skip("MsiApplyPatchA is not available\n");
return;
}
if (is_process_limited())
{
skip("process is limited\n");
return;
}
CreateDirectoryA( "msitest", NULL );
create_file( "msitest\\patch.txt", 1000 );
......@@ -1097,6 +1132,11 @@ static void test_patch_registration( void )
win_skip("required functions not available\n");
return;
}
if (is_process_limited())
{
skip("process is limited\n");
return;
}
CreateDirectoryA( "msitest", NULL );
create_file( "msitest\\patch.txt", 1000 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment