ChangeSet ID: 21488 CVSROOT: /opt/cvs-commit Module name: wine Changes by: julliard@winehq.org 2005/11/28 05:06:05
Modified files: dlls/rpcrt4 : ndr_marshall.c
Log message: Robert Shearman rob@codeweavers.com Implement conformant struct functions.
Patch: http://cvs.winehq.org/patch.py?id=21488
Old revision New revision Changes Path 1.35 1.36 +104 -3 wine/dlls/rpcrt4/ndr_marshall.c
Index: wine/dlls/rpcrt4/ndr_marshall.c diff -u -p wine/dlls/rpcrt4/ndr_marshall.c:1.35 wine/dlls/rpcrt4/ndr_marshall.c:1.36 --- wine/dlls/rpcrt4/ndr_marshall.c:1.35 28 Nov 2005 11: 6: 5 -0000 +++ wine/dlls/rpcrt4/ndr_marshall.c 28 Nov 2005 11: 6: 5 -0000 @@ -2280,6 +2280,14 @@ void WINAPI NdrConvert2( PMIDL_STUB_MESS is to raise an exception */ }
+typedef struct _NDR_CSTRUCT_FORMAT +{ + unsigned char type; + unsigned char alignment; + unsigned short memory_size; + short offset_to_array_description; +} NDR_CSTRUCT_FORMAT; + /*********************************************************************** * NdrConformantStructMarshall [RPCRT4.@] */ @@ -2287,7 +2295,32 @@ unsigned char * WINAPI NdrConformantStr unsigned char *pMemory, PFORMAT_STRING pFormat) { - FIXME("stub\n"); + const NDR_CSTRUCT_FORMAT * pCStructFormat = (NDR_CSTRUCT_FORMAT*)pFormat; + pFormat += sizeof(NDR_CSTRUCT_FORMAT); + + TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat); + + if ((pCStructFormat->type != RPC_FC_CPSTRUCT) && (pCStructFormat->type != RPC_FC_CSTRUCT)) + { + ERR("invalid format type %x\n", pCStructFormat->type); + RpcRaiseException(RPC_S_INTERNAL_ERROR); + return NULL; + } + + TRACE("memory_size = %d\n", pCStructFormat->memory_size); + + /* copy constant sized part of struct */ + memcpy(pStubMsg->Buffer, pMemory, pCStructFormat->memory_size); + pStubMsg->Buffer += pCStructFormat->memory_size; + + if (pCStructFormat->offset_to_array_description) + { + PFORMAT_STRING pArrayFormat = (unsigned char*)&pCStructFormat->offset_to_array_description + + pCStructFormat->offset_to_array_description; + NdrConformantArrayMarshall(pStubMsg, pMemory + pCStructFormat->memory_size, pArrayFormat); + } + if (pCStructFormat->type == RPC_FC_CPSTRUCT) + EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat); return NULL; }
@@ -2299,7 +2332,52 @@ unsigned char * WINAPI NdrConformantStr PFORMAT_STRING pFormat, unsigned char fMustAlloc) { - FIXME("stub\n"); + const NDR_CSTRUCT_FORMAT * pCStructFormat = (NDR_CSTRUCT_FORMAT*)pFormat; + pFormat += sizeof(NDR_CSTRUCT_FORMAT); + + TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc); + + if ((pCStructFormat->type != RPC_FC_CPSTRUCT) && (pCStructFormat->type != RPC_FC_CSTRUCT)) + { + ERR("invalid format type %x\n", pCStructFormat->type); + RpcRaiseException(RPC_S_INTERNAL_ERROR); + return NULL; + } + + TRACE("memory_size = %d\n", pCStructFormat->memory_size); + + /* work out how much memory to allocate if we need to do so */ + if (!*ppMemory || fMustAlloc) + { + SIZE_T size = pCStructFormat->memory_size; + + if (pCStructFormat->offset_to_array_description) + { + unsigned char *buffer; + PFORMAT_STRING pArrayFormat = (unsigned char*)&pCStructFormat->offset_to_array_description + + pCStructFormat->offset_to_array_description; + buffer = pStubMsg->Buffer; + pStubMsg->Buffer += pCStructFormat->memory_size; + size += NdrConformantArrayMemorySize(pStubMsg, pArrayFormat); + pStubMsg->Buffer = buffer; + } + *ppMemory = NdrAllocate(pStubMsg, size); + } + + /* now copy the data */ + memcpy(*ppMemory, pStubMsg->Buffer, pCStructFormat->memory_size); + pStubMsg->Buffer += pCStructFormat->memory_size; + if (pCStructFormat->offset_to_array_description) + { + PFORMAT_STRING pArrayFormat = (unsigned char*)&pCStructFormat->offset_to_array_description + + pCStructFormat->offset_to_array_description; + unsigned char *pMemoryArray = *ppMemory + pCStructFormat->memory_size; + /* note that we pass fMustAlloc as 0 as we have already allocated the + * memory */ + NdrConformantArrayUnmarshall(pStubMsg, &pMemoryArray, pArrayFormat, 0); + } + if (pCStructFormat->type == RPC_FC_CPSTRUCT) + EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc); return NULL; }
@@ -2310,7 +2388,30 @@ void WINAPI NdrConformantStructBufferSiz unsigned char *pMemory, PFORMAT_STRING pFormat) { - FIXME("stub\n"); + const NDR_CSTRUCT_FORMAT * pCStructFormat = (NDR_CSTRUCT_FORMAT*)pFormat; + pFormat += sizeof(NDR_CSTRUCT_FORMAT); + TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat); + + if ((pCStructFormat->type != RPC_FC_CPSTRUCT) && (pCStructFormat->type != RPC_FC_CSTRUCT)) + { + ERR("invalid format type %x\n", pCStructFormat->type); + RpcRaiseException(RPC_S_INTERNAL_ERROR); + return; + } + + TRACE("memory_size = %d\n", pCStructFormat->memory_size); + + /* add constant sized part of struct to buffer size */ + pStubMsg->BufferLength += pCStructFormat->memory_size; + + if (pCStructFormat->offset_to_array_description) + { + PFORMAT_STRING pArrayFormat = (unsigned char*)&pCStructFormat->offset_to_array_description + + pCStructFormat->offset_to_array_description; + NdrConformantArrayBufferSize(pStubMsg, pMemory + pCStructFormat->memory_size, pArrayFormat); + } + if (pCStructFormat->type == RPC_FC_CPSTRUCT) + EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat); }
/***********************************************************************