rpcrt4: Correctly align the buffer before reading/writing structure data.

This commit is contained in:
Robert Shearman 2006-05-10 13:12:30 +01:00 committed by Alexandre Julliard
parent 5616c4150c
commit 95d79e2c58
1 changed files with 19 additions and 0 deletions

View File

@ -1321,6 +1321,8 @@ unsigned char * WINAPI NdrSimpleStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
unsigned size = *(const WORD*)(pFormat+2);
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
memcpy(pStubMsg->Buffer, pMemory, size);
pStubMsg->BufferMark = pStubMsg->Buffer;
pStubMsg->Buffer += size;
@ -1344,6 +1346,8 @@ unsigned char * WINAPI NdrSimpleStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
unsigned size = *(const WORD*)(pFormat+2);
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
if (fMustAlloc) {
*ppMemory = NdrAllocate(pStubMsg, size);
memcpy(*ppMemory, pStubMsg->Buffer, size);
@ -1396,6 +1400,9 @@ void WINAPI NdrSimpleStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
{
unsigned size = *(const WORD*)(pFormat+2);
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
ALIGN_LENGTH(pStubMsg->BufferLength, pFormat[1] + 1);
pStubMsg->BufferLength += size;
if (pFormat[0] != RPC_FC_STRUCT)
EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat+4);
@ -1751,6 +1758,8 @@ unsigned char * WINAPI NdrComplexStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
pFormat += 4;
if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
pFormat += 2;
@ -1786,6 +1795,8 @@ unsigned char * WINAPI NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
if (fMustAlloc || !*ppMemory)
{
*ppMemory = NdrAllocate(pStubMsg, size);
@ -1819,6 +1830,8 @@ void WINAPI NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
ALIGN_LENGTH(pStubMsg->BufferLength, pFormat[1] + 1);
pFormat += 4;
if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
pFormat += 2;
@ -2479,6 +2492,8 @@ unsigned char * WINAPI NdrConformantStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
return NULL;
}
ALIGN_POINTER(pStubMsg->Buffer, pCStructFormat->alignment + 1);
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
/* copy constant sized part of struct */
@ -2516,6 +2531,8 @@ unsigned char * WINAPI NdrConformantStructUnmarshall(PMIDL_STUB_MESSAGE pStubMs
return NULL;
}
ALIGN_POINTER(pStubMsg->Buffer, pCStructFormat->alignment + 1);
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
/* work out how much memory to allocate if we need to do so */
@ -2571,6 +2588,8 @@ void WINAPI NdrConformantStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
return;
}
ALIGN_LENGTH(pStubMsg->BufferLength, pCStructFormat->alignment + 1);
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
/* add constant sized part of struct to buffer size */