Commit 45c00da4 authored by Paul Vriens's avatar Paul Vriens Committed by Alexandre Julliard

msi/tests: Prevent crash when ConvertSidToStringSidA is not available.

parent 8921b936
......@@ -40,6 +40,8 @@ static UINT (WINAPI *pMsiSourceListEnumSourcesA)
static UINT (WINAPI *pMsiSourceListGetInfoA)
(LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, LPCSTR, LPSTR, LPDWORD);
static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
static HMODULE hsrclient = 0;
static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD);
static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*);
......@@ -1316,6 +1318,7 @@ static int CDECL fci_delete(char *pszFile, int *err, void *pv)
static void init_functionpointers(void)
{
HMODULE hmsi = GetModuleHandleA("msi.dll");
HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
#define GET_PROC(mod, func) \
p ## func = (void*)GetProcAddress(mod, #func); \
......@@ -1326,6 +1329,8 @@ static void init_functionpointers(void)
GET_PROC(hmsi, MsiSourceListEnumSourcesA);
GET_PROC(hmsi, MsiSourceListGetInfoA);
GET_PROC(hadvapi32, ConvertSidToStringSidA);
hsrclient = LoadLibraryA("srclient.dll");
GET_PROC(hsrclient, SRRemoveRestorePoint);
GET_PROC(hsrclient, SRSetRestorePointA);
......@@ -1352,21 +1357,14 @@ static LPSTR get_user_sid(LPSTR *usersid)
BYTE buf[1024];
DWORD size;
PTOKEN_USER user;
static HMODULE hadvapi32 = NULL;
static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
*usersid = NULL;
if (!hadvapi32)
if (!pConvertSidToStringSidA)
{
hadvapi32 = GetModuleHandleA("advapi32.dll");
pConvertSidToStringSidA = (void *)GetProcAddress(hadvapi32, "ConvertSidToStringSidA");
if (!pConvertSidToStringSidA)
{
win_skip("ConvertSidToStringSidA is not available\n");
return NULL;
}
win_skip("ConvertSidToStringSidA is not available\n");
return NULL;
}
*usersid = NULL;
OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
size = sizeof(buf);
GetTokenInformation(token, TokenUser, buf, size, &size);
......
......@@ -34,27 +34,38 @@ char CURR_DIR[MAX_PATH];
static UINT (WINAPI *pMsiApplyMultiplePatchesA)(LPCSTR, LPCSTR, LPCSTR);
static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
static void init_functionpointers(void)
{
HMODULE hmsi = GetModuleHandleA("msi.dll");
HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
#define GET_PROC(mod, func) \
p ## func = (void*)GetProcAddress(mod, #func);
GET_PROC(hmsi, MsiApplyMultiplePatchesA);
GET_PROC(hadvapi32, ConvertSidToStringSidA);
#undef GET_PROC
}
static LPSTR get_user_sid(LPSTR *usersid)
{
HANDLE token;
BYTE buf[1024];
DWORD size;
PTOKEN_USER user;
static HMODULE hadvapi32 = NULL;
static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
*usersid = NULL;
if (!hadvapi32)
if (!pConvertSidToStringSidA)
{
hadvapi32 = GetModuleHandleA("advapi32.dll");
pConvertSidToStringSidA = (void *)GetProcAddress(hadvapi32, "ConvertSidToStringSidA");
if (!pConvertSidToStringSidA)
{
win_skip("ConvertSidToStringSidA is not available\n");
return NULL;
}
win_skip("ConvertSidToStringSidA is not available\n");
return NULL;
}
*usersid = NULL;
OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
size = sizeof(buf);
GetTokenInformation(token, TokenUser, buf, size, &size);
......@@ -11622,9 +11633,7 @@ static void test_MsiApplyPatch(void)
START_TEST(package)
{
HMODULE hmsi = GetModuleHandleA("msi.dll");
pMsiApplyMultiplePatchesA = (void *)GetProcAddress(hmsi, "MsiApplyMultiplePatchesA");
init_functionpointers();
GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
......
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