Fix handling of SEE_MASK_CLASSKEY

Francois Gouget fgouget at codeweavers.com
Wed Aug 10 10:34:45 CDT 2005


The code in shlexec.c seems to assume that SEE_MASK_CLASSNAME and 
SEE_MASK_CLASSKEY are disjoint flags but a quick look at their values 
shows that this is wrong:

#define SEE_MASK_CLASSNAME        0x00000001
#define SEE_MASK_CLASSKEY         0x00000003

This is causing ShellExecuteEx() to try to use SHELLEXECUTEINFO.lpClass 
whenever SEE_MASK_CLASSKEY is used, although that field would be 
uninitialized in such a case.

So I modified the code to look only at the two low order bits and to 
compare that with the above constants.


Changelog:

  * dlls/shell32/shlexec.c

    Francois Gouget <fgouget at codeweavers.com>
    Fix handling of SEE_MASK_CLASSNAME and SEE_MASK_CLASSKEY. They are 
not disjoint flags.

-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/shell32/shlexec.c
===================================================================
RCS file: /var/cvs/wine/dlls/shell32/shlexec.c,v
retrieving revision 1.66
diff -u -p -r1.66 shlexec.c
--- dlls/shell32/shlexec.c	11 Jul 2005 10:59:41 -0000	1.66
+++ dlls/shell32/shlexec.c	10 Aug 2005 15:29:26 -0000
@@ -57,6 +57,8 @@ static const WCHAR wszShell[] = {'\\','s
 static const WCHAR wszFolder[] = {'F','o','l','d','e','r',0};
 static const WCHAR wszEmpty[] = {0};
 
+#define SEE_MASK_CLASSALL (SEE_MASK_CLASSNAME | SEE_MASK_CLASSKEY)
+
 
 /***********************************************************************
  *	SHELL_ArgifyW [Internal]
@@ -996,7 +1011,8 @@ BOOL WINAPI ShellExecuteExW32 (LPSHELLEX
             sei_tmp.fMask, sei_tmp.hwnd, debugstr_w(sei_tmp.lpVerb),
             debugstr_w(sei_tmp.lpFile), debugstr_w(sei_tmp.lpParameters),
             debugstr_w(sei_tmp.lpDirectory), sei_tmp.nShow,
-            (sei_tmp.fMask & SEE_MASK_CLASSNAME) ? debugstr_w(sei_tmp.lpClass) : "not used");
+            ((sei_tmp.fMask & SEE_MASK_CLASSALL) == SEE_MASK_CLASSNAME) ?
+                debugstr_w(sei_tmp.lpClass) : "not used");
 
     sei->hProcess = NULL;
 
@@ -1049,13 +1074,14 @@ BOOL WINAPI ShellExecuteExW32 (LPSHELLEX
         TRACE("-- idlist=%p (%s)\n", sei_tmp.lpIDList, debugstr_w(wszApplicationName));
     }
 
-    if (sei_tmp.fMask & (SEE_MASK_CLASSNAME | SEE_MASK_CLASSKEY))
+    if (sei_tmp.fMask & SEE_MASK_CLASSALL)
     {
 	/* launch a document by fileclass like 'WordPad.Document.1' */
         /* the Commandline contains 'c:\Path\wordpad.exe "%1"' */
         /* FIXME: szCommandline should not be of a fixed size. Fixed to 1024, MAX_PATH is way too short! */
-        HCR_GetExecuteCommandW((sei_tmp.fMask & SEE_MASK_CLASSKEY) ? sei_tmp.hkeyClass : NULL,
-                               (sei_tmp.fMask & SEE_MASK_CLASSNAME) ? sei_tmp.lpClass: NULL,
+        ULONG cmask=(sei_tmp.fMask & SEE_MASK_CLASSALL);
+        HCR_GetExecuteCommandW((cmask == SEE_MASK_CLASSKEY) ? sei_tmp.hkeyClass : NULL,
+                               (cmask == SEE_MASK_CLASSNAME) ? sei_tmp.lpClass: NULL,
                                (sei_tmp.lpVerb) ? sei_tmp.lpVerb : wszOpen,
                                wszParameters, sizeof(wszParameters)/sizeof(WCHAR));
 
@@ -1391,7 +1417,7 @@ BOOL WINAPI ShellExecuteExA (LPSHELLEXEC
     if (sei->lpDirectory)
         seiW.lpDirectory = __SHCloneStrAtoW(&wDirectory, sei->lpDirectory);
 
-    if ((sei->fMask & SEE_MASK_CLASSNAME) && sei->lpClass)
+    if ((sei->fMask & SEE_MASK_CLASSALL) == SEE_MASK_CLASSNAME && sei->lpClass)
         seiW.lpClass = __SHCloneStrAtoW(&wClass, sei->lpClass);
     else
         seiW.lpClass = NULL;


More information about the wine-patches mailing list