Commit 04c67c2a authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Add support for the MSICODE_PATCH option.

parent 0cd708e7
......@@ -676,12 +676,14 @@ extern BOOL encode_base85_guid(GUID *,LPWSTR);
extern BOOL decode_base85_guid(LPCWSTR,GUID*);
extern UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create);
extern UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
extern UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
extern UINT MSIREG_OpenFeatures(HKEY* key);
extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
extern UINT MSIREG_OpenComponents(HKEY* key);
extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
extern UINT MSIREG_OpenComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
extern UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
extern UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
extern UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, HKEY* key, BOOL create);
extern UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
......
......@@ -108,6 +108,13 @@ static const WCHAR szUserProduct_fmt[] = {
'P','r','o','d','u','c','t','s','\\',
'%','s',0};
static const WCHAR szUserPatch_fmt[] = {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'I','n','s','t','a','l','l','e','r','\\',
'P','a','t','c','h','e','s','\\',
'%','s',0};
static const WCHAR szInstaller_Products[] = {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
......@@ -125,6 +132,15 @@ static const WCHAR szInstaller_Products_fmt[] = {
'P','r','o','d','u','c','t','s','\\',
'%','s',0};
static const WCHAR szInstaller_Patches_fmt[] = {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'I','n','s','t','a','l','l','e','r','\\',
'P','a','t','c','h','e','s','\\',
'%','s',0};
static const WCHAR szInstaller_UpgradeCodes_fmt[] = {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
......@@ -421,6 +437,26 @@ UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create)
return rc;
}
UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create)
{
UINT rc;
WCHAR squished_pc[GUID_SIZE];
WCHAR keypath[0x200];
TRACE("%s\n",debugstr_w(szPatch));
squash_guid(szPatch,squished_pc);
TRACE("squished (%s)\n", debugstr_w(squished_pc));
sprintfW(keypath,szUserPatch_fmt,squished_pc);
if (create)
rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key);
else
rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key);
return rc;
}
UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create)
{
UINT rc;
......@@ -585,6 +621,26 @@ UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create)
return rc;
}
UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create)
{
UINT rc;
WCHAR squished_pc[GUID_SIZE];
WCHAR keypath[0x200];
TRACE("%s\n",debugstr_w(szPatch));
squash_guid(szPatch,squished_pc);
TRACE("squished (%s)\n", debugstr_w(squished_pc));
sprintfW(keypath,szInstaller_Patches_fmt,squished_pc);
if (create)
rc = RegCreateKeyW(HKEY_LOCAL_MACHINE,keypath,key);
else
rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,keypath,key);
return rc;
}
UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY* key, BOOL create)
{
UINT rc;
......
......@@ -51,19 +51,34 @@ typedef struct tagMediaInfo
WCHAR type;
} media_info;
static UINT OpenSourceKey(LPCWSTR szProduct, HKEY* key, BOOL user, BOOL create)
static UINT OpenSourceKey(LPCWSTR szProduct, HKEY* key, DWORD dwOptions, BOOL user, BOOL create)
{
HKEY rootkey = 0;
UINT rc;
static const WCHAR szSourceList[] = {'S','o','u','r','c','e','L','i','s','t',0};
if (user)
rc = MSIREG_OpenUserProductsKey(szProduct, &rootkey, create);
{
if (dwOptions == MSICODE_PATCH)
rc = MSIREG_OpenUserPatchesKey(szProduct, &rootkey, create);
else
rc = MSIREG_OpenUserProductsKey(szProduct, &rootkey, create);
}
else
rc = MSIREG_OpenProductsKey(szProduct, &rootkey, create);
{
if (dwOptions == MSICODE_PATCH)
rc = MSIREG_OpenPatchesKey(szProduct, &rootkey, create);
else
rc = MSIREG_OpenProductsKey(szProduct, &rootkey, create);
}
if (rc)
return ERROR_UNKNOWN_PRODUCT;
{
if (dwOptions == MSICODE_PATCH)
return ERROR_UNKNOWN_PATCH;
else
return ERROR_UNKNOWN_PRODUCT;
}
if (create)
rc = RegCreateKeyW(rootkey, szSourceList, key);
......@@ -236,12 +251,6 @@ UINT WINAPI MsiSourceListGetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid,
if (!szProperty)
return ERROR_INVALID_PARAMETER;
if (dwOptions == MSICODE_PATCH)
{
FIXME("Unhandled options MSICODE_PATCH\n");
return ERROR_FUNCTION_FAILED;
}
if (szUserSid)
FIXME("Unhandled UserSid %s\n",debugstr_w(szUserSid));
......@@ -250,9 +259,9 @@ UINT WINAPI MsiSourceListGetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid,
FIXME("Unknown context MSIINSTALLCONTEXT_USERUNMANAGED\n");
if (dwContext == MSIINSTALLCONTEXT_MACHINE)
rc = OpenSourceKey(szProduct, &sourcekey, FALSE, FALSE);
rc = OpenSourceKey(szProduct, &sourcekey, dwOptions, FALSE, FALSE);
else
rc = OpenSourceKey(szProduct, &sourcekey, TRUE, FALSE);
rc = OpenSourceKey(szProduct, &sourcekey, dwOptions, TRUE, FALSE);
if (rc != ERROR_SUCCESS)
return rc;
......@@ -397,9 +406,9 @@ UINT WINAPI MsiSourceListSetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid,
FIXME("Unknown context MSIINSTALLCONTEXT_USERUNMANAGED\n");
if (dwContext == MSIINSTALLCONTEXT_MACHINE)
rc = OpenSourceKey(szProduct, &sourcekey, FALSE, TRUE);
rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, FALSE, TRUE);
else
rc = OpenSourceKey(szProduct, &sourcekey, TRUE, TRUE);
rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, TRUE, TRUE);
if (rc != ERROR_SUCCESS)
return ERROR_UNKNOWN_PRODUCT;
......@@ -567,9 +576,9 @@ UINT WINAPI MsiSourceListAddSourceExW( LPCWSTR szProduct, LPCWSTR szUserSid,
FIXME("Unknown context MSIINSTALLCONTEXT_USERUNMANAGED\n");
if (dwContext == MSIINSTALLCONTEXT_MACHINE)
rc = OpenSourceKey(szProduct, &sourcekey, FALSE, TRUE);
rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, FALSE, TRUE);
else
rc = OpenSourceKey(szProduct, &sourcekey, TRUE, TRUE);
rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, TRUE, TRUE);
if (rc != ERROR_SUCCESS)
return ERROR_UNKNOWN_PRODUCT;
......@@ -657,9 +666,9 @@ UINT WINAPI MsiSourceListAddMediaDiskW(LPCWSTR szProduct, LPCWSTR szUserSid,
FIXME("Unknown context MSIINSTALLCONTEXT_USERUNMANAGED\n");
if (dwContext == MSIINSTALLCONTEXT_MACHINE)
rc = OpenSourceKey(szProduct, &sourcekey, FALSE, TRUE);
rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, FALSE, TRUE);
else
rc = OpenSourceKey(szProduct, &sourcekey, TRUE, TRUE);
rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, TRUE, TRUE);
if (rc != ERROR_SUCCESS)
return ERROR_UNKNOWN_PRODUCT;
......
......@@ -281,10 +281,7 @@ static void test_MsiSourceListGetInfo(void)
size = 0xdeadbeef;
r = MsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
MSICODE_PATCH, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
todo_wine
{
ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
}
ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Patches\\");
......@@ -299,10 +296,7 @@ static void test_MsiSourceListGetInfo(void)
size = 0xdeadbeef;
r = MsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
MSICODE_PATCH, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
todo_wine
{
ok(r == ERROR_BAD_CONFIGURATION, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
}
ok(r == ERROR_BAD_CONFIGURATION, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
res = RegCreateKeyA(userkey, "SourceList", &hkey);
......@@ -312,11 +306,13 @@ static void test_MsiSourceListGetInfo(void)
size = 0xdeadbeef;
r = MsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
MSICODE_PATCH, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
todo_wine
{
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(size == 0, "Expected 0, got %d\n", size);
}
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(size == 0, "Expected 0, got %d\n", size);
RegDeleteKeyA(hkey, "");
RegDeleteKeyA(userkey, "");
RegCloseKey(hkey);
RegCloseKey(userkey);
}
START_TEST(source)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment