From 348f00e11653282c4a2e86928dae1b55f018f936 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 28 Jul 2011 17:30:40 +0200 Subject: [PATCH] rpcrt4: Convert old-style arguments for NdrMesProcEncodeDecode. --- dlls/rpcrt4/ndr_es.c | 19 +++--- dlls/rpcrt4/ndr_stubless.c | 125 ++----------------------------------- dlls/rpcrt4/ndr_stubless.h | 8 ++- 3 files changed, 19 insertions(+), 133 deletions(-) diff --git a/dlls/rpcrt4/ndr_es.c b/dlls/rpcrt4/ndr_es.c index b263ad9af1..eabfaa4eec 100644 --- a/dlls/rpcrt4/ndr_es.c +++ b/dlls/rpcrt4/ndr_es.c @@ -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); diff --git a/dlls/rpcrt4/ndr_stubless.c b/dlls/rpcrt4/ndr_stubless.c index 7c62b7ce59..ccce8882de 100644 --- a/dlls/rpcrt4/ndr_stubless.c +++ b/dlls/rpcrt4/ndr_stubless.c @@ -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 ) { diff --git a/dlls/rpcrt4/ndr_stubless.h b/dlls/rpcrt4/ndr_stubless.h index a6eb50b6b0..946847b7b1 100644 --- a/dlls/rpcrt4/ndr_stubless.h +++ b/dlls/rpcrt4/ndr_stubless.h @@ -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;