#include <msidefs.h>
#include <msi.h>
#include <msiquery.h>
+#include <srrestoreptapi.h>
#include "wine/test.h"
static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
+static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD);
+static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*);
+
static void init_functionpointers(void)
{
HMODULE hmsi = GetModuleHandleA("msi.dll");
HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
+ HMODULE hsrclient;
#define GET_PROC(mod, func) \
p ## func = (void*)GetProcAddress(mod, #func);
GET_PROC(hadvapi32, ConvertSidToStringSidA);
+ hsrclient = LoadLibraryA("srclient.dll");
+ GET_PROC(hsrclient, SRRemoveRestorePoint);
+ GET_PROC(hsrclient, SRSetRestorePointA);
#undef GET_PROC
}
BOOL ret = FALSE;
GetSystemDirectory(path, MAX_PATH);
- lstrcatA(path, "\\kernel32.dll");
+ /* Some dlls can't be updated on Vista/W2K8 */
+ lstrcatA(path, "\\version.dll");
CopyFileA(path, name, FALSE);
return ret;
}
+static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
+{
+ RESTOREPOINTINFOA spec;
+
+ spec.dwEventType = event_type;
+ spec.dwRestorePtType = APPLICATION_INSTALL;
+ spec.llSequenceNumber = status->llSequenceNumber;
+ lstrcpyA(spec.szDescription, "msitest restore point");
+
+ return pSRSetRestorePointA(&spec, status);
+}
+
+static void remove_restore_point(DWORD seq_number)
+{
+ DWORD res;
+
+ res = pSRRemoveRestorePoint(seq_number);
+ if (res != ERROR_SUCCESS)
+ trace("Failed to remove the restore point : %08x\n", res);
+}
+
static void test_createpackage(void)
{
MSIHANDLE hPackage = 0;
static void test_gettargetpath_bad(void)
{
+ static const WCHAR boo[] = {'b','o','o',0};
+ static const WCHAR empty[] = {0};
char buffer[0x80];
+ WCHAR bufferW[0x80];
MSIHANDLE hpkg;
DWORD sz;
UINT r;
r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
ok( r == ERROR_DIRECTORY, "wrong return val\n");
+ sz = 0;
+ r = MsiGetTargetPath( hpkg, "", buffer, &sz );
+ ok( r == ERROR_DIRECTORY, "wrong return val\n");
+
+ r = MsiGetTargetPathW( 0, NULL, NULL, NULL );
+ ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
+
+ r = MsiGetTargetPathW( 0, NULL, NULL, &sz );
+ ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
+
+ r = MsiGetTargetPathW( 0, boo, NULL, NULL );
+ ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
+
+ r = MsiGetTargetPathW( 0, boo, NULL, NULL );
+ ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
+
+ r = MsiGetTargetPathW( hpkg, boo, NULL, NULL );
+ ok( r == ERROR_DIRECTORY, "wrong return val\n");
+
+ r = MsiGetTargetPathW( hpkg, boo, bufferW, NULL );
+ ok( r == ERROR_DIRECTORY, "wrong return val\n");
+
+ sz = 0;
+ r = MsiGetTargetPathW( hpkg, empty, bufferW, &sz );
+ ok( r == ERROR_DIRECTORY, "wrong return val\n");
+
MsiCloseHandle( hpkg );
DeleteFile(msifile);
}
DeleteFileA("FileName10.dll");
MsiCloseHandle(hpkg);
DeleteFileA(msifile);
+ LocalFree(usersid);
}
static void test_appsearch_reglocator(void)
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
}
+ buffer[0] = 0;
size = MAX_PATH;
r = MsiRecordGetString(hrec, 1, buffer, &size);
todo_wine
START_TEST(package)
{
+ STATEMGRSTATUS status;
+ BOOL ret = FALSE;
+
init_functionpointers();
GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
+ /* Create a restore point ourselves so we circumvent the multitude of restore points
+ * that would have been created by all the installation and removal tests.
+ */
+ if (pSRSetRestorePointA)
+ {
+ memset(&status, 0, sizeof(status));
+ ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
+ }
+
test_createpackage();
test_doaction();
test_gettargetpath_bad();
test_MsiSetProperty();
test_MsiApplyMultiplePatches();
test_MsiApplyPatch();
+
+ if (pSRSetRestorePointA && ret)
+ {
+ ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
+ if (ret)
+ remove_restore_point(status.llSequenceNumber);
+ }
}