ole2disp: Implement SafeArrayAllocDescriptor().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-01-10 21:47:06 +03:00 committed by Alexandre Julliard
parent 1053b4d4fa
commit d8287b5500
2 changed files with 52 additions and 1 deletions

View File

@ -30,6 +30,7 @@
#include "ole2.h" #include "ole2.h"
#include "oleauto.h" #include "oleauto.h"
#include "winerror.h" #include "winerror.h"
#include "wownt32.h"
#include "wine/windef16.h" #include "wine/windef16.h"
#include "wine/winbase16.h" #include "wine/winbase16.h"
@ -39,6 +40,56 @@
WINE_DEFAULT_DEBUG_CHANNEL(ole); 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 /* This implementation of the BSTR API is 16-bit only. It
represents BSTR as a 16:16 far pointer, and the strings represents BSTR as a 16:16 far pointer, and the strings
as ISO-8859 */ as ISO-8859 */

View File

@ -35,7 +35,7 @@
35 pascal RegisterActiveObject(ptr ptr long ptr) RegisterActiveObject16 35 pascal RegisterActiveObject(ptr ptr long ptr) RegisterActiveObject16
36 stub REVOKEACTIVEOBJECT 36 stub REVOKEACTIVEOBJECT
37 stub GETACTIVEOBJECT 37 stub GETACTIVEOBJECT
38 stub SAFEARRAYALLOCDESCRIPTOR 38 pascal SafeArrayAllocDescriptor(word ptr) SafeArrayAllocDescriptor16
39 stub SAFEARRAYALLOCDATA 39 stub SAFEARRAYALLOCDATA
40 stub SAFEARRAYDESTROYDESCRIPTOR 40 stub SAFEARRAYDESTROYDESCRIPTOR
41 stub SAFEARRAYDESTROYDATA 41 stub SAFEARRAYDESTROYDATA