Juan Lang : msisip: Determine whether a file is an MSI file based on its CLSID rather than its extension .

Alexandre Julliard julliard at winehq.org
Fri Nov 26 10:20:05 CST 2010


Module: wine
Branch: master
Commit: ef4560e51fe760fefafd002b31975b96438b0ff4
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ef4560e51fe760fefafd002b31975b96438b0ff4

Author: Juan Lang <juan.lang at gmail.com>
Date:   Wed Nov 24 14:35:57 2010 -0800

msisip: Determine whether a file is an MSI file based on its CLSID rather than its extension.

---

 dlls/msisip/main.c |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/dlls/msisip/main.c b/dlls/msisip/main.c
index cea0398..98a5743 100644
--- a/dlls/msisip/main.c
+++ b/dlls/msisip/main.c
@@ -24,6 +24,7 @@
 #include "mssip.h"
 #define COBJMACROS
 #include "objbase.h"
+#include "initguid.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(msisip);
@@ -217,34 +218,39 @@ end:
     return ret;
 }
 
+DEFINE_GUID(CLSID_MsiTransform, 0x000c1082,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
+DEFINE_GUID(CLSID_MsiDatabase,  0x000c1084,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
+DEFINE_GUID(CLSID_MsiPatch,     0x000c1086,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
+
 /***********************************************************************
  *              MsiSIPIsMyTypeOfFile (MSISIP.@)
  */
 BOOL WINAPI MsiSIPIsMyTypeOfFile(WCHAR *name, GUID *subject)
 {
-    static const WCHAR msi[] = { '.','m','s','i',0 };
-    static const WCHAR msp[] = { '.','m','s','p',0 };
     BOOL ret = FALSE;
+    IStorage *stg = NULL;
+    HRESULT r;
 
     TRACE("(%s, %p)\n", debugstr_w(name), subject);
 
-    if (lstrlenW(name) < lstrlenW(msi))
-        return FALSE;
-    else if (lstrcmpiW(name + lstrlenW(name) - lstrlenW(msi), msi) &&
-     lstrcmpiW(name + lstrlenW(name) - lstrlenW(msp), msp))
-        return FALSE;
-    else
+    r = StgOpenStorage(name, NULL, STGM_DIRECT|STGM_READ|STGM_SHARE_DENY_WRITE,
+     NULL, 0, &stg);
+    if (SUCCEEDED(r))
     {
-        IStorage *stg = NULL;
-        HRESULT r = StgOpenStorage(name, NULL,
-         STGM_DIRECT|STGM_READ|STGM_SHARE_DENY_WRITE, NULL, 0, &stg);
+        STATSTG stat;
 
+        r = IStorage_Stat(stg, &stat, STATFLAG_NONAME);
         if (SUCCEEDED(r))
         {
-            IStorage_Release(stg);
-            *subject = mySubject;
-            ret = TRUE;
+            if (IsEqualGUID(&stat.clsid, &CLSID_MsiDatabase) ||
+             IsEqualGUID(&stat.clsid, &CLSID_MsiPatch) ||
+             IsEqualGUID(&stat.clsid, &CLSID_MsiTransform))
+            {
+                ret = TRUE;
+                *subject = mySubject;
+            }
         }
+        IStorage_Release(stg);
     }
     return ret;
 }




More information about the wine-cvs mailing list