rpcrt4: Use the same phase values for clients and stubs.

This commit is contained in:
Alexandre Julliard 2011-07-28 22:34:57 +02:00
parent f3734fd687
commit 78e8fccbd6
3 changed files with 228 additions and 257 deletions

View File

@ -409,14 +409,14 @@ void WINAPIV NdrMesProcEncodeDecode(handle_t Handle, const MIDL_STUB_DESC * pStu
case MES_ENCODE:
pEsMsg->StubMsg.BufferLength = mes_proc_header_buffer_size();
client_do_args( &pEsMsg->StubMsg, pFormat, PROXY_CALCSIZE, NULL, number_of_params, NULL );
client_do_args( &pEsMsg->StubMsg, pFormat, STUBLESS_CALCSIZE, NULL, number_of_params, NULL );
pEsMsg->ByteCount = pEsMsg->StubMsg.BufferLength - mes_proc_header_buffer_size();
es_data_alloc(pEsMsg, pEsMsg->StubMsg.BufferLength);
mes_proc_header_marshal(pEsMsg);
client_do_args( &pEsMsg->StubMsg, pFormat, PROXY_MARSHAL, NULL, number_of_params, NULL );
client_do_args( &pEsMsg->StubMsg, pFormat, STUBLESS_MARSHAL, NULL, number_of_params, NULL );
es_data_write(pEsMsg, pEsMsg->ByteCount);
break;
@ -425,7 +425,7 @@ void WINAPIV NdrMesProcEncodeDecode(handle_t Handle, const MIDL_STUB_DESC * pStu
es_data_read(pEsMsg, pEsMsg->ByteCount);
client_do_args( &pEsMsg->StubMsg, pFormat, PROXY_UNMARSHAL, NULL, number_of_params, NULL );
client_do_args( &pEsMsg->StubMsg, pFormat, STUBLESS_UNMARSHAL, NULL, number_of_params, NULL );
break;
default:
RpcRaiseException(RPC_S_INTERNAL_ERROR);

View File

@ -144,14 +144,6 @@ static inline void call_freer(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemor
if (m) m(pStubMsg, pMemory, pFormat);
}
#define STUBLESS_UNMARSHAL 1
#define STUBLESS_INITOUT 2
#define STUBLESS_CALLSERVER 3
#define STUBLESS_CALCSIZE 4
#define STUBLESS_GETBUFFER 5
#define STUBLESS_MARSHAL 6
#define STUBLESS_FREE 7
void WINAPI NdrRpcSmSetClientToOsf(PMIDL_STUB_MESSAGE pMessage)
{
#if 0 /* these functions are not defined yet */
@ -345,8 +337,8 @@ static void client_free_handle(
}
}
void client_do_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, int phase, void **fpu_args,
unsigned short number_of_params, unsigned char *pRetVal )
void client_do_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, enum stubless_phase phase,
void **fpu_args, unsigned short number_of_params, unsigned char *pRetVal )
{
const NDR_PARAM_OIF *params = (const NDR_PARAM_OIF *)pFormat;
unsigned int i;
@ -380,13 +372,13 @@ void client_do_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, int ph
switch (phase)
{
case PROXY_CALCSIZE:
case STUBLESS_CALCSIZE:
if (params[i].attr.IsIn) call_buffer_sizer(pStubMsg, pArg, &params[i]);
break;
case PROXY_MARSHAL:
case STUBLESS_MARSHAL:
if (params[i].attr.IsIn) call_marshaller(pStubMsg, pArg, &params[i]);
break;
case PROXY_UNMARSHAL:
case STUBLESS_UNMARSHAL:
if (params[i].attr.IsOut)
{
if (params[i].attr.IsReturn && pRetVal) pArg = pRetVal;
@ -535,8 +527,6 @@ LONG_PTR CDECL ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pForma
INTERPRETER_OPT_FLAGS Oif_flags = { 0 };
/* cache of extension flags from NDR_PROC_HEADER_EXTS */
INTERPRETER_OPT_FLAGS2 ext_flags = { 0 };
/* the type of pass we are currently doing */
int phase;
/* header for procedure string */
const NDR_PROC_HEADER * pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0];
/* the value to return to the client from the remote procedure */
@ -657,23 +647,24 @@ LONG_PTR CDECL ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pForma
}
/* order of phases:
* 1. PROXY_CALCSIZE - calculate the buffer size
* 2. PROXY_GETBUFFER - allocate the buffer
* 3. PROXY_MARHSAL - marshal [in] params into the buffer
* 4. PROXY_SENDRECEIVE - send/receive buffer
* 5. PROXY_UNMARHSAL - unmarshal [out] params from buffer
* 1. CALCSIZE - calculate the buffer size
* 2. GETBUFFER - allocate the buffer
* 3. MARSHAL - marshal [in] params into the buffer
* 4. SENDRECEIVE - send/receive buffer
* 5. UNMARSHAL - unmarshal [out] params from buffer
*/
if ((pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT) ||
(pProcHeader->Oi_flags & RPC_FC_PROC_OIF_HAS_COMM_OR_FAULT))
{
__TRY
{
for (phase = PROXY_CALCSIZE; phase <= PROXY_UNMARSHAL; phase++)
{
TRACE("phase = %d\n", phase);
switch (phase)
{
case PROXY_GETBUFFER:
/* 1. CALCSIZE */
TRACE( "CALCSIZE\n" );
client_do_args(&stubMsg, pFormat, STUBLESS_CALCSIZE, fpu_stack,
number_of_params, (unsigned char *)&RetVal);
/* 2. GETBUFFER */
TRACE( "GETBUFFER\n" );
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
{
/* allocate the buffer */
@ -697,8 +688,14 @@ LONG_PTR CDECL ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pForma
NdrGetBuffer(&stubMsg, stubMsg.BufferLength, hBinding);
}
}
break;
case PROXY_SENDRECEIVE:
/* 3. MARSHAL */
TRACE( "MARSHAL\n" );
client_do_args(&stubMsg, pFormat, STUBLESS_MARSHAL, fpu_stack,
number_of_params, (unsigned char *)&RetVal);
/* 4. SENDRECEIVE */
TRACE( "SENDRECEIVE\n" );
if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
{
/* send the [in] params and receive the [out] and [retval]
@ -730,18 +727,10 @@ LONG_PTR CDECL ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pForma
if ((rpcMsg.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
NdrConvert(&stubMsg, pFormat);
break;
case PROXY_CALCSIZE:
case PROXY_MARSHAL:
case PROXY_UNMARSHAL:
client_do_args(&stubMsg, pFormat, phase, fpu_stack,
/* 5. UNMARSHAL */
TRACE( "UNMARSHAL\n" );
client_do_args(&stubMsg, pFormat, STUBLESS_UNMARSHAL, fpu_stack,
number_of_params, (unsigned char *)&RetVal);
break;
default:
ERR("shouldn't reach here. phase %d\n", phase);
break;
}
}
}
__EXCEPT_ALL
{
@ -777,20 +766,13 @@ LONG_PTR CDECL ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pForma
}
else
{
/* order of phases:
* 1. PROXY_CALCSIZE - calculate the buffer size
* 2. PROXY_GETBUFFER - allocate the buffer
* 3. PROXY_MARHSAL - marshal [in] params into the buffer
* 4. PROXY_SENDRECEIVE - send/receive buffer
* 5. PROXY_UNMARHSAL - unmarshal [out] params from buffer
*/
for (phase = PROXY_CALCSIZE; phase <= PROXY_UNMARSHAL; phase++)
{
TRACE("phase = %d\n", phase);
switch (phase)
{
case PROXY_GETBUFFER:
/* allocate the buffer */
/* 1. CALCSIZE */
TRACE( "CALCSIZE\n" );
client_do_args(&stubMsg, pFormat, STUBLESS_CALCSIZE, fpu_stack,
number_of_params, (unsigned char *)&RetVal);
/* 2. GETBUFFER */
TRACE( "GETBUFFER\n" );
if (Oif_flags.HasPipes)
/* NdrGetPipeBuffer(...) */
FIXME("pipes not supported yet\n");
@ -805,10 +787,14 @@ LONG_PTR CDECL ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pForma
else
NdrGetBuffer(&stubMsg, stubMsg.BufferLength, hBinding);
}
break;
case PROXY_SENDRECEIVE:
/* send the [in] params and receive the [out] and [retval]
* params */
/* 3. MARSHAL */
TRACE( "MARSHAL\n" );
client_do_args(&stubMsg, pFormat, STUBLESS_MARSHAL, fpu_stack,
number_of_params, (unsigned char *)&RetVal);
/* 4. SENDRECEIVE */
TRACE( "SENDRECEIVE\n" );
if (Oif_flags.HasPipes)
/* NdrPipesSendReceive(...) */
FIXME("pipes not supported yet\n");
@ -829,18 +815,10 @@ LONG_PTR CDECL ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pForma
if ((rpcMsg.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
NdrConvert(&stubMsg, pFormat);
break;
case PROXY_CALCSIZE:
case PROXY_MARSHAL:
case PROXY_UNMARSHAL:
client_do_args(&stubMsg, pFormat, phase, fpu_stack,
/* 5. UNMARSHAL */
TRACE( "UNMARSHAL\n" );
client_do_args(&stubMsg, pFormat, STUBLESS_UNMARSHAL, fpu_stack,
number_of_params, (unsigned char *)&RetVal);
break;
default:
ERR("shouldn't reach here. phase %d\n", phase);
break;
}
}
}
if (ext_flags.HasNewCorrDesc)
@ -1071,7 +1049,7 @@ static DWORD calc_arg_size(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
}
static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
PFORMAT_STRING pFormat, int phase,
PFORMAT_STRING pFormat, enum stubless_phase phase,
unsigned short number_of_params)
{
const NDR_PARAM_OIF *params = (const NDR_PARAM_OIF *)pFormat;
@ -1187,7 +1165,7 @@ LONG WINAPI NdrStubCall2(
/* cache of extension flags from NDR_PROC_HEADER_EXTS */
INTERPRETER_OPT_FLAGS2 ext_flags = { 0 };
/* the type of pass we are currently doing */
int phase;
enum stubless_phase phase;
/* header for procedure string */
const NDR_PROC_HEADER *pProcHeader;
/* location to put retval into */
@ -1474,12 +1452,11 @@ LONG_PTR CDECL ndr_async_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING
INTERPRETER_OPT_FLAGS Oif_flags = { 0 };
/* cache of extension flags from NDR_PROC_HEADER_EXTS */
INTERPRETER_OPT_FLAGS2 ext_flags = { 0 };
/* the type of pass we are currently doing */
int phase;
/* header for procedure string */
const NDR_PROC_HEADER * pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0];
/* -Oif or -Oicf generated format */
BOOL bV2Format = FALSE;
RPC_STATUS status;
TRACE("pStubDesc %p, pFormat %p, ...\n", pStubDesc, pFormat);
@ -1596,22 +1573,21 @@ LONG_PTR CDECL ndr_async_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING
}
/* order of phases:
* 1. PROXY_CALCSIZE - calculate the buffer size
* 2. PROXY_GETBUFFER - allocate the buffer
* 3. PROXY_MARHSAL - marshal [in] params into the buffer
* 4. PROXY_SENDRECEIVE - send buffer
* 1. CALCSIZE - calculate the buffer size
* 2. GETBUFFER - allocate the buffer
* 3. MARSHAL - marshal [in] params into the buffer
* 4. SENDRECEIVE - send buffer
* Then in NdrpCompleteAsyncClientCall:
* 1. PROXY_SENDRECEIVE - receive buffer
* 2. PROXY_UNMARHSAL - unmarshal [out] params from buffer
* 1. SENDRECEIVE - receive buffer
* 2. UNMARSHAL - unmarshal [out] params from buffer
*/
for (phase = PROXY_CALCSIZE; phase <= PROXY_SENDRECEIVE; phase++)
{
RPC_STATUS status;
TRACE("phase = %d\n", phase);
switch (phase)
{
case PROXY_GETBUFFER:
/* allocate the buffer */
/* 1. CALCSIZE */
TRACE( "CALCSIZE\n" );
client_do_args(pStubMsg, pFormat, STUBLESS_CALCSIZE, NULL, async_call_data->number_of_params, NULL);
/* 2. GETBUFFER */
TRACE( "GETBUFFER\n" );
if (Oif_flags.HasPipes)
/* NdrGetPipeBuffer(...) */
FIXME("pipes not supported yet\n");
@ -1630,8 +1606,13 @@ LONG_PTR CDECL ndr_async_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING
status = I_RpcAsyncSetHandle(pRpcMsg, pAsync);
if (status != RPC_S_OK)
RpcRaiseException(status);
break;
case PROXY_SENDRECEIVE:
/* 3. MARSHAL */
TRACE( "MARSHAL\n" );
client_do_args(pStubMsg, pFormat, STUBLESS_MARSHAL, NULL, async_call_data->number_of_params, NULL);
/* 4. SENDRECEIVE */
TRACE( "SEND\n" );
pRpcMsg->RpcFlags |= RPC_BUFFER_ASYNC;
/* send the [in] params only */
if (Oif_flags.HasPipes)
@ -1654,17 +1635,6 @@ LONG_PTR CDECL ndr_async_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING
}
}
break;
case PROXY_CALCSIZE:
case PROXY_MARSHAL:
client_do_args(pStubMsg, pFormat, phase, NULL, async_call_data->number_of_params, NULL);
break;
default:
ERR("shouldn't reach here. phase %d\n", phase);
break;
}
}
done:
TRACE("returning 0\n");
return 0;
@ -1675,8 +1645,6 @@ RPC_STATUS NdrpCompleteAsyncClientCall(RPC_ASYNC_STATE *pAsync, void *Reply)
/* pointer to start of stack where arguments start */
PMIDL_STUB_MESSAGE pStubMsg;
struct async_call_data *async_call_data;
/* the type of pass we are currently doing */
int phase;
/* header for procedure string */
const NDR_PROC_HEADER * pProcHeader;
RPC_STATUS status = RPC_S_OK;
@ -1689,19 +1657,17 @@ RPC_STATUS NdrpCompleteAsyncClientCall(RPC_ASYNC_STATE *pAsync, void *Reply)
pProcHeader = async_call_data->pProcHeader;
/* order of phases:
* 1. PROXY_CALCSIZE - calculate the buffer size
* 2. PROXY_GETBUFFER - allocate the buffer
* 3. PROXY_MARHSAL - marshal [in] params into the buffer
* 4. PROXY_SENDRECEIVE - send buffer
* 1. CALCSIZE - calculate the buffer size
* 2. GETBUFFER - allocate the buffer
* 3. MARSHAL - marshal [in] params into the buffer
* 4. SENDRECEIVE - send buffer
* Then in NdrpCompleteAsyncClientCall:
* 1. PROXY_SENDRECEIVE - receive buffer
* 2. PROXY_UNMARHSAL - unmarshal [out] params from buffer
* 1. SENDRECEIVE - receive buffer
* 2. UNMARSHAL - unmarshal [out] params from buffer
*/
for (phase = PROXY_SENDRECEIVE; phase <= PROXY_UNMARSHAL; phase++)
{
switch (phase)
{
case PROXY_SENDRECEIVE:
/* 1. SENDRECEIVE */
TRACE( "RECEIVE\n" );
pStubMsg->RpcMsg->RpcFlags |= RPC_BUFFER_ASYNC;
/* receive the [out] params */
if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
@ -1728,16 +1694,10 @@ RPC_STATUS NdrpCompleteAsyncClientCall(RPC_ASYNC_STATE *pAsync, void *Reply)
NdrConvert(pStubMsg, pFormat);
#endif
break;
case PROXY_UNMARSHAL:
client_do_args(pStubMsg, async_call_data->pParamFormat, phase,
/* 2. UNMARSHAL */
TRACE( "UNMARSHAL\n" );
client_do_args(pStubMsg, async_call_data->pParamFormat, STUBLESS_UNMARSHAL,
NULL, async_call_data->number_of_params, Reply);
break;
default:
ERR("shouldn't reach here. phase %d\n", phase);
break;
}
}
cleanup:
if (pStubMsg->fHasNewCorrDesc)

View File

@ -225,12 +225,23 @@ typedef struct _NDR_EHD_CONTEXT
#include "poppack.h"
enum stubless_phase
{
STUBLESS_UNMARSHAL,
STUBLESS_INITOUT,
STUBLESS_CALLSERVER,
STUBLESS_CALCSIZE,
STUBLESS_GETBUFFER,
STUBLESS_MARSHAL,
STUBLESS_FREE
};
LONG_PTR CDECL ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pFormat,
void **stack_top, void **fpu_stack ) DECLSPEC_HIDDEN;
LONG_PTR CDECL ndr_async_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pFormat,
void **stack_top ) DECLSPEC_HIDDEN;
void client_do_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, int phase, void **fpu_args,
unsigned short number_of_params, unsigned char *pRetVal ) DECLSPEC_HIDDEN;
void client_do_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, enum stubless_phase phase,
void **fpu_args, unsigned short number_of_params, unsigned char *pRetVal ) DECLSPEC_HIDDEN;
PFORMAT_STRING convert_old_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat,
unsigned int stack_size, BOOL object_proc,
void *buffer, unsigned int size, unsigned int *count ) DECLSPEC_HIDDEN;