Rob Shearman : rpcrt4: Fix ndr_marshall tests to cope with using pointer ids instead of using pointer values .
Alexandre Julliard
julliard at winehq.org
Wed Jun 18 12:53:54 CDT 2008
Module: wine
Branch: master
Commit: c9ef063e12d2c2ef7ef5ccafad525b3cd31ba61d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c9ef063e12d2c2ef7ef5ccafad525b3cd31ba61d
Author: Rob Shearman <robertshearman at gmail.com>
Date: Sat Jun 14 16:29:35 2008 +0100
rpcrt4: Fix ndr_marshall tests to cope with using pointer ids instead of using pointer values.
This fixes a number of test failures on XP SP3 and Win2003 upwards.
---
dlls/rpcrt4/tests/ndr_marshall.c | 112 +++++++++++++++++++++++++++++++-------
1 files changed, 93 insertions(+), 19 deletions(-)
diff --git a/dlls/rpcrt4/tests/ndr_marshall.c b/dlls/rpcrt4/tests/ndr_marshall.c
index 26f67a7..3683027 100644
--- a/dlls/rpcrt4/tests/ndr_marshall.c
+++ b/dlls/rpcrt4/tests/ndr_marshall.c
@@ -97,6 +97,41 @@ static const RPC_SERVER_INTERFACE IFoo___RpcServerInterface =
};
static RPC_IF_HANDLE IFoo_v0_0_s_ifspec = (RPC_IF_HANDLE)& IFoo___RpcServerInterface;
+static BOOL use_pointer_ids = FALSE;
+
+static void determine_pointer_marshalling_style(void)
+{
+ RPC_MESSAGE RpcMessage;
+ MIDL_STUB_MESSAGE StubMsg;
+ MIDL_STUB_DESC StubDesc;
+ char ch = 0xde;
+
+ static const unsigned char fmtstr_up_char[] =
+ {
+ 0x12, 0x8, /* FC_UP [simple_pointer] */
+ 0x2, /* FC_CHAR */
+ 0x5c, /* FC_PAD */
+ };
+
+ StubDesc = Object_StubDesc;
+ StubDesc.pFormatTypes = NULL;
+
+ NdrClientInitializeNew(
+ &RpcMessage,
+ &StubMsg,
+ &StubDesc,
+ 0);
+
+ StubMsg.BufferLength = 8;
+ StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
+ NdrPointerMarshall(&StubMsg, (unsigned char*)&ch, fmtstr_up_char);
+ ok(StubMsg.Buffer == StubMsg.BufferStart + 5, "%p %p\n", StubMsg.Buffer, StubMsg.BufferStart);
+
+ use_pointer_ids = (*(unsigned int *)StubMsg.BufferStart != (unsigned int)&ch);
+ trace("Pointer marshalling using %s\n", use_pointer_ids ? "pointer ids" : "pointer value");
+
+ HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart);
+}
static void test_ndr_simple_type(void)
{
@@ -423,8 +458,11 @@ static void test_simple_types(void)
ch = 0xa5;
ch_ptr = &ch;
- *(void**)wiredata = ch_ptr;
- wiredata[sizeof(void*)] = ch;
+ if (use_pointer_ids)
+ *(unsigned int *)wiredata = 0x20000;
+ else
+ *(unsigned int *)wiredata = (unsigned int)ch_ptr;
+ wiredata[4] = ch;
test_pointer_marshal(fmtstr_up_char, ch_ptr, 1, wiredata, 5, NULL, 0, "up_char");
test_pointer_marshal(fmtstr_up_byte, ch_ptr, 1, wiredata, 5, NULL, 0, "up_byte");
@@ -437,21 +475,30 @@ static void test_simple_types(void)
test_pointer_marshal(fmtstr_rpup_char2, ch_ptr, 1, wiredata, 5, NULL, 0, "rpup_char2");
s = 0xa597;
- *(void**)wiredata = &s;
- *(unsigned short*)(wiredata + sizeof(void*)) = s;
+ if (use_pointer_ids)
+ *(unsigned int *)wiredata = 0x20000;
+ else
+ *(unsigned int *)wiredata = (unsigned int)&s;
+ *(unsigned short*)(wiredata + 4) = s;
test_pointer_marshal(fmtstr_up_wchar, &s, 2, wiredata, 6, NULL, 0, "up_wchar");
test_pointer_marshal(fmtstr_up_short, &s, 2, wiredata, 6, NULL, 0, "up_short");
test_pointer_marshal(fmtstr_up_ushort, &s, 2, wiredata, 6, NULL, 0, "up_ushort");
i = 0x7fff;
- *(void**)wiredata = &i;
- *(unsigned short*)(wiredata + sizeof(void*)) = i;
+ if (use_pointer_ids)
+ *(unsigned int *)wiredata = 0x20000;
+ else
+ *(unsigned int *)wiredata = (unsigned int)&i;
+ *(unsigned short*)(wiredata + 4) = i;
test_pointer_marshal(fmtstr_up_enum16, &i, 2, wiredata, 6, NULL, 0, "up_enum16");
l = 0xcafebabe;
- *(void**)wiredata = &l;
- *(unsigned long*)(wiredata + sizeof(void*)) = l;
+ if (use_pointer_ids)
+ *(unsigned int *)wiredata = 0x20000;
+ else
+ *(unsigned int *)wiredata = (unsigned int)&l;
+ *(unsigned long*)(wiredata + 4) = l;
test_pointer_marshal(fmtstr_up_long, &l, 4, wiredata, 8, NULL, 0, "up_long");
test_pointer_marshal(fmtstr_up_ulong, &l, 4, wiredata, 8, NULL, 0, "up_ulong");
@@ -459,20 +506,29 @@ static void test_simple_types(void)
test_pointer_marshal(fmtstr_up_errorstatus, &l, 4, wiredata, 8, NULL, 0, "up_errorstatus");
ll = ((ULONGLONG)0xcafebabe) << 32 | 0xdeadbeef;
- *(void**)wiredata = ≪
- *(void**)(wiredata + sizeof(void*)) = NULL;
- *(ULONGLONG*)(wiredata + 2 * sizeof(void*)) = ll;
+ if (use_pointer_ids)
+ *(unsigned int *)wiredata = 0x20000;
+ else
+ *(unsigned int *)wiredata = (unsigned int)≪
+ *(unsigned int **)(wiredata + 4) = 0;
+ *(ULONGLONG*)(wiredata + 8) = ll;
test_pointer_marshal(fmtstr_up_longlong, &ll, 8, wiredata, 16, NULL, 0, "up_longlong");
f = 3.1415f;
- *(void**)wiredata = &f;
- *(float*)(wiredata + sizeof(void*)) = f;
+ if (use_pointer_ids)
+ *(unsigned int *)wiredata = 0x20000;
+ else
+ *(unsigned int *)wiredata = (unsigned int)&f;
+ *(float*)(wiredata + 4) = f;
test_pointer_marshal(fmtstr_up_float, &f, 4, wiredata, 8, NULL, 0, "up_float");
d = 3.1415;
- *(void**)wiredata = &d;
- *(void**)(wiredata + sizeof(void*)) = NULL;
- *(double*)(wiredata + 2 * sizeof(void*)) = d;
+ if (use_pointer_ids)
+ *(unsigned int *)wiredata = 0x20000;
+ else
+ *(unsigned int *)wiredata = (unsigned int)&d;
+ *(unsigned int *)(wiredata + 4) = 0;
+ *(double*)(wiredata + 8) = d;
test_pointer_marshal(fmtstr_up_double, &d, 8, wiredata, 16, NULL, 0, "up_double");
}
@@ -888,7 +944,10 @@ static void test_simple_struct(void)
memcpy(wiredata, &s1, wiredatalen);
test_simple_struct_marshal(fmtstr_simple_struct + 4, &s1, 24, wiredata, 24, NULL, 0, "struct");
- *(void**)wiredata = &s1;
+ if (use_pointer_ids)
+ *(unsigned int *)wiredata = 0x20000;
+ else
+ *(unsigned int *)wiredata = (unsigned int)&s1;
memcpy(wiredata + 4, &s1, wiredatalen);
if (0)
{
@@ -905,12 +964,25 @@ static void test_simple_struct(void)
ps1.pl1 = &l;
c = 'a';
ps1.pc1 = &c;
- memcpy(wiredata + 4, &ps1, 12);
+ *(unsigned int *)(wiredata + 4) = 0xdeadbeef;
+ if (use_pointer_ids)
+ {
+ *(unsigned int *)(wiredata + 8) = 0x20000;
+ *(unsigned int *)(wiredata + 12) = 0x20004;
+ }
+ else
+ {
+ *(unsigned int *)(wiredata + 8) = (unsigned int)&l;
+ *(unsigned int *)(wiredata + 12) = (unsigned int)&c;
+ }
memcpy(wiredata + 16, &l, 4);
memcpy(wiredata + 20, &c, 1);
test_simple_struct_marshal(fmtstr_pointer_struct + 4, &ps1, 17, wiredata + 4, 17, ps1_cmp, 2, "pointer_struct");
- *(void**)wiredata = &ps1;
+ if (use_pointer_ids)
+ *(unsigned int *)wiredata = 0x20000;
+ else
+ *(unsigned int *)wiredata = (unsigned int)&ps1;
if (0)
{
/* one of the unmarshallings crashes Wine */
@@ -1823,6 +1895,8 @@ static void test_NdrMapCommAndFaultStatus(void)
START_TEST( ndr_marshall )
{
+ determine_pointer_marshalling_style();
+
test_ndr_simple_type();
test_simple_types();
test_nontrivial_pointer_types();
More information about the wine-cvs
mailing list