rpcrt4: Implement MesDecodeBufferHandleCreate and MesEncodeFixedBufferHandleCreate.

This commit is contained in:
Rob Shearman 2007-11-05 11:21:09 +00:00 committed by Alexandre Julliard
parent 734094ed2c
commit 2b0ad6e6e7
2 changed files with 72 additions and 2 deletions

View File

@ -132,6 +132,58 @@ RPC_STATUS WINAPI MesHandleFree(handle_t Handle)
return RPC_S_OK;
}
/***********************************************************************
* MesEncodeFixedBufferHandleCreate [RPCRT4.@]
*/
RPC_STATUS RPC_ENTRY MesEncodeFixedBufferHandleCreate(
char *Buffer, ULONG BufferSize, ULONG *pEncodedSize, handle_t *pHandle)
{
MIDL_ES_MESSAGE *pEsMsg;
TRACE("(%p, %d, %p, %p)\n", Buffer, BufferSize, pEncodedSize, pHandle);
pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg));
if (!pEsMsg)
return ERROR_OUTOFMEMORY;
init_MIDL_ES_MESSAGE(pEsMsg);
pEsMsg->Operation = MES_ENCODE;
pEsMsg->HandleStyle = MES_FIXED_BUFFER_HANDLE;
pEsMsg->Buffer = (unsigned char *)Buffer;
pEsMsg->BufferSize = BufferSize;
pEsMsg->pEncodedSize = pEncodedSize;
*pHandle = (handle_t)pEsMsg;
return RPC_S_OK;}
/***********************************************************************
* MesDecodeBufferHandleCreate [RPCRT4.@]
*/
RPC_STATUS RPC_ENTRY MesDecodeBufferHandleCreate(
char *Buffer, ULONG BufferSize, handle_t *pHandle)
{
MIDL_ES_MESSAGE *pEsMsg;
TRACE("(%p, %d, %p)\n", Buffer, BufferSize, pHandle);
pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg));
if (!pEsMsg)
return ERROR_OUTOFMEMORY;
init_MIDL_ES_MESSAGE(pEsMsg);
pEsMsg->Operation = MES_DECODE;
pEsMsg->HandleStyle = MES_FIXED_BUFFER_HANDLE;
pEsMsg->Buffer = (unsigned char *)Buffer;
pEsMsg->BufferSize = BufferSize;
*pHandle = (handle_t)pEsMsg;
return RPC_S_OK;
}
static void es_data_alloc(MIDL_ES_MESSAGE *pEsMsg, ULONG size)
{
if (pEsMsg->HandleStyle == MES_INCREMENTAL_HANDLE)
@ -145,6 +197,11 @@ static void es_data_alloc(MIDL_ES_MESSAGE *pEsMsg, ULONG size)
RpcRaiseException(ERROR_OUTOFMEMORY);
}
}
else if (pEsMsg->HandleStyle == MES_FIXED_BUFFER_HANDLE)
{
TRACE("%d with fixed buffer handle\n", size);
pEsMsg->StubMsg.Buffer = pEsMsg->Buffer;
}
pEsMsg->StubMsg.RpcMsg->Buffer = pEsMsg->StubMsg.BufferStart = pEsMsg->StubMsg.Buffer;
}
@ -161,6 +218,14 @@ static void es_data_read(MIDL_ES_MESSAGE *pEsMsg, ULONG size)
RpcRaiseException(ERROR_OUTOFMEMORY);
}
}
else
{
TRACE("%d from fixed or dynamic buffer handle\n", size);
/* FIXME: validate BufferSize? */
pEsMsg->StubMsg.Buffer = pEsMsg->Buffer;
pEsMsg->Buffer += size;
pEsMsg->BufferSize -= size;
}
pEsMsg->StubMsg.BufferLength = size;
pEsMsg->StubMsg.RpcMsg->Buffer = pEsMsg->StubMsg.BufferStart = pEsMsg->StubMsg.Buffer;
pEsMsg->StubMsg.BufferEnd = pEsMsg->StubMsg.Buffer + size;
@ -173,6 +238,11 @@ static void es_data_write(MIDL_ES_MESSAGE *pEsMsg, ULONG size)
TRACE("%d to incremental handle\n", size);
pEsMsg->Write(pEsMsg->UserState, (char *)pEsMsg->StubMsg.BufferStart, size);
}
else
{
TRACE("%d to dynamic or fixed buffer handle\n", size);
*pEsMsg->pEncodedSize += size;
}
}
static inline ULONG mes_proc_header_buffer_size(void)

View File

@ -97,10 +97,10 @@
@ stub MIDL_wchar_strcpy
@ stub MIDL_wchar_strlen
@ stub MesBufferHandleReset
@ stub MesDecodeBufferHandleCreate
@ stdcall MesDecodeBufferHandleCreate(ptr long ptr)
@ stdcall MesDecodeIncrementalHandleCreate(ptr ptr ptr)
@ stub MesEncodeDynBufferHandleCreate
@ stub MesEncodeFixedBufferHandleCreate
@ stdcall MesEncodeFixedBufferHandleCreate(ptr long ptr ptr)
@ stdcall MesEncodeIncrementalHandleCreate(ptr ptr ptr ptr)
@ stdcall MesHandleFree(ptr)
@ stdcall MesIncrementalHandleReset(ptr ptr ptr ptr ptr long)