From d240fdff18704298fd76f37d09a2ec704ab0addf Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Tue, 3 Mar 2015 22:49:07 +0300 Subject: [PATCH] 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 73bd867ab2d..e3cd48a21ff 100644 --- a/dlls/rpcrt4/ndr_es.c +++ b/dlls/rpcrt4/ndr_es.c @@ -123,6 +123,40 @@ RPC_STATUS WINAPI MesIncrementalHandleReset( return RPC_S_OK; } +/*********************************************************************** + * 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.@] */ diff --git a/dlls/rpcrt4/rpcrt4.spec b/dlls/rpcrt4/rpcrt4.spec index 378b277f411..c42fd8b4e57 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 fd1cbbbfc48..315a4523c66 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 99b2effd104..4cf3ddc7623 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