Commit fc17683f authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

Extend conformance computation function to also compute variances.

MSDN suggests that conformance and variance are pretty much the same, but there may be some subtleties to it.
parent fea8a762
...@@ -286,17 +286,27 @@ PFORMAT_STRING ReadConformance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pForm ...@@ -286,17 +286,27 @@ PFORMAT_STRING ReadConformance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pForm
return pFormat+4; return pFormat+4;
} }
PFORMAT_STRING ComputeConformance(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pMemory, static inline PFORMAT_STRING ReadVariance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
PFORMAT_STRING pFormat, ULONG_PTR def) {
pStubMsg->ActualCount = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
pStubMsg->Buffer += 4;
TRACE("unmarshalled variance is %ld\n", pStubMsg->ActualCount);
return pFormat+4;
}
PFORMAT_STRING ComputeConformanceOrVariance(
MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pMemory,
PFORMAT_STRING pFormat, ULONG_PTR def, ULONG *pCount)
{ {
BYTE dtype = pFormat[0] & 0xf; BYTE dtype = pFormat[0] & 0xf;
short ofs = *(short *)&pFormat[2]; short ofs = *(short *)&pFormat[2];
LPVOID ptr = NULL; LPVOID ptr = NULL;
DWORD data = 0; DWORD data = 0;
/* FIXME: is this correct? */
if (pFormat[0] == 0xff) { if (pFormat[0] == 0xff) {
/* null descriptor */ /* null descriptor */
pStubMsg->MaxCount = def; *pCount = def;
goto finish_conf; goto finish_conf;
} }
...@@ -315,14 +325,14 @@ PFORMAT_STRING ComputeConformance(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pM ...@@ -315,14 +325,14 @@ PFORMAT_STRING ComputeConformance(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pM
ptr = pStubMsg->StackTop + ofs; ptr = pStubMsg->StackTop + ofs;
} }
else { else {
/* -Os mode, MaxCount is already set */ /* -Os mode, *pCount is already set */
goto finish_conf; goto finish_conf;
} }
break; break;
case RPC_FC_CONSTANT_CONFORMANCE: case RPC_FC_CONSTANT_CONFORMANCE:
data = ofs | ((DWORD)pFormat[1] << 16); data = ofs | ((DWORD)pFormat[1] << 16);
TRACE("constant conformance, val=%ld\n", data); TRACE("constant conformance, val=%ld\n", data);
pStubMsg->MaxCount = data; *pCount = data;
goto finish_conf; goto finish_conf;
case RPC_FC_TOP_LEVEL_MULTID_CONFORMANCE: case RPC_FC_TOP_LEVEL_MULTID_CONFORMANCE:
FIXME("toplevel multidimensional conformance, ofs=%d\n", ofs); FIXME("toplevel multidimensional conformance, ofs=%d\n", ofs);
...@@ -376,7 +386,7 @@ PFORMAT_STRING ComputeConformance(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pM ...@@ -376,7 +386,7 @@ PFORMAT_STRING ComputeConformance(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pM
done_conf_grab: done_conf_grab:
switch (pFormat[1]) { switch (pFormat[1]) {
case 0: /* no op */ case 0: /* no op */
pStubMsg->MaxCount = data; *pCount = data;
break; break;
case RPC_FC_DEREFERENCE: case RPC_FC_DEREFERENCE:
/* already handled */ /* already handled */
...@@ -387,7 +397,7 @@ done_conf_grab: ...@@ -387,7 +397,7 @@ done_conf_grab:
} }
finish_conf: finish_conf:
TRACE("resulting conformance is %ld\n", pStubMsg->MaxCount); TRACE("resulting conformance is %ld\n", *pCount);
return pFormat+4; return pFormat+4;
} }
......
...@@ -35,8 +35,11 @@ LONG_PTR RPCRT4_NdrClientCall2(PMIDL_STUB_DESC pStubDesc, ...@@ -35,8 +35,11 @@ LONG_PTR RPCRT4_NdrClientCall2(PMIDL_STUB_DESC pStubDesc,
HRESULT RPCRT4_GetPSFactory(REFIID riid, struct IPSFactoryBuffer **ppPS); HRESULT RPCRT4_GetPSFactory(REFIID riid, struct IPSFactoryBuffer **ppPS);
PFORMAT_STRING ComputeConformance(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pMemory, #define ComputeConformance(pStubMsg, pMemory, pFormat, def) ComputeConformanceOrVariance(pStubMsg, pMemory, pFormat, def, &pStubMsg->MaxCount)
PFORMAT_STRING pFormat, ULONG_PTR def); #define ComputeVariance(pStubMsg, pMemory, pFormat, def) ComputeConformanceOrVariance(pStubMsg, pMemory, pFormat, def, &pStubMsg->ActualCount)
PFORMAT_STRING ComputeConformanceOrVariance(
MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pMemory,
PFORMAT_STRING pFormat, ULONG_PTR def, ULONG *pCount);
typedef unsigned char* (WINAPI *NDR_MARSHALL) (PMIDL_STUB_MESSAGE, unsigned char*, PFORMAT_STRING); typedef unsigned char* (WINAPI *NDR_MARSHALL) (PMIDL_STUB_MESSAGE, unsigned char*, PFORMAT_STRING);
typedef unsigned char* (WINAPI *NDR_UNMARSHALL)(PMIDL_STUB_MESSAGE, unsigned char**,PFORMAT_STRING, unsigned char); typedef unsigned char* (WINAPI *NDR_UNMARSHALL)(PMIDL_STUB_MESSAGE, unsigned char**,PFORMAT_STRING, unsigned char);
......
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