implement OleLoadPictureFile
Jeremy Drake
wine at jdrake.com
Wed Nov 12 02:16:08 CST 2008
I ran into a function that was not implemented when attempting to run a
program I work on under wine.
This patch implements OleLoadPictureFile based on the MSDN docs
(http://msdn.microsoft.com/en-us/library/ms221680.aspx) and what I saw
when stepping through in windbg on XP.
A few notes:
I'm not sure I got the spec file right. The first param is a VARIANT, not
a VARIANT *, so I'm not sure ptr is the right thing.
I'm not sure the right way to do the TRACE call with the VARIANT param.
I did not implement OleLoadPictureFileEx. Technically, OleLoadPictureFile
should call OleLoadPictureFileEx(varFilename, LP_DEFAULT, LP_DEFAULT,
LP_DEFAULT, ppdispPicture) and OleLoadPictureEx should pass the sizeX,
sizeY, and flags to OleLoadPictureEx.
When stepping through the function in windbg, I saw it call a function
OLEAUT32!CreateFileStream which does not exist in wine anywhere. Instead
of using that, I used the same mechanism as was used in OleLoadPicturePath
(GlobalAlloc the size of the file, read the whole file in, and
CreateStreamOnHGlobal).
Since this is my first wine patch, I hope you will forgive me these
shortcomings. I'm not subscribed to any wine list, so please copy me on
any replies.
Thanks,
Jeremy
--
Personifiers Unite! You have nothing to lose but Mr. Dignity!
-------------- next part --------------
From c8cfae1ccfb3b0f9e4237e26dd41adb4fd948603 Mon Sep 17 00:00:00 2001
From: Jeremy Drake <wine at jdrake.com>
Date: Wed, 12 Nov 2008 00:00:46 -0800
Subject: implement OleLoadPictureFile
---
dlls/oleaut32/oleaut32.spec | 2 +-
dlls/oleaut32/olepicture.c | 64 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 65 insertions(+), 1 deletions(-)
diff --git a/dlls/oleaut32/oleaut32.spec b/dlls/oleaut32/oleaut32.spec
index 7b764ef..b0d078c 100644
--- a/dlls/oleaut32/oleaut32.spec
+++ b/dlls/oleaut32/oleaut32.spec
@@ -390,7 +390,7 @@
419 stdcall OleCreatePictureIndirect(ptr ptr long ptr)
420 stdcall OleCreateFontIndirect(ptr ptr ptr)
421 stdcall OleTranslateColor(long long long)
-422 stub OleLoadPictureFile
+422 stdcall OleLoadPictureFile(ptr ptr)
423 stub OleSavePictureFile
424 stdcall OleLoadPicturePath(wstr ptr long long ptr ptr)
425 stdcall VarUI4FromI8(double ptr)
diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c
index 498ee53..10f316a 100644
--- a/dlls/oleaut32/olepicture.c
+++ b/dlls/oleaut32/olepicture.c
@@ -2695,6 +2695,70 @@ HRESULT WINAPI OleLoadPictureEx( LPSTREAM lpstream, LONG lSize, BOOL fRunmode,
}
/***********************************************************************
+ * OleLoadPictureFile (OLEAUT32.422)
+ */
+HRESULT WINAPI OleLoadPictureFile( VARIANT varFilename, IDispatch **ppdispPicture )
+{
+ HANDLE hFile;
+ DWORD dwFileSize;
+ HGLOBAL hGlobal = NULL;
+ DWORD dwBytesRead = 0;
+ IStream *stream;
+ BOOL bRead;
+ VARIANT varPath;
+ HRESULT hRes;
+
+/* TODO: debug trace?
+ TRACE("(%s,%p,%d,%08x,%s,%p): stub\n",
+ debugstr_w(szURLorPath), punkCaller, dwReserved, clrReserved,
+ debugstr_guid(riid), ppvRet);
+*/
+ if (!ppdispPicture) return E_POINTER;
+ VariantInit(&varPath);
+ hRes = VariantChangeType(&varPath, &varFilename, 0, VT_BSTR);
+ if (FAILED(hRes)) return hRes;
+
+ /* TODO: in windbg on XP, there's an OLEAUT32!CreateFileStream function call here instead */
+ hFile = CreateFileW(V_BSTR(&varFilename), GENERIC_READ, 0, NULL, OPEN_EXISTING,
+ 0, NULL);
+ VariantClear(&varPath);
+ if (hFile == INVALID_HANDLE_VALUE)
+ return E_UNEXPECTED;
+
+ dwFileSize = GetFileSize(hFile, NULL);
+ if (dwFileSize != INVALID_FILE_SIZE )
+ {
+ hGlobal = GlobalAlloc(GMEM_FIXED,dwFileSize);
+ if ( hGlobal)
+ {
+ bRead = ReadFile(hFile, hGlobal, dwFileSize, &dwBytesRead, NULL);
+ if (!bRead)
+ {
+ GlobalFree(hGlobal);
+ hGlobal = 0;
+ }
+ }
+ }
+ CloseHandle(hFile);
+
+ if (!hGlobal)
+ return E_UNEXPECTED;
+
+ hRes = CreateStreamOnHGlobal(hGlobal, TRUE, &stream);
+ if (FAILED(hRes))
+ {
+ GlobalFree(hGlobal);
+ return hRes;
+ }
+
+ /* END OLEAUT32!CreateFileStream replacement hack */
+
+ hRes = OleLoadPictureEx(stream, 0, TRUE, &IID_IDispatch, LP_DEFAULT, LP_DEFAULT, LP_DEFAULT, (LPVOID*)ppdispPicture);
+ IStream_Release(stream);
+ return hRes;
+}
+
+/***********************************************************************
* OleLoadPicturePath (OLEAUT32.424)
*/
HRESULT WINAPI OleLoadPicturePath( LPOLESTR szURLorPath, LPUNKNOWN punkCaller,
--
1.5.6.4
More information about the wine-patches
mailing list