WineHQ: PATCH to fix IPersistFile::Load() and associated functions

Subhobroto Sinha pasha_3d at yahoo.com
Sun Oct 26 11:20:35 CST 2003


Hello all

I finally produced the "official patch" after
verifying that everything is OK.

This patch has been inlined as well as attached as a
ZIP file, so suit yourself.

All reports regaring this patch is to be sent to
<subhobrotosinha at yahoo.com> with a proper subject
prefixed by "IPersistFile patch" in the subject
header.
Just don't simply hit the 'Reply' button !

This patch fixes:

(1) Stream_LoadString: Conflict of unicode strings
being taken as LPSTR and AGAIN being converted to
Unicode due to wrong value of SCF_UNICODE .(I have
really NOT changed the original code, but redirected
this call to a fixed function which I named
wineStream_LoadString. This should remain so until
SCF_UNICODE value is corrected) 
(2) Stream_LoadLocation: Previously the GetPath()
failed. It works great now.

For the uninitiated, here's what has to be done:

Please make sure that you have the 20031016 source
(latest tarball)

(1)Copy this .diff to the root folder of the Wine
source
(2)Run 'patch' on this diff file
(3)It should patch "dlls/shell32/shelllink.c". Change
to that directory
(4)Type 'make' to rebuild 'shell32.dll.so'
(5)'su' out and overwrite/symlink the current
'shell32.dll.so' over the installed one

Now IPersistFile::Load() should work as intended. Try
out McCormack's 'winemenubuilder' or my WineLib
'linkresolve' (NOT my C++ version)

If the diff is not proper, etc, please alert me at the
mentioned address

PS: As I am not a member of 'wine-patches',can the
moderator be kind enough... :=)
I really want these functions to get fixed. That's
all.

Regards

Subhobroto Sinha

__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.zip
Type: application/x-zip-compressed
Size: 1169 bytes
Desc: patch.zip
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20031026/53028151/patch.bin
-------------- next part --------------
--- dlls/shell32/shelllink.c.original	2003-10-22 17:56:31.000000000 +0530
+++ dlls/shell32/shelllink.c	2003-10-26 16:30:57.000000000 +0530
@@ -401,9 +401,49 @@
 	return S_OK;
 }
 
+static HRESULT wineStream_LoadString( IStream* stm, LPWSTR *pstr )
+{
+    DWORD count=0;
+    USHORT len;
+    LPWSTR str=NULL;
+    HRESULT r;
+    /*
+    From Win98 upwards unicode==TRUE.(Atleast for shortcuts..)
+    However, the value of SCF_UNICODE does NOT seem to be 0x1000.
+    Until then, we assume it true.
+    Anybody differing mail to <subhobrotosinha at yahoo.com>.
+    */
+    TRACE("%p\n", stm);
+
+    r = IStream_Read(stm, &len, sizeof(len), &count);
+    if(FAILED(r)||(count != sizeof(len))) return E_FAIL;
+
+    len *= sizeof(WCHAR);
+
+    TRACE("reading %d\n", len);
+    str = HeapAlloc(GetProcessHeap(), 0, len+sizeof(WCHAR));
+    if(!str) return E_OUTOFMEMORY;
+
+    count = 0;
+    r = IStream_Read(stm, str, len, &count);
+    if( FAILED(r)||( count!=len) )
+    {
+        HeapFree( GetProcessHeap(), 0, str );
+        return E_FAIL;
+    }
+
+    str[count/2]=0;
+    *pstr = str;
+    TRACE("read %s\n", debugstr_w(str));
+    return S_OK;
+}
 
 static HRESULT Stream_LoadString( IStream* stm, BOOL unicode, LPWSTR *pstr )
 {
+/*This is the original function short circuited to the above till we find out correct 'SCF_UNICODE'.
+Now it's assumed that the data's unicode. (This assumption failes iff the OS was <=Win95*/
+return (wineStream_LoadString(stm,pstr));
+#if 0
     DWORD count;
     USHORT len;
     LPVOID temp;
@@ -453,6 +493,7 @@
     *pstr = str;
 
     return S_OK;
+#endif
 }
 
 static HRESULT Stream_LoadLocation( IStream* stm )
@@ -533,6 +574,14 @@
         if( FAILED( r ) )
             return r;
     }
+    //////////////////////////////////////////////////////////////////////////////////////
+    char szTemp[MAX_PATH]={0};
+    SHGetPathFromIDListA(This->pPidl,szTemp);
+    This->sPath=HeapAlloc( GetProcessHeap(), 0,(strlen(szTemp)+1)*sizeof(WCHAR));
+    MultiByteToWideChar(CP_ACP,0,szTemp,(strlen(szTemp)+1),This->sPath,(strlen(szTemp)+1));
+    //TRACE("%s\n",szTemp);
+    //////////////////////////////////////////////////////////////////////////////////////
+
     This->wHotKey = hdr.wHotKey;
     This->iIcoNdx = hdr.nIcon;
     FileTimeToSystemTime (&hdr.Time1, &This->time1);


More information about the wine-devel mailing list