rpcrt4: Improve ReadVariance.
Extend ReadVariance to read the offset as well as the actual count, since these always come in pairs. Handle the variance not being present in ReadVariance and always call it from the unmarshalling functions to simplify the code there and also to fix a bug where the format pointer wasn't advanced properly for complex arrays (introduced in the previous patch when implementing variance).
This commit is contained in:
parent
2e875d5d35
commit
1926b6da63
|
@ -315,9 +315,21 @@ PFORMAT_STRING ReadConformance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pForm
|
||||||
|
|
||||||
static inline PFORMAT_STRING ReadVariance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
|
static inline PFORMAT_STRING ReadVariance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
|
||||||
{
|
{
|
||||||
|
if (!IsConformanceOrVariancePresent(pFormat))
|
||||||
|
{
|
||||||
|
pStubMsg->Offset = 0;
|
||||||
|
pStubMsg->ActualCount = pStubMsg->MaxCount;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
pStubMsg->Offset = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
|
||||||
|
pStubMsg->Buffer += 4;
|
||||||
|
TRACE("offset is %ld\n", pStubMsg->Offset);
|
||||||
pStubMsg->ActualCount = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
|
pStubMsg->ActualCount = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
|
||||||
pStubMsg->Buffer += 4;
|
pStubMsg->Buffer += 4;
|
||||||
TRACE("unmarshalled variance is %ld\n", pStubMsg->ActualCount);
|
TRACE("variance is %ld\n", pStubMsg->ActualCount);
|
||||||
|
|
||||||
|
done:
|
||||||
return pFormat+4;
|
return pFormat+4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2008,7 +2020,6 @@ unsigned char* WINAPI NdrConformantVaryingArrayUnmarshall( PMIDL_STUB_MESSAGE pS
|
||||||
PFORMAT_STRING pFormat,
|
PFORMAT_STRING pFormat,
|
||||||
unsigned char fMustAlloc )
|
unsigned char fMustAlloc )
|
||||||
{
|
{
|
||||||
DWORD offset;
|
|
||||||
DWORD esize = *(const WORD*)(pFormat+2);
|
DWORD esize = *(const WORD*)(pFormat+2);
|
||||||
|
|
||||||
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
||||||
|
@ -2020,13 +2031,11 @@ unsigned char* WINAPI NdrConformantVaryingArrayUnmarshall( PMIDL_STUB_MESSAGE pS
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pFormat = ReadConformance(pStubMsg, pFormat);
|
pFormat = ReadConformance(pStubMsg, pFormat);
|
||||||
offset = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
|
|
||||||
pStubMsg->Buffer += 4;
|
|
||||||
pFormat = ReadVariance(pStubMsg, pFormat);
|
pFormat = ReadVariance(pStubMsg, pFormat);
|
||||||
|
|
||||||
if (!*ppMemory || fMustAlloc)
|
if (!*ppMemory || fMustAlloc)
|
||||||
*ppMemory = NdrAllocate(pStubMsg, pStubMsg->MaxCount * esize);
|
*ppMemory = NdrAllocate(pStubMsg, pStubMsg->MaxCount * esize);
|
||||||
memcpy(*ppMemory + offset, pStubMsg->Buffer, pStubMsg->ActualCount * esize);
|
memcpy(*ppMemory + pStubMsg->Offset, pStubMsg->Buffer, pStubMsg->ActualCount * esize);
|
||||||
pStubMsg->Buffer += pStubMsg->ActualCount * esize;
|
pStubMsg->Buffer += pStubMsg->ActualCount * esize;
|
||||||
|
|
||||||
EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc);
|
EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc);
|
||||||
|
@ -2141,7 +2150,7 @@ unsigned char * WINAPI NdrComplexArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
||||||
PFORMAT_STRING pFormat,
|
PFORMAT_STRING pFormat,
|
||||||
unsigned char fMustAlloc)
|
unsigned char fMustAlloc)
|
||||||
{
|
{
|
||||||
ULONG offset, count, esize;
|
ULONG count, esize;
|
||||||
unsigned char *pMemory;
|
unsigned char *pMemory;
|
||||||
|
|
||||||
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
||||||
|
@ -2156,19 +2165,7 @@ unsigned char * WINAPI NdrComplexArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
||||||
pFormat += 4;
|
pFormat += 4;
|
||||||
|
|
||||||
pFormat = ReadConformance(pStubMsg, pFormat);
|
pFormat = ReadConformance(pStubMsg, pFormat);
|
||||||
TRACE("conformance = %ld\n", pStubMsg->MaxCount);
|
pFormat = ReadVariance(pStubMsg, pFormat);
|
||||||
if (IsConformanceOrVariancePresent(pFormat))
|
|
||||||
{
|
|
||||||
offset = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
|
|
||||||
pStubMsg->Buffer += 4;
|
|
||||||
pFormat = ReadVariance(pStubMsg, pFormat);
|
|
||||||
TRACE("variance = %ld\n", pStubMsg->ActualCount);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
offset = 0;
|
|
||||||
pStubMsg->ActualCount = pStubMsg->MaxCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
esize = ComplexStructSize(pStubMsg, pFormat);
|
esize = ComplexStructSize(pStubMsg, pFormat);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue