Nikolay Sivov : rpcrt4: Implement MesBufferHandleReset().

Alexandre Julliard julliard at wine.codeweavers.com
Wed Mar 4 09:22:16 CST 2015


Module: wine
Branch: master
Commit: d240fdff18704298fd76f37d09a2ec704ab0addf
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d240fdff18704298fd76f37d09a2ec704ab0addf

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Tue Mar  3 22:49:07 2015 +0300

rpcrt4: Implement MesBufferHandleReset().

---

 dlls/rpcrt4/ndr_es.c             | 34 ++++++++++++++++++++++++++++++++++
 dlls/rpcrt4/rpcrt4.spec          |  2 +-
 dlls/rpcrt4/tests/ndr_marshall.c | 22 ++++++++++++++++++++++
 include/midles.h                 |  3 ++-
 4 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/dlls/rpcrt4/ndr_es.c b/dlls/rpcrt4/ndr_es.c
index 73bd867..e3cd48a 100644
--- a/dlls/rpcrt4/ndr_es.c
+++ b/dlls/rpcrt4/ndr_es.c
@@ -124,6 +124,40 @@ RPC_STATUS WINAPI MesIncrementalHandleReset(
 }
 
 /***********************************************************************
+ *            MesBufferHandleReset [RPCRT4.@]
+ */
+RPC_STATUS WINAPI MesBufferHandleReset(handle_t Handle, ULONG HandleStyle,
+    MIDL_ES_CODE Operation, char **Buffer, ULONG BufferSize, ULONG *EncodedSize)
+{
+    MIDL_ES_MESSAGE *pEsMsg = (MIDL_ES_MESSAGE *)Handle;
+
+    TRACE("(%p, %u, %d, %p, %u, %p)\n", Handle, HandleStyle, Operation, Buffer,
+        BufferSize, EncodedSize);
+
+    if (!Handle || !Buffer || !EncodedSize)
+        return RPC_S_INVALID_ARG;
+
+    if (Operation != MES_ENCODE && Operation != MES_DECODE && Operation != MES_ENCODE_NDR64)
+        return RPC_S_INVALID_ARG;
+
+    if (HandleStyle != MES_FIXED_BUFFER_HANDLE && HandleStyle != MES_DYNAMIC_BUFFER_HANDLE)
+        return RPC_S_INVALID_ARG;
+
+    init_MIDL_ES_MESSAGE(pEsMsg);
+
+    pEsMsg->Operation = Operation;
+    pEsMsg->HandleStyle = HandleStyle;
+    if (HandleStyle == MES_FIXED_BUFFER_HANDLE)
+        pEsMsg->Buffer = (unsigned char*)*Buffer;
+    else
+        pEsMsg->pDynBuffer = (unsigned char**)Buffer;
+    pEsMsg->BufferSize = BufferSize;
+    pEsMsg->pEncodedSize = EncodedSize;
+
+    return RPC_S_OK;
+}
+
+/***********************************************************************
  *            MesHandleFree [RPCRT4.@]
  */
 RPC_STATUS WINAPI MesHandleFree(handle_t Handle)
diff --git a/dlls/rpcrt4/rpcrt4.spec b/dlls/rpcrt4/rpcrt4.spec
index 378b277..c42fd8b 100644
--- a/dlls/rpcrt4/rpcrt4.spec
+++ b/dlls/rpcrt4/rpcrt4.spec
@@ -96,7 +96,7 @@
 @ stub I_UuidCreate
 @ stub MIDL_wchar_strcpy
 @ stub MIDL_wchar_strlen
-@ stub MesBufferHandleReset
+@ stdcall MesBufferHandleReset(ptr long long ptr long ptr)
 @ stdcall MesDecodeBufferHandleCreate(ptr long ptr)
 @ stdcall MesDecodeIncrementalHandleCreate(ptr ptr ptr)
 @ stdcall MesEncodeDynBufferHandleCreate(ptr ptr ptr)
diff --git a/dlls/rpcrt4/tests/ndr_marshall.c b/dlls/rpcrt4/tests/ndr_marshall.c
index fd1cbbb..315a452 100644
--- a/dlls/rpcrt4/tests/ndr_marshall.c
+++ b/dlls/rpcrt4/tests/ndr_marshall.c
@@ -2437,6 +2437,28 @@ if (status == RPC_S_OK)
     status = MesEncodeFixedBufferHandleCreate(buffer, 32, &encoded_size, &handle);
     ok(status == RPC_S_OK, "got %d\n", status);
 
+    status = MesBufferHandleReset(NULL, MES_DYNAMIC_BUFFER_HANDLE, MES_ENCODE,
+        &buffer, 32, &encoded_size);
+    ok(status == RPC_S_INVALID_ARG, "got %d\n", status);
+
+    /* convert to dynamic buffer handle */
+    status = MesBufferHandleReset(handle, MES_DYNAMIC_BUFFER_HANDLE, MES_ENCODE,
+        &buffer, 32, &encoded_size);
+    ok(status == RPC_S_OK, "got %d\n", status);
+
+    status = MesBufferHandleReset(handle, MES_DYNAMIC_BUFFER_HANDLE, MES_ENCODE,
+        NULL, 32, &encoded_size);
+    ok(status == RPC_S_INVALID_ARG, "got %d\n", status);
+
+    status = MesBufferHandleReset(handle, MES_DYNAMIC_BUFFER_HANDLE, MES_ENCODE,
+        &buffer, 32, NULL);
+    ok(status == RPC_S_INVALID_ARG, "got %d\n", status);
+
+    /* invalid handle type */
+    status = MesBufferHandleReset(handle, MES_DYNAMIC_BUFFER_HANDLE+1, MES_ENCODE,
+        &buffer, 32, &encoded_size);
+    ok(status == RPC_S_INVALID_ARG, "got %d\n", status);
+
     status = MesHandleFree(handle);
     ok(status == RPC_S_OK, "got %d\n", status);
 }
diff --git a/include/midles.h b/include/midles.h
index 99b2eff..4cf3ddc 100644
--- a/include/midles.h
+++ b/include/midles.h
@@ -30,7 +30,8 @@ extern "C" {
 typedef enum
 {
     MES_ENCODE,
-    MES_DECODE
+    MES_DECODE,
+    MES_ENCODE_NDR64
 } MIDL_ES_CODE;
 
 typedef enum




More information about the wine-cvs mailing list