PATCH: GetHGlobalFromILockBytes
Marcus Meissner
meissner at suse.de
Fri Jul 5 04:44:11 CDT 2002
Hi,
Lotus Notes does in some cases a GetHGlobalFromILockBytes() on a seperate
ILockBytes interface. This adds a more generic way to get a HGLOBAL from
an ILockBytes interface.
I checked the relay trace and it looks good, it can read the respective
Storage Property (Shell.Explorer.2) out of the generated stream.
Ciao, Marcus
License: LGPL
Changelog:
Added a generic way of doing GetHGlobalFromILockBytes().
Index: memlockbytes.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/memlockbytes.c,v
retrieving revision 1.7
diff -u -r1.7 memlockbytes.c
--- memlockbytes.c 31 May 2002 23:25:50 -0000 1.7
+++ memlockbytes.c 5 Jul 2002 09:40:21 -0000
@@ -174,15 +174,38 @@
HRESULT WINAPI GetHGlobalFromILockBytes(ILockBytes* plkbyt, HGLOBAL* phglobal)
{
HGLOBALLockBytesImpl* const pMemLockBytes = (HGLOBALLockBytesImpl*)plkbyt;
+ STATSTG stbuf;
+ HRESULT hres;
+ ULARGE_INTEGER start;
+ ULONG xread;
- if (ICOM_VTBL(pMemLockBytes) == &HGLOBALLockBytesImpl_Vtbl)
+ *phglobal = 0;
+ if (ICOM_VTBL(pMemLockBytes) == &HGLOBALLockBytesImpl_Vtbl) {
*phglobal = pMemLockBytes->supportHandle;
- else
- *phglobal = 0;
-
- if (*phglobal == 0)
+ if (*phglobal == 0)
+ return E_INVALIDARG;
+ return S_OK;
+ }
+ /* It is not our lockbytes implementation, so use a more generic way */
+ hres = ILockBytes_Stat(plkbyt,&stbuf,0);
+ if (hres != S_OK) {
+ ERR("Cannot ILockBytes_Stat, %lx\n",hres);
+ return hres;
+ }
+ FIXME("cbSize is %ld\n",stbuf.cbSize.s.LowPart);
+ *phglobal = GlobalAlloc( GMEM_MOVEABLE|GMEM_SHARE, stbuf.cbSize.s.LowPart);
+ if (!*phglobal)
return E_INVALIDARG;
-
+ memset(&start,0,sizeof(start));
+ hres = ILockBytes_ReadAt(plkbyt, start, GlobalLock(*phglobal), stbuf.cbSize.s.LowPart, &xread);
+ GlobalUnlock(*phglobal);
+ if (hres != S_OK) {
+ FIXME("%p->ReadAt failed with %lx\n",plkbyt,hres);
+ return hres;
+ }
+ if (stbuf.cbSize.s.LowPart != xread) {
+ FIXME("Read size is not requested size %ld vs %ld?\n",stbuf.cbSize.s.LowPart, xread);
+ }
return S_OK;
}
More information about the wine-patches
mailing list