2006-01-27 12:54:22 +01:00
|
|
|
/*
|
|
|
|
* Marshaling Tests
|
|
|
|
*
|
|
|
|
* Copyright 2004 Robert Shearman
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-01-27 12:54:22 +01:00
|
|
|
*/
|
|
|
|
|
2007-03-19 15:54:57 +01:00
|
|
|
#define COBJMACROS
|
2010-12-29 02:53:23 +01:00
|
|
|
#define CONST_VTABLE
|
2007-03-19 15:54:57 +01:00
|
|
|
|
2006-01-27 12:54:22 +01:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
#include "propidl.h" /* for LPSAFEARRAY_User* routines */
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2006-09-29 12:52:22 +02:00
|
|
|
#if (__STDC__ && !defined(_FORCENAMELESSUNION)) || defined(NONAMELESSUNION)
|
|
|
|
# define V_U2(A) ((A)->n1.n2)
|
|
|
|
#else
|
|
|
|
# define V_U2(A) (*(A))
|
|
|
|
#endif
|
|
|
|
|
2012-01-09 10:03:06 +01:00
|
|
|
static HRESULT (WINAPI *pSafeArrayGetIID)(SAFEARRAY*,GUID*);
|
|
|
|
static HRESULT (WINAPI *pSafeArrayGetVartype)(SAFEARRAY*,VARTYPE*);
|
|
|
|
static HRESULT (WINAPI *pVarBstrCmp)(BSTR,BSTR,LCID,ULONG);
|
|
|
|
|
2006-05-02 13:00:30 +02:00
|
|
|
static inline SF_TYPE get_union_type(SAFEARRAY *psa)
|
|
|
|
{
|
|
|
|
VARTYPE vt;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2012-01-09 10:03:06 +01:00
|
|
|
hr = pSafeArrayGetVartype(psa, &vt);
|
2006-05-02 13:00:30 +02:00
|
|
|
if (FAILED(hr))
|
2007-01-30 13:39:37 +01:00
|
|
|
{
|
2007-06-22 16:10:04 +02:00
|
|
|
if(psa->fFeatures & FADF_VARIANT) return SF_VARIANT;
|
|
|
|
|
2007-01-30 13:39:37 +01:00
|
|
|
switch(psa->cbElements)
|
|
|
|
{
|
|
|
|
case 1: vt = VT_I1; break;
|
|
|
|
case 2: vt = VT_I2; break;
|
|
|
|
case 4: vt = VT_I4; break;
|
|
|
|
case 8: vt = VT_I8; break;
|
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
2006-05-02 13:00:30 +02:00
|
|
|
|
|
|
|
if (psa->fFeatures & FADF_HAVEIID)
|
|
|
|
return SF_HAVEIID;
|
|
|
|
|
|
|
|
switch (vt)
|
|
|
|
{
|
|
|
|
case VT_I1:
|
|
|
|
case VT_UI1: return SF_I1;
|
|
|
|
case VT_BOOL:
|
|
|
|
case VT_I2:
|
|
|
|
case VT_UI2: return SF_I2;
|
|
|
|
case VT_INT:
|
|
|
|
case VT_UINT:
|
|
|
|
case VT_I4:
|
|
|
|
case VT_UI4:
|
|
|
|
case VT_R4: return SF_I4;
|
|
|
|
case VT_DATE:
|
|
|
|
case VT_CY:
|
|
|
|
case VT_R8:
|
|
|
|
case VT_I8:
|
|
|
|
case VT_UI8: return SF_I8;
|
|
|
|
case VT_INT_PTR:
|
|
|
|
case VT_UINT_PTR: return (sizeof(UINT_PTR) == 4 ? SF_I4 : SF_I8);
|
|
|
|
case VT_BSTR: return SF_BSTR;
|
|
|
|
case VT_DISPATCH: return SF_DISPATCH;
|
|
|
|
case VT_VARIANT: return SF_VARIANT;
|
|
|
|
case VT_UNKNOWN: return SF_UNKNOWN;
|
|
|
|
/* Note: Return a non-zero size to indicate vt is valid. The actual size
|
|
|
|
* of a UDT is taken from the result of IRecordInfo_GetSize().
|
|
|
|
*/
|
|
|
|
case VT_RECORD: return SF_RECORD;
|
|
|
|
default: return SF_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG get_cell_count(const SAFEARRAY *psa)
|
|
|
|
{
|
|
|
|
const SAFEARRAYBOUND* psab = psa->rgsabound;
|
|
|
|
USHORT cCount = psa->cDims;
|
|
|
|
ULONG ulNumCells = 1;
|
|
|
|
|
|
|
|
while (cCount--)
|
|
|
|
{
|
|
|
|
if (!psab->cElements)
|
|
|
|
return 0;
|
|
|
|
ulNumCells *= psab->cElements;
|
|
|
|
psab++;
|
|
|
|
}
|
|
|
|
return ulNumCells;
|
|
|
|
}
|
|
|
|
|
2009-12-09 22:02:44 +01:00
|
|
|
static DWORD elem_wire_size(LPSAFEARRAY lpsa, SF_TYPE sftype)
|
|
|
|
{
|
|
|
|
if (sftype == SF_BSTR)
|
|
|
|
return sizeof(DWORD);
|
|
|
|
else
|
|
|
|
return lpsa->cbElements;
|
|
|
|
}
|
|
|
|
|
2006-05-02 13:00:30 +02:00
|
|
|
static void check_safearray(void *buffer, LPSAFEARRAY lpsa)
|
|
|
|
{
|
|
|
|
unsigned char *wiresa = buffer;
|
2010-10-19 00:35:27 +02:00
|
|
|
const SAFEARRAYBOUND *bounds;
|
2006-05-02 13:00:30 +02:00
|
|
|
VARTYPE vt;
|
|
|
|
SF_TYPE sftype;
|
|
|
|
ULONG cell_count;
|
2010-10-19 00:35:27 +02:00
|
|
|
int i;
|
2006-05-02 13:00:30 +02:00
|
|
|
|
|
|
|
if(!lpsa)
|
|
|
|
{
|
2009-07-10 19:13:16 +02:00
|
|
|
ok(*(DWORD *)wiresa == 0, "wiresa + 0x0 should be NULL instead of 0x%08x\n", *(DWORD *)wiresa);
|
2006-05-02 13:00:30 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-01-09 10:03:06 +01:00
|
|
|
if (!pSafeArrayGetVartype || !pSafeArrayGetIID)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(FAILED(pSafeArrayGetVartype(lpsa, &vt)))
|
2007-01-30 13:39:37 +01:00
|
|
|
vt = 0;
|
|
|
|
|
2006-05-02 13:00:30 +02:00
|
|
|
sftype = get_union_type(lpsa);
|
|
|
|
cell_count = get_cell_count(lpsa);
|
|
|
|
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*(DWORD *)wiresa, "wiresa + 0x0 should be non-NULL instead of 0x%08x\n", *(DWORD *)wiresa); /* win2k: this is lpsa. winxp: this is 0x00000001 */
|
2006-05-02 13:00:30 +02:00
|
|
|
wiresa += sizeof(DWORD);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*(DWORD *)wiresa == lpsa->cDims, "wiresa + 0x4 should be lpsa->cDims instead of 0x%08x\n", *(DWORD *)wiresa);
|
2006-05-02 13:00:30 +02:00
|
|
|
wiresa += sizeof(DWORD);
|
|
|
|
ok(*(WORD *)wiresa == lpsa->cDims, "wiresa + 0x8 should be lpsa->cDims instead of 0x%04x\n", *(WORD *)wiresa);
|
|
|
|
wiresa += sizeof(WORD);
|
2009-07-10 19:13:16 +02:00
|
|
|
ok(*(WORD *)wiresa == lpsa->fFeatures, "wiresa + 0xa should be lpsa->fFeatures instead of 0x%08x\n", *(WORD *)wiresa);
|
2006-05-02 13:00:30 +02:00
|
|
|
wiresa += sizeof(WORD);
|
2009-12-09 22:02:44 +01:00
|
|
|
ok(*(DWORD *)wiresa == elem_wire_size(lpsa, sftype), "wiresa + 0xc should be 0x%08x instead of 0x%08x\n", elem_wire_size(lpsa, sftype), *(DWORD *)wiresa);
|
2006-05-02 13:00:30 +02:00
|
|
|
wiresa += sizeof(DWORD);
|
2009-07-10 19:13:16 +02:00
|
|
|
ok(*(WORD *)wiresa == lpsa->cLocks, "wiresa + 0x10 should be lpsa->cLocks instead of 0x%04x\n", *(WORD *)wiresa);
|
2006-05-02 13:00:30 +02:00
|
|
|
wiresa += sizeof(WORD);
|
2009-07-10 19:13:16 +02:00
|
|
|
ok(*(WORD *)wiresa == vt, "wiresa + 0x12 should be %04x instead of 0x%04x\n", vt, *(WORD *)wiresa);
|
2006-05-02 13:00:30 +02:00
|
|
|
wiresa += sizeof(WORD);
|
2009-07-10 19:13:16 +02:00
|
|
|
ok(*(DWORD *)wiresa == sftype, "wiresa + 0x14 should be %08x instead of 0x%08x\n", (DWORD)sftype, *(DWORD *)wiresa);
|
2006-05-02 13:00:30 +02:00
|
|
|
wiresa += sizeof(DWORD);
|
2009-07-10 19:13:16 +02:00
|
|
|
ok(*(DWORD *)wiresa == cell_count, "wiresa + 0x18 should be %u instead of %u\n", cell_count, *(DWORD *)wiresa);
|
2006-05-02 13:00:30 +02:00
|
|
|
wiresa += sizeof(DWORD);
|
2009-07-10 19:13:16 +02:00
|
|
|
ok(*(DWORD *)wiresa, "wiresa + 0x1c should be non-zero instead of 0x%08x\n", *(DWORD *)wiresa);
|
2009-04-07 13:27:49 +02:00
|
|
|
wiresa += sizeof(DWORD);
|
2006-05-02 13:00:30 +02:00
|
|
|
if(sftype == SF_HAVEIID)
|
|
|
|
{
|
|
|
|
GUID guid;
|
2012-01-09 10:03:06 +01:00
|
|
|
pSafeArrayGetIID(lpsa, &guid);
|
2009-01-29 11:14:36 +01:00
|
|
|
ok(IsEqualGUID(&guid, wiresa), "guid mismatch\n");
|
2006-05-02 13:00:30 +02:00
|
|
|
wiresa += sizeof(GUID);
|
|
|
|
}
|
2010-10-19 00:35:27 +02:00
|
|
|
|
|
|
|
/* bounds are marshaled in natural dimensions order */
|
|
|
|
bounds = (SAFEARRAYBOUND*)wiresa;
|
|
|
|
for(i=0; i<lpsa->cDims; i++)
|
|
|
|
{
|
|
|
|
ok(memcmp(bounds, &lpsa->rgsabound[lpsa->cDims-i-1], sizeof(SAFEARRAYBOUND)) == 0,
|
|
|
|
"bounds mismatch for dimension %d, got (%d,%d), expected (%d,%d)\n", i,
|
|
|
|
bounds->lLbound, bounds->cElements, lpsa->rgsabound[lpsa->cDims-i-1].lLbound,
|
|
|
|
lpsa->rgsabound[lpsa->cDims-i-1].cElements);
|
|
|
|
bounds++;
|
|
|
|
}
|
|
|
|
|
2006-05-02 13:00:30 +02:00
|
|
|
wiresa += sizeof(lpsa->rgsabound[0]) * lpsa->cDims;
|
|
|
|
|
2009-07-10 19:13:16 +02:00
|
|
|
ok(*(DWORD *)wiresa == cell_count, "wiresa + 0x28 should be %u instead of %u\n", cell_count, *(DWORD*)wiresa);
|
2006-05-02 13:00:30 +02:00
|
|
|
wiresa += sizeof(DWORD);
|
|
|
|
/* elements are now pointed to by wiresa */
|
|
|
|
}
|
|
|
|
|
2009-01-30 14:48:38 +01:00
|
|
|
static void * WINAPI user_allocate(SIZE_T size)
|
|
|
|
{
|
2015-06-16 08:29:00 +02:00
|
|
|
ok(0, "unexpected user_allocate call\n");
|
2009-01-30 14:48:38 +01:00
|
|
|
return CoTaskMemAlloc(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI user_free(void *p)
|
|
|
|
{
|
2015-06-16 08:29:00 +02:00
|
|
|
ok(0, "unexpected user_free call\n");
|
2009-01-30 14:48:38 +01:00
|
|
|
CoTaskMemFree(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void init_user_marshal_cb(USER_MARSHAL_CB *umcb,
|
|
|
|
PMIDL_STUB_MESSAGE stub_msg,
|
|
|
|
PRPC_MESSAGE rpc_msg, unsigned char *buffer,
|
|
|
|
unsigned int size, MSHCTX context)
|
|
|
|
{
|
|
|
|
memset(rpc_msg, 0, sizeof(*rpc_msg));
|
|
|
|
rpc_msg->Buffer = buffer;
|
|
|
|
rpc_msg->BufferLength = size;
|
|
|
|
|
|
|
|
memset(stub_msg, 0, sizeof(*stub_msg));
|
|
|
|
stub_msg->RpcMsg = rpc_msg;
|
|
|
|
stub_msg->Buffer = buffer;
|
|
|
|
stub_msg->pfnAllocate = user_allocate;
|
|
|
|
stub_msg->pfnFree = user_free;
|
|
|
|
|
|
|
|
memset(umcb, 0, sizeof(*umcb));
|
|
|
|
umcb->Flags = MAKELONG(context, NDR_LOCAL_DATA_REPRESENTATION);
|
|
|
|
umcb->pStubMsg = stub_msg;
|
|
|
|
umcb->Signature = USER_MARSHAL_CB_SIGNATURE;
|
|
|
|
umcb->CBType = buffer ? USER_MARSHAL_CB_UNMARSHALL : USER_MARSHAL_CB_BUFFER_SIZE;
|
|
|
|
}
|
|
|
|
|
2006-01-27 12:54:22 +01:00
|
|
|
static void test_marshal_LPSAFEARRAY(void)
|
|
|
|
{
|
2009-12-11 16:25:50 +01:00
|
|
|
unsigned char *buffer, *next;
|
2009-07-10 19:13:16 +02:00
|
|
|
ULONG size, expected;
|
2006-01-27 12:54:22 +01:00
|
|
|
LPSAFEARRAY lpsa;
|
|
|
|
LPSAFEARRAY lpsa2 = NULL;
|
2010-10-19 00:35:27 +02:00
|
|
|
SAFEARRAYBOUND sab[2];
|
2009-01-30 14:48:38 +01:00
|
|
|
RPC_MESSAGE rpc_msg;
|
|
|
|
MIDL_STUB_MESSAGE stub_msg;
|
|
|
|
USER_MARSHAL_CB umcb;
|
2007-01-30 13:39:37 +01:00
|
|
|
HRESULT hr;
|
2011-05-19 09:56:46 +02:00
|
|
|
VARTYPE vt, vt2;
|
2009-12-09 22:02:44 +01:00
|
|
|
OLECHAR *values[10];
|
|
|
|
int expected_bstr_size;
|
|
|
|
int i;
|
|
|
|
LONG indices[1];
|
2006-01-27 12:54:22 +01:00
|
|
|
|
2010-10-19 00:35:27 +02:00
|
|
|
sab[0].lLbound = 5;
|
|
|
|
sab[0].cElements = 10;
|
2006-01-27 12:54:22 +01:00
|
|
|
|
2010-10-19 00:35:27 +02:00
|
|
|
lpsa = SafeArrayCreate(VT_I2, 1, sab);
|
2006-01-27 12:54:22 +01:00
|
|
|
*(DWORD *)lpsa->pvData = 0xcafebabe;
|
|
|
|
|
|
|
|
lpsa->cLocks = 7;
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
2006-05-03 18:30:35 +02:00
|
|
|
size = LPSAFEARRAY_UserSize(&umcb.Flags, 1, &lpsa);
|
2009-07-10 19:13:16 +02:00
|
|
|
expected = (44 + 1 + sizeof(ULONG) - 1) & ~(sizeof(ULONG) - 1);
|
2010-10-19 00:35:27 +02:00
|
|
|
expected += sab[0].cElements * sizeof(USHORT);
|
2009-07-10 19:13:16 +02:00
|
|
|
ok(size == expected || size == expected + 12, /* win64 */
|
|
|
|
"size should be %u bytes, not %u\n", expected, size);
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
2006-01-27 12:54:22 +01:00
|
|
|
size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa);
|
2010-10-19 00:35:27 +02:00
|
|
|
expected = 44 + sab[0].cElements * sizeof(USHORT);
|
|
|
|
ok(size == expected || size == expected + 12, /* win64 */
|
|
|
|
"size should be %u bytes, not %u\n", expected, size);
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
next = LPSAFEARRAY_UserMarshal(&umcb.Flags, buffer, &lpsa);
|
|
|
|
ok(next - buffer == expected, "Marshaled %u bytes, expected %u\n", (ULONG) (next - buffer), expected);
|
2011-01-22 23:24:06 +01:00
|
|
|
ok(lpsa->cLocks == 7, "got lock count %u\n", lpsa->cLocks);
|
2010-10-19 00:35:27 +02:00
|
|
|
|
|
|
|
check_safearray(buffer, lpsa);
|
|
|
|
|
2011-05-19 09:56:46 +02:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
LPSAFEARRAY_UserUnmarshal(&umcb.Flags, buffer, &lpsa2);
|
|
|
|
ok(lpsa2 != NULL, "LPSAFEARRAY didn't unmarshal\n");
|
2012-01-09 10:03:06 +01:00
|
|
|
if (pSafeArrayGetVartype)
|
|
|
|
{
|
|
|
|
pSafeArrayGetVartype(lpsa, &vt);
|
|
|
|
pSafeArrayGetVartype(lpsa2, &vt2);
|
|
|
|
ok(vt == vt2, "vts differ %x %x\n", vt, vt2);
|
|
|
|
}
|
2011-05-19 09:56:46 +02:00
|
|
|
ok(lpsa2->cLocks == 0, "got lock count %u, expected 0\n", lpsa2->cLocks);
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
LPSAFEARRAY_UserFree(&umcb.Flags, &lpsa2);
|
2016-01-13 09:51:12 +01:00
|
|
|
ok(!lpsa2, "lpsa2 was not set to 0 by LPSAFEARRAY_UserFree\n");
|
2010-10-19 00:35:27 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
lpsa->cLocks = 0;
|
2011-01-22 23:24:06 +01:00
|
|
|
hr = SafeArrayDestroy(lpsa);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2010-10-19 00:35:27 +02:00
|
|
|
|
|
|
|
/* use two dimensions */
|
|
|
|
sab[0].lLbound = 5;
|
|
|
|
sab[0].cElements = 10;
|
|
|
|
sab[1].lLbound = 1;
|
|
|
|
sab[1].cElements = 2;
|
|
|
|
|
|
|
|
lpsa = SafeArrayCreate(VT_I2, 2, sab);
|
|
|
|
*(DWORD *)lpsa->pvData = 0xcafebabe;
|
|
|
|
|
|
|
|
lpsa->cLocks = 7;
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
size = LPSAFEARRAY_UserSize(&umcb.Flags, 1, &lpsa);
|
|
|
|
expected = (44 + 1 + +sizeof(SAFEARRAYBOUND) + sizeof(ULONG) - 1) & ~(sizeof(ULONG) - 1);
|
|
|
|
expected += max(sab[0].cElements, sab[1].cElements) * lpsa->cDims * sizeof(USHORT);
|
|
|
|
ok(size == expected || size == expected + 12, /* win64 */
|
|
|
|
"size should be %u bytes, not %u\n", expected, size);
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa);
|
|
|
|
expected = 52 + max(sab[0].cElements, sab[1].cElements) * lpsa->cDims * sizeof(USHORT);
|
2009-07-10 19:13:16 +02:00
|
|
|
ok(size == expected || size == expected + 12, /* win64 */
|
|
|
|
"size should be %u bytes, not %u\n", expected, size);
|
2007-06-27 00:12:48 +02:00
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, size);
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
2009-12-11 16:25:50 +01:00
|
|
|
next = LPSAFEARRAY_UserMarshal(&umcb.Flags, buffer, &lpsa);
|
|
|
|
ok(next - buffer == expected, "Marshaled %u bytes, expected %u\n", (ULONG) (next - buffer), expected);
|
2011-01-22 23:24:06 +01:00
|
|
|
ok(lpsa->cLocks == 7, "got lock count %u\n", lpsa->cLocks);
|
2006-05-02 13:00:30 +02:00
|
|
|
|
|
|
|
check_safearray(buffer, lpsa);
|
2006-01-27 12:54:22 +01:00
|
|
|
|
2011-05-19 09:56:46 +02:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
LPSAFEARRAY_UserUnmarshal(&umcb.Flags, buffer, &lpsa2);
|
|
|
|
ok(lpsa2 != NULL, "LPSAFEARRAY didn't unmarshal\n");
|
2012-01-09 10:03:06 +01:00
|
|
|
if (pSafeArrayGetVartype)
|
|
|
|
{
|
|
|
|
pSafeArrayGetVartype(lpsa, &vt);
|
|
|
|
pSafeArrayGetVartype(lpsa2, &vt2);
|
|
|
|
ok(vt == vt2, "vts differ %x %x\n", vt, vt2);
|
|
|
|
}
|
2011-05-19 09:56:46 +02:00
|
|
|
ok(lpsa2->cLocks == 0, "got lock count %u, expected 0\n", lpsa2->cLocks);
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
LPSAFEARRAY_UserFree(&umcb.Flags, &lpsa2);
|
2006-01-27 12:54:22 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
2007-12-07 15:14:33 +01:00
|
|
|
lpsa->cLocks = 0;
|
2011-01-22 23:24:06 +01:00
|
|
|
hr = SafeArrayDestroy(lpsa);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2006-01-27 12:54:22 +01:00
|
|
|
|
|
|
|
/* test NULL safe array */
|
|
|
|
lpsa = NULL;
|
|
|
|
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
2006-01-27 12:54:22 +01:00
|
|
|
size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa);
|
2009-12-11 16:25:50 +01:00
|
|
|
expected = 4;
|
|
|
|
ok(size == expected, "size should be 4 bytes, not %d\n", size);
|
2007-06-27 00:12:48 +02:00
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, size);
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
2009-12-11 16:25:50 +01:00
|
|
|
next = LPSAFEARRAY_UserMarshal(&umcb.Flags, buffer, &lpsa);
|
|
|
|
ok(next - buffer == expected, "Marshaled %u bytes, expected %u\n", (ULONG) (next - buffer), expected);
|
2006-05-02 13:00:30 +02:00
|
|
|
check_safearray(buffer, lpsa);
|
2006-01-27 12:54:22 +01:00
|
|
|
|
2011-05-19 09:56:46 +02:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
LPSAFEARRAY_UserUnmarshal(&umcb.Flags, buffer, &lpsa2);
|
|
|
|
ok(lpsa2 == NULL, "NULL LPSAFEARRAY didn't unmarshal\n");
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
LPSAFEARRAY_UserFree(&umcb.Flags, &lpsa2);
|
2006-01-27 12:54:22 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
2006-05-03 18:30:35 +02:00
|
|
|
|
2010-10-19 00:35:27 +02:00
|
|
|
sab[0].lLbound = 5;
|
|
|
|
sab[0].cElements = 10;
|
2006-05-03 18:30:35 +02:00
|
|
|
|
2010-10-19 00:35:27 +02:00
|
|
|
lpsa = SafeArrayCreate(VT_R8, 1, sab);
|
2006-05-03 18:30:35 +02:00
|
|
|
*(double *)lpsa->pvData = 3.1415;
|
|
|
|
|
|
|
|
lpsa->cLocks = 7;
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
2006-05-03 18:30:35 +02:00
|
|
|
size = LPSAFEARRAY_UserSize(&umcb.Flags, 1, &lpsa);
|
2009-07-10 19:13:16 +02:00
|
|
|
expected = (44 + 1 + (sizeof(double) - 1)) & ~(sizeof(double) - 1);
|
2010-10-19 00:35:27 +02:00
|
|
|
expected += sab[0].cElements * sizeof(double);
|
2009-07-10 19:13:16 +02:00
|
|
|
ok(size == expected || size == expected + 16, /* win64 */
|
|
|
|
"size should be %u bytes, not %u\n", expected, size);
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
2009-07-10 19:13:16 +02:00
|
|
|
expected = (44 + (sizeof(double) - 1)) & ~(sizeof(double) - 1);
|
2010-10-19 00:35:27 +02:00
|
|
|
expected += sab[0].cElements * sizeof(double);
|
2006-05-03 18:30:35 +02:00
|
|
|
size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa);
|
2009-07-10 19:13:16 +02:00
|
|
|
ok(size == expected || size == expected + 8, /* win64 */
|
|
|
|
"size should be %u bytes, not %u\n", expected, size);
|
2007-06-27 00:12:48 +02:00
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, size);
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
2009-12-11 16:25:50 +01:00
|
|
|
next = LPSAFEARRAY_UserMarshal(&umcb.Flags, buffer, &lpsa);
|
2009-12-17 21:54:00 +01:00
|
|
|
ok(next - buffer == expected || broken(next - buffer + sizeof(DWORD) == expected),
|
|
|
|
"Marshaled %u bytes, expected %u\n", (ULONG) (next - buffer), expected);
|
2006-05-03 18:30:35 +02:00
|
|
|
|
|
|
|
check_safearray(buffer, lpsa);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
2007-12-07 15:14:33 +01:00
|
|
|
lpsa->cLocks = 0;
|
2011-01-22 23:24:06 +01:00
|
|
|
hr = SafeArrayDestroy(lpsa);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2007-01-30 13:39:37 +01:00
|
|
|
|
|
|
|
/* VARTYPE-less arrays can be marshaled if cbElements is 1,2,4 or 8 as type SF_In */
|
|
|
|
hr = SafeArrayAllocDescriptor(1, &lpsa);
|
|
|
|
ok(hr == S_OK, "saad failed %08x\n", hr);
|
|
|
|
lpsa->cbElements = 8;
|
|
|
|
lpsa->rgsabound[0].lLbound = 2;
|
|
|
|
lpsa->rgsabound[0].cElements = 48;
|
|
|
|
hr = SafeArrayAllocData(lpsa);
|
|
|
|
ok(hr == S_OK, "saad failed %08x\n", hr);
|
|
|
|
|
2012-01-09 10:03:06 +01:00
|
|
|
if (pSafeArrayGetVartype)
|
|
|
|
{
|
|
|
|
hr = pSafeArrayGetVartype(lpsa, &vt);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr);
|
|
|
|
}
|
2007-01-30 13:39:37 +01:00
|
|
|
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
2007-01-30 13:39:37 +01:00
|
|
|
size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa);
|
2009-07-10 19:13:16 +02:00
|
|
|
expected = (44 + lpsa->cbElements - 1) & ~(lpsa->cbElements - 1);
|
|
|
|
expected += lpsa->cbElements * lpsa->rgsabound[0].cElements;
|
|
|
|
ok(size == expected || size == expected + 8, /* win64 */
|
|
|
|
"size should be %u bytes, not %u\n", expected, size);
|
2007-06-27 00:12:48 +02:00
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, size);
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
2009-12-11 16:25:50 +01:00
|
|
|
next = LPSAFEARRAY_UserMarshal(&umcb.Flags, buffer, &lpsa);
|
2009-12-17 21:54:00 +01:00
|
|
|
ok(next - buffer == expected || broken(next - buffer + sizeof(DWORD) == expected),
|
|
|
|
"Marshaled %u bytes, expected %u\n", (ULONG) (next - buffer), expected);
|
2007-01-30 13:39:37 +01:00
|
|
|
check_safearray(buffer, lpsa);
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
2011-01-22 23:24:06 +01:00
|
|
|
hr = SafeArrayDestroyData(lpsa);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
hr = SafeArrayDestroyDescriptor(lpsa);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2007-06-22 16:10:04 +02:00
|
|
|
|
2009-12-09 22:02:44 +01:00
|
|
|
/* Test an array of VT_BSTR */
|
2010-10-19 00:35:27 +02:00
|
|
|
sab[0].lLbound = 3;
|
|
|
|
sab[0].cElements = sizeof(values) / sizeof(values[0]);
|
2009-12-09 22:02:44 +01:00
|
|
|
|
2010-10-19 00:35:27 +02:00
|
|
|
lpsa = SafeArrayCreate(VT_BSTR, 1, sab);
|
2009-12-09 22:02:44 +01:00
|
|
|
expected_bstr_size = 0;
|
2010-10-19 00:35:27 +02:00
|
|
|
for (i = 0; i < sab[0].cElements; i++)
|
2009-12-09 22:02:44 +01:00
|
|
|
{
|
|
|
|
int j;
|
|
|
|
WCHAR buf[128];
|
|
|
|
for (j = 0; j <= i; j++)
|
|
|
|
buf[j] = 'a' + j;
|
|
|
|
buf[j] = 0;
|
2010-10-19 00:35:27 +02:00
|
|
|
indices[0] = i + sab[0].lLbound;
|
2009-12-09 22:02:44 +01:00
|
|
|
values[i] = SysAllocString(buf);
|
|
|
|
hr = SafeArrayPutElement(lpsa, indices, values[i]);
|
|
|
|
ok(hr == S_OK, "Failed to put bstr element hr 0x%x\n", hr);
|
|
|
|
expected_bstr_size += (j * sizeof(WCHAR)) + (3 * sizeof(DWORD));
|
|
|
|
if (i % 2 == 0) /* Account for DWORD padding. Works so long as cElements is even */
|
|
|
|
expected_bstr_size += sizeof(WCHAR);
|
|
|
|
}
|
|
|
|
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
size = LPSAFEARRAY_UserSize(&umcb.Flags, 1, &lpsa);
|
2010-10-19 00:35:27 +02:00
|
|
|
expected = 44 + (sab[0].cElements * sizeof(DWORD)) + expected_bstr_size;
|
2009-12-09 22:02:44 +01:00
|
|
|
todo_wine
|
2009-12-11 16:25:50 +01:00
|
|
|
ok(size == expected + sizeof(DWORD) || size == (expected + sizeof(DWORD) + 12 /* win64 */),
|
|
|
|
"size should be %u bytes, not %u\n", expected + (ULONG) sizeof(DWORD), size);
|
2009-12-09 22:02:44 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa);
|
|
|
|
todo_wine
|
2009-12-11 16:25:50 +01:00
|
|
|
ok(size == expected || size == (expected + 12 /* win64 */),
|
|
|
|
"size should be %u bytes, not %u\n", expected, size);
|
2009-12-09 22:02:44 +01:00
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
memset(buffer, 0xcc, size);
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
2009-12-11 16:25:50 +01:00
|
|
|
next = LPSAFEARRAY_UserMarshal(&umcb.Flags, buffer, &lpsa);
|
|
|
|
todo_wine
|
|
|
|
ok(next - buffer == expected, "Marshaled %u bytes, expected %u\n", (ULONG) (next - buffer), expected);
|
2009-12-09 22:02:44 +01:00
|
|
|
|
|
|
|
check_safearray(buffer, lpsa);
|
|
|
|
|
|
|
|
lpsa2 = NULL;
|
2011-05-19 09:56:46 +02:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
next = LPSAFEARRAY_UserUnmarshal(&umcb.Flags, buffer, &lpsa2);
|
|
|
|
todo_wine
|
|
|
|
ok(next - buffer == expected, "Marshaled %u bytes, expected %u\n", (ULONG) (next - buffer), expected);
|
|
|
|
ok(lpsa2 != NULL, "LPSAFEARRAY didn't unmarshal, result %p\n", next);
|
2009-12-09 22:02:44 +01:00
|
|
|
|
|
|
|
for (i = 0; i < sizeof(values) / sizeof(values[0]); i++)
|
|
|
|
{
|
|
|
|
BSTR gotvalue = NULL;
|
|
|
|
|
|
|
|
if (lpsa2)
|
|
|
|
{
|
2010-10-19 00:35:27 +02:00
|
|
|
indices[0] = i + sab[0].lLbound;
|
2009-12-09 22:02:44 +01:00
|
|
|
hr = SafeArrayGetElement(lpsa2, indices, &gotvalue);
|
|
|
|
ok(hr == S_OK, "Failed to get bstr element at hres 0x%x\n", hr);
|
|
|
|
if (hr == S_OK)
|
2009-12-11 16:25:25 +01:00
|
|
|
{
|
2012-01-09 10:03:06 +01:00
|
|
|
if (pVarBstrCmp)
|
|
|
|
ok(pVarBstrCmp(values[i], gotvalue, 0, 0) == VARCMP_EQ, "String %d does not match\n", i);
|
2009-12-11 16:25:25 +01:00
|
|
|
SysFreeString(gotvalue);
|
|
|
|
}
|
2009-12-09 22:02:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SysFreeString(values[i]);
|
|
|
|
}
|
|
|
|
|
2011-05-19 09:56:46 +02:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
LPSAFEARRAY_UserFree(&umcb.Flags, &lpsa2);
|
2009-12-09 22:02:44 +01:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
2011-01-22 23:24:06 +01:00
|
|
|
hr = SafeArrayDestroy(lpsa);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2009-12-09 22:02:44 +01:00
|
|
|
|
2007-06-22 16:10:04 +02:00
|
|
|
/* VARTYPE-less arrays with FADF_VARIANT */
|
|
|
|
hr = SafeArrayAllocDescriptor(1, &lpsa);
|
|
|
|
ok(hr == S_OK, "saad failed %08x\n", hr);
|
2009-07-10 19:13:16 +02:00
|
|
|
lpsa->cbElements = sizeof(VARIANT);
|
2007-06-22 16:10:04 +02:00
|
|
|
lpsa->fFeatures = FADF_VARIANT;
|
|
|
|
lpsa->rgsabound[0].lLbound = 2;
|
|
|
|
lpsa->rgsabound[0].cElements = 48;
|
|
|
|
hr = SafeArrayAllocData(lpsa);
|
|
|
|
ok(hr == S_OK, "saad failed %08x\n", hr);
|
|
|
|
|
2012-01-09 10:03:06 +01:00
|
|
|
if (pSafeArrayGetVartype)
|
|
|
|
{
|
|
|
|
hr = pSafeArrayGetVartype(lpsa, &vt);
|
|
|
|
ok(hr == E_INVALIDARG, "ret %08x\n", hr);
|
|
|
|
}
|
2007-06-22 16:10:04 +02:00
|
|
|
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
2007-06-22 16:10:04 +02:00
|
|
|
size = LPSAFEARRAY_UserSize(&umcb.Flags, 0, &lpsa);
|
2009-07-10 19:13:16 +02:00
|
|
|
expected = 44 + 28 * lpsa->rgsabound[0].cElements;
|
2007-06-22 16:10:04 +02:00
|
|
|
todo_wine
|
2009-07-10 19:13:16 +02:00
|
|
|
ok(size == expected || size == expected + 8, /* win64 */
|
|
|
|
"size should be %u bytes, not %u\n", expected, size);
|
2007-06-27 00:12:48 +02:00
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, size);
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
2009-12-11 16:25:50 +01:00
|
|
|
next = LPSAFEARRAY_UserMarshal(&umcb.Flags, buffer, &lpsa);
|
|
|
|
todo_wine
|
2009-12-17 21:54:00 +01:00
|
|
|
ok(next - buffer == expected || broken(next - buffer + sizeof(DWORD) == expected),
|
|
|
|
"Marshaled %u bytes, expected %u\n", (ULONG) (next - buffer), expected);
|
2009-07-10 19:13:16 +02:00
|
|
|
lpsa->cbElements = 16; /* VARIANT wire size */
|
2007-06-22 16:10:04 +02:00
|
|
|
check_safearray(buffer, lpsa);
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
2011-01-22 23:24:06 +01:00
|
|
|
hr = SafeArrayDestroyData(lpsa);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
hr = SafeArrayDestroyDescriptor(lpsa);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2006-01-27 12:54:22 +01:00
|
|
|
}
|
|
|
|
|
2006-05-02 13:00:30 +02:00
|
|
|
static void check_bstr(void *buffer, BSTR b)
|
|
|
|
{
|
|
|
|
DWORD *wireb = buffer;
|
2006-05-10 13:41:32 +02:00
|
|
|
DWORD len = SysStringByteLen(b);
|
2006-05-02 13:00:30 +02:00
|
|
|
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wireb == (len + 1) / 2, "wv[0] %08x\n", *wireb);
|
2006-05-02 13:00:30 +02:00
|
|
|
wireb++;
|
2006-05-10 13:41:32 +02:00
|
|
|
if(b)
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wireb == len, "wv[1] %08x\n", *wireb);
|
2006-05-02 13:00:30 +02:00
|
|
|
else
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wireb == 0xffffffff, "wv[1] %08x\n", *wireb);
|
2006-05-02 13:00:30 +02:00
|
|
|
wireb++;
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wireb == (len + 1) / 2, "wv[2] %08x\n", *wireb);
|
2006-05-02 13:00:30 +02:00
|
|
|
if(len)
|
|
|
|
{
|
|
|
|
wireb++;
|
2006-05-10 13:41:32 +02:00
|
|
|
ok(!memcmp(wireb, b, (len + 1) & ~1), "strings differ\n");
|
2006-05-02 13:00:30 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-04-29 15:40:28 +02:00
|
|
|
static void test_marshal_BSTR(void)
|
|
|
|
{
|
2009-01-30 14:48:38 +01:00
|
|
|
ULONG size;
|
|
|
|
RPC_MESSAGE rpc_msg;
|
|
|
|
MIDL_STUB_MESSAGE stub_msg;
|
|
|
|
USER_MARSHAL_CB umcb;
|
2006-05-10 13:41:32 +02:00
|
|
|
unsigned char *buffer, *next;
|
2006-04-29 15:40:28 +02:00
|
|
|
BSTR b, b2;
|
|
|
|
WCHAR str[] = {'m','a','r','s','h','a','l',' ','t','e','s','t','1',0};
|
2006-05-02 13:00:30 +02:00
|
|
|
DWORD len;
|
2006-04-29 15:40:28 +02:00
|
|
|
|
|
|
|
b = SysAllocString(str);
|
|
|
|
len = SysStringLen(b);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(len == 13, "get %d\n", len);
|
2006-04-29 15:40:28 +02:00
|
|
|
|
|
|
|
/* BSTRs are DWORD aligned */
|
2009-01-30 14:48:38 +01:00
|
|
|
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
2006-04-29 15:40:28 +02:00
|
|
|
size = BSTR_UserSize(&umcb.Flags, 1, &b);
|
2009-01-30 14:48:38 +01:00
|
|
|
ok(size == 42, "size %d\n", size);
|
2006-04-29 15:40:28 +02:00
|
|
|
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
2006-04-29 15:40:28 +02:00
|
|
|
size = BSTR_UserSize(&umcb.Flags, 0, &b);
|
2009-01-30 14:48:38 +01:00
|
|
|
ok(size == 38, "size %d\n", size);
|
2006-04-29 15:40:28 +02:00
|
|
|
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, size);
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
2006-05-10 13:41:32 +02:00
|
|
|
next = BSTR_UserMarshal(&umcb.Flags, buffer, &b);
|
|
|
|
ok(next == buffer + size, "got %p expect %p\n", next, buffer + size);
|
2006-05-02 13:00:30 +02:00
|
|
|
check_bstr(buffer, b);
|
2006-04-29 15:40:28 +02:00
|
|
|
|
2011-05-19 09:56:46 +02:00
|
|
|
b2 = NULL;
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
next = BSTR_UserUnmarshal(&umcb.Flags, buffer, &b2);
|
|
|
|
ok(next == buffer + size, "got %p expect %p\n", next, buffer + size);
|
|
|
|
ok(b2 != NULL, "BSTR didn't unmarshal\n");
|
|
|
|
ok(!memcmp(b, b2, (len + 1) * 2), "strings differ\n");
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
BSTR_UserFree(&umcb.Flags, &b2);
|
2006-04-29 15:40:28 +02:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
SysFreeString(b);
|
|
|
|
|
|
|
|
b = NULL;
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
2006-04-29 15:40:28 +02:00
|
|
|
size = BSTR_UserSize(&umcb.Flags, 0, &b);
|
2009-01-30 14:48:38 +01:00
|
|
|
ok(size == 12, "size %d\n", size);
|
2006-04-29 15:40:28 +02:00
|
|
|
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, size);
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
2006-05-10 13:41:32 +02:00
|
|
|
next = BSTR_UserMarshal(&umcb.Flags, buffer, &b);
|
|
|
|
ok(next == buffer + size, "got %p expect %p\n", next, buffer + size);
|
2006-04-29 15:40:28 +02:00
|
|
|
|
2006-05-02 13:00:30 +02:00
|
|
|
check_bstr(buffer, b);
|
2011-05-19 09:56:46 +02:00
|
|
|
b2 = NULL;
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
next = BSTR_UserUnmarshal(&umcb.Flags, buffer, &b2);
|
|
|
|
ok(next == buffer + size, "got %p expect %p\n", next, buffer + size);
|
|
|
|
ok(b2 == NULL, "NULL BSTR didn't unmarshal\n");
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
BSTR_UserFree(&umcb.Flags, &b2);
|
2006-04-29 15:40:28 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
|
2006-05-10 13:41:32 +02:00
|
|
|
b = SysAllocStringByteLen("abc", 3);
|
|
|
|
*(((char*)b) + 3) = 'd';
|
|
|
|
len = SysStringLen(b);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(len == 1, "get %d\n", len);
|
2006-05-10 13:41:32 +02:00
|
|
|
len = SysStringByteLen(b);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(len == 3, "get %d\n", len);
|
2006-05-10 13:41:32 +02:00
|
|
|
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
2006-05-10 13:41:32 +02:00
|
|
|
size = BSTR_UserSize(&umcb.Flags, 0, &b);
|
2009-01-30 14:48:38 +01:00
|
|
|
ok(size == 16, "size %d\n", size);
|
2006-05-10 13:41:32 +02:00
|
|
|
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
memset(buffer, 0xcc, size);
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
2006-05-10 13:41:32 +02:00
|
|
|
next = BSTR_UserMarshal(&umcb.Flags, buffer, &b);
|
|
|
|
ok(next == buffer + size, "got %p expect %p\n", next, buffer + size);
|
|
|
|
check_bstr(buffer, b);
|
|
|
|
ok(buffer[15] == 'd', "buffer[15] %02x\n", buffer[15]);
|
|
|
|
|
2011-05-19 09:56:46 +02:00
|
|
|
b2 = NULL;
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
next = BSTR_UserUnmarshal(&umcb.Flags, buffer, &b2);
|
|
|
|
ok(next == buffer + size, "got %p expect %p\n", next, buffer + size);
|
|
|
|
ok(b2 != NULL, "BSTR didn't unmarshal\n");
|
|
|
|
ok(!memcmp(b, b2, len), "strings differ\n");
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
BSTR_UserFree(&umcb.Flags, &b2);
|
2006-05-10 13:41:32 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
SysFreeString(b);
|
|
|
|
|
|
|
|
b = SysAllocStringByteLen("", 0);
|
|
|
|
len = SysStringLen(b);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(len == 0, "get %d\n", len);
|
2006-05-10 13:41:32 +02:00
|
|
|
len = SysStringByteLen(b);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(len == 0, "get %d\n", len);
|
2006-05-10 13:41:32 +02:00
|
|
|
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
2006-05-10 13:41:32 +02:00
|
|
|
size = BSTR_UserSize(&umcb.Flags, 0, &b);
|
2009-01-30 14:48:38 +01:00
|
|
|
ok(size == 12, "size %d\n", size);
|
2006-05-10 13:41:32 +02:00
|
|
|
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, size);
|
2009-01-30 14:48:38 +01:00
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
2006-05-10 13:41:32 +02:00
|
|
|
next = BSTR_UserMarshal(&umcb.Flags, buffer, &b);
|
|
|
|
ok(next == buffer + size, "got %p expect %p\n", next, buffer + size);
|
|
|
|
check_bstr(buffer, b);
|
|
|
|
|
2011-05-19 09:56:46 +02:00
|
|
|
b2 = NULL;
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
next = BSTR_UserUnmarshal(&umcb.Flags, buffer, &b2);
|
|
|
|
ok(next == buffer + size, "got %p expect %p\n", next, buffer + size);
|
|
|
|
ok(b2 != NULL, "NULL LPSAFEARRAY didn't unmarshal\n");
|
|
|
|
len = SysStringByteLen(b2);
|
|
|
|
ok(len == 0, "byte len %d\n", len);
|
|
|
|
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
|
|
|
|
BSTR_UserFree(&umcb.Flags, &b2);
|
2006-05-10 13:41:32 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
SysFreeString(b);
|
2006-04-29 15:40:28 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:54:57 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2010-12-29 02:53:23 +01:00
|
|
|
IUnknown IUnknown_iface;
|
2007-03-19 15:54:57 +01:00
|
|
|
ULONG refs;
|
|
|
|
} HeapUnknown;
|
|
|
|
|
2010-12-29 02:53:23 +01:00
|
|
|
static inline HeapUnknown *impl_from_IUnknown(IUnknown *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HeapUnknown, IUnknown_iface);
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:54:57 +01:00
|
|
|
static HRESULT WINAPI HeapUnknown_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
IUnknown_AddRef(iface);
|
2009-01-29 11:14:36 +01:00
|
|
|
*ppv = iface;
|
2007-03-19 15:54:57 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HeapUnknown_AddRef(IUnknown *iface)
|
|
|
|
{
|
2010-12-29 02:53:23 +01:00
|
|
|
HeapUnknown *This = impl_from_IUnknown(iface);
|
2007-03-19 15:54:57 +01:00
|
|
|
return InterlockedIncrement((LONG*)&This->refs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HeapUnknown_Release(IUnknown *iface)
|
|
|
|
{
|
2010-12-29 02:53:23 +01:00
|
|
|
HeapUnknown *This = impl_from_IUnknown(iface);
|
2007-03-19 15:54:57 +01:00
|
|
|
ULONG refs = InterlockedDecrement((LONG*)&This->refs);
|
|
|
|
if (!refs) HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
return refs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IUnknownVtbl HeapUnknown_Vtbl =
|
|
|
|
{
|
|
|
|
HeapUnknown_QueryInterface,
|
|
|
|
HeapUnknown_AddRef,
|
|
|
|
HeapUnknown_Release
|
|
|
|
};
|
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
typedef struct
|
2006-05-05 13:18:41 +02:00
|
|
|
{
|
2015-03-07 21:40:35 +01:00
|
|
|
DWORD clSize;
|
|
|
|
DWORD rpcReserved;
|
|
|
|
USHORT vt;
|
|
|
|
USHORT wReserved1;
|
|
|
|
USHORT wReserved2;
|
|
|
|
USHORT wReserved3;
|
2006-05-05 13:18:41 +02:00
|
|
|
DWORD switch_is;
|
2015-03-07 21:40:35 +01:00
|
|
|
} variant_wire_t;
|
|
|
|
|
|
|
|
static DWORD *check_variant_header(DWORD *wirev, VARIANT *v, ULONG size)
|
|
|
|
{
|
|
|
|
const variant_wire_t *header = (const variant_wire_t*)wirev;
|
|
|
|
DWORD switch_is;
|
|
|
|
|
|
|
|
ok(header->clSize == (size + 7) >> 3, "wv[0] %08x, expected %08x\n", header->clSize, (size + 7) >> 3);
|
|
|
|
ok(header->rpcReserved == 0, "wv[1] %08x\n", header->rpcReserved);
|
|
|
|
ok(header->vt == V_VT(v), "vt %04x expected %04x\n", header->vt, V_VT(v));
|
|
|
|
ok(header->wReserved1 == V_U2(v).wReserved1, "res1 %04x expected %04x\n", header->wReserved1, V_U2(v).wReserved1);
|
|
|
|
ok(header->wReserved2 == V_U2(v).wReserved2, "res2 %04x expected %04x\n", header->wReserved2, V_U2(v).wReserved2);
|
|
|
|
ok(header->wReserved3 == V_U2(v).wReserved3, "res3 %04x expected %04x\n", header->wReserved3, V_U2(v).wReserved3);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
switch_is = V_VT(v);
|
|
|
|
if(switch_is & VT_ARRAY)
|
|
|
|
switch_is &= ~VT_TYPEMASK;
|
2015-03-07 21:40:35 +01:00
|
|
|
ok(header->switch_is == switch_is, "switch_is %08x expected %08x\n", header->switch_is, switch_is);
|
|
|
|
|
|
|
|
return (DWORD*)((unsigned char*)wirev + sizeof(variant_wire_t));
|
2006-05-05 13:18:41 +02:00
|
|
|
}
|
|
|
|
|
2009-07-02 08:52:25 +02:00
|
|
|
/* Win9x and WinME don't always align as needed. Variants have
|
|
|
|
* an alignment of 8.
|
|
|
|
*/
|
|
|
|
static void *alloc_aligned(SIZE_T size, void **buf)
|
|
|
|
{
|
|
|
|
*buf = HeapAlloc(GetProcessHeap(), 0, size + 7);
|
|
|
|
return (void *)(((UINT_PTR)*buf + 7) & ~7);
|
|
|
|
}
|
|
|
|
|
2006-05-05 13:18:41 +02:00
|
|
|
static void test_marshal_VARIANT(void)
|
|
|
|
{
|
2011-05-19 09:56:46 +02:00
|
|
|
VARIANT v, v2, v3;
|
2006-05-05 13:18:41 +02:00
|
|
|
MIDL_STUB_MESSAGE stubMsg = { 0 };
|
2007-03-19 15:57:22 +01:00
|
|
|
RPC_MESSAGE rpcMsg = { 0 };
|
2006-05-05 13:18:41 +02:00
|
|
|
USER_MARSHAL_CB umcb = { 0 };
|
|
|
|
unsigned char *buffer, *next;
|
2009-07-02 08:52:25 +02:00
|
|
|
void *oldbuffer;
|
2006-06-16 04:52:54 +02:00
|
|
|
ULONG ul;
|
2006-05-05 13:18:41 +02:00
|
|
|
short s;
|
|
|
|
double d;
|
2011-05-19 09:56:46 +02:00
|
|
|
void *mem;
|
2006-05-05 13:18:41 +02:00
|
|
|
DWORD *wirev;
|
2016-01-13 09:51:57 +01:00
|
|
|
BSTR b, b2;
|
2006-05-05 13:18:41 +02:00
|
|
|
WCHAR str[] = {'m','a','r','s','h','a','l',' ','t','e','s','t',0};
|
|
|
|
SAFEARRAYBOUND sab;
|
2016-01-13 09:50:55 +01:00
|
|
|
LPSAFEARRAY lpsa, lpsa2, lpsa_copy;
|
2006-05-05 13:18:41 +02:00
|
|
|
DECIMAL dec, dec2;
|
2007-03-19 15:54:57 +01:00
|
|
|
HeapUnknown *heap_unknown;
|
2009-07-10 19:13:16 +02:00
|
|
|
DWORD expected;
|
2011-01-22 23:24:06 +01:00
|
|
|
HRESULT hr;
|
2011-05-19 09:56:46 +02:00
|
|
|
LONG bound, bound2;
|
|
|
|
VARTYPE vt, vt2;
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.RpcMsg = &rpcMsg;
|
|
|
|
|
2006-05-05 13:18:41 +02:00
|
|
|
umcb.Flags = MAKELONG(MSHCTX_DIFFERENTMACHINE, NDR_LOCAL_DATA_REPRESENTATION);
|
|
|
|
umcb.pStubMsg = &stubMsg;
|
2007-03-19 15:57:22 +01:00
|
|
|
umcb.pReserve = NULL;
|
|
|
|
umcb.Signature = USER_MARSHAL_CB_SIGNATURE;
|
|
|
|
umcb.CBType = USER_MARSHAL_CB_UNMARSHALL;
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** I1 ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_I1;
|
|
|
|
V_I1(&v) = 0x12;
|
|
|
|
|
2008-06-09 01:27:04 +02:00
|
|
|
/* check_variant_header tests wReserved[123], so initialize to unique values.
|
|
|
|
* (Could probably also do this by setting the variant to a known DECIMAL.)
|
|
|
|
*/
|
|
|
|
V_U2(&v).wReserved1 = 0x1234;
|
|
|
|
V_U2(&v).wReserved2 = 0x5678;
|
|
|
|
V_U2(&v).wReserved3 = 0x9abc;
|
|
|
|
|
2006-05-05 13:18:41 +02:00
|
|
|
/* Variants have an alignment of 8 */
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 1, &v);
|
|
|
|
ok(stubMsg.BufferLength == 29, "size %d\n", stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 21, "size %d\n", stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*(char*)wirev == V_I1(&v), "wv[5] %08x\n", *wirev);
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
|
|
|
ok(V_I1(&v) == V_I1(&v2), "got i1 %x expect %x\n", V_I1(&v), V_I1(&v2));
|
|
|
|
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** I2 ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_I2;
|
|
|
|
V_I2(&v) = 0x1234;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 22, "size %d\n", stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*(short*)wirev == V_I2(&v), "wv[5] %08x\n", *wirev);
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
|
|
|
ok(V_I2(&v) == V_I2(&v2), "got i2 %x expect %x\n", V_I2(&v), V_I2(&v2));
|
|
|
|
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** I2 BYREF ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_I2 | VT_BYREF;
|
|
|
|
s = 0x1234;
|
|
|
|
V_I2REF(&v) = &s;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 26, "size %d\n", stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev == 0x4, "wv[5] %08x\n", *wirev);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev++;
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*(short*)wirev == s, "wv[6] %08x\n", *wirev);
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
V_VT(&v2) = VT_I2 | VT_BYREF;
|
|
|
|
V_BYREF(&v2) = mem = CoTaskMemAlloc(sizeof(V_I2(&v2)));
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
|
|
|
ok(V_BYREF(&v2) == mem, "didn't reuse existing memory\n");
|
|
|
|
ok(*V_I2REF(&v) == *V_I2REF(&v2), "got i2 ref %x expect ui4 ref %x\n", *V_I2REF(&v), *V_I2REF(&v2));
|
|
|
|
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** I4 ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_I4;
|
|
|
|
V_I4(&v) = 0x1234;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 24, "size %d\n", stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev == V_I4(&v), "wv[5] %08x\n", *wirev);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
|
|
|
ok(V_I4(&v) == V_I4(&v2), "got i4 %x expect %x\n", V_I4(&v), V_I4(&v2));
|
|
|
|
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** UI4 ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_UI4;
|
|
|
|
V_UI4(&v) = 0x1234;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 24, "size %d\n", stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev == 0x1234, "wv[5] %08x\n", *wirev);
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
|
|
|
ok(V_UI4(&v) == V_UI4(&v2), "got ui4 %x expect %x\n", V_UI4(&v), V_UI4(&v2));
|
|
|
|
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** UI4 BYREF ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_UI4 | VT_BYREF;
|
|
|
|
ul = 0x1234;
|
|
|
|
V_UI4REF(&v) = &ul;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 28, "size %d\n", stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev == 0x4, "wv[5] %08x\n", *wirev);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev++;
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev == ul, "wv[6] %08x\n", *wirev);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
|
|
|
ok(*V_UI4REF(&v) == *V_UI4REF(&v2), "got ui4 ref %x expect ui4 ref %x\n", *V_UI4REF(&v), *V_UI4REF(&v2));
|
|
|
|
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** R4 ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_R4;
|
|
|
|
V_R8(&v) = 3.1415;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 24, "size %d\n", stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*(float*)wirev == V_R4(&v), "wv[5] %08x\n", *wirev);
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
|
|
|
ok(V_R4(&v) == V_R4(&v2), "got r4 %f expect %f\n", V_R4(&v), V_R4(&v2));
|
|
|
|
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** R8 ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_R8;
|
|
|
|
V_R8(&v) = 3.1415;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 32, "size %d\n", stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
|
|
|
memset(buffer, 0xcc, stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev == 0xcccccccc, "wv[5] %08x\n", *wirev); /* pad */
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev++;
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*(double*)wirev == V_R8(&v), "wv[6] %08x, wv[7] %08x\n", *wirev, *(wirev+1));
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
|
|
|
ok(V_R8(&v) == V_R8(&v2), "got r8 %f expect %f\n", V_R8(&v), V_R8(&v2));
|
|
|
|
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** R8 BYREF ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_R8 | VT_BYREF;
|
|
|
|
d = 3.1415;
|
|
|
|
V_R8REF(&v) = &d;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 32, "size %d\n", stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev == 8, "wv[5] %08x\n", *wirev);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev++;
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*(double*)wirev == d, "wv[6] %08x wv[7] %08x\n", *wirev, *(wirev+1));
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
|
|
|
ok(*V_R8REF(&v) == *V_R8REF(&v2), "got r8 ref %f expect %f\n", *V_R8REF(&v), *V_R8REF(&v2));
|
|
|
|
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** VARIANT_BOOL ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_BOOL;
|
|
|
|
V_BOOL(&v) = 0x1234;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 22, "size %d\n", stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
ok(*(short*)wirev == V_BOOL(&v), "wv[5] %04x\n", *(WORD*)wirev);
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
|
|
|
ok(V_BOOL(&v) == V_BOOL(&v2), "got bool %x expect %x\n", V_BOOL(&v), V_BOOL(&v2));
|
|
|
|
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** DECIMAL ***/
|
|
|
|
VarDecFromI4(0x12345678, &dec);
|
2008-06-09 01:27:04 +02:00
|
|
|
dec.wReserved = 0xfedc; /* Also initialize reserved field, as we check it later */
|
2006-05-05 13:18:41 +02:00
|
|
|
VariantInit(&v);
|
|
|
|
V_DECIMAL(&v) = dec;
|
|
|
|
V_VT(&v) = VT_DECIMAL;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 40, "size %d\n", stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
|
|
|
memset(buffer, 0xcc, stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev == 0xcccccccc, "wirev[5] %08x\n", *wirev); /* pad */
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev++;
|
|
|
|
dec2 = dec;
|
|
|
|
dec2.wReserved = VT_DECIMAL;
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(!memcmp(wirev, &dec2, sizeof(dec2)), "wirev[6] %08x wirev[7] %08x wirev[8] %08x wirev[9] %08x\n",
|
2006-05-05 13:18:41 +02:00
|
|
|
*wirev, *(wirev + 1), *(wirev + 2), *(wirev + 3));
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
|
|
|
ok(!memcmp(&V_DECIMAL(&v), & V_DECIMAL(&v2), sizeof(DECIMAL)), "decimals differ\n");
|
|
|
|
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** DECIMAL BYREF ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_DECIMAL | VT_BYREF;
|
|
|
|
V_DECIMALREF(&v) = &dec;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 40, "size %d\n", stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev == 16, "wv[5] %08x\n", *wirev);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev++;
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(!memcmp(wirev, &dec, sizeof(dec)), "wirev[6] %08x wirev[7] %08x wirev[8] %08x wirev[9] %08x\n", *wirev, *(wirev + 1), *(wirev + 2), *(wirev + 3));
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
/* check_variant_header tests wReserved[123], so initialize to unique values.
|
|
|
|
* (Could probably also do this by setting the variant to a known DECIMAL.)
|
|
|
|
*/
|
|
|
|
V_U2(&v2).wReserved1 = 0x0123;
|
|
|
|
V_U2(&v2).wReserved2 = 0x4567;
|
|
|
|
V_U2(&v2).wReserved3 = 0x89ab;
|
|
|
|
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
|
|
|
ok(!memcmp(V_DECIMALREF(&v), V_DECIMALREF(&v2), sizeof(DECIMAL)), "decimals differ\n");
|
|
|
|
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** EMPTY ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 20, "size %d\n", stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2011-05-19 09:56:46 +02:00
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** NULL ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_NULL;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 20, "size %d\n", stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2011-05-19 09:56:46 +02:00
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** BSTR ***/
|
|
|
|
b = SysAllocString(str);
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_BSTR;
|
|
|
|
V_BSTR(&v) = b;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 60, "size %d\n", stubMsg.BufferLength);
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev, "wv[5] %08x\n", *wirev); /* win2k: this is b. winxp: this is (char*)b + 1 */
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev++;
|
|
|
|
check_bstr(wirev, V_BSTR(&v));
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
|
|
|
ok(SysStringByteLen(V_BSTR(&v)) == SysStringByteLen(V_BSTR(&v2)), "bstr string lens differ\n");
|
|
|
|
ok(!memcmp(V_BSTR(&v), V_BSTR(&v2), SysStringByteLen(V_BSTR(&v))), "bstrs differ\n");
|
|
|
|
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** BSTR BYREF ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_BSTR | VT_BYREF;
|
|
|
|
V_BSTRREF(&v) = &b;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 64, "size %d\n", stubMsg.BufferLength);
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev == 0x4, "wv[5] %08x\n", *wirev);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev++;
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev, "wv[6] %08x\n", *wirev); /* win2k: this is b. winxp: this is (char*)b + 1 */
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev++;
|
|
|
|
check_bstr(wirev, b);
|
2016-01-13 09:51:57 +01:00
|
|
|
b2 = SysAllocString(str);
|
|
|
|
b2[0] = 0;
|
|
|
|
V_VT(&v2) = VT_BSTR | VT_BYREF;
|
|
|
|
V_BSTRREF(&v2) = &b2;
|
|
|
|
mem = b2;
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2016-01-13 09:51:57 +01:00
|
|
|
ok(mem == b2, "BSTR should be reused\n");
|
2011-05-19 09:56:46 +02:00
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
|
|
|
ok(SysStringByteLen(*V_BSTRREF(&v)) == SysStringByteLen(*V_BSTRREF(&v2)), "bstr string lens differ\n");
|
|
|
|
ok(!memcmp(*V_BSTRREF(&v), *V_BSTRREF(&v2), SysStringByteLen(*V_BSTRREF(&v))), "bstrs differ\n");
|
|
|
|
|
2016-01-13 09:51:57 +01:00
|
|
|
SysFreeString(b2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
SysFreeString(b);
|
|
|
|
|
|
|
|
/*** ARRAY ***/
|
|
|
|
sab.lLbound = 5;
|
|
|
|
sab.cElements = 10;
|
|
|
|
|
|
|
|
lpsa = SafeArrayCreate(VT_R8, 1, &sab);
|
|
|
|
*(DWORD *)lpsa->pvData = 0xcafebabe;
|
|
|
|
*((DWORD *)lpsa->pvData + 1) = 0xdeadbeef;
|
|
|
|
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_UI4 | VT_ARRAY;
|
|
|
|
V_ARRAY(&v) = lpsa;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
2009-07-10 19:13:16 +02:00
|
|
|
expected = 152;
|
|
|
|
ok(stubMsg.BufferLength == expected || stubMsg.BufferLength == expected + 8, /* win64 */
|
|
|
|
"size %u instead of %u\n", stubMsg.BufferLength, expected);
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2009-07-10 19:13:16 +02:00
|
|
|
ok(next == buffer + expected, "got %p expect %p\n", next, buffer + expected);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, expected);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev, "wv[5] %08x\n", *wirev); /* win2k: this is lpsa. winxp: this is (char*)lpsa + 1 */
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev++;
|
|
|
|
check_safearray(wirev, lpsa);
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + expected, "got %p expect %p\n", next, buffer + expected);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
2012-04-15 21:50:42 +02:00
|
|
|
ok(SafeArrayGetDim(V_ARRAY(&v)) == SafeArrayGetDim(V_ARRAY(&v2)), "array dims differ\n");
|
2011-05-19 09:56:46 +02:00
|
|
|
SafeArrayGetLBound(V_ARRAY(&v), 1, &bound);
|
|
|
|
SafeArrayGetLBound(V_ARRAY(&v2), 1, &bound2);
|
|
|
|
ok(bound == bound2, "array lbounds differ\n");
|
|
|
|
SafeArrayGetUBound(V_ARRAY(&v), 1, &bound);
|
|
|
|
SafeArrayGetUBound(V_ARRAY(&v2), 1, &bound2);
|
|
|
|
ok(bound == bound2, "array ubounds differ\n");
|
2012-01-09 10:03:06 +01:00
|
|
|
if (pSafeArrayGetVartype)
|
|
|
|
{
|
|
|
|
pSafeArrayGetVartype(V_ARRAY(&v), &vt);
|
|
|
|
pSafeArrayGetVartype(V_ARRAY(&v2), &vt2);
|
|
|
|
ok(vt == vt2, "array vts differ %x %x\n", vt, vt2);
|
|
|
|
}
|
2011-05-19 09:56:46 +02:00
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** ARRAY BYREF ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_UI4 | VT_ARRAY | VT_BYREF;
|
|
|
|
V_ARRAYREF(&v) = &lpsa;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
2009-07-10 19:13:16 +02:00
|
|
|
expected = 152;
|
|
|
|
ok(stubMsg.BufferLength == expected || stubMsg.BufferLength == expected + 16, /* win64 */
|
|
|
|
"size %u instead of %u\n", stubMsg.BufferLength, expected);
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2009-07-10 19:13:16 +02:00
|
|
|
ok(next == buffer + expected, "got %p expect %p\n", next, buffer + expected);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
2009-07-10 19:13:16 +02:00
|
|
|
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, expected);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev == 4, "wv[5] %08x\n", *wirev);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev++;
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev, "wv[6] %08x\n", *wirev); /* win2k: this is lpsa. winxp: this is (char*)lpsa + 1 */
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev++;
|
|
|
|
check_safearray(wirev, lpsa);
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + expected, "got %p expect %p\n", next, buffer + expected);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
2012-04-15 21:50:42 +02:00
|
|
|
ok(SafeArrayGetDim(*V_ARRAYREF(&v)) == SafeArrayGetDim(*V_ARRAYREF(&v2)), "array dims differ\n");
|
2011-05-19 09:56:46 +02:00
|
|
|
SafeArrayGetLBound(*V_ARRAYREF(&v), 1, &bound);
|
|
|
|
SafeArrayGetLBound(*V_ARRAYREF(&v2), 1, &bound2);
|
|
|
|
ok(bound == bound2, "array lbounds differ\n");
|
|
|
|
SafeArrayGetUBound(*V_ARRAYREF(&v), 1, &bound);
|
|
|
|
SafeArrayGetUBound(*V_ARRAYREF(&v2), 1, &bound2);
|
|
|
|
ok(bound == bound2, "array ubounds differ\n");
|
2012-01-09 10:03:06 +01:00
|
|
|
if (pSafeArrayGetVartype)
|
|
|
|
{
|
|
|
|
pSafeArrayGetVartype(*V_ARRAYREF(&v), &vt);
|
|
|
|
pSafeArrayGetVartype(*V_ARRAYREF(&v2), &vt2);
|
|
|
|
ok(vt == vt2, "array vts differ %x %x\n", vt, vt2);
|
|
|
|
}
|
2011-05-19 09:56:46 +02:00
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2016-01-13 09:50:55 +01:00
|
|
|
|
|
|
|
/*** ARRAY BYREF ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_UI4 | VT_ARRAY | VT_BYREF;
|
|
|
|
V_ARRAYREF(&v) = &lpsa;
|
|
|
|
lpsa->fFeatures |= FADF_STATIC;
|
|
|
|
|
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
expected = 152;
|
|
|
|
ok(stubMsg.BufferLength == expected || stubMsg.BufferLength == expected + 16, /* win64 */
|
|
|
|
"size %u instead of %u\n", stubMsg.BufferLength, expected);
|
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
|
|
|
ok(next == buffer + expected, "got %p expect %p\n", next, buffer + expected);
|
|
|
|
wirev = (DWORD*)buffer;
|
|
|
|
|
|
|
|
wirev = check_variant_header(wirev, &v, expected);
|
|
|
|
ok(*wirev == 4, "wv[5] %08x\n", *wirev);
|
|
|
|
wirev++;
|
|
|
|
ok(*wirev, "wv[6] %08x\n", *wirev); /* win2k: this is lpsa. winxp: this is (char*)lpsa + 1 */
|
|
|
|
wirev++;
|
|
|
|
check_safearray(wirev, lpsa);
|
|
|
|
lpsa_copy = lpsa2 = SafeArrayCreate(VT_I8, 1, &sab);
|
|
|
|
/* set FADF_STATIC feature to make sure lpsa2->pvData pointer changes if new data buffer is allocated */
|
|
|
|
lpsa2->fFeatures |= FADF_STATIC;
|
|
|
|
mem = lpsa2->pvData;
|
|
|
|
V_VT(&v2) = VT_UI4 | VT_ARRAY | VT_BYREF;
|
|
|
|
V_ARRAYREF(&v2) = &lpsa2;
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(next == buffer + expected, "got %p expect %p\n", next, buffer + expected);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
2016-01-13 09:51:23 +01:00
|
|
|
ok(lpsa2 == lpsa_copy, "safearray should be reused\n");
|
2016-01-13 09:51:32 +01:00
|
|
|
ok(mem == lpsa2->pvData, "safearray data should be reused\n");
|
2016-01-13 09:50:55 +01:00
|
|
|
ok(SafeArrayGetDim(*V_ARRAYREF(&v)) == SafeArrayGetDim(*V_ARRAYREF(&v2)), "array dims differ\n");
|
|
|
|
SafeArrayGetLBound(*V_ARRAYREF(&v), 1, &bound);
|
|
|
|
SafeArrayGetLBound(*V_ARRAYREF(&v2), 1, &bound2);
|
|
|
|
ok(bound == bound2, "array lbounds differ\n");
|
|
|
|
SafeArrayGetUBound(*V_ARRAYREF(&v), 1, &bound);
|
|
|
|
SafeArrayGetUBound(*V_ARRAYREF(&v2), 1, &bound2);
|
|
|
|
ok(bound == bound2, "array ubounds differ\n");
|
|
|
|
if (pSafeArrayGetVartype)
|
|
|
|
{
|
|
|
|
pSafeArrayGetVartype(*V_ARRAYREF(&v), &vt);
|
|
|
|
pSafeArrayGetVartype(*V_ARRAYREF(&v2), &vt2);
|
|
|
|
ok(vt == vt2, "array vts differ %x %x\n", vt, vt2);
|
|
|
|
}
|
|
|
|
lpsa2->fFeatures &= ~FADF_STATIC;
|
|
|
|
hr = SafeArrayDestroy(*V_ARRAYREF(&v2));
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
|
|
|
lpsa->fFeatures &= ~FADF_STATIC;
|
2011-01-22 23:24:06 +01:00
|
|
|
hr = SafeArrayDestroy(lpsa);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
|
|
|
/*** VARIANT BYREF ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
VariantInit(&v2);
|
|
|
|
V_VT(&v2) = VT_R8;
|
|
|
|
V_R8(&v2) = 3.1415;
|
|
|
|
V_VT(&v) = VT_VARIANT | VT_BYREF;
|
|
|
|
V_VARIANTREF(&v) = &v2;
|
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength == 64, "size %d\n", stubMsg.BufferLength);
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
|
|
|
memset(buffer, 0xcc, stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, stubMsg.BufferLength);
|
2006-05-05 13:18:41 +02:00
|
|
|
|
2009-07-10 19:13:16 +02:00
|
|
|
ok(*wirev == sizeof(VARIANT), "wv[5] %08x\n", *wirev);
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev++;
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev == ('U' | 's' << 8 | 'e' << 16 | 'r' << 24), "wv[6] %08x\n", *wirev); /* 'User' */
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev++;
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev == 0xcccccccc, "wv[7] %08x\n", *wirev); /* pad */
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev++;
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v2, stubMsg.BufferLength - 32);
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*wirev == 0xcccccccc, "wv[13] %08x\n", *wirev); /* pad for VT_R8 */
|
2006-05-05 13:18:41 +02:00
|
|
|
wirev++;
|
2006-10-12 13:56:01 +02:00
|
|
|
ok(*(double*)wirev == V_R8(&v2), "wv[6] %08x wv[7] %08x\n", *wirev, *(wirev+1));
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v3);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v3);
|
|
|
|
ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength);
|
|
|
|
ok(V_VT(&v) == V_VT(&v3), "got vt %d expect %d\n", V_VT(&v), V_VT(&v3));
|
|
|
|
ok(V_VT(V_VARIANTREF(&v)) == V_VT(V_VARIANTREF(&v3)), "vts differ %x %x\n",
|
|
|
|
V_VT(V_VARIANTREF(&v)), V_VT(V_VARIANTREF(&v3)));
|
|
|
|
ok(V_R8(V_VARIANTREF(&v)) == V_R8(V_VARIANTREF(&v3)), "r8s differ\n");
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v3);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2007-03-19 15:54:57 +01:00
|
|
|
|
|
|
|
/*** UNKNOWN ***/
|
|
|
|
heap_unknown = HeapAlloc(GetProcessHeap(), 0, sizeof(*heap_unknown));
|
2010-12-29 02:53:23 +01:00
|
|
|
heap_unknown->IUnknown_iface.lpVtbl = &HeapUnknown_Vtbl;
|
2007-03-19 15:54:57 +01:00
|
|
|
heap_unknown->refs = 1;
|
|
|
|
VariantInit(&v);
|
|
|
|
VariantInit(&v2);
|
|
|
|
V_VT(&v) = VT_UNKNOWN;
|
2010-12-29 02:53:23 +01:00
|
|
|
V_UNKNOWN(&v) = &heap_unknown->IUnknown_iface;
|
2007-03-19 15:54:57 +01:00
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
2015-03-08 09:04:29 +01:00
|
|
|
ok(stubMsg.BufferLength > 40, "size %d\n", stubMsg.BufferLength);
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-03-19 15:57:22 +01:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
|
|
|
memset(buffer, 0xcc, stubMsg.BufferLength);
|
2007-03-19 15:54:57 +01:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2015-03-08 09:04:29 +01:00
|
|
|
todo_wine
|
|
|
|
ok(heap_unknown->refs == 2, "got refcount %d\n", heap_unknown->refs);
|
2007-03-19 15:54:57 +01:00
|
|
|
wirev = (DWORD*)buffer;
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, next - buffer);
|
2007-03-19 15:54:57 +01:00
|
|
|
|
2007-03-19 15:57:22 +01:00
|
|
|
ok(*wirev == (DWORD_PTR)V_UNKNOWN(&v) /* Win9x */ ||
|
|
|
|
*wirev == (DWORD_PTR)V_UNKNOWN(&v) + 1 /* NT */, "wv[5] %08x\n", *wirev);
|
2007-03-19 15:54:57 +01:00
|
|
|
wirev++;
|
|
|
|
ok(*wirev == next - buffer - 0x20, "wv[6] %08x\n", *wirev);
|
|
|
|
wirev++;
|
|
|
|
ok(*wirev == next - buffer - 0x20, "wv[7] %08x\n", *wirev);
|
|
|
|
wirev++;
|
|
|
|
ok(*wirev == 0x574f454d, "wv[8] %08x\n", *wirev);
|
2011-05-19 09:56:46 +02:00
|
|
|
VariantInit(&v3);
|
|
|
|
V_VT(&v3) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&v3) = &heap_unknown->IUnknown_iface;
|
|
|
|
IUnknown_AddRef(V_UNKNOWN(&v3));
|
|
|
|
stubMsg.Buffer = buffer;
|
2015-03-08 09:04:29 +01:00
|
|
|
todo_wine
|
|
|
|
ok(heap_unknown->refs == 3, "got refcount %d\n", heap_unknown->refs);
|
2011-05-19 09:56:46 +02:00
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v3);
|
|
|
|
ok(V_VT(&v) == V_VT(&v3), "got vt %d expect %d\n", V_VT(&v), V_VT(&v3));
|
|
|
|
ok(V_UNKNOWN(&v) == V_UNKNOWN(&v3), "got %p expect %p\n", V_UNKNOWN(&v), V_UNKNOWN(&v3));
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v3);
|
|
|
|
ok(heap_unknown->refs == 1, "%d refcounts of IUnknown leaked\n", heap_unknown->refs - 1);
|
|
|
|
IUnknown_Release(&heap_unknown->IUnknown_iface);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2007-06-22 15:40:36 +02:00
|
|
|
|
2010-02-25 14:48:22 +01:00
|
|
|
/*** NULL UNKNOWN ***/
|
|
|
|
VariantInit(&v);
|
|
|
|
V_VT(&v) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&v) = NULL;
|
|
|
|
|
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
|
|
|
ok(stubMsg.BufferLength >= 24, "size %d\n", stubMsg.BufferLength);
|
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
|
|
|
memset(buffer, 0xcc, stubMsg.BufferLength);
|
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
|
|
|
wirev = (DWORD*)buffer;
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, next - buffer);
|
2010-02-25 14:48:22 +01:00
|
|
|
ok(*wirev == 0, "wv[5] %08x\n", *wirev);
|
|
|
|
|
|
|
|
VariantInit(&v2);
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2);
|
|
|
|
ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2));
|
|
|
|
ok(V_UNKNOWN(&v2) == NULL, "got %p expect NULL\n", V_UNKNOWN(&v2));
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v2);
|
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
|
|
|
|
2007-06-22 15:40:36 +02:00
|
|
|
/*** UNKNOWN BYREF ***/
|
|
|
|
heap_unknown = HeapAlloc(GetProcessHeap(), 0, sizeof(*heap_unknown));
|
2010-12-29 02:53:23 +01:00
|
|
|
heap_unknown->IUnknown_iface.lpVtbl = &HeapUnknown_Vtbl;
|
2007-06-22 15:40:36 +02:00
|
|
|
heap_unknown->refs = 1;
|
|
|
|
VariantInit(&v);
|
|
|
|
VariantInit(&v2);
|
|
|
|
V_VT(&v) = VT_UNKNOWN | VT_BYREF;
|
|
|
|
V_UNKNOWNREF(&v) = (IUnknown **)&heap_unknown;
|
|
|
|
|
|
|
|
rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v);
|
2015-03-08 09:04:29 +01:00
|
|
|
ok(stubMsg.BufferLength >= 44, "size %d\n", stubMsg.BufferLength);
|
2009-07-02 08:52:25 +02:00
|
|
|
buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer);
|
2007-06-22 15:40:36 +02:00
|
|
|
stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength;
|
|
|
|
memset(buffer, 0xcc, stubMsg.BufferLength);
|
2015-03-08 09:04:29 +01:00
|
|
|
ok(heap_unknown->refs == 1, "got refcount %d\n", heap_unknown->refs);
|
2007-06-22 15:40:36 +02:00
|
|
|
next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v);
|
2015-03-08 09:04:29 +01:00
|
|
|
todo_wine
|
|
|
|
ok(heap_unknown->refs == 2, "got refcount %d\n", heap_unknown->refs);
|
2007-06-22 15:40:36 +02:00
|
|
|
wirev = (DWORD*)buffer;
|
2015-03-07 21:40:35 +01:00
|
|
|
wirev = check_variant_header(wirev, &v, next - buffer);
|
2007-06-22 15:40:36 +02:00
|
|
|
|
|
|
|
ok(*wirev == 4, "wv[5] %08x\n", *wirev);
|
|
|
|
wirev++;
|
|
|
|
ok(*wirev == (DWORD_PTR)heap_unknown /* Win9x, Win2000 */ ||
|
|
|
|
*wirev == (DWORD_PTR)heap_unknown + 1 /* XP */, "wv[6] %08x\n", *wirev);
|
|
|
|
wirev++;
|
|
|
|
ok(*wirev == next - buffer - 0x24, "wv[7] %08x\n", *wirev);
|
|
|
|
wirev++;
|
|
|
|
ok(*wirev == next - buffer - 0x24, "wv[8] %08x\n", *wirev);
|
|
|
|
wirev++;
|
|
|
|
ok(*wirev == 0x574f454d, "wv[9] %08x\n", *wirev);
|
2011-05-19 09:56:46 +02:00
|
|
|
|
|
|
|
VariantInit(&v3);
|
|
|
|
V_VT(&v3) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&v3) = &heap_unknown->IUnknown_iface;
|
|
|
|
IUnknown_AddRef(V_UNKNOWN(&v3));
|
|
|
|
stubMsg.Buffer = buffer;
|
|
|
|
next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v3);
|
2015-03-08 09:04:29 +01:00
|
|
|
ok(heap_unknown->refs == 2, "got refcount %d\n", heap_unknown->refs);
|
2011-05-19 09:56:46 +02:00
|
|
|
ok(V_VT(&v) == V_VT(&v3), "got vt %d expect %d\n", V_VT(&v), V_VT(&v3));
|
|
|
|
ok(*V_UNKNOWNREF(&v) == *V_UNKNOWNREF(&v3), "got %p expect %p\n", *V_UNKNOWNREF(&v), *V_UNKNOWNREF(&v3));
|
|
|
|
VARIANT_UserFree(&umcb.Flags, &v3);
|
|
|
|
ok(heap_unknown->refs == 1, "%d refcounts of IUnknown leaked\n", heap_unknown->refs - 1);
|
|
|
|
IUnknown_Release(&heap_unknown->IUnknown_iface);
|
2009-07-02 08:52:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, oldbuffer);
|
2006-05-05 13:18:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-27 12:54:22 +01:00
|
|
|
START_TEST(usrmarshal)
|
|
|
|
{
|
2012-01-09 10:03:06 +01:00
|
|
|
HANDLE hOleaut32 = GetModuleHandleA("oleaut32.dll");
|
|
|
|
#define GETPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func)
|
|
|
|
GETPTR(SafeArrayGetIID);
|
|
|
|
GETPTR(SafeArrayGetVartype);
|
|
|
|
GETPTR(VarBstrCmp);
|
|
|
|
#undef GETPTR
|
|
|
|
|
|
|
|
if (!pSafeArrayGetIID || !pSafeArrayGetVartype)
|
|
|
|
win_skip("SafeArrayGetIID and/or SafeArrayGetVartype is not available, some tests will be skipped\n");
|
|
|
|
|
2006-01-27 12:54:22 +01:00
|
|
|
CoInitialize(NULL);
|
|
|
|
|
|
|
|
test_marshal_LPSAFEARRAY();
|
2006-04-29 15:40:28 +02:00
|
|
|
test_marshal_BSTR();
|
2006-05-05 13:18:41 +02:00
|
|
|
test_marshal_VARIANT();
|
2006-01-27 12:54:22 +01:00
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
}
|