msi [2/13]: Add support for the MSICODE_PATCH option

James Hawkins truiken at gmail.com
Mon Jul 2 22:18:34 CDT 2007


Hi,

Changelog:
* Add support for the MSICODE_PATCH option.

 dlls/msi/msipriv.h      |    2 ++
 dlls/msi/registry.c     |   56 +++++++++++++++++++++++++++++++++++++++++++++++
 dlls/msi/source.c       |   45 +++++++++++++++++++++++---------------
 dlls/msi/tests/source.c |   22 ++++++++----------
 4 files changed, 94 insertions(+), 31 deletions(-)

-- 
James Hawkins
-------------- next part --------------
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index 78b3e24..7e563a4 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -676,12 +676,14 @@ extern BOOL encode_base85_guid(GUID *,LP
 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);
diff --git a/dlls/msi/registry.c b/dlls/msi/registry.c
index 21e0804..c557264 100644
--- a/dlls/msi/registry.c
+++ b/dlls/msi/registry.c
@@ -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_
 '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 
     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 szPr
     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;
diff --git a/dlls/msi/source.c b/dlls/msi/source.c
index 6223400..975b0f2 100644
--- a/dlls/msi/source.c
+++ b/dlls/msi/source.c
@@ -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( LPCWS
 
     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( LPCWS
         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( LPCWS
         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( L
         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(L
         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;
diff --git a/dlls/msi/tests/source.c b/dlls/msi/tests/source.c
index 58c2e86..e67bae8 100644
--- a/dlls/msi/tests/source.c
+++ b/dlls/msi/tests/source.c
@@ -281,10 +281,7 @@ static void test_MsiSourceListGetInfo(vo
     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(vo
     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(vo
     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)
-- 
1.4.1


More information about the wine-patches mailing list