mirror of
https://github.com/reactos/wine.git
synced 2024-11-26 13:10:28 +00:00
rpcrt4: Convert old-style arguments for NdrMesProcEncodeDecode.
This commit is contained in:
parent
e8e3a2da83
commit
348f00e116
@ -329,10 +329,10 @@ void WINAPIV NdrMesProcEncodeDecode(handle_t Handle, const MIDL_STUB_DESC * pStu
|
||||
unsigned short stack_size;
|
||||
/* 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 */
|
||||
LONG_PTR RetVal = 0;
|
||||
const RPC_CLIENT_INTERFACE *client_interface;
|
||||
__ms_va_list args;
|
||||
unsigned int number_of_params;
|
||||
ULONG_PTR arg_buffer[256];
|
||||
|
||||
TRACE("Handle %p, pStubDesc %p, pFormat %p, ...\n", Handle, pStubDesc, pFormat);
|
||||
|
||||
@ -401,23 +401,22 @@ void WINAPIV NdrMesProcEncodeDecode(handle_t Handle, const MIDL_STUB_DESC * pStu
|
||||
pEsMsg->StubMsg.StackTop = va_arg( args, unsigned char * );
|
||||
__ms_va_end( args );
|
||||
|
||||
pFormat = convert_old_args( &pEsMsg->StubMsg, pFormat, stack_size, FALSE,
|
||||
arg_buffer, sizeof(arg_buffer), &number_of_params );
|
||||
|
||||
switch (pEsMsg->Operation)
|
||||
{
|
||||
case MES_ENCODE:
|
||||
pEsMsg->StubMsg.BufferLength = mes_proc_header_buffer_size();
|
||||
|
||||
client_do_args_old_format(&pEsMsg->StubMsg, pFormat, PROXY_CALCSIZE,
|
||||
stack_size, (unsigned char *)&RetVal,
|
||||
FALSE /* object_proc */, TRUE /* ignore_retval */);
|
||||
client_do_args( &pEsMsg->StubMsg, pFormat, PROXY_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_old_format(&pEsMsg->StubMsg, pFormat, PROXY_MARSHAL,
|
||||
stack_size, (unsigned char *)&RetVal,
|
||||
FALSE /* object_proc */, TRUE /* ignore_retval */);
|
||||
client_do_args( &pEsMsg->StubMsg, pFormat, PROXY_MARSHAL, NULL, number_of_params, NULL );
|
||||
|
||||
es_data_write(pEsMsg, pEsMsg->ByteCount);
|
||||
break;
|
||||
@ -426,9 +425,7 @@ void WINAPIV NdrMesProcEncodeDecode(handle_t Handle, const MIDL_STUB_DESC * pStu
|
||||
|
||||
es_data_read(pEsMsg, pEsMsg->ByteCount);
|
||||
|
||||
client_do_args_old_format(&pEsMsg->StubMsg, pFormat, PROXY_UNMARSHAL,
|
||||
stack_size, (unsigned char *)&RetVal,
|
||||
FALSE /* object_proc */, TRUE /* ignore_retval */);
|
||||
client_do_args( &pEsMsg->StubMsg, pFormat, PROXY_UNMARSHAL, NULL, number_of_params, NULL );
|
||||
break;
|
||||
default:
|
||||
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
||||
|
@ -292,8 +292,8 @@ static void client_free_handle(
|
||||
}
|
||||
}
|
||||
|
||||
static 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, int 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;
|
||||
@ -337,7 +337,7 @@ static void client_do_args(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat,
|
||||
case PROXY_UNMARSHAL:
|
||||
if (params[i].attr.IsOut)
|
||||
{
|
||||
if (params[i].attr.IsReturn) pArg = pRetVal;
|
||||
if (params[i].attr.IsReturn && pRetVal) pArg = pRetVal;
|
||||
call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
|
||||
}
|
||||
break;
|
||||
@ -446,9 +446,9 @@ static BOOL is_by_value( PFORMAT_STRING format )
|
||||
}
|
||||
}
|
||||
|
||||
static 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 )
|
||||
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 )
|
||||
{
|
||||
NDR_PARAM_OIF *args = buffer;
|
||||
unsigned int i, stack_offset = object_proc ? sizeof(void *) : 0;
|
||||
@ -515,119 +515,6 @@ static PFORMAT_STRING convert_old_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STR
|
||||
return (PFORMAT_STRING)args;
|
||||
}
|
||||
|
||||
void client_do_args_old_format(PMIDL_STUB_MESSAGE pStubMsg,
|
||||
PFORMAT_STRING pFormat, int phase, unsigned short stack_size,
|
||||
unsigned char *pRetVal, BOOL object_proc, BOOL ignore_retval)
|
||||
{
|
||||
/* current format string offset */
|
||||
int current_offset = 0;
|
||||
/* current stack offset */
|
||||
unsigned short current_stack_offset = object_proc ? sizeof(void *) : 0;
|
||||
/* counter */
|
||||
unsigned short i;
|
||||
|
||||
/* NOTE: V1 style format doesn't terminate on the number_of_params
|
||||
* condition as it doesn't have this attribute. Instead it
|
||||
* terminates when the stack size given in the header is exceeded.
|
||||
*/
|
||||
for (i = 0; TRUE; i++)
|
||||
{
|
||||
const NDR_PARAM_OI_BASETYPE *pParam =
|
||||
(const NDR_PARAM_OI_BASETYPE *)&pFormat[current_offset];
|
||||
unsigned char * pArg = pStubMsg->StackTop + current_stack_offset;
|
||||
|
||||
/* no more parameters; exit loop */
|
||||
if (current_stack_offset >= stack_size)
|
||||
break;
|
||||
|
||||
TRACE("param[%d]: old format\n", i);
|
||||
TRACE("\tparam_direction: 0x%x\n", pParam->param_direction);
|
||||
TRACE("\tstack_offset: 0x%x\n", current_stack_offset);
|
||||
TRACE("\tmemory addr (before): %p\n", pArg);
|
||||
|
||||
if (pParam->param_direction == RPC_FC_IN_PARAM_BASETYPE ||
|
||||
pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
|
||||
{
|
||||
const unsigned char * pTypeFormat =
|
||||
&pParam->type_format_char;
|
||||
|
||||
TRACE("\tbase type 0x%02x\n", *pTypeFormat);
|
||||
|
||||
switch (phase)
|
||||
{
|
||||
case PROXY_CALCSIZE:
|
||||
if (pParam->param_direction == RPC_FC_IN_PARAM_BASETYPE)
|
||||
call_buffer_sizer(pStubMsg, pArg, pTypeFormat);
|
||||
break;
|
||||
case PROXY_MARSHAL:
|
||||
if (pParam->param_direction == RPC_FC_IN_PARAM_BASETYPE)
|
||||
call_marshaller(pStubMsg, pArg, pTypeFormat);
|
||||
break;
|
||||
case PROXY_UNMARSHAL:
|
||||
if (!ignore_retval &&
|
||||
pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
|
||||
{
|
||||
if (pParam->param_direction & RPC_FC_RETURN_PARAM)
|
||||
call_unmarshaller(pStubMsg, &pRetVal, pTypeFormat, 0);
|
||||
else
|
||||
call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
current_stack_offset += type_stack_size(*pTypeFormat);
|
||||
current_offset += sizeof(NDR_PARAM_OI_BASETYPE);
|
||||
}
|
||||
else
|
||||
{
|
||||
const NDR_PARAM_OI_OTHER *pParamOther = (const NDR_PARAM_OI_OTHER *)&pFormat[current_offset];
|
||||
const unsigned char *pTypeFormat = &pStubMsg->StubDesc->pFormatTypes[pParamOther->type_offset];
|
||||
const BOOL by_value = is_by_value( pTypeFormat );
|
||||
|
||||
TRACE("\tcomplex type 0x%02x\n", *pTypeFormat);
|
||||
|
||||
switch (phase)
|
||||
{
|
||||
case PROXY_CALCSIZE:
|
||||
if (pParam->param_direction == RPC_FC_IN_PARAM ||
|
||||
pParam->param_direction == RPC_FC_IN_OUT_PARAM)
|
||||
{
|
||||
if (!by_value) pArg = *(unsigned char **)pArg;
|
||||
call_buffer_sizer(pStubMsg, pArg, pTypeFormat);
|
||||
}
|
||||
break;
|
||||
case PROXY_MARSHAL:
|
||||
if (pParam->param_direction == RPC_FC_IN_PARAM ||
|
||||
pParam->param_direction == RPC_FC_IN_OUT_PARAM)
|
||||
{
|
||||
if (!by_value) pArg = *(unsigned char **)pArg;
|
||||
call_marshaller(pStubMsg, pArg, pTypeFormat);
|
||||
}
|
||||
break;
|
||||
case PROXY_UNMARSHAL:
|
||||
if (pParam->param_direction == RPC_FC_IN_OUT_PARAM ||
|
||||
pParam->param_direction == RPC_FC_OUT_PARAM)
|
||||
{
|
||||
if (by_value)
|
||||
call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
|
||||
else
|
||||
call_unmarshaller(pStubMsg, (unsigned char **)pArg, pTypeFormat, 0);
|
||||
}
|
||||
else if (pParam->param_direction == RPC_FC_RETURN_PARAM)
|
||||
call_unmarshaller(pStubMsg, (unsigned char **)pRetVal, pTypeFormat, 0);
|
||||
break;
|
||||
default:
|
||||
RpcRaiseException(RPC_S_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
current_stack_offset += pParamOther->stack_size * sizeof(void *);
|
||||
current_offset += sizeof(NDR_PARAM_OI_OTHER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LONG_PTR CDECL ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pFormat,
|
||||
void **stack_top, void **fpu_stack )
|
||||
{
|
||||
|
@ -229,7 +229,9 @@ LONG_PTR CDECL ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pForma
|
||||
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_old_format(PMIDL_STUB_MESSAGE pStubMsg,
|
||||
PFORMAT_STRING pFormat, int phase, unsigned short stack_size,
|
||||
unsigned char *pRetVal, BOOL object_proc, BOOL ignore_retval) 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;
|
||||
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;
|
||||
RPC_STATUS NdrpCompleteAsyncClientCall(RPC_ASYNC_STATE *pAsync, void *Reply) DECLSPEC_HIDDEN;
|
||||
|
Loading…
Reference in New Issue
Block a user