Commit 36bc8563 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

rpcrt4: Implement MesEncodeDynBufferHandleCreate().

parent d240fdff
...@@ -167,6 +167,17 @@ RPC_STATUS WINAPI MesHandleFree(handle_t Handle) ...@@ -167,6 +167,17 @@ RPC_STATUS WINAPI MesHandleFree(handle_t Handle)
return RPC_S_OK; return RPC_S_OK;
} }
static RPC_STATUS validate_mes_buffer_pointer(const char *Buffer)
{
if (!Buffer)
return RPC_S_INVALID_ARG;
if (((ULONG_PTR)Buffer & 7) != 0)
return RPC_X_INVALID_BUFFER;
return RPC_S_OK;
}
/*********************************************************************** /***********************************************************************
* MesEncodeFixedBufferHandleCreate [RPCRT4.@] * MesEncodeFixedBufferHandleCreate [RPCRT4.@]
*/ */
...@@ -174,14 +185,12 @@ RPC_STATUS RPC_ENTRY MesEncodeFixedBufferHandleCreate( ...@@ -174,14 +185,12 @@ RPC_STATUS RPC_ENTRY MesEncodeFixedBufferHandleCreate(
char *Buffer, ULONG BufferSize, ULONG *pEncodedSize, handle_t *pHandle) char *Buffer, ULONG BufferSize, ULONG *pEncodedSize, handle_t *pHandle)
{ {
MIDL_ES_MESSAGE *pEsMsg; MIDL_ES_MESSAGE *pEsMsg;
RPC_STATUS status;
TRACE("(%p, %d, %p, %p)\n", Buffer, BufferSize, pEncodedSize, pHandle); TRACE("(%p, %d, %p, %p)\n", Buffer, BufferSize, pEncodedSize, pHandle);
if (!Buffer) if ((status = validate_mes_buffer_pointer(Buffer)))
return RPC_S_INVALID_ARG; return status;
if (((ULONG_PTR)Buffer % 8) != 0)
return RPC_X_INVALID_BUFFER;
if (!pEncodedSize) if (!pEncodedSize)
return RPC_S_INVALID_ARG; return RPC_S_INVALID_ARG;
...@@ -208,10 +217,29 @@ RPC_STATUS RPC_ENTRY MesEncodeFixedBufferHandleCreate( ...@@ -208,10 +217,29 @@ RPC_STATUS RPC_ENTRY MesEncodeFixedBufferHandleCreate(
/*********************************************************************** /***********************************************************************
* MesEncodeDynBufferHandleCreate [RPCRT4.@] * MesEncodeDynBufferHandleCreate [RPCRT4.@]
*/ */
RPC_STATUS RPC_ENTRY MesEncodeDynBufferHandleCreate(char **ppBuffer, RPC_STATUS RPC_ENTRY MesEncodeDynBufferHandleCreate(char **Buffer,
ULONG *pEncodedSize, handle_t *pHandle) ULONG *pEncodedSize, handle_t *pHandle)
{ {
FIXME("%p %p %p stub\n", ppBuffer, pEncodedSize, pHandle); MIDL_ES_MESSAGE *pEsMsg;
TRACE("(%p, %p, %p)\n", Buffer, pEncodedSize, pHandle);
if (!pEncodedSize)
return RPC_S_INVALID_ARG;
pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg));
if (!pEsMsg)
return RPC_S_OUT_OF_MEMORY;
init_MIDL_ES_MESSAGE(pEsMsg);
pEsMsg->Operation = MES_ENCODE;
pEsMsg->HandleStyle = MES_DYNAMIC_BUFFER_HANDLE;
pEsMsg->pDynBuffer = (unsigned char **)Buffer;
pEsMsg->pEncodedSize = pEncodedSize;
*pHandle = (handle_t)pEsMsg;
return RPC_S_OK; return RPC_S_OK;
} }
...@@ -222,9 +250,13 @@ RPC_STATUS RPC_ENTRY MesDecodeBufferHandleCreate( ...@@ -222,9 +250,13 @@ RPC_STATUS RPC_ENTRY MesDecodeBufferHandleCreate(
char *Buffer, ULONG BufferSize, handle_t *pHandle) char *Buffer, ULONG BufferSize, handle_t *pHandle)
{ {
MIDL_ES_MESSAGE *pEsMsg; MIDL_ES_MESSAGE *pEsMsg;
RPC_STATUS status;
TRACE("(%p, %d, %p)\n", Buffer, BufferSize, pHandle); TRACE("(%p, %d, %p)\n", Buffer, BufferSize, pHandle);
if ((status = validate_mes_buffer_pointer(Buffer)))
return status;
pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg)); pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg));
if (!pEsMsg) if (!pEsMsg)
return RPC_S_OUT_OF_MEMORY; return RPC_S_OUT_OF_MEMORY;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment