SHELL: fixed SHGetFileInfoW

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch fixes:

- typo in SHGetFileInfoA (szLoaction instead of szLocation)
- wrong code in SHGetFileInfoW: this function relies on SHGetFileInfoA, so 
it should convert the requested name from Unicode into a multi byte string, 
then copy/convert the data returned in the SHFILEINFOA structure into the 
caller-supplied SHFILEINFOW structure.
The old code was not returning anything to the caller and, depending on 
what was in the provided SHFILEINFOW structure (usually garbage 
characters), it could crash trying to convert two strings from Unicode to 
multi byte.

Alberto

Index: shell32_main.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shell32_main.c,v
retrieving revision 1.102
diff -u -r1.102 shell32_main.c
--- shell32_main.c      23 Oct 2002 20:20:59 -0000      1.102
+++ shell32_main.c      26 Oct 2002 14:24:25 -0000
@@ -209,7 +209,7 @@
                                SHFILEINFOA *psfi, UINT sizeofpsfi,
                                UINT flags )
  {
-       char szLoaction[MAX_PATH];
+       char szLocation[MAX_PATH];
         int iIndex;
         DWORD ret = TRUE, dwAttributes = 0;
         IShellFolder * psfParent = NULL;
@@ -367,11 +367,11 @@

           if (SUCCEEDED(hr))
           {
-           hr = IExtractIconA_GetIconLocation(pei, (flags & 
SHGFI_OPENICON)? GIL_OPENICON : 0,szLoaction, MAX_PATH, &iIndex, &uFlags);
+           hr = IExtractIconA_GetIconLocation(pei, (flags & 
SHGFI_OPENICON)? GIL_OPENICON : 0,szLocation, MAX_PATH, &iIndex, &uFlags);
             /* FIXME what to do with the index? */

             if(uFlags != GIL_NOTFILENAME)
-             strcpy (psfi->szDisplayName, szLoaction);
+             strcpy (psfi->szDisplayName, szLocation);
             else
               ret = FALSE;

@@ -466,12 +466,21 @@
         temppath = HeapAlloc(GetProcessHeap(), 0, len);
         WideCharToMultiByte(CP_ACP, 0, path, -1, temppath, len, NULL, NULL);

-        WideCharToMultiByte(CP_ACP, 0, psfi->szDisplayName, -1, 
temppsfi.szDisplayName,
-                            sizeof(temppsfi.szDisplayName), NULL, NULL);
-        WideCharToMultiByte(CP_ACP, 0, psfi->szTypeName, -1, 
temppsfi.szTypeName,
-                            sizeof(temppsfi.szTypeName), NULL, NULL);
+       if(flags & SHGFI_ATTR_SPECIFIED)
+               temppsfi.dwAttributes=psfi->dwAttributes;

         ret = SHGetFileInfoA(temppath, dwFileAttributes, &temppsfi, 
sizeof(temppsfi), flags);
+
+       if(flags & SHGFI_ICON)
+               psfi->hIcon=temppsfi.hIcon;
+       if(flags & (SHGFI_SYSICONINDEX|SHGFI_ICON|SHGFI_ICONLOCATION))
+               psfi->iIcon=temppsfi.iIcon;
+       if(flags & SHGFI_ATTRIBUTES)
+               psfi->dwAttributes=temppsfi.dwAttributes;
+       if(flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION))
+               MultiByteToWideChar(CP_ACP, 0, temppsfi.szDisplayName, -1, 
psfi->szDisplayName, sizeof(psfi->szDisplayName));
+       if(flags & SHGFI_TYPENAME)
+               MultiByteToWideChar(CP_ACP, 0, temppsfi.szTypeName, -1, 
psfi->szTypeName, sizeof(psfi->szTypeName));

         HeapFree(GetProcessHeap(), 0, temppath);




[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux