From: Vibhav Pant vibhavp@gmail.com
--- dlls/combase/usrmarshal.c | 39 +++++++++++++++++++++++++++++++- dlls/oleaut32/tests/usrmarshal.c | 10 ++++---- 2 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/dlls/combase/usrmarshal.c b/dlls/combase/usrmarshal.c index d1bc3df2836..5e4e49c0e6e 100644 --- a/dlls/combase/usrmarshal.c +++ b/dlls/combase/usrmarshal.c @@ -22,6 +22,7 @@ #define COBJMACROS #include "ole2.h"
+#include "winstring.h" #include "inspectable.h" #include "wine/debug.h"
@@ -1047,7 +1048,43 @@ ULONG __RPC_USER HSTRING_UserSize(ULONG *flags, ULONG start, HSTRING *str) */ BYTE * __RPC_USER HSTRING_UserMarshal(ULONG *flags, BYTE *buf, HSTRING *str) { - FIXME("%p, %p, %p: stub\n", flags, buf, str); + TRACE("%p, %p, %p: stub\n", flags, buf, debugstr_hstring(*str)); + + if (LOWORD(*flags) == MSHCTX_DIFFERENTMACHINE) + { + FIXME("MSHCTX_DIFFERENTMACHINE is not supported yet.\n"); + RpcRaiseException(RPC_S_INVALID_TAG); + return buf; + } + + ALIGN_POINTER(buf, 7); +#ifdef _WIN64 + *(ULONG *)buf = WDT_INPROC64_CALL; +#else + *(ULONG *)buf = WDT_INPROC_CALL; +#endif + buf += sizeof(ULONG); + if (LOWORD(*flags) == MSHCTX_INPROC) + { + HSTRING dup; + + WindowsDuplicateString(*str, &dup); + ALIGN_POINTER(buf, sizeof(*str) - 1); + *(HSTRING *)buf = dup; + buf += sizeof(*str); + } + else + { + UINT32 len, size; + const WCHAR *str_buf; + + str_buf = WindowsGetStringRawBuffer(*str, &len); + *(ULONG *)buf = size = len * sizeof(WCHAR); + buf += sizeof(ULONG); + memcpy(buf, str_buf, size); + buf += size; + } + return buf; }
diff --git a/dlls/oleaut32/tests/usrmarshal.c b/dlls/oleaut32/tests/usrmarshal.c index 41c7c1d255b..0f2ce7dd70d 100644 --- a/dlls/oleaut32/tests/usrmarshal.c +++ b/dlls/oleaut32/tests/usrmarshal.c @@ -873,24 +873,24 @@ static void test_marshal_HSTRING(void) buffer = calloc(1, size); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, test->ctx); next = HSTRING_UserMarshal(&umcb.Flags, &buffer[test->offset], &str); - 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); ptr = ALIGNED_POINTER(&buffer[test->offset], 7); - todo_wine ok(*(ULONG *)ptr == exp_prefix, "got unexpected prefix %lx\n", *(ULONG *)ptr); + ok(*(ULONG *)ptr == exp_prefix, "got unexpected prefix %lx\n", *(ULONG *)ptr); ptr += sizeof(ULONG); if (test->ctx == MSHCTX_INPROC) { ALIGN_POINTER(ptr, sizeof(HSTRING) - 1); - todo_wine_if(!empty) ok(*(DWORD_PTR *)ptr == (DWORD_PTR)str, "got unexpected address %Ix\n", *(DWORD_PTR *)ptr); + ok(*(DWORD_PTR *)ptr == (DWORD_PTR)str, "got unexpected address %Ix\n", *(DWORD_PTR *)ptr); } else { ULONG size;
size = *(ULONG *)ptr; - todo_wine_if(!empty) ok(size == wcslen(test->buf) * sizeof(WCHAR), "got unexpected size %lu\n", *(ULONG *)ptr); + ok(size == wcslen(test->buf) * sizeof(WCHAR), "got unexpected size %lu\n", *(ULONG *)ptr); ptr += sizeof(ULONG); if (size == wcslen(test->buf) * sizeof(WCHAR)) - todo_wine_if(size) ok(!memcmp(ptr, test->buf, size), "got unexpected buffer %s\n", debugstr_wn((WCHAR *)ptr, size)); + ok(!memcmp(ptr, test->buf, size), "got unexpected buffer %s\n", debugstr_wn((WCHAR *)ptr, size)); }
next = HSTRING_UserUnmarshal(&umcb.Flags, &buffer[test->offset], &str2);