mscms: Fix OpenColorProfile to handle relative file names.

Hans Leidekker hans at codeweavers.com
Tue Sep 20 04:31:13 CDT 2011


See http://bugs.winehq.org/show_bug.cgi?id=20034
---
 dlls/mscms/Makefile.in     |    2 +-
 dlls/mscms/profile.c       |   21 ++++++++++++++++++++-
 dlls/mscms/tests/profile.c |   10 ++++++++++
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/dlls/mscms/Makefile.in b/dlls/mscms/Makefile.in
index 9a55cdb..6589598 100644
--- a/dlls/mscms/Makefile.in
+++ b/dlls/mscms/Makefile.in
@@ -1,6 +1,6 @@
 MODULE    = mscms.dll
 IMPORTLIB = mscms
-IMPORTS   = advapi32
+IMPORTS   = shlwapi advapi32
 EXTRALIBS = @LCMSLIBS@
 
 C_SRCS = \
diff --git a/dlls/mscms/profile.c b/dlls/mscms/profile.c
index 7fc94be..c4eae9d 100644
--- a/dlls/mscms/profile.c
+++ b/dlls/mscms/profile.c
@@ -30,6 +30,7 @@
 #include "wingdi.h"
 #include "winuser.h"
 #include "winreg.h"
+#include "shlwapi.h"
 #include "icm.h"
 
 #include "mscms_priv.h"
@@ -1470,7 +1471,25 @@ HPROFILE WINAPI OpenColorProfileW( PPROFILE profile, DWORD access, DWORD sharing
         if (!flags) return NULL;
         if (!sharing) sharing = FILE_SHARE_READ;
 
-        handle = CreateFileW( profile->pProfileData, flags, sharing, NULL, creation, 0, NULL );
+        if (!PathIsRelativeW( profile->pProfileData ))
+            handle = CreateFileW( profile->pProfileData, flags, sharing, NULL, creation, 0, NULL );
+        else
+        {
+            DWORD size;
+            WCHAR *path;
+
+            if (!GetColorDirectoryW( NULL, NULL, &size ) && GetLastError() == ERROR_MORE_DATA)
+            {
+                size += (strlenW( profile->pProfileData ) + 2) * sizeof(WCHAR);
+                if (!(path = HeapAlloc( GetProcessHeap(), 0, size ))) return NULL;
+                GetColorDirectoryW( NULL, path, &size );
+                PathAddBackslashW( path );
+                strcatW( path, profile->pProfileData );
+            }
+            else return NULL;
+            handle = CreateFileW( path, flags, sharing, NULL, creation, 0, NULL );
+            HeapFree( GetProcessHeap(), 0, path );
+        }
         if (handle == INVALID_HANDLE_VALUE)
         {
             WARN( "Unable to open color profile %u\n", GetLastError() );
diff --git a/dlls/mscms/tests/profile.c b/dlls/mscms/tests/profile.c
index 7cbface..d4293ff 100644
--- a/dlls/mscms/tests/profile.c
+++ b/dlls/mscms/tests/profile.c
@@ -952,6 +952,16 @@ static void test_OpenColorProfileA(void)
 
         ret = pCloseColorProfile( handle );
         ok( ret, "CloseColorProfile() failed (%d)\n", GetLastError() );
+
+        profile.dwType = PROFILE_FILENAME;
+        profile.pProfileData = (void *)"sRGB Color Space Profile.icm";
+        profile.cbDataSize = sizeof("sRGB Color Space Profile.icm");
+
+        handle = pOpenColorProfileA( &profile, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING );
+        ok( handle != NULL, "OpenColorProfileA() failed (%d)\n", GetLastError() );
+
+        ret = pCloseColorProfile( handle );
+        ok( ret, "CloseColorProfile() failed (%d)\n", GetLastError() );
     }
 }
 
-- 
1.7.5.4






More information about the wine-patches mailing list