[PATCH] setupapi: Implement installing catalog files

Maarten Lankhorst maarten at codeweavers.com
Tue Oct 14 15:31:15 CDT 2008


---
 dlls/setupapi/misc.c |   53 +++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/dlls/setupapi/misc.c b/dlls/setupapi/misc.c
index 62abc85..62b964d 100644
--- a/dlls/setupapi/misc.c
+++ b/dlls/setupapi/misc.c
@@ -28,13 +28,14 @@
 #include "winreg.h"
 #include "setupapi.h"
 #include "lzexpand.h"
+#include "softpub.h"
+#include "mscat.h"
 
 #include "wine/unicode.h"
 #include "wine/debug.h"
 
 #include "setupapi_private.h"
 
-
 WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
 
 /* arbitrary limit not related to what native actually uses */
@@ -1052,17 +1053,59 @@ BOOL WINAPI SetupCopyOEMInfW( PCWSTR source, PCWSTR location,
                            sizeof(catalog_file)/sizeof(catalog_file[0]), NULL ))
     {
         WCHAR source_cat[MAX_PATH];
-        strcpyW( source_cat, source );
+        static const WCHAR wintrust_dll[] = {'w','i','n','t','r','u','s','t','.','d','l','l',0};
+        HMODULE wintrust;
+        BOOL (WINAPI *pCryptCATAdminAcquireContext)(HCATADMIN*,const GUID*,DWORD);
+        HCATINFO (WINAPI *pCryptCATAdminAddCatalog)(HCATADMIN,PWSTR,PWSTR,DWORD);
+        BOOL (WINAPI *pCryptCATAdminReleaseCatalogContext)(HCATADMIN,HCATINFO,DWORD);
+        BOOL (WINAPI *pCryptCATAdminReleaseContext)(HCATADMIN,DWORD);
+        HCATADMIN handle;
+        HCATINFO cat;
+        GUID msguid = DRIVER_ACTION_VERIFY;
+
+        SetupCloseInfFile( hinf );
 
+        strcpyW( source_cat, source );
         p = strrchrW( source_cat, '\\' );
         if (p) p++;
         else p = source_cat;
-
         strcpyW( p, catalog_file );
 
-        FIXME("install catalog file %s\n", debugstr_w( source_cat ));
+        TRACE("installing catalog file %s\n", debugstr_w( source_cat ));
+
+        wintrust = LoadLibraryW(wintrust_dll);
+        pCryptCATAdminAcquireContext = (void *)GetProcAddress(wintrust, "CryptCATAdminAcquireContext");
+        pCryptCATAdminAddCatalog = (void *)GetProcAddress(wintrust, "CryptCATAdminAddCatalog");
+        pCryptCATAdminReleaseCatalogContext = (void *)GetProcAddress(wintrust, "CryptCATAdminReleaseCatalogContext");
+        pCryptCATAdminReleaseContext = (void *)GetProcAddress(wintrust, "CryptCATAdminReleaseContext");
+        FreeLibrary(wintrust);
+
+        if (!pCryptCATAdminAcquireContext
+            || !pCryptCATAdminAddCatalog
+            || !pCryptCATAdminReleaseCatalogContext
+            || !pCryptCATAdminReleaseContext)
+        {
+            ERR("Could not load wintrust.dll or its import functions\n");
+            SetLastError(ERROR_TRUST_FAILURE);
+            return FALSE;
+        }
+        if (!pCryptCATAdminAcquireContext(&handle, &msguid, 0))
+        {
+            ERR("Could not acquire security context\n");
+            return FALSE;
+        }
+
+        if (!(cat = pCryptCATAdminAddCatalog(handle, source_cat, catalog_file, 0)))
+        {
+            ERR("Could not add catalog\n");
+            return FALSE;
+        }
+
+        pCryptCATAdminReleaseCatalogContext(handle, cat, 0);
+        pCryptCATAdminReleaseContext(handle, 0);
     }
-    SetupCloseInfFile( hinf );
+    else
+        SetupCloseInfFile( hinf );
 
     if (!(ret = CopyFileW( source, target, (style & SP_COPY_NOOVERWRITE) != 0 )))
         return ret;
-- 
1.5.6.5


--------------060903030604020302050600--



More information about the wine-patches mailing list