[PATCH] ole2disp: Implement SafeArrayAllocDescriptor()

Nikolay Sivov nsivov at codeweavers.com
Sun Jan 10 12:47:06 CST 2016


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---

For https://bugs.winehq.org/show_bug.cgi?id=28113

 dlls/ole2disp.dll16/ole2disp.c          | 51 +++++++++++++++++++++++++++++++++
 dlls/ole2disp.dll16/ole2disp.dll16.spec |  2 +-
 2 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/dlls/ole2disp.dll16/ole2disp.c b/dlls/ole2disp.dll16/ole2disp.c
index 43336c4..1774211 100644
--- a/dlls/ole2disp.dll16/ole2disp.c
+++ b/dlls/ole2disp.dll16/ole2disp.c
@@ -30,6 +30,7 @@
 #include "ole2.h"
 #include "oleauto.h"
 #include "winerror.h"
+#include "wownt32.h"
 #include "wine/windef16.h"
 #include "wine/winbase16.h"
 
@@ -39,6 +40,56 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(ole);
 
+#define E_OUTOFMEMORY16 MAKE_SCODE(SEVERITY_ERROR, FACILITY_NULL, 2)
+#define E_INVALIDARG16  MAKE_SCODE(SEVERITY_ERROR, FACILITY_NULL, 3)
+
+/* 16-bit SAFEARRAY implementation */
+typedef struct tagSAFEARRAYBOUND16
+{
+    ULONG cElements;
+    LONG  lLbound;
+} SAFEARRAYBOUND16;
+
+typedef struct tagSAFEARRAY16
+{
+    USHORT cDims;
+    USHORT fFeatures;
+    USHORT cbElements;
+    USHORT cLocks;
+    ULONG  handle;
+    SEGPTR pvData;
+    SAFEARRAYBOUND16 rgsabound[1];
+} SAFEARRAY16;
+
+static SEGPTR safearray_alloc(ULONG size)
+{
+    HANDLE16 h;
+    return WOWGlobalAllocLock16(GPTR, size, &h);
+}
+
+/******************************************************************************
+ *    SafeArrayAllocDescriptor [OLE2DISP.38]
+ */
+HRESULT WINAPI SafeArrayAllocDescriptor16(UINT16 dims, SEGPTR *ret)
+{
+    SAFEARRAY16 *sa;
+    ULONG size;
+
+    TRACE("%u, %p\n", dims, ret);
+
+    if (!dims)
+        return E_INVALIDARG16;
+
+    size = sizeof(SAFEARRAY16) + sizeof(SAFEARRAYBOUND16) * (dims - 1);
+    *ret = safearray_alloc(size);
+    if (!*ret)
+        return E_OUTOFMEMORY16;
+
+    sa = MapSL(*ret);
+    sa->cDims = dims;
+    return S_OK;
+}
+
 /* This implementation of the BSTR API is 16-bit only. It
    represents BSTR as a 16:16 far pointer, and the strings
    as ISO-8859 */
diff --git a/dlls/ole2disp.dll16/ole2disp.dll16.spec b/dlls/ole2disp.dll16/ole2disp.dll16.spec
index e4655f0..08372c5 100644
--- a/dlls/ole2disp.dll16/ole2disp.dll16.spec
+++ b/dlls/ole2disp.dll16/ole2disp.dll16.spec
@@ -35,7 +35,7 @@
 35 pascal RegisterActiveObject(ptr ptr long ptr) RegisterActiveObject16
 36 stub REVOKEACTIVEOBJECT
 37 stub GETACTIVEOBJECT
-38 stub SAFEARRAYALLOCDESCRIPTOR
+38 pascal SafeArrayAllocDescriptor(word ptr) SafeArrayAllocDescriptor16
 39 stub SAFEARRAYALLOCDATA
 40 stub SAFEARRAYDESTROYDESCRIPTOR
 41 stub SAFEARRAYDESTROYDATA
-- 
2.6.4




More information about the wine-patches mailing list