From: Vibhav Pant vibhavp@gmail.com
--- dlls/combase/tests/string.c | 48 ++++++++++++++++--------------------- dlls/combase/usrmarshal.c | 29 +++++++++++++++++++++- 2 files changed, 48 insertions(+), 29 deletions(-)
diff --git a/dlls/combase/tests/string.c b/dlls/combase/tests/string.c index de99cd35ea8..0a07eabc085 100644 --- a/dlls/combase/tests/string.c +++ b/dlls/combase/tests/string.c @@ -634,12 +634,11 @@ static void test_marshal(void) ok(size == exp_size, "got size %lu != %lu\n", size, exp_size); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_INPROC); next = HSTRING_UserMarshal(&umcb.Flags, buffer, &str); - if (size == exp_size) - todo_wine ok(next == &buffer[size], "got next %p != %p\n", next, &buffer[size]); + ok(next == &buffer[size], "got next %p != %p\n", next, &buffer[size]); wire = (struct hstring_wire *)buffer; - todo_wine ok(wire->context == exp_context, "got unexpected prefix %#lx != %#lx\n", wire->context, exp_context); + ok(wire->context == exp_context, "got unexpected prefix %#lx != %#lx\n", wire->context, exp_context); /* INPROC marshaling just consists of increasing the refcount and copying the address. */ - todo_wine ok(wire->str == str, "got unexpected address %p\n", wire->str); + ok(wire->str == str, "got unexpected address %p\n", wire->str); next = HSTRING_UserUnmarshal(&umcb.Flags, buffer, &str2); if (size == exp_size) todo_wine ok(next == &buffer[size], "got next %p != %p\n", next, &buffer[size]); @@ -654,11 +653,10 @@ static void test_marshal(void) memset(buffer, 0, 80); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_INPROC); next = HSTRING_UserMarshal(&umcb.Flags, &buffer[1], &str); - if (size == exp_size) - todo_wine ok(next == &buffer[size], "got next %p != %p\n", next, &buffer[size]); + ok(next == &buffer[size], "got next %p != %p\n", next, &buffer[size]); wire = ALIGNED_POINTER(&buffer[1], 7); - todo_wine ok(wire->context == exp_context, "got unexpected prefix %#lx != %#lx\n", wire->context, exp_context); - todo_wine ok(wire->str == str, "got unexpected address %p\n", wire->str); + ok(wire->context == exp_context, "got unexpected prefix %#lx != %#lx\n", wire->context, exp_context); + ok(wire->str == str, "got unexpected address %p\n", wire->str); next = HSTRING_UserUnmarshal(&umcb.Flags, &buffer[1], &str2); if (size == exp_size) todo_wine ok(next == &buffer[size], "got next %p != %p\n", next, &buffer[size]); @@ -673,11 +671,10 @@ static void test_marshal(void) memset(buffer, 0xff, 80); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_INPROC); next = HSTRING_UserMarshal(&umcb.Flags, buffer, &str_empty); - if (size == exp_size) - todo_wine ok(next == &buffer[size], "got next %p != %p\n", next, &buffer[size]); + ok(next == &buffer[size], "got next %p != %p\n", next, &buffer[size]); wire = (struct hstring_wire *)buffer; - todo_wine ok(wire->context == exp_context, "got unexpected prefix %#lx != %#lx\n", wire->context, exp_context); - todo_wine ok(!wire->str, "got unexpected address %p\n", wire->str); + ok(wire->context == exp_context, "got unexpected prefix %#lx != %#lx\n", wire->context, exp_context); + ok(!wire->str, "got unexpected address %p\n", wire->str); str2 = NULL; next = HSTRING_UserUnmarshal(&umcb.Flags, buffer, &str2); if (size == exp_size) @@ -693,13 +690,11 @@ static void test_marshal(void) memset(buffer, 0, 80); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_LOCAL); next = HSTRING_UserMarshal(&umcb.Flags, buffer, &str); - if (size == exp_size) - todo_wine ok(next == &buffer[size], "got next %p != %p\n", next, &buffer[size]); + ok(next == &buffer[size], "got next %p != %p\n", next, &buffer[size]); wire = (struct hstring_wire *)buffer; - todo_wine ok(wire->buf.size == str_bytes, "got buf.size %lu != %lu\n", wire->buf.size, str_bytes); - todo_wine ok(wire->context == exp_context, "got unexpected prefix %#lx != %#lx\n", wire->context, exp_context); - if (size == exp_size) - todo_wine ok(!memcmp(wire->buf.data, str_buf, str_bytes), "got buf.data %s\n", debugstr_wn(wire->buf.data, str_bytes)); + ok(wire->buf.size == str_bytes, "got buf.size %lu != %lu\n", wire->buf.size, str_bytes); + ok(wire->context == exp_context, "got unexpected prefix %#lx != %#lx\n", wire->context, exp_context); + ok(!memcmp(wire->buf.data, str_buf, str_bytes), "got buf.data %s\n", debugstr_wn(wire->buf.data, str_bytes)); str2 = NULL; next = HSTRING_UserUnmarshal(&umcb.Flags, buffer, &str2); if (size == exp_size) @@ -718,13 +713,11 @@ static void test_marshal(void) memset(buffer, 0, 80); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_LOCAL); next = HSTRING_UserMarshal(&umcb.Flags, &buffer[1], &str); - if (size == exp_size) - todo_wine ok(next == &buffer[size], "got next %p != %p\n", next, &buffer[size]); + ok(next == &buffer[size], "got next %p != %p\n", next, &buffer[size]); wire = ALIGNED_POINTER(&buffer[1], 7); - todo_wine ok(wire->buf.size == str_bytes, "got buf.size %lu != %lu\n", wire->buf.size, str_bytes); - todo_wine ok(wire->context == exp_context, "got unexpected prefix %#lx != %#lx\n", wire->context, exp_context); - if (size == exp_size) - todo_wine ok(!memcmp(wire->buf.data, str_buf, str_bytes), "got buf.data %s\n", debugstr_wn(wire->buf.data, str_bytes)); + ok(wire->buf.size == str_bytes, "got buf.size %lu != %lu\n", wire->buf.size, str_bytes); + ok(wire->context == exp_context, "got unexpected prefix %#lx != %#lx\n", wire->context, exp_context); + ok(!memcmp(wire->buf.data, str_buf, str_bytes), "got buf.data %s\n", debugstr_wn(wire->buf.data, str_bytes)); next = HSTRING_UserUnmarshal(&umcb.Flags, &buffer[1], &str2); if (size == exp_size) todo_wine ok(next == &buffer[size], "got next %p != %p\n", next, &buffer[size]); @@ -742,11 +735,10 @@ static void test_marshal(void) memset(buffer, 0xff, 80); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_LOCAL); next = HSTRING_UserMarshal(&umcb.Flags, buffer, &str_empty); - if (size == exp_size) - todo_wine ok(next == &buffer[size], "got next %p != %p\n", next, &buffer[size]); + ok(next == &buffer[size], "got next %p != %p\n", next, &buffer[size]); wire = (struct hstring_wire *)buffer; - todo_wine ok(wire->context == exp_context, "got unexpected prefix %#lx != %#lx\n", wire->context, exp_context); - todo_wine ok(!wire->buf.size, "got buf.size %lu\n", wire->buf.size); + ok(wire->context == exp_context, "got unexpected prefix %#lx != %#lx\n", wire->context, exp_context); + ok(!wire->buf.size, "got buf.size %lu\n", wire->buf.size); str2 = NULL; next = HSTRING_UserUnmarshal(&umcb.Flags, buffer, &str2); if (size == exp_size) diff --git a/dlls/combase/usrmarshal.c b/dlls/combase/usrmarshal.c index 0d7743c614e..e85145c2328 100644 --- a/dlls/combase/usrmarshal.c +++ b/dlls/combase/usrmarshal.c @@ -1067,7 +1067,34 @@ ULONG __RPC_USER HSTRING_UserSize(ULONG *flags, ULONG size, HSTRING *str) */ BYTE * __RPC_USER HSTRING_UserMarshal(ULONG *flags, BYTE *buf, HSTRING *str) { - FIXME("%p, %p, %p: stub\n", flags, buf, str); + struct hstring_wire *wire; + + TRACE("%s, %p, %s.\n", debugstr_user_flags(flags), buf, debugstr_hstring(*str)); + + if (LOWORD(*flags) == MSHCTX_DIFFERENTMACHINE) + { + FIXME("MSHCTX_DIFFERENTMACHINE is not supported yet.\n"); + RpcRaiseException(RPC_S_INVALID_TAG); + } + + wire = ALIGNED_POINTER(buf, 7); + wire->context = sizeof(*str) == 8 ? WDT_INPROC64_CALL : WDT_INPROC_CALL; + if (LOWORD(*flags) == MSHCTX_INPROC) + { + WindowsDuplicateString(*str, &wire->str); + buf = (BYTE *)(&wire->str + 1); + } + else + { + const WCHAR *str_buf; + UINT32 len; + + str_buf = WindowsGetStringRawBuffer(*str, &len); + wire->buf.size = len * sizeof(WCHAR); + memcpy(wire->buf.data, str_buf, wire->buf.size); + buf = (BYTE*)&wire->buf.data[len]; + } + return buf; }