OLEAUT32: direct image header detection in OLEPicture_Load
Alex Villacís Lasso
a_villacis at palosanto.com
Tue Aug 17 20:07:34 CDT 2004
Sometimes an IStream is mapped to a plain file in order to load a file
(VB6 does this sometimes). This
patch allows detection of 3 common file headers in order to treat them
as ¨no-header¨ case
Changelog:
* Add detection of graphic file header in picture load, treat it as
no-header case
This patch should be applied after ¨OLEAUT32: fix for icon rendering in
OLEPicture¨
-------------- next part --------------
--- wine-20040813/dlls/oleaut32/olepicture.c 2004-08-12 18:00:54.000000000 -0500
+++ wine-20040813-patch/dlls/oleaut32/olepicture.c 2004-08-17 19:10:57.000000000 -0500
@@ -956,6 +956,13 @@
/* Sometimes we have a header, sometimes we don't. Apply some guesses to find
* out whether we do.
+ *
+ * UPDATE: the IStream can be mapped to a plain file instead of a stream in a
+ * compound file. This may explain most, if not all, of the cases of "no header",
+ * and the header validation should take this into account. At least in Visual Basic 6,
+ * resource streams, valid headers are
+ * header[0] == "lt\0\0",
+ * header[1] == length_of_stream.
*/
hr=IStream_Stat(pStm,&statstg,STATFLAG_NONAME);
if (hr)
@@ -965,7 +972,10 @@
FIXME("Failure while reading picture header (hr is %lx, nread is %ld).\n",hr,xread);
return hr;
}
- if (header[1] > statstg.cbSize.QuadPart || (header[1]==0)) {/* Incorrect header, assume none. */
+ if (!memcmp(&(header[0]), "GIF8", 4) || /* GIF header */
+ !memcmp(&(header[0]), "BM", 2) || /* BMP header */
+ !memcmp(&(header[0]), "\xff\xd8", 2) || /* JPEG header */
+ header[1] > statstg.cbSize.QuadPart || (header[1]==0)) {/* Incorrect header, assume none. */
xread = 8;
xbuf = This->data = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,statstg.cbSize.QuadPart);
memcpy(xbuf,&header,8);
More information about the wine-patches
mailing list