Piotr Caban : oleacc: Add LresultFromObject implementation.

Alexandre Julliard julliard at winehq.org
Fri Apr 25 14:15:25 CDT 2014


Module: wine
Branch: master
Commit: 959f785c0f66c931f558435c30dd38f9718dfd95
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=959f785c0f66c931f558435c30dd38f9718dfd95

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Fri Apr 25 12:45:16 2014 +0200

oleacc: Add LresultFromObject implementation.

---

 dlls/oleacc/Makefile.in |    2 +-
 dlls/oleacc/main.c      |   96 ++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 95 insertions(+), 3 deletions(-)

diff --git a/dlls/oleacc/Makefile.in b/dlls/oleacc/Makefile.in
index 2f99ec7..0fb6eaf 100644
--- a/dlls/oleacc/Makefile.in
+++ b/dlls/oleacc/Makefile.in
@@ -1,6 +1,6 @@
 MODULE    = oleacc.dll
 IMPORTLIB = oleacc
-IMPORTS   = user32
+IMPORTS   = ole32 user32
 
 C_SRCS = \
 	main.c
diff --git a/dlls/oleacc/main.c b/dlls/oleacc/main.c
index 4a3e920..079b2aa 100644
--- a/dlls/oleacc/main.c
+++ b/dlls/oleacc/main.c
@@ -18,6 +18,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#define COBJMACROS
+
 #include <stdarg.h>
 #include "windef.h"
 #include "winbase.h"
@@ -30,6 +32,8 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(oleacc);
 
+static const WCHAR lresult_atom_prefix[] = {'w','i','n','e','_','o','l','e','a','c','c',':'};
+
 static HINSTANCE oleacc_handle = 0;
 
 HRESULT WINAPI CreateStdAccessibleObject( HWND hwnd, LONG idObject,
@@ -48,8 +52,96 @@ HRESULT WINAPI ObjectFromLresult( LRESULT result, REFIID riid, WPARAM wParam, vo
 
 LRESULT WINAPI LresultFromObject( REFIID riid, WPARAM wParam, LPUNKNOWN pAcc )
 {
-    FIXME("%s %ld %p\n", debugstr_guid(riid), wParam, pAcc );
-    return E_NOTIMPL;
+    static const WCHAR atom_fmt[] = {'%','0','8','x',':','%','0','8','x',':','%','0','8','x',0};
+    static const LARGE_INTEGER seek_zero = {{0}};
+
+    WCHAR atom_str[sizeof(lresult_atom_prefix)/sizeof(WCHAR)+3*8+3];
+    IStream *stream;
+    HANDLE mapping;
+    STATSTG stat;
+    HRESULT hr;
+    ATOM atom;
+    void *view;
+
+    TRACE("%s %ld %p\n", debugstr_guid(riid), wParam, pAcc);
+
+    if(wParam)
+        FIXME("unsupported wParam = %lx\n", wParam);
+
+    if(!pAcc)
+        return E_INVALIDARG;
+
+    hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
+    if(FAILED(hr))
+        return hr;
+
+    hr = CoMarshalInterface(stream, riid, pAcc, MSHCTX_LOCAL, NULL, MSHLFLAGS_NORMAL);
+    if(FAILED(hr)) {
+        IStream_Release(stream);
+        return hr;
+    }
+
+    hr = IStream_Seek(stream, seek_zero, STREAM_SEEK_SET, NULL);
+    if(FAILED(hr)) {
+        IStream_Release(stream);
+        return hr;
+    }
+
+    hr = IStream_Stat(stream, &stat, STATFLAG_NONAME);
+    if(FAILED(hr)) {
+        CoReleaseMarshalData(stream);
+        IStream_Release(stream);
+        return hr;
+    }else if(stat.cbSize.u.HighPart) {
+        FIXME("stream size to big\n");
+        CoReleaseMarshalData(stream);
+        IStream_Release(stream);
+        return E_NOTIMPL;
+    }
+
+    mapping = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
+            stat.cbSize.u.HighPart, stat.cbSize.u.LowPart, NULL);
+    if(!mapping) {
+        CoReleaseMarshalData(stream);
+        IStream_Release(stream);
+        return hr;
+    }
+
+    view = MapViewOfFile(mapping, FILE_MAP_WRITE, 0, 0, 0);
+    if(!view) {
+        CloseHandle(mapping);
+        CoReleaseMarshalData(stream);
+        IStream_Release(stream);
+        return E_FAIL;
+    }
+
+    hr = IStream_Read(stream, view, stat.cbSize.u.LowPart, NULL);
+    UnmapViewOfFile(view);
+    if(FAILED(hr)) {
+        CloseHandle(mapping);
+        hr = IStream_Seek(stream, seek_zero, STREAM_SEEK_SET, NULL);
+        if(SUCCEEDED(hr))
+            CoReleaseMarshalData(stream);
+        IStream_Release(stream);
+        return hr;
+
+    }
+
+    memcpy(atom_str, lresult_atom_prefix, sizeof(lresult_atom_prefix));
+    sprintfW(atom_str+sizeof(lresult_atom_prefix)/sizeof(WCHAR),
+             atom_fmt, GetCurrentProcessId(), HandleToUlong(mapping), stat.cbSize.u.LowPart);
+    atom = GlobalAddAtomW(atom_str);
+    if(!atom) {
+        CloseHandle(mapping);
+        hr = IStream_Seek(stream, seek_zero, STREAM_SEEK_SET, NULL);
+        if(SUCCEEDED(hr))
+            CoReleaseMarshalData(stream);
+        IStream_Release(stream);
+        return E_FAIL;
+    }
+
+    IStream_Release(stream);
+    return atom;
 }
 
 HRESULT WINAPI AccessibleObjectFromPoint( POINT ptScreen, IAccessible** ppacc, VARIANT* pvarChild )




More information about the wine-cvs mailing list