#include <windows.h>
#include <msi.h>
#include <msiquery.h>
+#include <msidefs.h>
#include <sddl.h>
#include "wine/test.h"
+static const char msifile[] = "winetest.msi";
+
static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
static INSTALLSTATE (WINAPI *pMsiGetComponentPathA)
(LPCSTR, DWORD, MSIHANDLE*);
static UINT (WINAPI *pMsiOpenPackageExW)
(LPCWSTR, DWORD, MSIHANDLE*);
+static UINT (WINAPI *pMsiEnumPatchesExA)
+ (LPCSTR, LPCSTR, DWORD, DWORD, DWORD, LPSTR, LPSTR,
+ MSIINSTALLCONTEXT*, LPSTR, LPDWORD);
static UINT (WINAPI *pMsiQueryComponentStateA)
(LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE*);
static INSTALLSTATE (WINAPI *pMsiUseFeatureExA)
- (LPCSTR, LPCSTR ,DWORD, DWORD );
+ (LPCSTR, LPCSTR ,DWORD, DWORD);
+static UINT (WINAPI *pMsiGetPatchInfoExA)
+ (LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, LPSTR, DWORD *);
static void init_functionpointers(void)
{
GET_PROC(hmsi, MsiGetProductInfoExA)
GET_PROC(hmsi, MsiOpenPackageExA)
GET_PROC(hmsi, MsiOpenPackageExW)
+ GET_PROC(hmsi, MsiEnumPatchesExA)
GET_PROC(hmsi, MsiQueryComponentStateA)
GET_PROC(hmsi, MsiUseFeatureExA)
+ GET_PROC(hmsi, MsiGetPatchInfoExA)
GET_PROC(hadvapi32, ConvertSidToStringSidA)
#undef GET_PROC
}
+static UINT run_query(MSIHANDLE hdb, const char *query)
+{
+ MSIHANDLE hview = 0;
+ UINT r;
+
+ r = MsiDatabaseOpenView(hdb, query, &hview);
+ if (r != ERROR_SUCCESS)
+ return r;
+
+ r = MsiViewExecute(hview, 0);
+ if (r == ERROR_SUCCESS)
+ r = MsiViewClose(hview);
+ MsiCloseHandle(hview);
+ return r;
+}
+
+static UINT set_summary_info(MSIHANDLE hdb, LPSTR prodcode)
+{
+ UINT res;
+ MSIHANDLE suminfo;
+
+ /* build summary info */
+ res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
+ ok(res == ERROR_SUCCESS, "Failed to open summaryinfo\n");
+
+ res = MsiSummaryInfoSetProperty(suminfo, 2, VT_LPSTR, 0, NULL,
+ "Installation Database");
+ ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
+
+ res = MsiSummaryInfoSetProperty(suminfo, 3, VT_LPSTR, 0, NULL,
+ "Installation Database");
+ ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
+
+ res = MsiSummaryInfoSetProperty(suminfo, 4, VT_LPSTR, 0, NULL,
+ "Wine Hackers");
+ ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
+
+ res = MsiSummaryInfoSetProperty(suminfo, 7, VT_LPSTR, 0, NULL,
+ ";1033");
+ ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
+
+ res = MsiSummaryInfoSetProperty(suminfo, PID_REVNUMBER, VT_LPSTR, 0, NULL,
+ "{A2078D65-94D6-4205-8DEE-F68D6FD622AA}");
+ ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
+
+ res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
+ ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
+
+ res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
+ ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
+
+ res = MsiSummaryInfoPersist(suminfo);
+ ok(res == ERROR_SUCCESS, "Failed to make summary info persist\n");
+
+ res = MsiCloseHandle(suminfo);
+ ok(res == ERROR_SUCCESS, "Failed to close suminfo\n");
+
+ return res;
+}
+
+static MSIHANDLE create_package_db(LPSTR prodcode)
+{
+ MSIHANDLE hdb = 0;
+ CHAR query[MAX_PATH];
+ UINT res;
+
+ DeleteFile(msifile);
+
+ /* create an empty database */
+ res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
+ ok( res == ERROR_SUCCESS , "Failed to create database\n" );
+ if (res != ERROR_SUCCESS)
+ return hdb;
+
+ res = MsiDatabaseCommit(hdb);
+ ok(res == ERROR_SUCCESS, "Failed to commit database\n");
+
+ set_summary_info(hdb, prodcode);
+
+ res = run_query(hdb,
+ "CREATE TABLE `Directory` ( "
+ "`Directory` CHAR(255) NOT NULL, "
+ "`Directory_Parent` CHAR(255), "
+ "`DefaultDir` CHAR(255) NOT NULL "
+ "PRIMARY KEY `Directory`)");
+ ok(res == ERROR_SUCCESS , "Failed to create directory table\n");
+
+ res = run_query(hdb,
+ "CREATE TABLE `Property` ( "
+ "`Property` CHAR(72) NOT NULL, "
+ "`Value` CHAR(255) "
+ "PRIMARY KEY `Property`)");
+ ok(res == ERROR_SUCCESS , "Failed to create directory table\n");
+
+ sprintf(query, "INSERT INTO `Property` "
+ "(`Property`, `Value`) "
+ "VALUES( 'ProductCode', '%s' )", prodcode);
+ res = run_query(hdb, query);
+ ok(res == ERROR_SUCCESS , "Failed\n");
+
+ res = MsiDatabaseCommit(hdb);
+ ok(res == ERROR_SUCCESS, "Failed to commit database\n");
+
+ return hdb;
+}
+
static void test_usefeature(void)
{
INSTALLSTATE r;
if (!pMsiUseFeatureExA)
{
- skip("MsiUseFeatureExA not implemented\n");
+ win_skip("MsiUseFeatureExA not implemented\n");
return;
}
if (!pMsiGetFileHashA)
{
- skip("MsiGetFileHash not implemented\n");
+ win_skip("MsiGetFileHash not implemented\n");
return;
}
for (i = 0; i < sizeof(hash_data) / sizeof(hash_data[0]); i++)
{
+ int ret;
+
create_file(name, hash_data[i].data, hash_data[i].size);
memset(&hash, 0, sizeof(MSIFILEHASHINFO));
r = pMsiGetFileHashA(name, 0, &hash);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
- ok(!memcmp(&hash, &hash_data[i].hash, HASHSIZE), "Hash incorrect\n");
+
+ ret = memcmp(&hash, &hash_data[i].hash, HASHSIZE);
+ ok(ret == 0 ||
+ broken(ret != 0), /* win95 */
+ "Hash incorrect\n");
DeleteFile(name);
}
hr = CoCreateGuid(&guid);
ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
- size = StringFromGUID2(&guid, (LPOLESTR)guidW, MAX_PATH);
+ size = StringFromGUID2(&guid, guidW, MAX_PATH);
ok(size == 39, "Expected 39, got %d\n", hr);
WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
static void get_user_sid(LPSTR *usersid)
{
HANDLE token;
- BYTE buf[1024];
DWORD size;
PTOKEN_USER user;
OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
- size = sizeof(buf);
- GetTokenInformation(token, TokenUser, (void *)buf, size, &size);
- user = (PTOKEN_USER)buf;
+
+ size = 0;
+ GetTokenInformation(token, TokenUser, NULL, size, &size);
+ user = HeapAlloc(GetProcessHeap(), 0, size);
+
+ GetTokenInformation(token, TokenUser, user, size, &size);
pConvertSidToStringSidA(user->User.Sid, usersid);
+
+ HeapFree(GetProcessHeap(), 0, user);
+ CloseHandle(token);
}
static void test_MsiQueryProductState(void)
/*
* Encodes a base85 guid given a GUID pointer
* Caller should provide a 21 character buffer for the encoded string.
- *
- * returns TRUE if successful, FALSE if not
*/
-static BOOL encode_base85_guid( GUID *guid, LPWSTR str )
+static void encode_base85_guid( GUID *guid, LPWSTR str )
{
unsigned int x, *p, i;
*str++ = table_enc85[x%85];
}
*str = 0;
-
- return TRUE;
}
static void compose_base85_guid(LPSTR component, LPSTR comp_base85, LPSTR squashed)
hr = CoCreateGuid(&guid);
ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
- size = StringFromGUID2(&guid, (LPOLESTR)guidW, MAX_PATH);
+ size = StringFromGUID2(&guid, guidW, MAX_PATH);
ok(size == 39, "Expected 39, got %d\n", hr);
WideCharToMultiByte(CP_ACP, 0, guidW, size, component, MAX_PATH, NULL, NULL);
static void test_MsiQueryFeatureState(void)
{
- HKEY userkey, localkey, compkey;
+ HKEY userkey, localkey, compkey, compkey2;
CHAR prodcode[MAX_PATH];
CHAR prod_squashed[MAX_PATH];
CHAR component[MAX_PATH];
CHAR comp_base85[MAX_PATH];
- CHAR comp_squashed[MAX_PATH];
+ CHAR comp_squashed[MAX_PATH], comp_squashed2[MAX_PATH];
CHAR keypath[MAX_PATH*2];
INSTALLSTATE state;
LPSTR usersid;
create_test_guid(prodcode, prod_squashed);
compose_base85_guid(component, comp_base85, comp_squashed);
+ compose_base85_guid(component, comp_base85 + 20, comp_squashed2);
get_user_sid(&usersid);
/* NULL prodcode */
state = MsiQueryFeatureStateA(prodcode, "feature");
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
- res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 21);
+ res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 41);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
state = MsiQueryFeatureStateA(prodcode, "feature");
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
+ lstrcatA(keypath, usersid);
+ lstrcatA(keypath, "\\Components\\");
+ lstrcatA(keypath, comp_squashed2);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey2);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
state = MsiQueryFeatureStateA(prodcode, "feature");
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+ state = MsiQueryFeatureStateA(prodcode, "feature");
+ ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
+
+ res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 6);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ state = MsiQueryFeatureStateA(prodcode, "feature");
+ ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
+
+ res = RegSetValueExA(compkey2, prod_squashed, 0, REG_SZ, (const BYTE *)"orange", 7);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* INSTALLSTATE_LOCAL */
+ state = MsiQueryFeatureStateA(prodcode, "feature");
+ ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
+
+ res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01\\", 4);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* INSTALLSTATE_SOURCE */
+ state = MsiQueryFeatureStateA(prodcode, "feature");
+ ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
+
+ res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* bad INSTALLSTATE_SOURCE */
state = MsiQueryFeatureStateA(prodcode, "feature");
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
- res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 1);
+ res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01a", 4);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* INSTALLSTATE_SOURCE */
+ state = MsiQueryFeatureStateA(prodcode, "feature");
+ ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
+
+ res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+ /* bad INSTALLSTATE_SOURCE */
state = MsiQueryFeatureStateA(prodcode, "feature");
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
RegDeleteValueA(compkey, prod_squashed);
+ RegDeleteValueA(compkey2, prod_squashed);
RegDeleteKeyA(compkey, "");
+ RegDeleteKeyA(compkey2, "");
RegDeleteValueA(localkey, "feature");
RegDeleteValueA(userkey, "feature");
RegDeleteKeyA(userkey, "");
RegCloseKey(compkey);
+ RegCloseKey(compkey2);
RegCloseKey(localkey);
RegCloseKey(userkey);
state = MsiQueryFeatureStateA(prodcode, "feature");
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
- res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 2);
+ res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 1);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* feature value exists */
state = MsiQueryFeatureStateA(prodcode, "feature");
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
- res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 21);
+ res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 41);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
state = MsiQueryFeatureStateA(prodcode, "feature");
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
+ lstrcatA(keypath, usersid);
+ lstrcatA(keypath, "\\Components\\");
+ lstrcatA(keypath, comp_squashed2);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey2);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
state = MsiQueryFeatureStateA(prodcode, "feature");
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
state = MsiQueryFeatureStateA(prodcode, "feature");
- ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
+ ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
+
+ res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 6);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ state = MsiQueryFeatureStateA(prodcode, "feature");
+ ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
- res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 1);
+ res = RegSetValueExA(compkey2, prod_squashed, 0, REG_SZ, (const BYTE *)"orange", 7);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
state = MsiQueryFeatureStateA(prodcode, "feature");
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
RegDeleteValueA(compkey, prod_squashed);
+ RegDeleteValueA(compkey2, prod_squashed);
RegDeleteKeyA(compkey, "");
+ RegDeleteKeyA(compkey2, "");
RegDeleteValueA(localkey, "feature");
RegDeleteValueA(userkey, "feature");
RegDeleteKeyA(userkey, "");
RegCloseKey(compkey);
+ RegCloseKey(compkey2);
RegCloseKey(localkey);
RegCloseKey(userkey);
state = MsiQueryFeatureStateA(prodcode, "feature");
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
- res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 2);
+ res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 1);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* feature value exists */
state = MsiQueryFeatureStateA(prodcode, "feature");
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
- res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 21);
+ res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 41);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
state = MsiQueryFeatureStateA(prodcode, "feature");
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
+ lstrcatA(keypath, "S-1-5-18\\Components\\");
+ lstrcatA(keypath, comp_squashed2);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey2);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
state = MsiQueryFeatureStateA(prodcode, "feature");
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
state = MsiQueryFeatureStateA(prodcode, "feature");
- ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
+ ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
+
+ res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 6);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ state = MsiQueryFeatureStateA(prodcode, "feature");
+ ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
- res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 1);
+ res = RegSetValueExA(compkey2, prod_squashed, 0, REG_SZ, (const BYTE *)"orange", 7);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
state = MsiQueryFeatureStateA(prodcode, "feature");
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
RegDeleteValueA(compkey, prod_squashed);
+ RegDeleteValueA(compkey2, prod_squashed);
RegDeleteKeyA(compkey, "");
+ RegDeleteKeyA(compkey2, "");
RegDeleteValueA(localkey, "feature");
RegDeleteValueA(userkey, "feature");
RegDeleteKeyA(userkey, "");
RegCloseKey(compkey);
+ RegCloseKey(compkey2);
RegCloseKey(localkey);
RegCloseKey(userkey);
+ LocalFree(usersid);
}
static void test_MsiQueryComponentState(void)
if (!pMsiQueryComponentStateA)
{
- skip("MsiQueryComponentStateA not implemented\n");
+ win_skip("MsiQueryComponentStateA not implemented\n");
return;
}
state = MAGIC_ERROR;
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
- ok(state == INSTALLSTATE_NOTUSED, "Expected INSTALLSTATE_NOTUSED, got %d\n", state);
+ ok(state == INSTALLSTATE_NOTUSED || state == INSTALLSTATE_LOCAL,
+ "Expected INSTALLSTATE_NOTUSED or INSTALLSTATE_LOCAL, got %d\n", state);
+
+ /* NULL component, product exists */
+ state = MAGIC_ERROR;
+ r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, NULL, &state);
+ ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(state == MAGIC_ERROR, "Expected state not changed, got %d\n", state);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+ /* INSTALLSTATE_LOCAL */
+ state = MAGIC_ERROR;
+ r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
+
+ res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01\\", 4);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* INSTALLSTATE_SOURCE */
+ state = MAGIC_ERROR;
+ r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
+
+ res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* bad INSTALLSTATE_SOURCE */
+ state = MAGIC_ERROR;
+ r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
+
+ res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01a", 4);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* INSTALLSTATE_SOURCE */
+ state = MAGIC_ERROR;
+ r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
+
+ res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* bad INSTALLSTATE_SOURCE */
state = MAGIC_ERROR;
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
state = MAGIC_ERROR;
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
- ok(state == INSTALLSTATE_NOTUSED, "Expected INSTALLSTATE_NOTUSED, got %d\n", state);
+ ok(state == INSTALLSTATE_NOTUSED || state == INSTALLSTATE_LOCAL,
+ "Expected INSTALLSTATE_NOTUSED or INSTALLSTATE_LOCAL, got %d\n", state);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
RegDeleteKeyA(compkey, "");
RegCloseKey(prodkey);
RegCloseKey(compkey);
+ LocalFree(usersid);
}
static void test_MsiGetComponentPath(void)
RegDeleteKeyA(compkey, "");
RegCloseKey(prodkey);
RegCloseKey(compkey);
- RegCloseKey(installprop);
DeleteFileA("C:\\imapath");
lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
RegCloseKey(prodkey);
RegCloseKey(compkey);
DeleteFileA("C:\\imapath");
+ LocalFree(usersid);
}
static void test_MsiGetProductCode(void)
RegDeleteKeyA(prodkey, "");
RegCloseKey(prodkey);
- RegDeleteKeyA(prodkey, "");
- RegCloseKey(prodkey);
-
lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
lstrcatA(keypath, prod_squashed);
RegDeleteValueA(compkey, prod2_squashed);
RegDeleteKeyA(compkey, "");
RegCloseKey(compkey);
+ LocalFree(usersid);
}
static void test_MsiEnumClients(void)
RegDeleteValueA(compkey, prod2_squashed);
RegDeleteKeyA(compkey, "");
RegCloseKey(compkey);
+ LocalFree(usersid);
}
static void get_version_info(LPSTR path, LPSTR *vercheck, LPDWORD verchecksz,
r = MsiGetFileVersionA(path, version, &versz, lang, &langsz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
- ok(!lstrcmpA(lang, langcheck), "Expected %s, got %s\n", langcheck, lang);
- ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
+ ok(strstr(lang, langcheck) != NULL, "Expected %s in %s\n", langcheck, lang);
ok(!lstrcmpA(version, vercheck),
"Expected %s, got %s\n", vercheck, version);
lstrcpyA(lang, "lang");
r = MsiGetFileVersionA(path, NULL, NULL, lang, &langsz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
- ok(!lstrcmpA(lang, langcheck), "Expected %s, got %s\n", langcheck, lang);
- ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
+ ok(strstr(lang, langcheck) != NULL, "Expected %s in %s\n", langcheck, lang);
/* check neither version nor language */
r = MsiGetFileVersionA(path, NULL, NULL, NULL, NULL);
langsz = MAX_PATH;
r = MsiGetFileVersionA(path, NULL, NULL, NULL, &langsz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
- ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
+ ok(langsz >= langchecksz, "Expected %d >= %d\n", langsz, langchecksz);
/* pcchVersionBuf not big enough */
versz = 5;
ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
ok(!strncmp(lang, langcheck, 2),
"Expected first character of %s, got %s\n", langcheck, lang);
- ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
+ ok(langsz >= langchecksz, "Expected %d >= %d\n", langsz, langchecksz);
HeapFree(GetProcessHeap(), 0, vercheck);
HeapFree(GetProcessHeap(), 0, langcheck);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(sz == 4, "Expected 4, got %d\n", sz);
- /* lpValueBuf is NULL, pcchValueBuf is too small */
+ /* lpValueBuf is non-NULL, pcchValueBuf is too small */
sz = 2;
lstrcpyA(buf, "apple");
r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
ok(sz == 4, "Expected 4, got %d\n", sz);
- /* lpValueBuf is NULL, pcchValueBuf is exactly 4 */
+ /* lpValueBuf is non-NULL, pcchValueBuf is exactly 4 */
sz = 4;
lstrcpyA(buf, "apple");
r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
ok(sz == 2, "Expected 2, got %d\n", sz);
+ /* SourceList key does not exist */
+ sz = MAX_PATH;
+ lstrcpyA(buf, "apple");
+ r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(!lstrcmpA(buf, "apple"),
+ "Expected buf to be unchanged, got \"%s\"\n", buf);
+ ok(sz == MAX_PATH, "Expected sz to be unchanged, got %d\n", sz);
+
res = RegCreateKeyA(prodkey, "SourceList", &source);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+ /* SourceList key exists, but PackageName val does not exist */
+ sz = MAX_PATH;
+ lstrcpyA(buf, "apple");
+ r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
+ ok(sz == 0, "Expected 0, got %d\n", sz);
+
res = RegSetValueExA(source, "PackageName", 0, REG_SZ, (LPBYTE)"packname", 9);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+ /* PackageName val exists */
sz = MAX_PATH;
lstrcpyA(buf, "apple");
r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz);
RegCloseKey(localkey);
RegCloseKey(source);
RegCloseKey(prodkey);
+ LocalFree(usersid);
}
static void test_MsiGetProductInfoEx(void)
if (!pMsiGetProductInfoExA)
{
- skip("MsiGetProductInfoExA is not available\n");
+ win_skip("MsiGetProductInfoExA is not available\n");
return;
}
INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
ok(r == ERROR_MORE_DATA,
"Expected ERROR_MORE_DATA, got %d\n", r);
- ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
ok(sz == 10, "Expected 10, got %d\n", sz);
/* szValue is NULL, pcchValue is exactly 5 */
RegDeleteValueA(prodkey, "HelpLink");
RegDeleteKeyA(prodkey, "");
RegCloseKey(prodkey);
+ LocalFree(usersid);
}
#define INIT_USERINFO() \
RegCloseKey(userprod);
RegDeleteKeyA(prodkey, "");
RegCloseKey(prodkey);
+ LocalFree(usersid);
+}
+
+static void test_MsiOpenProduct(void)
+{
+ MSIHANDLE hprod, hdb;
+ CHAR val[MAX_PATH];
+ CHAR path[MAX_PATH];
+ CHAR keypath[MAX_PATH*2];
+ CHAR prodcode[MAX_PATH];
+ CHAR prod_squashed[MAX_PATH];
+ HKEY prodkey, userkey, props;
+ LPSTR usersid;
+ DWORD size;
+ LONG res;
+ UINT r;
+
+ GetCurrentDirectoryA(MAX_PATH, path);
+ lstrcatA(path, "\\");
+
+ create_test_guid(prodcode, prod_squashed);
+ get_user_sid(&usersid);
+
+ hdb = create_package_db(prodcode);
+ MsiCloseHandle(hdb);
+
+ /* NULL szProduct */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA(NULL, &hprod);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ /* empty szProduct */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA("", &hprod);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ /* garbage szProduct */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA("garbage", &hprod);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ /* guid without brackets */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", &hprod);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ /* guid with brackets */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", &hprod);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ /* same length as guid, but random */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", &hprod);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ /* hProduct is NULL */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA(prodcode, NULL);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ /* MSIINSTALLCONTEXT_USERMANAGED */
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
+ lstrcatA(keypath, "Installer\\Managed\\");
+ lstrcatA(keypath, usersid);
+ lstrcatA(keypath, "\\Installer\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* managed product key exists */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA(prodcode, &hprod);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
+ lstrcatA(keypath, "Installer\\UserData\\");
+ lstrcatA(keypath, usersid);
+ lstrcatA(keypath, "\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* user product key exists */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA(prodcode, &hprod);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ res = RegCreateKeyA(userkey, "InstallProperties", &props);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* InstallProperties key exists */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA(prodcode, &hprod);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ lstrcpyA(val, path);
+ lstrcatA(val, "\\winetest.msi");
+ res = RegSetValueExA(props, "ManagedLocalPackage", 0, REG_SZ,
+ (const BYTE *)val, lstrlenA(val) + 1);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* ManagedLocalPackage value exists */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA(prodcode, &hprod);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
+
+ size = MAX_PATH;
+ r = MsiGetPropertyA(hprod, "ProductCode", val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, prodcode), "Expected \"%s\", got \"%s\"\n", prodcode, val);
+ ok(size == lstrlenA(prodcode), "Expected %d, got %d\n", lstrlenA(prodcode), size);
+
+ MsiCloseHandle(hprod);
+
+ RegDeleteValueA(props, "ManagedLocalPackage");
+ RegDeleteKeyA(props, "");
+ RegCloseKey(props);
+ RegDeleteKeyA(userkey, "");
+ RegCloseKey(userkey);
+ RegDeleteKeyA(prodkey, "");
+ RegCloseKey(prodkey);
+
+ /* MSIINSTALLCONTEXT_USERUNMANAGED */
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* unmanaged product key exists */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA(prodcode, &hprod);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
+ lstrcatA(keypath, "Installer\\UserData\\");
+ lstrcatA(keypath, usersid);
+ lstrcatA(keypath, "\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* user product key exists */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA(prodcode, &hprod);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ res = RegCreateKeyA(userkey, "InstallProperties", &props);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* InstallProperties key exists */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA(prodcode, &hprod);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ lstrcpyA(val, path);
+ lstrcatA(val, "\\winetest.msi");
+ res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
+ (const BYTE *)val, lstrlenA(val) + 1);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* LocalPackage value exists */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA(prodcode, &hprod);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
+
+ size = MAX_PATH;
+ r = MsiGetPropertyA(hprod, "ProductCode", val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, prodcode), "Expected \"%s\", got \"%s\"\n", prodcode, val);
+ ok(size == lstrlenA(prodcode), "Expected %d, got %d\n", lstrlenA(prodcode), size);
+
+ MsiCloseHandle(hprod);
+
+ RegDeleteValueA(props, "LocalPackage");
+ RegDeleteKeyA(props, "");
+ RegCloseKey(props);
+ RegDeleteKeyA(userkey, "");
+ RegCloseKey(userkey);
+ RegDeleteKeyA(prodkey, "");
+ RegCloseKey(prodkey);
+
+ /* MSIINSTALLCONTEXT_MACHINE */
+
+ lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* managed product key exists */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA(prodcode, &hprod);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
+ lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* user product key exists */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA(prodcode, &hprod);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ res = RegCreateKeyA(userkey, "InstallProperties", &props);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* InstallProperties key exists */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA(prodcode, &hprod);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ lstrcpyA(val, path);
+ lstrcatA(val, "\\winetest.msi");
+ res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
+ (const BYTE *)val, lstrlenA(val) + 1);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* LocalPackage value exists */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA(prodcode, &hprod);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
+
+ size = MAX_PATH;
+ r = MsiGetPropertyA(hprod, "ProductCode", val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, prodcode), "Expected \"%s\", got \"%s\"\n", prodcode, val);
+ ok(size == lstrlenA(prodcode), "Expected %d, got %d\n", lstrlenA(prodcode), size);
+
+ MsiCloseHandle(hprod);
+
+ res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
+ (const BYTE *)"winetest.msi", 13);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* LocalPackage has just the package name */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA(prodcode, &hprod);
+ ok(r == ERROR_INSTALL_PACKAGE_OPEN_FAILED || r == ERROR_SUCCESS,
+ "Expected ERROR_INSTALL_PACKAGE_OPEN_FAILED or ERROR_SUCCESS, got %d\n", r);
+ if (r == ERROR_SUCCESS)
+ MsiCloseHandle(hprod);
+ else
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ lstrcpyA(val, path);
+ lstrcatA(val, "\\winetest.msi");
+ res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
+ (const BYTE *)val, lstrlenA(val) + 1);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ DeleteFileA(msifile);
+
+ /* local package does not exist */
+ hprod = 0xdeadbeef;
+ r = MsiOpenProductA(prodcode, &hprod);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
+
+ RegDeleteValueA(props, "LocalPackage");
+ RegDeleteKeyA(props, "");
+ RegCloseKey(props);
+ RegDeleteKeyA(userkey, "");
+ RegCloseKey(userkey);
+ RegDeleteKeyA(prodkey, "");
+ RegCloseKey(prodkey);
+
+ DeleteFileA(msifile);
+ LocalFree(usersid);
+}
+
+static void test_MsiEnumPatchesEx_usermanaged(LPCSTR usersid, LPCSTR expectedsid)
+{
+ MSIINSTALLCONTEXT context;
+ CHAR keypath[MAX_PATH], patch[MAX_PATH];
+ CHAR patch_squashed[MAX_PATH], patchcode[MAX_PATH];
+ CHAR targetsid[MAX_PATH], targetprod[MAX_PATH];
+ CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
+ HKEY prodkey, patches, udprod, udpatch, hpatch;
+ DWORD size, data;
+ LONG res;
+ UINT r;
+
+ create_test_guid(prodcode, prod_squashed);
+ create_test_guid(patch, patch_squashed);
+
+ /* MSIPATCHSTATE_APPLIED */
+
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
+ lstrcatA(keypath, expectedsid);
+ lstrcatA(keypath, "\\Installer\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* managed product key exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(prodkey, "Patches", &patches);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* patches key exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
+ (const BYTE *)patch_squashed,
+ lstrlenA(patch_squashed) + 1);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists, is not REG_MULTI_SZ */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_BAD_CONFIGURATION,
+ "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
+ (const BYTE *)"a\0b\0c\0\0", 7);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists, is not a squashed guid */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_BAD_CONFIGURATION,
+ "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ patch_squashed[lstrlenA(patch_squashed) + 1] = '\0';
+ res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
+ (const BYTE *)patch_squashed,
+ lstrlenA(patch_squashed) + 2);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
+ (const BYTE *)"whatever", 9);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* patch squashed value exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_USERMANAGED,
+ "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
+ ok(!lstrcmpA(targetsid, expectedsid),
+ "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
+ ok(size == lstrlenA(expectedsid),
+ "Expected %d, got %d\n", lstrlenA(expectedsid), size);
+
+ /* increase the index */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_APPLIED, 1, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* increase again */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_APPLIED, 2, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* szPatchCode is NULL */
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, NULL, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_USERMANAGED,
+ "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
+ ok(!lstrcmpA(targetsid, expectedsid),
+ "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
+ ok(size == lstrlenA(expectedsid),
+ "Expected %d, got %d\n", lstrlenA(expectedsid), size);
+
+ /* szTargetProductCode is NULL */
+ lstrcpyA(patchcode, "apple");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, NULL,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(context == MSIINSTALLCONTEXT_USERMANAGED,
+ "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
+ ok(!lstrcmpA(targetsid, expectedsid),
+ "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
+ ok(size == lstrlenA(expectedsid),
+ "Expected %d, got %d\n", lstrlenA(expectedsid), size);
+
+ /* pdwTargetProductContext is NULL */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ NULL, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(!lstrcmpA(targetsid, expectedsid),
+ "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
+ ok(size == lstrlenA(expectedsid),
+ "Expected %d, got %d\n", lstrlenA(expectedsid), size);
+
+ /* szTargetUserSid is NULL */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, NULL, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_USERMANAGED,
+ "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
+ ok(size == lstrlenA(expectedsid) * sizeof(WCHAR),
+ "Expected %d*sizeof(WCHAR), got %d\n", lstrlenA(expectedsid), size);
+
+ /* pcchTargetUserSid is exactly the length of szTargetUserSid */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = lstrlenA(expectedsid);
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_USERMANAGED,
+ "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
+ ok(!strncmp(targetsid, expectedsid, lstrlenA(expectedsid) - 1),
+ "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
+ ok(size == lstrlenA(expectedsid) * sizeof(WCHAR),
+ "Expected %d*sizeof(WCHAR), got %d\n", lstrlenA(expectedsid), size);
+
+ /* pcchTargetUserSid has enough room for NULL terminator */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = lstrlenA(expectedsid) + 1;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_USERMANAGED,
+ "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
+ ok(!lstrcmpA(targetsid, expectedsid),
+ "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
+ ok(size == lstrlenA(expectedsid),
+ "Expected %d, got %d\n", lstrlenA(expectedsid), size);
+
+ /* both szTargetuserSid and pcchTargetUserSid are NULL */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, NULL, NULL);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_USERMANAGED,
+ "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
+
+ /* MSIPATCHSTATE_SUPERSEDED */
+
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
+ lstrcatA(keypath, expectedsid);
+ lstrcatA(keypath, "\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &udprod);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* UserData product key exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(udprod, "Patches", &udpatch);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* UserData patches key exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(udpatch, patch_squashed, &hpatch);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* specific UserData patch key exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_BAD_CONFIGURATION,
+ "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ data = MSIPATCHSTATE_SUPERSEDED;
+ res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
+ (const BYTE *)&data, sizeof(DWORD));
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* State value exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_USERMANAGED,
+ "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
+ ok(!lstrcmpA(targetsid, expectedsid),
+ "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
+ ok(size == lstrlenA(expectedsid),
+ "Expected %d, got %d\n", lstrlenA(expectedsid), size);
+
+ /* MSIPATCHSTATE_OBSOLETED */
+
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ data = MSIPATCHSTATE_OBSOLETED;
+ res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
+ (const BYTE *)&data, sizeof(DWORD));
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* State value is obsoleted */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_USERMANAGED,
+ "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
+ ok(!lstrcmpA(targetsid, expectedsid),
+ "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
+ ok(size == lstrlenA(expectedsid),
+ "Expected %d, got %d\n", lstrlenA(expectedsid), size);
+
+ /* MSIPATCHSTATE_REGISTERED */
+ /* FIXME */
+
+ /* MSIPATCHSTATE_ALL */
+
+ /* 1st */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_USERMANAGED,
+ "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
+ ok(!lstrcmpA(targetsid, expectedsid),
+ "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
+ ok(size == lstrlenA(expectedsid),
+ "Expected %d, got %d\n", lstrlenA(expectedsid), size);
+
+ /* same patch in multiple places, only one is enumerated */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
+ MSIPATCHSTATE_ALL, 1, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ RegDeleteValueA(hpatch, "State");
+ RegDeleteKeyA(hpatch, "");
+ RegCloseKey(hpatch);
+ RegDeleteKeyA(udpatch, "");
+ RegCloseKey(udpatch);
+ RegDeleteKeyA(udprod, "");
+ RegCloseKey(udprod);
+ RegDeleteValueA(patches, "Patches");
+ RegDeleteKeyA(patches, "");
+ RegCloseKey(patches);
+ RegDeleteKeyA(prodkey, "");
+ RegCloseKey(prodkey);
+}
+
+static void test_MsiEnumPatchesEx_userunmanaged(LPCSTR usersid, LPCSTR expectedsid)
+{
+ MSIINSTALLCONTEXT context;
+ CHAR keypath[MAX_PATH], patch[MAX_PATH];
+ CHAR patch_squashed[MAX_PATH], patchcode[MAX_PATH];
+ CHAR targetsid[MAX_PATH], targetprod[MAX_PATH];
+ CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
+ HKEY prodkey, patches, udprod, udpatch;
+ HKEY userkey, hpatch;
+ DWORD size, data;
+ LONG res;
+ UINT r;
+
+ create_test_guid(prodcode, prod_squashed);
+ create_test_guid(patch, patch_squashed);
+
+ /* MSIPATCHSTATE_APPLIED */
+
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* current user product key exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(prodkey, "Patches", &patches);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches key exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
+ (const BYTE *)patch_squashed,
+ lstrlenA(patch_squashed) + 1);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists, is not REG_MULTI_SZ */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_BAD_CONFIGURATION,
+ "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
+ (const BYTE *)"a\0b\0c\0\0", 7);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists, is not a squashed guid */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_BAD_CONFIGURATION,
+ "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
+ (const BYTE *)patch_squashed,
+ lstrlenA(patch_squashed) + 1);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
+ (const BYTE *)"whatever", 9);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* patch code value exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
+ lstrcatA(keypath, expectedsid);
+ lstrcatA(keypath, "\\Patches\\");
+ lstrcatA(keypath, patch_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* userdata patch key exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_USERUNMANAGED,
+ "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context);
+ ok(!lstrcmpA(targetsid, expectedsid),
+ "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
+ ok(size == lstrlenA(expectedsid),
+ "Expected %d, got %d\n", lstrlenA(expectedsid), size);
+
+ /* MSIPATCHSTATE_SUPERSEDED */
+
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
+ lstrcatA(keypath, expectedsid);
+ lstrcatA(keypath, "\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &udprod);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* UserData product key exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(udprod, "Patches", &udpatch);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* UserData patches key exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(udpatch, patch_squashed, &hpatch);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* specific UserData patch key exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_BAD_CONFIGURATION,
+ "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ data = MSIPATCHSTATE_SUPERSEDED;
+ res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
+ (const BYTE *)&data, sizeof(DWORD));
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* State value exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_USERUNMANAGED,
+ "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context);
+ ok(!lstrcmpA(targetsid, expectedsid),
+ "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
+ ok(size == lstrlenA(expectedsid),
+ "Expected %d, got %d\n", lstrlenA(expectedsid), size);
+
+ /* MSIPATCHSTATE_OBSOLETED */
+
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ data = MSIPATCHSTATE_OBSOLETED;
+ res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
+ (const BYTE *)&data, sizeof(DWORD));
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* State value is obsoleted */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_USERUNMANAGED,
+ "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context);
+ ok(!lstrcmpA(targetsid, expectedsid),
+ "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
+ ok(size == lstrlenA(expectedsid),
+ "Expected %d, got %d\n", lstrlenA(expectedsid), size);
+
+ /* MSIPATCHSTATE_REGISTERED */
+ /* FIXME */
+
+ /* MSIPATCHSTATE_ALL */
+
+ /* 1st */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_USERUNMANAGED,
+ "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context);
+ ok(!lstrcmpA(targetsid, expectedsid),
+ "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
+ ok(size == lstrlenA(expectedsid),
+ "Expected %d, got %d\n", lstrlenA(expectedsid), size);
+
+ /* same patch in multiple places, only one is enumerated */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_ALL, 1, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ RegDeleteValueA(hpatch, "State");
+ RegDeleteKeyA(hpatch, "");
+ RegCloseKey(hpatch);
+ RegDeleteKeyA(udpatch, "");
+ RegCloseKey(udpatch);
+ RegDeleteKeyA(udprod, "");
+ RegCloseKey(udprod);
+ RegDeleteKeyA(userkey, "");
+ RegCloseKey(userkey);
+ RegDeleteValueA(patches, patch_squashed);
+ RegDeleteValueA(patches, "Patches");
+ RegDeleteKeyA(patches, "");
+ RegCloseKey(patches);
+ RegDeleteKeyA(prodkey, "");
+ RegCloseKey(prodkey);
+}
+
+static void test_MsiEnumPatchesEx_machine(void)
+{
+ CHAR keypath[MAX_PATH], patch[MAX_PATH];
+ CHAR patch_squashed[MAX_PATH], patchcode[MAX_PATH];
+ CHAR targetsid[MAX_PATH], targetprod[MAX_PATH];
+ CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
+ HKEY prodkey, patches, udprod, udpatch;
+ HKEY hpatch;
+ MSIINSTALLCONTEXT context;
+ DWORD size, data;
+ LONG res;
+ UINT r;
+
+ create_test_guid(prodcode, prod_squashed);
+ create_test_guid(patch, patch_squashed);
+
+ /* MSIPATCHSTATE_APPLIED */
+
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* local product key exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(prodkey, "Patches", &patches);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches key exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
+ (const BYTE *)patch_squashed,
+ lstrlenA(patch_squashed) + 1);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists, is not REG_MULTI_SZ */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_BAD_CONFIGURATION,
+ "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
+ (const BYTE *)"a\0b\0c\0\0", 7);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists, is not a squashed guid */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_BAD_CONFIGURATION,
+ "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ patch_squashed[lstrlenA(patch_squashed) + 1] = '\0';
+ res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
+ (const BYTE *)patch_squashed,
+ lstrlenA(patch_squashed) + 2);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
+ (const BYTE *)"whatever", 9);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* patch code value exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_MACHINE,
+ "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
+ ok(!lstrcmpA(targetsid, ""), "Expected \"\", got \"%s\"\n", targetsid);
+ ok(size == 0, "Expected 0, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
+ lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &udprod);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* local UserData product key exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_MACHINE,
+ "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
+ ok(!lstrcmpA(targetsid, ""),
+ "Expected \"\", got \"%s\"\n", targetsid);
+ ok(size == 0, "Expected 0, got %d\n", size);
+
+ res = RegCreateKeyA(udprod, "Patches", &udpatch);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* local UserData Patches key exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_MACHINE,
+ "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
+ ok(!lstrcmpA(targetsid, ""),
+ "Expected \"\", got \"%s\"\n", targetsid);
+ ok(size == 0, "Expected 0, got %d\n", size);
+
+ res = RegCreateKeyA(udpatch, patch_squashed, &hpatch);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* local UserData Product patch key exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ data = MSIPATCHSTATE_APPLIED;
+ res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
+ (const BYTE *)&data, sizeof(DWORD));
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* State value exists */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_MACHINE,
+ "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
+ ok(!lstrcmpA(targetsid, ""),
+ "Expected \"\", got \"%s\"\n", targetsid);
+ ok(size == 0, "Expected 0, got %d\n", size);
+
+ /* MSIPATCHSTATE_SUPERSEDED */
+
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ data = MSIPATCHSTATE_SUPERSEDED;
+ res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
+ (const BYTE *)&data, sizeof(DWORD));
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* State value is MSIPATCHSTATE_SUPERSEDED */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_MACHINE,
+ "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
+ ok(!lstrcmpA(targetsid, ""), "Expected \"\", got \"%s\"\n", targetsid);
+ ok(size == 0, "Expected 0, got %d\n", size);
+
+ /* MSIPATCHSTATE_OBSOLETED */
+
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ data = MSIPATCHSTATE_OBSOLETED;
+ res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
+ (const BYTE *)&data, sizeof(DWORD));
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* State value is obsoleted */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_MACHINE,
+ "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
+ ok(!lstrcmpA(targetsid, ""), "Expected \"\", got \"%s\"\n", targetsid);
+ ok(size == 0, "Expected 0, got %d\n", size);
+
+ /* MSIPATCHSTATE_REGISTERED */
+ /* FIXME */
+
+ /* MSIPATCHSTATE_ALL */
+
+ /* 1st */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, patch),
+ "Expected \"%s\", got \"%s\"\n", patch, patchcode);
+ ok(!lstrcmpA(targetprod, prodcode),
+ "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
+ ok(context == MSIINSTALLCONTEXT_MACHINE,
+ "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
+ ok(!lstrcmpA(targetsid, ""), "Expected \"\", got \"%s\"\n", targetsid);
+ ok(size == 0, "Expected 0, got %d\n", size);
+
+ /* same patch in multiple places, only one is enumerated */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_ALL, 1, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ RegDeleteValueA(patches, patch_squashed);
+ RegDeleteValueA(patches, "Patches");
+ RegDeleteKeyA(patches, "");
+ RegCloseKey(patches);
+ RegDeleteValueA(hpatch, "State");
+ RegDeleteKeyA(hpatch, "");
+ RegCloseKey(hpatch);
+ RegDeleteKeyA(udpatch, "");
+ RegCloseKey(udpatch);
+ RegDeleteKeyA(udprod, "");
+ RegCloseKey(udprod);
+ RegDeleteKeyA(prodkey, "");
+ RegCloseKey(prodkey);
+}
+
+static void test_MsiEnumPatchesEx(void)
+{
+ CHAR targetsid[MAX_PATH], targetprod[MAX_PATH];
+ CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
+ CHAR patchcode[MAX_PATH];
+ MSIINSTALLCONTEXT context;
+ LPSTR usersid;
+ DWORD size;
+ UINT r;
+
+ if (!pMsiEnumPatchesExA)
+ {
+ win_skip("MsiEnumPatchesExA not implemented\n");
+ return;
+ }
+
+ create_test_guid(prodcode, prod_squashed);
+ get_user_sid(&usersid);
+
+ /* empty szProductCode */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA("", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_ALL, 0, patchcode, targetprod, &context,
+ targetsid, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* garbage szProductCode */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA("garbage", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_ALL, 0, patchcode, targetprod, &context,
+ targetsid, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* guid without brackets */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", usersid,
+ MSIINSTALLCONTEXT_USERUNMANAGED, MSIPATCHSTATE_ALL,
+ 0, patchcode, targetprod, &context,
+ targetsid, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* guid with brackets */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA("{6700E8CF-95AB-4D9C-BC2C-15840DDA7A5D}", usersid,
+ MSIINSTALLCONTEXT_USERUNMANAGED, MSIPATCHSTATE_ALL,
+ 0, patchcode, targetprod, &context,
+ targetsid, &size);
+ ok(r == ERROR_NO_MORE_ITEMS,
+ "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* szUserSid is S-1-5-18 */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, "S-1-5-18",
+ MSIINSTALLCONTEXT_USERUNMANAGED, MSIPATCHSTATE_ALL,
+ 0, patchcode, targetprod, &context,
+ targetsid, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* dwContext is MSIINSTALLCONTEXT_MACHINE, but szUserSid is non-NULL */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_MACHINE,
+ MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* dwContext is out of bounds */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, 0,
+ MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* dwContext is out of bounds */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_ALL + 1,
+ MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* dwFilter is out of bounds */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_INVALID, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* dwFilter is out of bounds */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ size = MAX_PATH;
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_ALL + 1, 0, patchcode, targetprod,
+ &context, targetsid, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* pcchTargetUserSid is NULL while szTargetUserSid is non-NULL */
+ lstrcpyA(patchcode, "apple");
+ lstrcpyA(targetprod, "banana");
+ context = 0xdeadbeef;
+ lstrcpyA(targetsid, "kiwi");
+ r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
+ MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
+ &context, targetsid, NULL);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patchcode, "apple"),
+ "Expected patchcode to be unchanged, got %s\n", patchcode);
+ ok(!lstrcmpA(targetprod, "banana"),
+ "Expected targetprod to be unchanged, got %s\n", targetprod);
+ ok(context == 0xdeadbeef,
+ "Expected context to be unchanged, got %d\n", context);
+ ok(!lstrcmpA(targetsid, "kiwi"),
+ "Expected targetsid to be unchanged, got %s\n", targetsid);
+
+ test_MsiEnumPatchesEx_usermanaged(usersid, usersid);
+ test_MsiEnumPatchesEx_usermanaged(NULL, usersid);
+ test_MsiEnumPatchesEx_usermanaged("S-1-2-34", "S-1-2-34");
+ test_MsiEnumPatchesEx_userunmanaged(usersid, usersid);
+ test_MsiEnumPatchesEx_userunmanaged(NULL, usersid);
+ /* FIXME: Successfully test userunmanaged with a different user */
+ test_MsiEnumPatchesEx_machine();
+ LocalFree(usersid);
+}
+
+static void test_MsiEnumPatches(void)
+{
+ CHAR keypath[MAX_PATH], patch[MAX_PATH];
+ CHAR patchcode[MAX_PATH], patch_squashed[MAX_PATH];
+ CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
+ CHAR transforms[MAX_PATH];
+ WCHAR patchW[MAX_PATH], prodcodeW[MAX_PATH], transformsW[MAX_PATH];
+ HKEY prodkey, patches, udprod;
+ HKEY userkey, hpatch, udpatch;
+ DWORD size, data;
+ LPSTR usersid;
+ LONG res;
+ UINT r;
+
+ create_test_guid(prodcode, prod_squashed);
+ create_test_guid(patchcode, patch_squashed);
+ get_user_sid(&usersid);
+
+ /* NULL szProduct */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(NULL, 0, patch, transforms, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* empty szProduct */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA("", 0, patch, transforms, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* garbage szProduct */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA("garbage", 0, patch, transforms, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* guid without brackets */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", 0, patch,
+ transforms, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* guid with brackets */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", 0, patch,
+ transforms, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* same length as guid, but random */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", 0, patch,
+ transforms, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* MSIINSTALLCONTEXT_USERMANAGED */
+
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
+ lstrcatA(keypath, usersid);
+ lstrcatA(keypath, "\\Installer\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* managed product key exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(prodkey, "Patches", &patches);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
+ (const BYTE *)patch_squashed,
+ lstrlenA(patch_squashed) + 1);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists, is not REG_MULTI_SZ */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_BAD_CONFIGURATION,
+ "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
+ (const BYTE *)"a\0b\0c\0\0", 7);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists, is not a squashed guid */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_BAD_CONFIGURATION,
+ "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ patch_squashed[lstrlenA(patch_squashed) + 1] = '\0';
+ res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
+ (const BYTE *)patch_squashed,
+ lstrlenA(patch_squashed) + 2);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
+ (const BYTE *)"whatever", 9);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* patch squashed value exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patch, patchcode),
+ "Expected \"%s\", got \"%s\"\n", patchcode, patch);
+ ok(!lstrcmpA(transforms, "whatever"),
+ "Expected \"whatever\", got \"%s\"\n", transforms);
+ ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
+
+ /* lpPatchBuf is NULL */
+ size = MAX_PATH;
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, NULL, transforms, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* lpTransformsBuf is NULL, pcchTransformsBuf is not */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ r = MsiEnumPatchesA(prodcode, 0, patch, NULL, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* pcchTransformsBuf is NULL, lpTransformsBuf is not */
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, NULL);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+
+ /* pcchTransformsBuf is too small */
+ size = 6;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
+ ok(!lstrcmpA(patch, patchcode),
+ "Expected \"%s\", got \"%s\"\n", patchcode, patch);
+ ok(!lstrcmpA(transforms, "whate"),
+ "Expected \"whate\", got \"%s\"\n", transforms);
+ ok(size == 8 || size == 16, "Expected 8 or 16, got %d\n", size);
+
+ /* increase the index */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 1, patch, transforms, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* increase again */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 2, patch, transforms, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ RegDeleteValueA(patches, "Patches");
+ RegDeleteKeyA(patches, "");
+ RegCloseKey(patches);
+ RegDeleteKeyA(prodkey, "");
+ RegCloseKey(prodkey);
+
+ /* MSIINSTALLCONTEXT_USERUNMANAGED */
+
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* current user product key exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(prodkey, "Patches", &patches);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
+ (const BYTE *)patch_squashed,
+ lstrlenA(patch_squashed) + 1);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists, is not REG_MULTI_SZ */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_BAD_CONFIGURATION,
+ "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
+ (const BYTE *)"a\0b\0c\0\0", 7);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists, is not a squashed guid */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_BAD_CONFIGURATION,
+ "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ patch_squashed[lstrlenA(patch_squashed) + 1] = '\0';
+ res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
+ (const BYTE *)patch_squashed,
+ lstrlenA(patch_squashed) + 2);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
+ (const BYTE *)"whatever", 9);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* patch code value exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
+ lstrcatA(keypath, usersid);
+ lstrcatA(keypath, "\\Patches\\");
+ lstrcatA(keypath, patch_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* userdata patch key exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patch, patchcode),
+ "Expected \"%s\", got \"%s\"\n", patchcode, patch);
+ ok(!lstrcmpA(transforms, "whatever"),
+ "Expected \"whatever\", got \"%s\"\n", transforms);
+ ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
+
+ RegDeleteKeyA(userkey, "");
+ RegCloseKey(userkey);
+ RegDeleteValueA(patches, patch_squashed);
+ RegDeleteValueA(patches, "Patches");
+ RegDeleteKeyA(patches, "");
+ RegCloseKey(patches);
+ RegDeleteKeyA(prodkey, "");
+ RegCloseKey(prodkey);
+
+ /* MSIINSTALLCONTEXT_MACHINE */
+
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* local product key exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(prodkey, "Patches", &patches);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
+ (const BYTE *)patch_squashed,
+ lstrlenA(patch_squashed) + 1);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists, is not REG_MULTI_SZ */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_BAD_CONFIGURATION,
+ "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
+ (const BYTE *)"a\0b\0c\0\0", 7);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists, is not a squashed guid */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_BAD_CONFIGURATION,
+ "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ patch_squashed[lstrlenA(patch_squashed) + 1] = '\0';
+ res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
+ (const BYTE *)patch_squashed,
+ lstrlenA(patch_squashed) + 2);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches value exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
+ (const BYTE *)"whatever", 9);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* patch code value exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patch, patchcode),
+ "Expected \"%s\", got \"%s\"\n", patchcode, patch);
+ ok(!lstrcmpA(transforms, "whatever"),
+ "Expected \"whatever\", got \"%s\"\n", transforms);
+ ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
+ lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &udprod);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* local UserData product key exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patch, patchcode),
+ "Expected \"%s\", got \"%s\"\n", patchcode, patch);
+ ok(!lstrcmpA(transforms, "whatever"),
+ "Expected \"whatever\", got \"%s\"\n", transforms);
+ ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
+
+ res = RegCreateKeyA(udprod, "Patches", &udpatch);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* local UserData Patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patch, patchcode),
+ "Expected \"%s\", got \"%s\"\n", patchcode, patch);
+ ok(!lstrcmpA(transforms, "whatever"),
+ "Expected \"whatever\", got \"%s\"\n", transforms);
+ ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
+
+ res = RegCreateKeyA(udpatch, patch_squashed, &hpatch);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* local UserData Product patch key exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
+ ok(!lstrcmpA(patch, "apple"),
+ "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
+ ok(!lstrcmpA(transforms, "banana"),
+ "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ data = MSIPATCHSTATE_APPLIED;
+ res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
+ (const BYTE *)&data, sizeof(DWORD));
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* State value exists */
+ size = MAX_PATH;
+ lstrcpyA(patch, "apple");
+ lstrcpyA(transforms, "banana");
+ r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(patch, patchcode),
+ "Expected \"%s\", got \"%s\"\n", patchcode, patch);
+ ok(!lstrcmpA(transforms, "whatever"),
+ "Expected \"whatever\", got \"%s\"\n", transforms);
+ ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
+
+ /* now duplicate some of the tests for the W version */
+
+ /* pcchTransformsBuf is too small */
+ size = 6;
+ MultiByteToWideChar( CP_ACP, 0, prodcode, -1, prodcodeW, MAX_PATH );
+ MultiByteToWideChar( CP_ACP, 0, "apple", -1, patchW, MAX_PATH );
+ MultiByteToWideChar( CP_ACP, 0, "banana", -1, transformsW, MAX_PATH );
+ r = MsiEnumPatchesW(prodcodeW, 0, patchW, transformsW, &size);
+ ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
+ WideCharToMultiByte( CP_ACP, 0, patchW, -1, patch, MAX_PATH, NULL, NULL );
+ WideCharToMultiByte( CP_ACP, 0, transformsW, -1, transforms, MAX_PATH, NULL, NULL );
+ ok(!lstrcmpA(patch, patchcode),
+ "Expected \"%s\", got \"%s\"\n", patchcode, patch);
+ ok(!lstrcmpA(transforms, "whate"),
+ "Expected \"whate\", got \"%s\"\n", transforms);
+ ok(size == 8, "Expected 8, got %d\n", size);
+
+ /* patch code value exists */
+ size = MAX_PATH;
+ MultiByteToWideChar( CP_ACP, 0, "apple", -1, patchW, MAX_PATH );
+ MultiByteToWideChar( CP_ACP, 0, "banana", -1, transformsW, MAX_PATH );
+ r = MsiEnumPatchesW(prodcodeW, 0, patchW, transformsW, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ WideCharToMultiByte( CP_ACP, 0, patchW, -1, patch, MAX_PATH, NULL, NULL );
+ WideCharToMultiByte( CP_ACP, 0, transformsW, -1, transforms, MAX_PATH, NULL, NULL );
+ ok(!lstrcmpA(patch, patchcode),
+ "Expected \"%s\", got \"%s\"\n", patchcode, patch);
+ ok(!lstrcmpA(transforms, "whatever"),
+ "Expected \"whatever\", got \"%s\"\n", transforms);
+ ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
+
+ RegDeleteValueA(patches, patch_squashed);
+ RegDeleteValueA(patches, "Patches");
+ RegDeleteKeyA(patches, "");
+ RegCloseKey(patches);
+ RegDeleteValueA(hpatch, "State");
+ RegDeleteKeyA(hpatch, "");
+ RegCloseKey(hpatch);
+ RegDeleteKeyA(udpatch, "");
+ RegCloseKey(udpatch);
+ RegDeleteKeyA(udprod, "");
+ RegCloseKey(udprod);
+ RegDeleteKeyA(prodkey, "");
+ RegCloseKey(prodkey);
+ LocalFree(usersid);
+}
+
+static void test_MsiGetPatchInfoEx(void)
+{
+ CHAR keypath[MAX_PATH], val[MAX_PATH];
+ CHAR patchcode[MAX_PATH], patch_squashed[MAX_PATH];
+ CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
+ HKEY prodkey, patches, udprod, props;
+ HKEY hpatch, udpatch, prodpatches;
+ LPSTR usersid;
+ DWORD size;
+ LONG res;
+ UINT r;
+
+ if (!pMsiGetPatchInfoExA)
+ {
+ win_skip("MsiGetPatchInfoEx not implemented\n");
+ return;
+ }
+
+ create_test_guid(prodcode, prod_squashed);
+ create_test_guid(patchcode, patch_squashed);
+ get_user_sid(&usersid);
+
+ /* NULL szPatchCode */
+ lstrcpyA(val, "apple");
+ size = MAX_PATH;
+ r = pMsiGetPatchInfoExA(NULL, prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* empty szPatchCode */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA("", prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* garbage szPatchCode */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA("garbage", prodcode, NULL,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* guid without brackets */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", prodcode,
+ NULL, MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* guid with brackets */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", prodcode,
+ NULL, MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* same length as guid, but random */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", prodcode,
+ NULL, MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* NULL szProductCode */
+ lstrcpyA(val, "apple");
+ size = MAX_PATH;
+ r = pMsiGetPatchInfoExA(patchcode, NULL, NULL, MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* empty szProductCode */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, "", NULL, MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* garbage szProductCode */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, "garbage", NULL,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* guid without brackets */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, "6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
+ NULL, MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* guid with brackets */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, "{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
+ NULL, MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* same length as guid, but random */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, "A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
+ NULL, MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* szUserSid cannot be S-1-5-18 for MSIINSTALLCONTEXT_USERMANAGED */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, "S-1-5-18",
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* szUserSid cannot be S-1-5-18 for MSIINSTALLCONTEXT_USERUNMANAGED */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, "S-1-5-18",
+ MSIINSTALLCONTEXT_USERUNMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* szUserSid cannot be S-1-5-18 for MSIINSTALLCONTEXT_MACHINE */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, "S-1-5-18",
+ MSIINSTALLCONTEXT_MACHINE,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* szUserSid must be NULL for MSIINSTALLCONTEXT_MACHINE */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_MACHINE,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* dwContext is out of range */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_NONE,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* dwContext is out of range */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_ALL,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* dwContext is invalid */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid, 3,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ /* MSIINSTALLCONTEXT_USERMANAGED */
+
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
+ lstrcatA(keypath, usersid);
+ lstrcatA(keypath, "\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &udprod);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* local UserData product key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(udprod, "InstallProperties", &props);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* InstallProperties key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(udprod, "Patches", &patches);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(patches, patch_squashed, &hpatch);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
+ lstrcatA(keypath, usersid);
+ lstrcatA(keypath, "\\Installer\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* managed product key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(prodkey, "Patches", &prodpatches);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(prodpatches, patch_squashed, 0, REG_SZ,
+ (const BYTE *)"transforms", 11);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* specific patch value exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
+ lstrcatA(keypath, usersid);
+ lstrcatA(keypath, "\\Patches\\");
+ lstrcatA(keypath, patch_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &udpatch);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* UserData Patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
+ ok(size == 0, "Expected 0, got %d\n", size);
+
+ res = RegSetValueExA(udpatch, "ManagedLocalPackage", 0, REG_SZ,
+ (const BYTE *)"pack", 5);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* ManagedLocalPatch value exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
+ ok(size == 4, "Expected 4, got %d\n", size);
+
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_TRANSFORMS, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, "transforms"), "Expected \"transforms\", got \"%s\"\n", val);
+ ok(size == 10, "Expected 10, got %d\n", size);
+
+ res = RegSetValueExA(hpatch, "Installed", 0, REG_SZ,
+ (const BYTE *)"mydate", 7);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Installed value exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_INSTALLDATE, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, "mydate"), "Expected \"mydate\", got \"%s\"\n", val);
+ ok(size == 6, "Expected 6, got %d\n", size);
+
+ res = RegSetValueExA(hpatch, "Uninstallable", 0, REG_SZ,
+ (const BYTE *)"yes", 4);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Uninstallable value exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_UNINSTALLABLE, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, "yes"), "Expected \"yes\", got \"%s\"\n", val);
+ ok(size == 3, "Expected 3, got %d\n", size);
+
+ res = RegSetValueExA(hpatch, "State", 0, REG_SZ,
+ (const BYTE *)"good", 5);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* State value exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_PATCHSTATE, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, "good"), "Expected \"good\", got \"%s\"\n", val);
+ ok(size == 4, "Expected 4, got %d\n", size);
+
+ size = 1;
+ res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
+ (const BYTE *)&size, sizeof(DWORD));
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* State value exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_PATCHSTATE, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ todo_wine ok(!lstrcmpA(val, "1"), "Expected \"1\", got \"%s\"\n", val);
+ ok(size == 1, "Expected 1, got %d\n", size);
+
+ res = RegSetValueExA(hpatch, "DisplayName", 0, REG_SZ,
+ (const BYTE *)"display", 8);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* DisplayName value exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_DISPLAYNAME, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, "display"), "Expected \"display\", got \"%s\"\n", val);
+ ok(size == 7, "Expected 7, got %d\n", size);
+
+ res = RegSetValueExA(hpatch, "MoreInfoURL", 0, REG_SZ,
+ (const BYTE *)"moreinfo", 9);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* MoreInfoURL value exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_MOREINFOURL, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, "moreinfo"), "Expected \"moreinfo\", got \"%s\"\n", val);
+ ok(size == 8, "Expected 8, got %d\n", size);
+
+ /* szProperty is invalid */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ "IDontExist", val, &size);
+ ok(r == ERROR_UNKNOWN_PROPERTY,
+ "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"), "Expected \"apple\", got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
+
+ /* lpValue is NULL, while pcchValue is non-NULL */
+ size = MAX_PATH;
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_MOREINFOURL, NULL, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(size == 16, "Expected 16, got %d\n", size);
+
+ /* pcchValue is NULL, while lpValue is non-NULL */
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_MOREINFOURL, val, NULL);
+ ok(r == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"), "Expected \"apple\", got \"%s\"\n", val);
+
+ /* both lpValue and pcchValue are NULL */
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_MOREINFOURL, NULL, NULL);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+
+ /* pcchValue doesn't have enough room for NULL terminator */
+ size = 8;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_MOREINFOURL, val, &size);
+ ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
+ ok(!lstrcmpA(val, "moreinf"),
+ "Expected \"moreinf\", got \"%s\"\n", val);
+ ok(size == 16, "Expected 16, got %d\n", size);
+
+ /* pcchValue has exactly enough room for NULL terminator */
+ size = 9;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_MOREINFOURL, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, "moreinfo"),
+ "Expected \"moreinfo\", got \"%s\"\n", val);
+ ok(size == 8, "Expected 8, got %d\n", size);
+
+ /* pcchValue is too small, lpValue is NULL */
+ size = 0;
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_MOREINFOURL, NULL, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(size == 16, "Expected 16, got %d\n", size);
+
+ RegDeleteValueA(prodpatches, patch_squashed);
+ RegDeleteKeyA(prodpatches, "");
+ RegCloseKey(prodpatches);
+ RegDeleteKeyA(prodkey, "");
+ RegCloseKey(prodkey);
+
+ /* UserData is sufficient for all properties
+ * except INSTALLPROPERTY_TRANSFORMS
+ */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
+ ok(size == 4, "Expected 4, got %d\n", size);
+
+ /* UserData is sufficient for all properties
+ * except INSTALLPROPERTY_TRANSFORMS
+ */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERMANAGED,
+ INSTALLPROPERTY_TRANSFORMS, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"), "Expected \"apple\", got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
+
+ RegDeleteValueA(hpatch, "MoreInfoURL");
+ RegDeleteValueA(hpatch, "Display");
+ RegDeleteValueA(hpatch, "State");
+ RegDeleteValueA(hpatch, "Uninstallable");
+ RegDeleteValueA(hpatch, "Installed");
+ RegDeleteValueA(udpatch, "ManagedLocalPackage");
+ RegDeleteKeyA(udpatch, "");
+ RegCloseKey(udpatch);
+ RegDeleteKeyA(hpatch, "");
+ RegCloseKey(hpatch);
+ RegDeleteKeyA(patches, "");
+ RegCloseKey(patches);
+ RegDeleteKeyA(props, "");
+ RegCloseKey(props);
+ RegDeleteKeyA(udprod, "");
+ RegCloseKey(udprod);
+
+ /* MSIINSTALLCONTEXT_USERUNMANAGED */
+
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERUNMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
+ lstrcatA(keypath, usersid);
+ lstrcatA(keypath, "\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &udprod);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* local UserData product key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERUNMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(udprod, "InstallProperties", &props);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* InstallProperties key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERUNMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(udprod, "Patches", &patches);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERUNMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(patches, patch_squashed, &hpatch);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERUNMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* current user product key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERUNMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(prodkey, "Patches", &prodpatches);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERUNMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(prodpatches, patch_squashed, 0, REG_SZ,
+ (const BYTE *)"transforms", 11);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* specific patch value exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERUNMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
+ lstrcatA(keypath, usersid);
+ lstrcatA(keypath, "\\Patches\\");
+ lstrcatA(keypath, patch_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &udpatch);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* UserData Patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERUNMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
+ ok(size == 0, "Expected 0, got %d\n", size);
+
+ res = RegSetValueExA(udpatch, "LocalPackage", 0, REG_SZ,
+ (const BYTE *)"pack", 5);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* LocalPatch value exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERUNMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
+ ok(size == 4, "Expected 4, got %d\n", size);
+
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERUNMANAGED,
+ INSTALLPROPERTY_TRANSFORMS, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, "transforms"), "Expected \"transforms\", got \"%s\"\n", val);
+ ok(size == 10, "Expected 10, got %d\n", size);
+
+ RegDeleteValueA(prodpatches, patch_squashed);
+ RegDeleteKeyA(prodpatches, "");
+ RegCloseKey(prodpatches);
+ RegDeleteKeyA(prodkey, "");
+ RegCloseKey(prodkey);
+
+ /* UserData is sufficient for all properties
+ * except INSTALLPROPERTY_TRANSFORMS
+ */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERUNMANAGED,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
+ ok(size == 4, "Expected 4, got %d\n", size);
+
+ /* UserData is sufficient for all properties
+ * except INSTALLPROPERTY_TRANSFORMS
+ */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
+ MSIINSTALLCONTEXT_USERUNMANAGED,
+ INSTALLPROPERTY_TRANSFORMS, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"), "Expected \"apple\", got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
+
+ RegDeleteValueA(udpatch, "LocalPackage");
+ RegDeleteKeyA(udpatch, "");
+ RegCloseKey(udpatch);
+ RegDeleteKeyA(hpatch, "");
+ RegCloseKey(hpatch);
+ RegDeleteKeyA(patches, "");
+ RegCloseKey(patches);
+ RegDeleteKeyA(props, "");
+ RegCloseKey(props);
+ RegDeleteKeyA(udprod, "");
+ RegCloseKey(udprod);
+
+ /* MSIINSTALLCONTEXT_MACHINE */
+
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
+ MSIINSTALLCONTEXT_MACHINE,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
+ lstrcatA(keypath, "\\UserData\\S-1-5-18\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &udprod);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* local UserData product key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
+ MSIINSTALLCONTEXT_MACHINE,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT,
+ "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(udprod, "InstallProperties", &props);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* InstallProperties key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
+ MSIINSTALLCONTEXT_MACHINE,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(udprod, "Patches", &patches);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
+ MSIINSTALLCONTEXT_MACHINE,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(patches, patch_squashed, &hpatch);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
+ MSIINSTALLCONTEXT_MACHINE,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* local product key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
+ MSIINSTALLCONTEXT_MACHINE,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegCreateKeyA(prodkey, "Patches", &prodpatches);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* Patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
+ MSIINSTALLCONTEXT_MACHINE,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ res = RegSetValueExA(prodpatches, patch_squashed, 0, REG_SZ,
+ (const BYTE *)"transforms", 11);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* specific patch value exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
+ MSIINSTALLCONTEXT_MACHINE,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"),
+ "Expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
+ lstrcatA(keypath, "\\UserData\\S-1-5-18\\Patches\\");
+ lstrcatA(keypath, patch_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &udpatch);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* UserData Patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
+ MSIINSTALLCONTEXT_MACHINE,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
+ ok(size == 0, "Expected 0, got %d\n", size);
+
+ res = RegSetValueExA(udpatch, "LocalPackage", 0, REG_SZ,
+ (const BYTE *)"pack", 5);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* LocalPatch value exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
+ MSIINSTALLCONTEXT_MACHINE,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
+ ok(size == 4, "Expected 4, got %d\n", size);
+
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
+ MSIINSTALLCONTEXT_MACHINE,
+ INSTALLPROPERTY_TRANSFORMS, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, "transforms"), "Expected \"transforms\", got \"%s\"\n", val);
+ ok(size == 10, "Expected 10, got %d\n", size);
+
+ RegDeleteValueA(prodpatches, patch_squashed);
+ RegDeleteKeyA(prodpatches, "");
+ RegCloseKey(prodpatches);
+ RegDeleteKeyA(prodkey, "");
+ RegCloseKey(prodkey);
+
+ /* UserData is sufficient for all properties
+ * except INSTALLPROPERTY_TRANSFORMS
+ */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
+ MSIINSTALLCONTEXT_MACHINE,
+ INSTALLPROPERTY_LOCALPACKAGE, val, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
+ ok(size == 4, "Expected 4, got %d\n", size);
+
+ /* UserData is sufficient for all properties
+ * except INSTALLPROPERTY_TRANSFORMS
+ */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
+ MSIINSTALLCONTEXT_MACHINE,
+ INSTALLPROPERTY_TRANSFORMS, val, &size);
+ ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
+ ok(!lstrcmpA(val, "apple"), "Expected \"apple\", got \"%s\"\n", val);
+ ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
+
+ RegDeleteValueA(udpatch, "LocalPackage");
+ RegDeleteKeyA(udpatch, "");
+ RegCloseKey(udpatch);
+ RegDeleteKeyA(hpatch, "");
+ RegCloseKey(hpatch);
+ RegDeleteKeyA(patches, "");
+ RegCloseKey(patches);
+ RegDeleteKeyA(props, "");
+ RegCloseKey(props);
+ RegDeleteKeyA(udprod, "");
+ RegCloseKey(udprod);
+ LocalFree(usersid);
+}
+
+static void test_MsiGetPatchInfo(void)
+{
+ UINT r;
+ char prod_code[MAX_PATH], prod_squashed[MAX_PATH], val[MAX_PATH];
+ char patch_code[MAX_PATH], patch_squashed[MAX_PATH], keypath[MAX_PATH];
+ WCHAR valW[MAX_PATH], patch_codeW[MAX_PATH];
+ HKEY hkey_product, hkey_patch, hkey_patches, hkey_udprops, hkey_udproduct;
+ HKEY hkey_udpatch, hkey_udpatches, hkey_udproductpatches, hkey_udproductpatch;
+ DWORD size;
+ LONG res;
+
+ create_test_guid(patch_code, patch_squashed);
+ create_test_guid(prod_code, prod_squashed);
+ MultiByteToWideChar(CP_ACP, 0, patch_code, -1, patch_codeW, MAX_PATH);
+
+ r = MsiGetPatchInfoA(NULL, NULL, NULL, NULL);
+ ok(r == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", r);
+
+ r = MsiGetPatchInfoA(patch_code, NULL, NULL, NULL);
+ ok(r == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", r);
+
+ r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, NULL, NULL);
+ ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
+
+ size = 0;
+ r = MsiGetPatchInfoA(patch_code, NULL, NULL, &size);
+ ok(r == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", r);
+
+ r = MsiGetPatchInfoA(patch_code, "", NULL, &size);
+ ok(r == ERROR_UNKNOWN_PROPERTY, "expected ERROR_UNKNOWN_PROPERTY, got %u\n", r);
+
+ lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &hkey_product);
+ ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
+
+ /* product key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
+ ok(!lstrcmpA(val, "apple"), "expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
+
+ res = RegCreateKeyA(hkey_product, "Patches", &hkey_patches);
+ ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
+
+ /* patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
+ ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val);
+ ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
+
+ res = RegCreateKeyA(hkey_patches, patch_squashed, &hkey_patch);
+ ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
+
+ /* patch key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
+ ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val);
+ ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
+ lstrcatA(keypath, "\\UserData\\S-1-5-18\\Products\\");
+ lstrcatA(keypath, prod_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &hkey_udproduct);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
+
+ /* UserData product key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
+ ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val);
+ ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
+
+ res = RegCreateKeyA(hkey_udproduct, "InstallProperties", &hkey_udprops);
+ ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
+
+ /* InstallProperties key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
+ ok(!lstrcmpA(val, "apple"), "expected val to be unchanged, got \"%s\"\n", val);
+ ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
+
+ res = RegCreateKeyA(hkey_udproduct, "Patches", &hkey_udpatches);
+ ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
+
+ /* UserData Patches key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
+ ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val);
+ ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
+
+ res = RegCreateKeyA(hkey_udproduct, "Patches", &hkey_udproductpatches);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ res = RegCreateKeyA(hkey_udproductpatches, patch_squashed, &hkey_udproductpatch);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* UserData product patch key exists */
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
+ ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
+ ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val);
+ ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
+
+ lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
+ lstrcatA(keypath, "\\UserData\\S-1-5-18\\Patches\\");
+ lstrcatA(keypath, patch_squashed);
+
+ res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &hkey_udpatch);
+ ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
+
+ res = RegSetValueExA(hkey_udpatch, "LocalPackage", 0, REG_SZ, (const BYTE *)"c:\\test.msp", 12);
+ ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
+
+ /* UserData Patch key exists */
+ size = 0;
+ lstrcpyA(val, "apple");
+ r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
+ ok(r == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %u\n", r);
+ ok(!lstrcmpA(val, "apple"), "expected \"apple\", got \"%s\"\n", val);
+ ok(size == 11, "expected 11 got %u\n", size);
+
+ size = MAX_PATH;
+ lstrcpyA(val, "apple");
+ r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
+ ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS got %u\n", r);
+ ok(!lstrcmpA(val, "c:\\test.msp"), "expected \"c:\\test.msp\", got \"%s\"\n", val);
+ ok(size == 11, "expected 11 got %u\n", size);
+
+ size = 0;
+ valW[0] = 0;
+ r = MsiGetPatchInfoW(patch_codeW, INSTALLPROPERTY_LOCALPACKAGEW, valW, &size);
+ ok(r == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %u\n", r);
+ ok(!valW[0], "expected 0 got %u\n", valW[0]);
+ ok(size == 11, "expected 11 got %u\n", size);
+
+ size = MAX_PATH;
+ valW[0] = 0;
+ r = MsiGetPatchInfoW(patch_codeW, INSTALLPROPERTY_LOCALPACKAGEW, valW, &size);
+ ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS got %u\n", r);
+ ok(valW[0], "expected > 0 got %u\n", valW[0]);
+ ok(size == 11, "expected 11 got %u\n", size);
+
+ RegDeleteKeyA(hkey_udproductpatch, "");
+ RegCloseKey(hkey_udproductpatch);
+ RegDeleteKeyA(hkey_udproductpatches, "");
+ RegCloseKey(hkey_udproductpatches);
+ RegDeleteKeyA(hkey_udpatch, "");
+ RegCloseKey(hkey_udpatch);
+ RegDeleteKeyA(hkey_patches, "");
+ RegCloseKey(hkey_patches);
+ RegDeleteKeyA(hkey_product, "");
+ RegCloseKey(hkey_product);
+ RegDeleteKeyA(hkey_patch, "");
+ RegCloseKey(hkey_patch);
+ RegDeleteKeyA(hkey_udpatches, "");
+ RegCloseKey(hkey_udpatches);
+ RegDeleteKeyA(hkey_udprops, "");
+ RegCloseKey(hkey_udprops);
+ RegDeleteKeyA(hkey_udproduct, "");
+ RegCloseKey(hkey_udproduct);
+}
+
+static void test_MsiEnumProducts(void)
+{
+ UINT r;
+ int found1, found2, found3;
+ DWORD index;
+ char product1[39], product2[39], product3[39], guid[39];
+ char product_squashed1[33], product_squashed2[33], product_squashed3[33];
+ char keypath1[MAX_PATH], keypath2[MAX_PATH], keypath3[MAX_PATH];
+ char *usersid;
+ HKEY key1, key2, key3;
+
+ create_test_guid(product1, product_squashed1);
+ create_test_guid(product2, product_squashed2);
+ create_test_guid(product3, product_squashed3);
+ get_user_sid(&usersid);
+
+ strcpy(keypath1, "Software\\Classes\\Installer\\Products\\");
+ strcat(keypath1, product_squashed1);
+
+ r = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath1, &key1);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+
+ strcpy(keypath2, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
+ strcat(keypath2, usersid);
+ strcat(keypath2, "\\Installer\\Products\\");
+ strcat(keypath2, product_squashed2);
+
+ r = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath2, &key2);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+
+ strcpy(keypath3, "Software\\Microsoft\\Installer\\Products\\");
+ strcat(keypath3, product_squashed3);
+
+ r = RegCreateKeyA(HKEY_CURRENT_USER, keypath3, &key3);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+
+ index = 0;
+ r = MsiEnumProductsA(index, NULL);
+ ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
+
+ index = 2;
+ r = MsiEnumProductsA(index, guid);
+ ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
+
+ index = 0;
+ r = MsiEnumProductsA(index, guid);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
+
+ found1 = found2 = found3 = 0;
+ while ((r = MsiEnumProductsA(index, guid)) == ERROR_SUCCESS)
+ {
+ if (!strcmp(product1, guid)) found1 = 1;
+ if (!strcmp(product2, guid)) found2 = 1;
+ if (!strcmp(product3, guid)) found3 = 1;
+ index++;
+ }
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r);
+ ok(found1, "product1 not found\n");
+ ok(found2, "product2 not found\n");
+ ok(found3, "product3 not found\n");
+
+ RegDeleteKeyA(key1, "");
+ RegDeleteKeyA(key2, "");
+ RegDeleteKeyA(key3, "");
+ RegCloseKey(key1);
+ RegCloseKey(key2);
+ RegCloseKey(key3);
+ LocalFree(usersid);
}
START_TEST(msi)
test_MsiGetFileHash();
if (!pConvertSidToStringSidA)
- skip("ConvertSidToStringSidA not implemented\n");
+ win_skip("ConvertSidToStringSidA not implemented\n");
else
{
/* These tests rely on get_user_sid that needs ConvertSidToStringSidA */
test_MsiGetProductInfo();
test_MsiGetProductInfoEx();
test_MsiGetUserInfo();
+ test_MsiOpenProduct();
+ test_MsiEnumPatchesEx();
+ test_MsiEnumPatches();
+ test_MsiGetPatchInfoEx();
+ test_MsiGetPatchInfo();
+ test_MsiEnumProducts();
}
test_MsiGetFileVersion();