2 * NDR -Oi,-Oif,-Oicf Interpreter
4 * Copyright 2001 Ove Kåven, TransGaming Technologies
5 * Copyright 2003-5 Robert Shearman (for CodeWeavers)
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * - Some types of binding handles
27 #include "wine/port.h"
41 #include "wine/exception.h"
42 #include "wine/debug.h"
43 #include "wine/rpcfc.h"
47 #include "ndr_stubless.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(rpc);
51 #define NDR_TABLE_MASK 127
53 static inline void call_buffer_sizer(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
55 NDR_BUFFERSIZE m = NdrBufferSizer[pFormat[0] & NDR_TABLE_MASK];
56 if (m) m(pStubMsg, pMemory, pFormat);
59 FIXME("format type 0x%x not implemented\n", pFormat[0]);
60 RpcRaiseException(RPC_X_BAD_STUB_DATA);
64 static inline unsigned char *call_marshaller(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
66 NDR_MARSHALL m = NdrMarshaller[pFormat[0] & NDR_TABLE_MASK];
67 if (m) return m(pStubMsg, pMemory, pFormat);
70 FIXME("format type 0x%x not implemented\n", pFormat[0]);
71 RpcRaiseException(RPC_X_BAD_STUB_DATA);
76 static inline unsigned char *call_unmarshaller(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
78 NDR_UNMARSHALL m = NdrUnmarshaller[pFormat[0] & NDR_TABLE_MASK];
79 if (m) return m(pStubMsg, ppMemory, pFormat, fMustAlloc);
82 FIXME("format type 0x%x not implemented\n", pFormat[0]);
83 RpcRaiseException(RPC_X_BAD_STUB_DATA);
88 static inline void call_freer(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
90 NDR_FREE m = NdrFreer[pFormat[0] & NDR_TABLE_MASK];
91 if (m) m(pStubMsg, pMemory, pFormat);
94 #define STUBLESS_UNMARSHAL 1
95 #define STUBLESS_INITOUT 2
96 #define STUBLESS_CALLSERVER 3
97 #define STUBLESS_CALCSIZE 4
98 #define STUBLESS_GETBUFFER 5
99 #define STUBLESS_MARSHAL 6
100 #define STUBLESS_FREE 7
102 void WINAPI NdrRpcSmSetClientToOsf(PMIDL_STUB_MESSAGE pMessage)
104 #if 0 /* these functions are not defined yet */
105 pMessage->pfnAllocate = NdrRpcSmClientAllocate;
106 pMessage->pfnFree = NdrRpcSmClientFree;
110 static void dump_RPC_FC_PROC_PF(PARAM_ATTRIBUTES param_attributes)
112 if (param_attributes.MustSize) TRACE(" MustSize");
113 if (param_attributes.MustFree) TRACE(" MustFree");
114 if (param_attributes.IsPipe) TRACE(" IsPipe");
115 if (param_attributes.IsIn) TRACE(" IsIn");
116 if (param_attributes.IsOut) TRACE(" IsOut");
117 if (param_attributes.IsReturn) TRACE(" IsReturn");
118 if (param_attributes.IsBasetype) TRACE(" IsBasetype");
119 if (param_attributes.IsByValue) TRACE(" IsByValue");
120 if (param_attributes.IsSimpleRef) TRACE(" IsSimpleRef");
121 if (param_attributes.IsDontCallFreeInst) TRACE(" IsDontCallFreeInst");
122 if (param_attributes.SaveForAsyncFinish) TRACE(" SaveForAsyncFinish");
123 if (param_attributes.ServerAllocSize) TRACE(" ServerAllocSize = %d", param_attributes.ServerAllocSize * 8);
126 static void dump_INTERPRETER_OPT_FLAGS(INTERPRETER_OPT_FLAGS Oi2Flags)
128 if (Oi2Flags.ServerMustSize) TRACE(" ServerMustSize");
129 if (Oi2Flags.ClientMustSize) TRACE(" ClientMustSize");
130 if (Oi2Flags.HasReturn) TRACE(" HasReturn");
131 if (Oi2Flags.HasPipes) TRACE(" HasPipes");
132 if (Oi2Flags.Unused) TRACE(" Unused");
133 if (Oi2Flags.HasAsyncUuid) TRACE(" HasAsyncUuid");
134 if (Oi2Flags.HasExtensions) TRACE(" HasExtensions");
135 if (Oi2Flags.HasAsyncHandle) TRACE(" HasAsyncHandle");
139 #define ARG_FROM_OFFSET(args, offset) ((args) + (offset))
141 static PFORMAT_STRING client_get_handle(
142 PMIDL_STUB_MESSAGE pStubMsg, const NDR_PROC_HEADER *pProcHeader,
143 PFORMAT_STRING pFormat, handle_t *phBinding)
146 switch (pProcHeader->handle_type)
148 /* explicit binding: parse additional section */
149 case RPC_FC_BIND_EXPLICIT:
150 switch (*pFormat) /* handle_type */
152 case RPC_FC_BIND_PRIMITIVE: /* explicit primitive */
154 const NDR_EHD_PRIMITIVE *pDesc = (const NDR_EHD_PRIMITIVE *)pFormat;
156 TRACE("Explicit primitive handle @ %d\n", pDesc->offset);
158 if (pDesc->flag) /* pointer to binding */
159 *phBinding = **(handle_t **)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
161 *phBinding = *(handle_t *)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
162 return pFormat + sizeof(NDR_EHD_PRIMITIVE);
164 case RPC_FC_BIND_GENERIC: /* explicit generic */
166 const NDR_EHD_GENERIC *pDesc = (const NDR_EHD_GENERIC *)pFormat;
167 void *pObject = NULL;
169 const GENERIC_BINDING_ROUTINE_PAIR *pGenPair;
171 TRACE("Explicit generic binding handle #%d\n", pDesc->binding_routine_pair_index);
173 if (pDesc->flag_and_size & HANDLE_PARAM_IS_VIA_PTR)
174 pArg = *(void **)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
176 pArg = ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
177 memcpy(&pObject, pArg, pDesc->flag_and_size & 0xf);
178 pGenPair = &pStubMsg->StubDesc->aGenericBindingRoutinePairs[pDesc->binding_routine_pair_index];
179 *phBinding = pGenPair->pfnBind(pObject);
180 return pFormat + sizeof(NDR_EHD_GENERIC);
182 case RPC_FC_BIND_CONTEXT: /* explicit context */
184 const NDR_EHD_CONTEXT *pDesc = (const NDR_EHD_CONTEXT *)pFormat;
185 NDR_CCONTEXT context_handle;
186 TRACE("Explicit bind context\n");
187 if (pDesc->flags & HANDLE_PARAM_IS_VIA_PTR)
189 TRACE("\tHANDLE_PARAM_IS_VIA_PTR\n");
190 context_handle = **(NDR_CCONTEXT **)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
193 context_handle = *(NDR_CCONTEXT *)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
194 if ((pDesc->flags & NDR_CONTEXT_HANDLE_CANNOT_BE_NULL) &&
197 ERR("null context handle isn't allowed\n");
198 RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT);
201 *phBinding = NDRCContextBinding(context_handle);
202 /* FIXME: should we store this structure in stubMsg.pContext? */
203 return pFormat + sizeof(NDR_EHD_CONTEXT);
206 ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
207 RpcRaiseException(RPC_X_BAD_STUB_DATA);
210 case RPC_FC_BIND_GENERIC: /* implicit generic */
211 FIXME("RPC_FC_BIND_GENERIC\n");
212 RpcRaiseException(RPC_X_BAD_STUB_DATA); /* FIXME: remove when implemented */
214 case RPC_FC_BIND_PRIMITIVE: /* implicit primitive */
215 TRACE("Implicit primitive handle\n");
216 *phBinding = *pStubMsg->StubDesc->IMPLICIT_HANDLE_INFO.pPrimitiveHandle;
218 case RPC_FC_CALLBACK_HANDLE: /* implicit callback */
219 FIXME("RPC_FC_CALLBACK_HANDLE\n");
221 case RPC_FC_AUTO_HANDLE: /* implicit auto handle */
222 /* strictly speaking, it isn't necessary to set hBinding here
223 * since it isn't actually used (hence the automatic in its name),
224 * but then why does MIDL generate a valid entry in the
225 * MIDL_STUB_DESC for it? */
226 TRACE("Implicit auto handle\n");
227 *phBinding = *pStubMsg->StubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle;
230 ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
231 RpcRaiseException(RPC_X_BAD_STUB_DATA);
236 static void client_free_handle(
237 PMIDL_STUB_MESSAGE pStubMsg, const NDR_PROC_HEADER *pProcHeader,
238 PFORMAT_STRING pFormat, handle_t hBinding)
241 switch (pProcHeader->handle_type)
243 /* explicit binding: parse additional section */
244 case RPC_FC_BIND_EXPLICIT:
245 switch (*pFormat) /* handle_type */
247 case RPC_FC_BIND_GENERIC: /* explicit generic */
249 const NDR_EHD_GENERIC *pDesc = (const NDR_EHD_GENERIC *)pFormat;
250 void *pObject = NULL;
252 const GENERIC_BINDING_ROUTINE_PAIR *pGenPair;
254 TRACE("Explicit generic binding handle #%d\n", pDesc->binding_routine_pair_index);
256 if (pDesc->flag_and_size & HANDLE_PARAM_IS_VIA_PTR)
257 pArg = *(void **)ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
259 pArg = ARG_FROM_OFFSET(pStubMsg->StackTop, pDesc->offset);
260 memcpy(&pObject, pArg, pDesc->flag_and_size & 0xf);
261 pGenPair = &pStubMsg->StubDesc->aGenericBindingRoutinePairs[pDesc->binding_routine_pair_index];
262 pGenPair->pfnUnbind(pObject, hBinding);
265 case RPC_FC_BIND_CONTEXT: /* explicit context */
266 case RPC_FC_BIND_PRIMITIVE: /* explicit primitive */
269 ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
270 RpcRaiseException(RPC_X_BAD_STUB_DATA);
273 case RPC_FC_BIND_GENERIC: /* implicit generic */
274 FIXME("RPC_FC_BIND_GENERIC\n");
275 RpcRaiseException(RPC_X_BAD_STUB_DATA); /* FIXME: remove when implemented */
277 case RPC_FC_CALLBACK_HANDLE: /* implicit callback */
278 case RPC_FC_BIND_PRIMITIVE: /* implicit primitive */
279 case RPC_FC_AUTO_HANDLE: /* implicit auto handle */
282 ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
283 RpcRaiseException(RPC_X_BAD_STUB_DATA);
287 static void client_do_args(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat,
288 int phase, unsigned char *args, unsigned short number_of_params,
289 unsigned char *pRetVal)
291 /* current format string offset */
292 int current_offset = 0;
293 /* current stack offset */
294 unsigned short current_stack_offset = 0;
298 for (i = 0; i < number_of_params; i++)
300 const NDR_PARAM_OIF_BASETYPE *pParam =
301 (const NDR_PARAM_OIF_BASETYPE *)&pFormat[current_offset];
302 unsigned char * pArg;
304 current_stack_offset = pParam->stack_offset;
305 pArg = ARG_FROM_OFFSET(args, current_stack_offset);
307 TRACE("param[%d]: new format\n", i);
308 TRACE("\tparam_attributes:"); dump_RPC_FC_PROC_PF(pParam->param_attributes); TRACE("\n");
309 TRACE("\tstack_offset: 0x%x\n", current_stack_offset);
310 TRACE("\tmemory addr (before): %p\n", pArg);
312 if (pParam->param_attributes.IsBasetype)
314 const unsigned char * pTypeFormat =
315 &pParam->type_format_char;
317 if (pParam->param_attributes.IsSimpleRef)
318 pArg = *(unsigned char **)pArg;
320 TRACE("\tbase type: 0x%02x\n", *pTypeFormat);
325 if (pParam->param_attributes.IsIn)
326 call_buffer_sizer(pStubMsg, pArg, pTypeFormat);
329 if (pParam->param_attributes.IsIn)
330 call_marshaller(pStubMsg, pArg, pTypeFormat);
332 case PROXY_UNMARSHAL:
333 if (pParam->param_attributes.IsOut)
335 if (pParam->param_attributes.IsReturn)
336 call_unmarshaller(pStubMsg, &pRetVal, pTypeFormat, 0);
338 call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
339 TRACE("pRetVal = %p\n", pRetVal);
343 RpcRaiseException(RPC_S_INTERNAL_ERROR);
346 current_offset += sizeof(NDR_PARAM_OIF_BASETYPE);
350 const NDR_PARAM_OIF_OTHER *pParamOther =
351 (const NDR_PARAM_OIF_OTHER *)&pFormat[current_offset];
353 const unsigned char * pTypeFormat =
354 &(pStubMsg->StubDesc->pFormatTypes[pParamOther->type_offset]);
356 /* if a simple ref pointer then we have to do the
357 * check for the pointer being non-NULL. */
358 if (pParam->param_attributes.IsSimpleRef)
360 if (!*(unsigned char **)pArg)
361 RpcRaiseException(RPC_X_NULL_REF_POINTER);
364 TRACE("\tcomplex type: 0x%02x\n", *pTypeFormat);
369 if (pParam->param_attributes.IsIn)
371 if (pParam->param_attributes.IsByValue)
372 call_buffer_sizer(pStubMsg, pArg, pTypeFormat);
374 call_buffer_sizer(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
378 if (pParam->param_attributes.IsIn)
380 if (pParam->param_attributes.IsByValue)
381 call_marshaller(pStubMsg, pArg, pTypeFormat);
383 call_marshaller(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
386 case PROXY_UNMARSHAL:
387 if (pParam->param_attributes.IsOut)
389 if (pParam->param_attributes.IsReturn)
390 call_unmarshaller(pStubMsg, &pRetVal, pTypeFormat, 0);
391 else if (pParam->param_attributes.IsByValue)
392 call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
394 call_unmarshaller(pStubMsg, (unsigned char **)pArg, pTypeFormat, 0);
398 RpcRaiseException(RPC_S_INTERNAL_ERROR);
401 current_offset += sizeof(NDR_PARAM_OIF_OTHER);
403 TRACE("\tmemory addr (after): %p\n", pArg);
407 static unsigned int type_stack_size(unsigned char fc)
419 return sizeof(short);
426 return sizeof(float);
428 return sizeof(double);
430 return sizeof(ULONGLONG);
431 case RPC_FC_ERROR_STATUS_T:
432 return sizeof(error_status_t);
434 return sizeof(void *);
436 ERR("invalid base type 0x%x\n", fc);
437 RpcRaiseException(RPC_S_INTERNAL_ERROR);
441 void client_do_args_old_format(PMIDL_STUB_MESSAGE pStubMsg,
442 PFORMAT_STRING pFormat, int phase, unsigned char *args,
443 unsigned short stack_size,
444 unsigned char *pRetVal, BOOL object_proc, BOOL ignore_retval)
446 /* current format string offset */
447 int current_offset = 0;
448 /* current stack offset */
449 unsigned short current_stack_offset = 0;
453 /* NOTE: V1 style format doesn't terminate on the number_of_params
454 * condition as it doesn't have this attribute. Instead it
455 * terminates when the stack size given in the header is exceeded.
457 for (i = 0; TRUE; i++)
459 const NDR_PARAM_OI_BASETYPE *pParam =
460 (const NDR_PARAM_OI_BASETYPE *)&pFormat[current_offset];
461 /* note: current_stack_offset starts after the This pointer
462 * if present, so adjust this */
463 unsigned short current_stack_offset_adjusted = current_stack_offset +
464 (object_proc ? sizeof(void *) : 0);
465 unsigned char * pArg = ARG_FROM_OFFSET(args, current_stack_offset_adjusted);
467 /* no more parameters; exit loop */
468 if (current_stack_offset_adjusted >= stack_size)
471 TRACE("param[%d]: old format\n", i);
472 TRACE("\tparam_direction: 0x%x\n", pParam->param_direction);
473 TRACE("\tstack_offset: 0x%x\n", current_stack_offset_adjusted);
474 TRACE("\tmemory addr (before): %p\n", pArg);
476 if (pParam->param_direction == RPC_FC_IN_PARAM_BASETYPE ||
477 pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
479 const unsigned char * pTypeFormat =
480 &pParam->type_format_char;
482 TRACE("\tbase type 0x%02x\n", *pTypeFormat);
487 if (pParam->param_direction == RPC_FC_IN_PARAM_BASETYPE)
488 call_buffer_sizer(pStubMsg, pArg, pTypeFormat);
491 if (pParam->param_direction == RPC_FC_IN_PARAM_BASETYPE)
492 call_marshaller(pStubMsg, pArg, pTypeFormat);
494 case PROXY_UNMARSHAL:
495 if (!ignore_retval &&
496 pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
498 if (pParam->param_direction & RPC_FC_RETURN_PARAM)
499 call_unmarshaller(pStubMsg, &pRetVal, pTypeFormat, 0);
501 call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
505 RpcRaiseException(RPC_S_INTERNAL_ERROR);
508 current_stack_offset += type_stack_size(*pTypeFormat);
509 current_offset += sizeof(NDR_PARAM_OI_BASETYPE);
513 const NDR_PARAM_OI_OTHER *pParamOther =
514 (const NDR_PARAM_OI_OTHER *)&pFormat[current_offset];
516 const unsigned char *pTypeFormat =
517 &pStubMsg->StubDesc->pFormatTypes[pParamOther->type_offset];
519 TRACE("\tcomplex type 0x%02x\n", *pTypeFormat);
524 if (pParam->param_direction == RPC_FC_IN_PARAM ||
525 pParam->param_direction & RPC_FC_IN_OUT_PARAM)
526 call_buffer_sizer(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
529 if (pParam->param_direction == RPC_FC_IN_PARAM ||
530 pParam->param_direction & RPC_FC_IN_OUT_PARAM)
531 call_marshaller(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
533 case PROXY_UNMARSHAL:
534 if (pParam->param_direction == RPC_FC_IN_OUT_PARAM ||
535 pParam->param_direction == RPC_FC_OUT_PARAM)
536 call_unmarshaller(pStubMsg, (unsigned char **)pArg, pTypeFormat, 0);
537 else if (pParam->param_direction == RPC_FC_RETURN_PARAM)
538 call_unmarshaller(pStubMsg, (unsigned char **)pRetVal, pTypeFormat, 0);
541 RpcRaiseException(RPC_S_INTERNAL_ERROR);
544 current_stack_offset += pParamOther->stack_size * sizeof(INT);
545 current_offset += sizeof(NDR_PARAM_OI_OTHER);
547 TRACE("\tmemory addr (after): %p\n", pArg);
551 CLIENT_CALL_RETURN WINAPIV NdrClientCall2(PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pFormat, ...)
553 /* pointer to start of stack where arguments start */
555 MIDL_STUB_MESSAGE stubMsg;
556 handle_t hBinding = NULL;
557 /* procedure number */
558 unsigned short procedure_number;
560 unsigned short stack_size;
561 /* number of parameters. optional for client to give it to us */
562 unsigned char number_of_params = ~0;
563 /* cache of Oif_flags from v2 procedure header */
564 INTERPRETER_OPT_FLAGS Oif_flags = { 0 };
565 /* cache of extension flags from NDR_PROC_HEADER_EXTS */
566 INTERPRETER_OPT_FLAGS2 ext_flags = { 0 };
567 /* the type of pass we are currently doing */
569 /* header for procedure string */
570 const NDR_PROC_HEADER * pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0];
571 /* -Oif or -Oicf generated format */
572 BOOL bV2Format = FALSE;
573 /* the value to return to the client from the remote procedure */
575 /* the pointer to the object when in OLE mode */
577 PFORMAT_STRING pHandleFormat;
578 /* correlation cache */
579 ULONG_PTR NdrCorrCache[256];
582 TRACE("pStubDesc %p, pFormat %p, ...\n", pStubDesc, pFormat);
584 TRACE("NDR Version: 0x%x\n", pStubDesc->Version);
586 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
588 const NDR_PROC_HEADER_RPC *pProcHeader = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
589 stack_size = pProcHeader->stack_size;
590 procedure_number = pProcHeader->proc_num;
591 pFormat += sizeof(NDR_PROC_HEADER_RPC);
595 stack_size = pProcHeader->stack_size;
596 procedure_number = pProcHeader->proc_num;
597 pFormat += sizeof(NDR_PROC_HEADER);
599 TRACE("stack size: 0x%x\n", stack_size);
600 TRACE("proc num: %d\n", procedure_number);
602 /* create the full pointer translation tables, if requested */
603 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
604 stubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_CLIENT);
606 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
608 /* object is always the first argument */
609 This = **(void *const **)(&pFormat+1);
610 NdrProxyInitialize(This, &rpcMsg, &stubMsg, pStubDesc, procedure_number);
613 NdrClientInitializeNew(&rpcMsg, &stubMsg, pStubDesc, procedure_number);
615 TRACE("Oi_flags = 0x%02x\n", pProcHeader->Oi_flags);
616 TRACE("MIDL stub version = 0x%x\n", pStubDesc->MIDLVersion);
618 /* needed for conformance of top-level objects */
619 __ms_va_start( args, pFormat );
620 stubMsg.StackTop = va_arg( args, unsigned char * );
623 pHandleFormat = pFormat;
625 /* we only need a handle if this isn't an object method */
626 if (!(pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT))
628 pFormat = client_get_handle(&stubMsg, pProcHeader, pHandleFormat, &hBinding);
629 if (!pFormat) goto done;
632 bV2Format = (pStubDesc->Version >= 0x20000);
636 const NDR_PROC_PARTIAL_OIF_HEADER *pOIFHeader =
637 (const NDR_PROC_PARTIAL_OIF_HEADER *)pFormat;
639 Oif_flags = pOIFHeader->Oi2Flags;
640 number_of_params = pOIFHeader->number_of_params;
642 pFormat += sizeof(NDR_PROC_PARTIAL_OIF_HEADER);
645 TRACE("Oif_flags = "); dump_INTERPRETER_OPT_FLAGS(Oif_flags);
647 if (Oif_flags.HasExtensions)
649 const NDR_PROC_HEADER_EXTS *pExtensions =
650 (const NDR_PROC_HEADER_EXTS *)pFormat;
651 ext_flags = pExtensions->Flags2;
652 pFormat += pExtensions->Size;
655 stubMsg.BufferLength = 0;
657 /* store the RPC flags away */
658 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
659 rpcMsg.RpcFlags = ((const NDR_PROC_HEADER_RPC *)pProcHeader)->rpc_flags;
661 /* use alternate memory allocation routines */
662 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCSSALLOC)
663 NdrRpcSmSetClientToOsf(&stubMsg);
665 if (Oif_flags.HasPipes)
667 FIXME("pipes not supported yet\n");
668 RpcRaiseException(RPC_X_WRONG_STUB_VERSION); /* FIXME: remove when implemented */
669 /* init pipes package */
670 /* NdrPipesInitialize(...) */
672 if (ext_flags.HasNewCorrDesc)
674 /* initialize extra correlation package */
675 NdrCorrelationInitialize(&stubMsg, NdrCorrCache, sizeof(NdrCorrCache), 0);
679 * 1. PROXY_CALCSIZE - calculate the buffer size
680 * 2. PROXY_GETBUFFER - allocate the buffer
681 * 3. PROXY_MARHSAL - marshal [in] params into the buffer
682 * 4. PROXY_SENDRECEIVE - send/receive buffer
683 * 5. PROXY_UNMARHSAL - unmarshal [out] params from buffer
685 if ((pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT) ||
686 (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_HAS_COMM_OR_FAULT))
690 for (phase = PROXY_CALCSIZE; phase <= PROXY_UNMARSHAL; phase++)
692 TRACE("phase = %d\n", phase);
695 case PROXY_GETBUFFER:
696 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
698 /* allocate the buffer */
699 NdrProxyGetBuffer(This, &stubMsg);
703 /* allocate the buffer */
704 if (Oif_flags.HasPipes)
705 /* NdrGetPipeBuffer(...) */
706 FIXME("pipes not supported yet\n");
709 if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
711 NdrNsGetBuffer(&stubMsg, stubMsg.BufferLength, hBinding);
713 FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
716 NdrGetBuffer(&stubMsg, stubMsg.BufferLength, hBinding);
720 case PROXY_SENDRECEIVE:
721 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
723 /* send the [in] params and receive the [out] and [retval]
725 NdrProxySendReceive(This, &stubMsg);
729 /* send the [in] params and receive the [out] and [retval]
731 if (Oif_flags.HasPipes)
732 /* NdrPipesSendReceive(...) */
733 FIXME("pipes not supported yet\n");
736 if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
738 NdrNsSendReceive(&stubMsg, stubMsg.Buffer, pStubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle);
740 FIXME("using auto handle - call NdrNsSendReceive when it gets implemented\n");
743 NdrSendReceive(&stubMsg, stubMsg.Buffer);
747 /* convert strings, floating point values and endianess into our
748 * preferred format */
749 if ((rpcMsg.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
750 NdrConvert(&stubMsg, pFormat);
755 case PROXY_UNMARSHAL:
757 client_do_args(&stubMsg, pFormat, phase, stubMsg.StackTop,
758 number_of_params, (unsigned char *)&RetVal);
760 client_do_args_old_format(&stubMsg, pFormat, phase,
761 stubMsg.StackTop, stack_size, (unsigned char *)&RetVal,
762 (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT), FALSE);
765 ERR("shouldn't reach here. phase %d\n", phase);
772 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
773 RetVal = NdrProxyErrorHandler(GetExceptionCode());
776 const COMM_FAULT_OFFSETS *comm_fault_offsets = &pStubDesc->CommFaultOffsets[procedure_number];
780 TRACE("comm_fault_offsets = {0x%hx, 0x%hx}\n", comm_fault_offsets->CommOffset, comm_fault_offsets->FaultOffset);
782 if (comm_fault_offsets->CommOffset == -1)
783 comm_status = (ULONG *)&RetVal;
784 else if (comm_fault_offsets->CommOffset >= 0)
785 comm_status = *(ULONG **)ARG_FROM_OFFSET(stubMsg.StackTop, comm_fault_offsets->CommOffset);
789 if (comm_fault_offsets->FaultOffset == -1)
790 fault_status = (ULONG *)&RetVal;
791 else if (comm_fault_offsets->FaultOffset >= 0)
792 fault_status = *(ULONG **)ARG_FROM_OFFSET(stubMsg.StackTop, comm_fault_offsets->CommOffset);
796 NdrMapCommAndFaultStatus(&stubMsg, comm_status, fault_status,
805 * 1. PROXY_CALCSIZE - calculate the buffer size
806 * 2. PROXY_GETBUFFER - allocate the buffer
807 * 3. PROXY_MARHSAL - marshal [in] params into the buffer
808 * 4. PROXY_SENDRECEIVE - send/receive buffer
809 * 5. PROXY_UNMARHSAL - unmarshal [out] params from buffer
811 for (phase = PROXY_CALCSIZE; phase <= PROXY_UNMARSHAL; phase++)
813 TRACE("phase = %d\n", phase);
816 case PROXY_GETBUFFER:
817 /* allocate the buffer */
818 if (Oif_flags.HasPipes)
819 /* NdrGetPipeBuffer(...) */
820 FIXME("pipes not supported yet\n");
823 if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
825 NdrNsGetBuffer(&stubMsg, stubMsg.BufferLength, hBinding);
827 FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
830 NdrGetBuffer(&stubMsg, stubMsg.BufferLength, hBinding);
833 case PROXY_SENDRECEIVE:
834 /* send the [in] params and receive the [out] and [retval]
836 if (Oif_flags.HasPipes)
837 /* NdrPipesSendReceive(...) */
838 FIXME("pipes not supported yet\n");
841 if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
843 NdrNsSendReceive(&stubMsg, stubMsg.Buffer, pStubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle);
845 FIXME("using auto handle - call NdrNsSendReceive when it gets implemented\n");
848 NdrSendReceive(&stubMsg, stubMsg.Buffer);
851 /* convert strings, floating point values and endianess into our
852 * preferred format */
853 if ((rpcMsg.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
854 NdrConvert(&stubMsg, pFormat);
859 case PROXY_UNMARSHAL:
861 client_do_args(&stubMsg, pFormat, phase, stubMsg.StackTop,
862 number_of_params, (unsigned char *)&RetVal);
864 client_do_args_old_format(&stubMsg, pFormat, phase,
865 stubMsg.StackTop, stack_size, (unsigned char *)&RetVal,
866 (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT), FALSE);
869 ERR("shouldn't reach here. phase %d\n", phase);
875 if (ext_flags.HasNewCorrDesc)
877 /* free extra correlation package */
878 NdrCorrelationFree(&stubMsg);
881 if (Oif_flags.HasPipes)
883 /* NdrPipesDone(...) */
886 /* free the full pointer translation tables */
887 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
888 NdrFullPointerXlatFree(stubMsg.FullPtrXlatTables);
890 /* free marshalling buffer */
891 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
892 NdrProxyFreeBuffer(This, &stubMsg);
895 NdrFreeBuffer(&stubMsg);
896 client_free_handle(&stubMsg, pProcHeader, pHandleFormat, hBinding);
900 TRACE("RetVal = 0x%lx\n", RetVal);
901 return *(CLIENT_CALL_RETURN *)&RetVal;
904 /* Calls a function with the specified arguments, restoring the stack
905 * properly afterwards as we don't know the calling convention of the
907 #if defined __i386__ && defined _MSC_VER
908 __declspec(naked) LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char * args, unsigned int stack_size)
913 push edi ; Save registers
916 mov eax, [ebp+16] ; Get stack size
917 sub esp, eax ; Make room in stack for arguments
923 rep movsd ; Copy dword blocks
924 call [ebp+8] ; Call function
925 lea esp, [ebp-8] ; Restore stack
926 pop esi ; Restore registers
932 #elif defined __i386__ && defined __GNUC__
933 LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char * args, unsigned int stack_size);
934 __ASM_GLOBAL_FUNC(call_server_func,
936 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
937 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
939 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
940 "pushl %edi\n\t" /* Save registers */
941 __ASM_CFI(".cfi_rel_offset %edi,-4\n\t")
943 __ASM_CFI(".cfi_rel_offset %esi,-8\n\t")
944 "movl 16(%ebp), %eax\n\t" /* Get stack size */
945 "subl %eax, %esp\n\t" /* Make room in stack for arguments */
946 "andl $~15, %esp\n\t" /* Make sure stack has 16-byte alignment for Mac OS X */
947 "movl %esp, %edi\n\t"
948 "movl %eax, %ecx\n\t"
949 "movl 12(%ebp), %esi\n\t"
950 "shrl $2, %ecx\n\t" /* divide by 4 */
952 "rep; movsl\n\t" /* Copy dword blocks */
953 "call *8(%ebp)\n\t" /* Call function */
954 "leal -8(%ebp), %esp\n\t" /* Restore stack */
955 "popl %esi\n\t" /* Restore registers */
956 __ASM_CFI(".cfi_same_value %esi\n\t")
958 __ASM_CFI(".cfi_same_value %edi\n\t")
960 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
961 __ASM_CFI(".cfi_same_value %ebp\n\t")
964 #warning call_server_func not implemented for your architecture
965 LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char * args, unsigned short stack_size)
967 FIXME("Not implemented for your architecture\n");
972 static DWORD calc_arg_size(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
978 size = *(const WORD*)(pFormat + 2);
980 case RPC_FC_BOGUS_STRUCT:
981 size = *(const WORD*)(pFormat + 2);
982 if(*(const WORD*)(pFormat + 4))
983 FIXME("Unhandled conformant description\n");
986 size = *(const WORD*)(pFormat + 2);
987 ComputeConformance(pStubMsg, NULL, pFormat + 4, 0);
988 size *= pStubMsg->MaxCount;
990 case RPC_FC_SMFARRAY:
991 size = *(const WORD*)(pFormat + 2);
993 case RPC_FC_LGFARRAY:
994 size = *(const DWORD*)(pFormat + 2);
996 case RPC_FC_BOGUS_ARRAY:
997 pFormat = ComputeConformance(pStubMsg, NULL, pFormat + 4, *(const WORD*)&pFormat[2]);
998 TRACE("conformance = %ld\n", pStubMsg->MaxCount);
999 pFormat = ComputeVariance(pStubMsg, NULL, pFormat, pStubMsg->MaxCount);
1000 size = ComplexStructSize(pStubMsg, pFormat);
1001 size *= pStubMsg->MaxCount;
1003 case RPC_FC_C_CSTRING:
1004 case RPC_FC_C_WSTRING:
1005 if (*pFormat == RPC_FC_C_CSTRING)
1006 size = sizeof(CHAR);
1008 size = sizeof(WCHAR);
1009 if (pFormat[1] == RPC_FC_STRING_SIZED)
1010 ComputeConformance(pStubMsg, NULL, pFormat + 2, 0);
1012 pStubMsg->MaxCount = 0;
1013 size *= pStubMsg->MaxCount;
1016 FIXME("Unhandled type %02x\n", *pFormat);
1019 size = sizeof(void *);
1025 static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
1026 PFORMAT_STRING pFormat, int phase,
1027 unsigned char *args,
1028 unsigned short number_of_params)
1032 /* current format string offset */
1033 int current_offset = 0;
1034 /* current stack offset */
1035 unsigned short current_stack_offset = 0;
1036 /* location to put retval into */
1037 LONG_PTR *retval_ptr = NULL;
1039 for (i = 0; i < number_of_params; i++)
1041 const NDR_PARAM_OIF_BASETYPE *pParam =
1042 (const NDR_PARAM_OIF_BASETYPE *)&pFormat[current_offset];
1043 unsigned char *pArg;
1045 current_stack_offset = pParam->stack_offset;
1046 pArg = args + current_stack_offset;
1048 TRACE("param[%d]: new format\n", i);
1049 TRACE("\tparam_attributes:"); dump_RPC_FC_PROC_PF(pParam->param_attributes); TRACE("\n");
1050 TRACE("\tstack_offset: 0x%x\n", current_stack_offset);
1051 TRACE("\tmemory addr (before): %p -> %p\n", pArg, *(unsigned char **)pArg);
1053 if (pParam->param_attributes.IsBasetype)
1055 const unsigned char *pTypeFormat =
1056 &pParam->type_format_char;
1058 TRACE("\tbase type: 0x%02x\n", *pTypeFormat);
1060 /* make a note of the address of the return value parameter for later */
1061 if (pParam->param_attributes.IsReturn)
1062 retval_ptr = (LONG_PTR *)pArg;
1066 case STUBLESS_MARSHAL:
1067 if (pParam->param_attributes.IsOut || pParam->param_attributes.IsReturn)
1069 if (pParam->param_attributes.IsSimpleRef)
1070 call_marshaller(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
1072 call_marshaller(pStubMsg, pArg, pTypeFormat);
1076 if (pParam->param_attributes.ServerAllocSize)
1077 HeapFree(GetProcessHeap(), 0, *(void **)pArg);
1079 case STUBLESS_INITOUT:
1081 case STUBLESS_UNMARSHAL:
1082 if (pParam->param_attributes.ServerAllocSize)
1083 *(void **)pArg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
1084 pParam->param_attributes.ServerAllocSize * 8);
1086 if (pParam->param_attributes.IsIn)
1088 if (pParam->param_attributes.IsSimpleRef)
1089 call_unmarshaller(pStubMsg, (unsigned char **)pArg, pTypeFormat, 0);
1091 call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
1094 case STUBLESS_CALCSIZE:
1095 if (pParam->param_attributes.IsOut || pParam->param_attributes.IsReturn)
1097 if (pParam->param_attributes.IsSimpleRef)
1098 call_buffer_sizer(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
1100 call_buffer_sizer(pStubMsg, pArg, pTypeFormat);
1104 RpcRaiseException(RPC_S_INTERNAL_ERROR);
1107 current_offset += sizeof(NDR_PARAM_OIF_BASETYPE);
1111 const NDR_PARAM_OIF_OTHER *pParamOther =
1112 (const NDR_PARAM_OIF_OTHER *)&pFormat[current_offset];
1114 const unsigned char * pTypeFormat =
1115 &(pStubMsg->StubDesc->pFormatTypes[pParamOther->type_offset]);
1117 TRACE("\tcomplex type 0x%02x\n", *pTypeFormat);
1121 case STUBLESS_MARSHAL:
1122 if (pParam->param_attributes.IsOut || pParam->param_attributes.IsReturn)
1124 if (pParam->param_attributes.IsByValue)
1125 call_marshaller(pStubMsg, pArg, pTypeFormat);
1127 call_marshaller(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
1131 if (pParam->param_attributes.MustFree)
1133 if (pParam->param_attributes.IsByValue)
1134 call_freer(pStubMsg, pArg, pTypeFormat);
1136 call_freer(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
1139 if (pParam->param_attributes.IsOut &&
1140 !pParam->param_attributes.IsIn &&
1141 !pParam->param_attributes.IsByValue &&
1142 !pParam->param_attributes.ServerAllocSize)
1144 if (*pTypeFormat != RPC_FC_BIND_CONTEXT)
1145 pStubMsg->pfnFree(*(void **)pArg);
1148 if (pParam->param_attributes.ServerAllocSize)
1149 HeapFree(GetProcessHeap(), 0, *(void **)pArg);
1151 case STUBLESS_INITOUT:
1152 if (!pParam->param_attributes.IsIn &&
1153 pParam->param_attributes.IsOut &&
1154 !pParam->param_attributes.ServerAllocSize &&
1155 !pParam->param_attributes.IsByValue)
1157 if (*pTypeFormat == RPC_FC_BIND_CONTEXT)
1159 NDR_SCONTEXT ctxt = NdrContextHandleInitialize(
1160 pStubMsg, pTypeFormat);
1161 *(void **)pArg = NDRSContextValue(ctxt);
1165 DWORD size = calc_arg_size(pStubMsg, pTypeFormat);
1169 *(void **)pArg = NdrAllocate(pStubMsg, size);
1170 memset(*(void **)pArg, 0, size);
1175 case STUBLESS_UNMARSHAL:
1176 if (pParam->param_attributes.ServerAllocSize)
1177 *(void **)pArg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
1178 pParam->param_attributes.ServerAllocSize * 8);
1180 if (pParam->param_attributes.IsIn)
1182 if (pParam->param_attributes.IsByValue)
1183 call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
1185 call_unmarshaller(pStubMsg, (unsigned char **)pArg, pTypeFormat, 0);
1188 case STUBLESS_CALCSIZE:
1189 if (pParam->param_attributes.IsOut || pParam->param_attributes.IsReturn)
1191 if (pParam->param_attributes.IsByValue)
1192 call_buffer_sizer(pStubMsg, pArg, pTypeFormat);
1194 call_buffer_sizer(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
1198 RpcRaiseException(RPC_S_INTERNAL_ERROR);
1201 current_offset += sizeof(NDR_PARAM_OIF_OTHER);
1203 TRACE("\tmemory addr (after): %p -> %p\n", pArg, *(unsigned char **)pArg);
1209 static LONG_PTR *stub_do_old_args(MIDL_STUB_MESSAGE *pStubMsg,
1210 PFORMAT_STRING pFormat, int phase,
1211 unsigned char *args,
1212 unsigned short stack_size, BOOL object)
1216 /* current format string offset */
1217 int current_offset = 0;
1218 /* current stack offset */
1219 unsigned short current_stack_offset = 0;
1220 /* location to put retval into */
1221 LONG_PTR *retval_ptr = NULL;
1223 for (i = 0; TRUE; i++)
1225 const NDR_PARAM_OI_BASETYPE *pParam =
1226 (const NDR_PARAM_OI_BASETYPE *)&pFormat[current_offset];
1227 /* note: current_stack_offset starts after the This pointer
1228 * if present, so adjust this */
1229 unsigned short current_stack_offset_adjusted = current_stack_offset +
1230 (object ? sizeof(void *) : 0);
1231 unsigned char *pArg = args + current_stack_offset_adjusted;
1233 /* no more parameters; exit loop */
1234 if (current_stack_offset_adjusted >= stack_size)
1237 TRACE("param[%d]: old format\n", i);
1238 TRACE("\tparam_direction: 0x%x\n", pParam->param_direction);
1239 TRACE("\tstack_offset: 0x%x\n", current_stack_offset_adjusted);
1241 if (pParam->param_direction == RPC_FC_IN_PARAM_BASETYPE ||
1242 pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
1244 const unsigned char *pTypeFormat =
1245 &pParam->type_format_char;
1247 TRACE("\tbase type 0x%02x\n", *pTypeFormat);
1249 if (pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
1250 retval_ptr = (LONG_PTR *)pArg;
1254 case STUBLESS_MARSHAL:
1255 if (pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
1256 call_marshaller(pStubMsg, pArg, pTypeFormat);
1259 if (pParam->param_direction == RPC_FC_IN_PARAM_BASETYPE)
1260 call_freer(pStubMsg, pArg, pTypeFormat);
1262 case STUBLESS_INITOUT:
1264 case STUBLESS_UNMARSHAL:
1265 if (pParam->param_direction == RPC_FC_IN_PARAM_BASETYPE)
1266 call_unmarshaller(pStubMsg, &pArg, pTypeFormat, 0);
1268 case STUBLESS_CALCSIZE:
1269 if (pParam->param_direction == RPC_FC_RETURN_PARAM_BASETYPE)
1270 call_buffer_sizer(pStubMsg, pArg, pTypeFormat);
1273 RpcRaiseException(RPC_S_INTERNAL_ERROR);
1276 current_stack_offset += type_stack_size(*pTypeFormat);
1277 current_offset += sizeof(NDR_PARAM_OI_BASETYPE);
1281 const NDR_PARAM_OI_OTHER *pParamOther =
1282 (const NDR_PARAM_OI_OTHER *)&pFormat[current_offset];
1284 const unsigned char * pTypeFormat =
1285 &pStubMsg->StubDesc->pFormatTypes[pParamOther->type_offset];
1287 TRACE("\tcomplex type 0x%02x\n", *pTypeFormat);
1289 if (pParam->param_direction == RPC_FC_RETURN_PARAM)
1290 retval_ptr = (LONG_PTR *)pArg;
1294 case STUBLESS_MARSHAL:
1295 if (pParam->param_direction == RPC_FC_OUT_PARAM ||
1296 pParam->param_direction == RPC_FC_IN_OUT_PARAM ||
1297 pParam->param_direction == RPC_FC_RETURN_PARAM)
1298 call_marshaller(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
1301 if (pParam->param_direction == RPC_FC_IN_OUT_PARAM ||
1302 pParam->param_direction == RPC_FC_IN_PARAM)
1303 call_freer(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
1304 else if (pParam->param_direction == RPC_FC_OUT_PARAM)
1305 pStubMsg->pfnFree(*(void **)pArg);
1307 case STUBLESS_INITOUT:
1308 if (pParam->param_direction == RPC_FC_OUT_PARAM)
1310 DWORD size = calc_arg_size(pStubMsg, pTypeFormat);
1314 *(void **)pArg = NdrAllocate(pStubMsg, size);
1315 memset(*(void **)pArg, 0, size);
1319 case STUBLESS_UNMARSHAL:
1320 if (pParam->param_direction == RPC_FC_IN_OUT_PARAM ||
1321 pParam->param_direction == RPC_FC_IN_PARAM)
1322 call_unmarshaller(pStubMsg, (unsigned char **)pArg, pTypeFormat, 0);
1324 case STUBLESS_CALCSIZE:
1325 if (pParam->param_direction == RPC_FC_OUT_PARAM ||
1326 pParam->param_direction == RPC_FC_IN_OUT_PARAM ||
1327 pParam->param_direction == RPC_FC_RETURN_PARAM)
1328 call_buffer_sizer(pStubMsg, *(unsigned char **)pArg, pTypeFormat);
1331 RpcRaiseException(RPC_S_INTERNAL_ERROR);
1334 current_stack_offset += pParamOther->stack_size * sizeof(INT);
1335 current_offset += sizeof(NDR_PARAM_OI_OTHER);
1342 /***********************************************************************
1343 * NdrStubCall2 [RPCRT4.@]
1345 * Unmarshals [in] parameters, calls either a method in an object or a server
1346 * function, marshals any [out] parameters and frees any allocated data.
1349 * Used by stubless MIDL-generated code.
1351 LONG WINAPI NdrStubCall2(
1352 struct IRpcStubBuffer * pThis,
1353 struct IRpcChannelBuffer * pChannel,
1354 PRPC_MESSAGE pRpcMsg,
1355 DWORD * pdwStubPhase)
1357 const MIDL_SERVER_INFO *pServerInfo;
1358 const MIDL_STUB_DESC *pStubDesc;
1359 PFORMAT_STRING pFormat;
1360 MIDL_STUB_MESSAGE stubMsg;
1361 /* pointer to start of stack to pass into stub implementation */
1362 unsigned char * args;
1364 unsigned short stack_size;
1365 /* number of parameters. optional for client to give it to us */
1366 unsigned char number_of_params = ~0;
1367 /* cache of Oif_flags from v2 procedure header */
1368 INTERPRETER_OPT_FLAGS Oif_flags = { 0 };
1369 /* cache of extension flags from NDR_PROC_HEADER_EXTS */
1370 INTERPRETER_OPT_FLAGS2 ext_flags = { 0 };
1371 /* the type of pass we are currently doing */
1373 /* header for procedure string */
1374 const NDR_PROC_HEADER *pProcHeader;
1375 /* offset in format string for start of params */
1376 int parameter_start_offset;
1377 /* current format string offset */
1379 /* -Oif or -Oicf generated format */
1380 BOOL bV2Format = FALSE;
1381 /* location to put retval into */
1382 LONG_PTR *retval_ptr = NULL;
1384 TRACE("pThis %p, pChannel %p, pRpcMsg %p, pdwStubPhase %p\n", pThis, pChannel, pRpcMsg, pdwStubPhase);
1387 pServerInfo = CStdStubBuffer_GetServerInfo(pThis);
1389 pServerInfo = ((RPC_SERVER_INTERFACE *)pRpcMsg->RpcInterfaceInformation)->InterpreterInfo;
1391 pStubDesc = pServerInfo->pStubDesc;
1392 pFormat = pServerInfo->ProcString + pServerInfo->FmtStringOffset[pRpcMsg->ProcNum];
1393 pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0];
1395 TRACE("NDR Version: 0x%x\n", pStubDesc->Version);
1397 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
1399 const NDR_PROC_HEADER_RPC *pProcHeader = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
1400 stack_size = pProcHeader->stack_size;
1401 current_offset = sizeof(NDR_PROC_HEADER_RPC);
1406 stack_size = pProcHeader->stack_size;
1407 current_offset = sizeof(NDR_PROC_HEADER);
1410 TRACE("Oi_flags = 0x%02x\n", pProcHeader->Oi_flags);
1413 switch (pProcHeader->handle_type)
1415 /* explicit binding: parse additional section */
1416 case RPC_FC_BIND_EXPLICIT:
1417 switch (pFormat[current_offset]) /* handle_type */
1419 case RPC_FC_BIND_PRIMITIVE: /* explicit primitive */
1420 current_offset += sizeof(NDR_EHD_PRIMITIVE);
1422 case RPC_FC_BIND_GENERIC: /* explicit generic */
1423 current_offset += sizeof(NDR_EHD_GENERIC);
1425 case RPC_FC_BIND_CONTEXT: /* explicit context */
1426 current_offset += sizeof(NDR_EHD_CONTEXT);
1429 ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
1430 RpcRaiseException(RPC_X_BAD_STUB_DATA);
1433 case RPC_FC_BIND_GENERIC: /* implicit generic */
1434 case RPC_FC_BIND_PRIMITIVE: /* implicit primitive */
1435 case RPC_FC_CALLBACK_HANDLE: /* implicit callback */
1436 case RPC_FC_AUTO_HANDLE: /* implicit auto handle */
1439 ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader->handle_type);
1440 RpcRaiseException(RPC_X_BAD_STUB_DATA);
1443 bV2Format = (pStubDesc->Version >= 0x20000);
1447 const NDR_PROC_PARTIAL_OIF_HEADER *pOIFHeader =
1448 (const NDR_PROC_PARTIAL_OIF_HEADER *)&pFormat[current_offset];
1450 Oif_flags = pOIFHeader->Oi2Flags;
1451 number_of_params = pOIFHeader->number_of_params;
1453 current_offset += sizeof(NDR_PROC_PARTIAL_OIF_HEADER);
1456 TRACE("Oif_flags = "); dump_INTERPRETER_OPT_FLAGS(Oif_flags);
1458 if (Oif_flags.HasExtensions)
1460 const NDR_PROC_HEADER_EXTS *pExtensions =
1461 (const NDR_PROC_HEADER_EXTS *)&pFormat[current_offset];
1462 ext_flags = pExtensions->Flags2;
1463 current_offset += pExtensions->Size;
1466 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
1467 NdrStubInitialize(pRpcMsg, &stubMsg, pStubDesc, pChannel);
1469 NdrServerInitializeNew(pRpcMsg, &stubMsg, pStubDesc);
1471 /* create the full pointer translation tables, if requested */
1472 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
1473 stubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_SERVER);
1475 /* store the RPC flags away */
1476 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
1477 pRpcMsg->RpcFlags = ((const NDR_PROC_HEADER_RPC *)pProcHeader)->rpc_flags;
1479 /* use alternate memory allocation routines */
1480 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCSSALLOC)
1482 NdrRpcSsEnableAllocate(&stubMsg);
1484 FIXME("Set RPCSS memory allocation routines\n");
1487 if (Oif_flags.HasPipes)
1489 FIXME("pipes not supported yet\n");
1490 RpcRaiseException(RPC_X_WRONG_STUB_VERSION); /* FIXME: remove when implemented */
1491 /* init pipes package */
1492 /* NdrPipesInitialize(...) */
1494 if (ext_flags.HasNewCorrDesc)
1496 /* initialize extra correlation package */
1497 FIXME("new correlation description not implemented\n");
1498 stubMsg.fHasNewCorrDesc = TRUE;
1501 /* convert strings, floating point values and endianess into our
1502 * preferred format */
1503 if ((pRpcMsg->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
1504 NdrConvert(&stubMsg, pFormat);
1506 parameter_start_offset = current_offset;
1508 TRACE("allocating memory for stack of size %x\n", stack_size);
1510 args = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, stack_size);
1511 stubMsg.StackTop = args; /* used by conformance of top-level objects */
1513 /* add the implicit This pointer as the first arg to the function if we
1514 * are calling an object method */
1516 *(void **)args = ((CStdStubBuffer *)pThis)->pvServerObject;
1518 for (phase = STUBLESS_UNMARSHAL; phase <= STUBLESS_FREE; phase++)
1520 TRACE("phase = %d\n", phase);
1523 case STUBLESS_CALLSERVER:
1524 /* call the server function */
1525 if (pServerInfo->ThunkTable && pServerInfo->ThunkTable[pRpcMsg->ProcNum])
1526 pServerInfo->ThunkTable[pRpcMsg->ProcNum](&stubMsg);
1529 SERVER_ROUTINE func;
1532 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
1534 SERVER_ROUTINE *vtbl = *(SERVER_ROUTINE **)((CStdStubBuffer *)pThis)->pvServerObject;
1535 func = vtbl[pRpcMsg->ProcNum];
1538 func = pServerInfo->DispatchTable[pRpcMsg->ProcNum];
1540 /* FIXME: what happens with return values that don't fit into a single register on x86? */
1541 retval = call_server_func(func, args, stack_size);
1545 TRACE("stub implementation returned 0x%lx\n", retval);
1546 *retval_ptr = retval;
1549 TRACE("void stub implementation\n");
1552 stubMsg.Buffer = NULL;
1553 stubMsg.BufferLength = 0;
1556 case STUBLESS_GETBUFFER:
1557 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
1558 NdrStubGetBuffer(pThis, pChannel, &stubMsg);
1563 pRpcMsg->BufferLength = stubMsg.BufferLength;
1564 /* allocate buffer for [out] and [ret] params */
1565 Status = I_RpcGetBuffer(pRpcMsg);
1567 RpcRaiseException(Status);
1568 stubMsg.Buffer = pRpcMsg->Buffer;
1571 case STUBLESS_UNMARSHAL:
1572 case STUBLESS_INITOUT:
1573 case STUBLESS_CALCSIZE:
1574 case STUBLESS_MARSHAL:
1577 retval_ptr = stub_do_args(&stubMsg, &pFormat[parameter_start_offset],
1578 phase, args, number_of_params);
1580 retval_ptr = stub_do_old_args(&stubMsg, &pFormat[parameter_start_offset],
1581 phase, args, stack_size,
1582 (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT));
1586 ERR("shouldn't reach here. phase %d\n", phase);
1591 pRpcMsg->BufferLength = (unsigned int)(stubMsg.Buffer - (unsigned char *)pRpcMsg->Buffer);
1593 if (ext_flags.HasNewCorrDesc)
1595 /* free extra correlation package */
1596 /* NdrCorrelationFree(&stubMsg); */
1599 if (Oif_flags.HasPipes)
1601 /* NdrPipesDone(...) */
1604 /* free the full pointer translation tables */
1605 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
1606 NdrFullPointerXlatFree(stubMsg.FullPtrXlatTables);
1608 /* free server function stack */
1609 HeapFree(GetProcessHeap(), 0, args);
1614 /***********************************************************************
1615 * NdrServerCall2 [RPCRT4.@]
1617 void WINAPI NdrServerCall2(PRPC_MESSAGE pRpcMsg)
1620 NdrStubCall2(NULL, NULL, pRpcMsg, &dwPhase);
1623 struct async_call_data
1625 MIDL_STUB_MESSAGE *pStubMsg;
1626 const NDR_PROC_HEADER *pProcHeader;
1627 PFORMAT_STRING pHandleFormat;
1628 PFORMAT_STRING pParamFormat;
1629 RPC_BINDING_HANDLE hBinding;
1631 unsigned short stack_size;
1632 /* number of parameters. optional for client to give it to us */
1633 unsigned char number_of_params;
1634 /* correlation cache */
1635 ULONG_PTR NdrCorrCache[256];
1638 CLIENT_CALL_RETURN WINAPIV NdrAsyncClientCall(PMIDL_STUB_DESC pStubDesc,
1639 PFORMAT_STRING pFormat, ...)
1641 /* pointer to start of stack where arguments start */
1642 PRPC_MESSAGE pRpcMsg;
1643 PMIDL_STUB_MESSAGE pStubMsg;
1644 RPC_ASYNC_STATE *pAsync;
1645 struct async_call_data *async_call_data;
1646 /* procedure number */
1647 unsigned short procedure_number;
1648 /* cache of Oif_flags from v2 procedure header */
1649 INTERPRETER_OPT_FLAGS Oif_flags = { 0 };
1650 /* cache of extension flags from NDR_PROC_HEADER_EXTS */
1651 INTERPRETER_OPT_FLAGS2 ext_flags = { 0 };
1652 /* the type of pass we are currently doing */
1654 /* header for procedure string */
1655 const NDR_PROC_HEADER * pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0];
1656 /* -Oif or -Oicf generated format */
1657 BOOL bV2Format = FALSE;
1661 TRACE("pStubDesc %p, pFormat %p, ...\n", pStubDesc, pFormat);
1663 /* Later NDR language versions probably won't be backwards compatible */
1664 if (pStubDesc->Version > 0x50002)
1666 FIXME("Incompatible stub description version: 0x%x\n", pStubDesc->Version);
1667 RpcRaiseException(RPC_X_WRONG_STUB_VERSION);
1670 async_call_data = I_RpcAllocate(sizeof(*async_call_data) + sizeof(MIDL_STUB_MESSAGE) + sizeof(RPC_MESSAGE));
1671 if (!async_call_data) RpcRaiseException(ERROR_OUTOFMEMORY);
1672 async_call_data->number_of_params = ~0;
1673 async_call_data->pProcHeader = pProcHeader;
1675 async_call_data->pStubMsg = pStubMsg = (PMIDL_STUB_MESSAGE)(async_call_data + 1);
1676 pRpcMsg = (PRPC_MESSAGE)(pStubMsg + 1);
1678 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
1680 const NDR_PROC_HEADER_RPC *pProcHeader = (const NDR_PROC_HEADER_RPC *)&pFormat[0];
1681 async_call_data->stack_size = pProcHeader->stack_size;
1682 procedure_number = pProcHeader->proc_num;
1683 pFormat += sizeof(NDR_PROC_HEADER_RPC);
1687 async_call_data->stack_size = pProcHeader->stack_size;
1688 procedure_number = pProcHeader->proc_num;
1689 pFormat += sizeof(NDR_PROC_HEADER);
1691 TRACE("stack size: 0x%x\n", async_call_data->stack_size);
1692 TRACE("proc num: %d\n", procedure_number);
1694 /* create the full pointer translation tables, if requested */
1695 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
1696 pStubMsg->FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_CLIENT);
1698 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT)
1700 ERR("objects not supported\n");
1701 I_RpcFree(async_call_data);
1702 RpcRaiseException(RPC_X_BAD_STUB_DATA);
1705 NdrClientInitializeNew(pRpcMsg, pStubMsg, pStubDesc, procedure_number);
1707 TRACE("Oi_flags = 0x%02x\n", pProcHeader->Oi_flags);
1708 TRACE("MIDL stub version = 0x%x\n", pStubDesc->MIDLVersion);
1710 /* needed for conformance of top-level objects */
1711 pStubMsg->StackTop = I_RpcAllocate(async_call_data->stack_size);
1712 __ms_va_start( args, pFormat );
1713 memcpy(pStubMsg->StackTop, va_arg( args, unsigned char * ), async_call_data->stack_size);
1714 __ms_va_end( args );
1716 pAsync = *(RPC_ASYNC_STATE **)pStubMsg->StackTop;
1717 pAsync->StubInfo = async_call_data;
1718 async_call_data->pHandleFormat = pFormat;
1720 pFormat = client_get_handle(pStubMsg, pProcHeader, async_call_data->pHandleFormat, &async_call_data->hBinding);
1721 if (!pFormat) goto done;
1723 bV2Format = (pStubDesc->Version >= 0x20000);
1727 const NDR_PROC_PARTIAL_OIF_HEADER *pOIFHeader =
1728 (const NDR_PROC_PARTIAL_OIF_HEADER *)pFormat;
1730 Oif_flags = pOIFHeader->Oi2Flags;
1731 async_call_data->number_of_params = pOIFHeader->number_of_params;
1733 pFormat += sizeof(NDR_PROC_PARTIAL_OIF_HEADER);
1736 TRACE("Oif_flags = "); dump_INTERPRETER_OPT_FLAGS(Oif_flags);
1738 if (Oif_flags.HasExtensions)
1740 const NDR_PROC_HEADER_EXTS *pExtensions =
1741 (const NDR_PROC_HEADER_EXTS *)pFormat;
1742 ext_flags = pExtensions->Flags2;
1743 pFormat += pExtensions->Size;
1746 async_call_data->pParamFormat = pFormat;
1748 pStubMsg->BufferLength = 0;
1750 /* store the RPC flags away */
1751 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCFLAGS)
1752 pRpcMsg->RpcFlags = ((const NDR_PROC_HEADER_RPC *)pProcHeader)->rpc_flags;
1754 /* use alternate memory allocation routines */
1755 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_RPCSSALLOC)
1756 NdrRpcSmSetClientToOsf(pStubMsg);
1758 if (Oif_flags.HasPipes)
1760 FIXME("pipes not supported yet\n");
1761 RpcRaiseException(RPC_X_WRONG_STUB_VERSION); /* FIXME: remove when implemented */
1762 /* init pipes package */
1763 /* NdrPipesInitialize(...) */
1765 if (ext_flags.HasNewCorrDesc)
1767 /* initialize extra correlation package */
1768 NdrCorrelationInitialize(pStubMsg, async_call_data->NdrCorrCache, sizeof(async_call_data->NdrCorrCache), 0);
1772 * 1. PROXY_CALCSIZE - calculate the buffer size
1773 * 2. PROXY_GETBUFFER - allocate the buffer
1774 * 3. PROXY_MARHSAL - marshal [in] params into the buffer
1775 * 4. PROXY_SENDRECEIVE - send buffer
1776 * Then in NdrpCompleteAsyncClientCall:
1777 * 1. PROXY_SENDRECEIVE - receive buffer
1778 * 2. PROXY_UNMARHSAL - unmarshal [out] params from buffer
1780 for (phase = PROXY_CALCSIZE; phase <= PROXY_SENDRECEIVE; phase++)
1783 TRACE("phase = %d\n", phase);
1786 case PROXY_GETBUFFER:
1787 /* allocate the buffer */
1788 if (Oif_flags.HasPipes)
1789 /* NdrGetPipeBuffer(...) */
1790 FIXME("pipes not supported yet\n");
1793 if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
1795 NdrNsGetBuffer(pStubMsg, pStubMsg->BufferLength, async_call_data->hBinding);
1797 FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
1800 NdrGetBuffer(pStubMsg, pStubMsg->BufferLength, async_call_data->hBinding);
1802 pRpcMsg->RpcFlags |= RPC_BUFFER_ASYNC;
1803 status = I_RpcAsyncSetHandle(pRpcMsg, pAsync);
1804 if (status != RPC_S_OK)
1805 RpcRaiseException(status);
1807 case PROXY_SENDRECEIVE:
1808 pRpcMsg->RpcFlags |= RPC_BUFFER_ASYNC;
1809 /* send the [in] params only */
1810 if (Oif_flags.HasPipes)
1811 /* NdrPipesSend(...) */
1812 FIXME("pipes not supported yet\n");
1815 if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
1817 NdrNsSend(&stubMsg, stubMsg.Buffer, pStubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle);
1819 FIXME("using auto handle - call NdrNsSend when it gets implemented\n");
1823 pStubMsg->RpcMsg->BufferLength = pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer;
1824 status = I_RpcSend(pStubMsg->RpcMsg);
1825 if (status != RPC_S_OK)
1826 RpcRaiseException(status);
1831 case PROXY_CALCSIZE:
1834 client_do_args(pStubMsg, pFormat, phase, pStubMsg->StackTop,
1835 async_call_data->number_of_params, NULL);
1837 client_do_args_old_format(pStubMsg, pFormat, phase,
1838 pStubMsg->StackTop, async_call_data->stack_size, NULL,
1839 (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT), FALSE);
1842 ERR("shouldn't reach here. phase %d\n", phase);
1848 TRACE("returning 0\n");
1850 return *(CLIENT_CALL_RETURN *)&RetVal;
1853 RPC_STATUS NdrpCompleteAsyncClientCall(RPC_ASYNC_STATE *pAsync, void *Reply)
1855 /* pointer to start of stack where arguments start */
1856 PMIDL_STUB_MESSAGE pStubMsg;
1857 struct async_call_data *async_call_data;
1858 /* the type of pass we are currently doing */
1860 /* header for procedure string */
1861 const NDR_PROC_HEADER * pProcHeader;
1862 /* -Oif or -Oicf generated format */
1864 RPC_STATUS status = RPC_S_OK;
1866 if (!pAsync->StubInfo)
1867 return RPC_S_INVALID_ASYNC_HANDLE;
1869 async_call_data = pAsync->StubInfo;
1870 pStubMsg = async_call_data->pStubMsg;
1871 pProcHeader = async_call_data->pProcHeader;
1873 bV2Format = (pStubMsg->StubDesc->Version >= 0x20000);
1876 * 1. PROXY_CALCSIZE - calculate the buffer size
1877 * 2. PROXY_GETBUFFER - allocate the buffer
1878 * 3. PROXY_MARHSAL - marshal [in] params into the buffer
1879 * 4. PROXY_SENDRECEIVE - send buffer
1880 * Then in NdrpCompleteAsyncClientCall:
1881 * 1. PROXY_SENDRECEIVE - receive buffer
1882 * 2. PROXY_UNMARHSAL - unmarshal [out] params from buffer
1884 for (phase = PROXY_SENDRECEIVE; phase <= PROXY_UNMARSHAL; phase++)
1888 case PROXY_SENDRECEIVE:
1889 pStubMsg->RpcMsg->RpcFlags |= RPC_BUFFER_ASYNC;
1890 /* receive the [out] params */
1891 if (pProcHeader->handle_type == RPC_FC_AUTO_HANDLE)
1893 NdrNsReceive(&stubMsg, stubMsg.Buffer, pStubDesc->IMPLICIT_HANDLE_INFO.pAutoHandle);
1895 FIXME("using auto handle - call NdrNsReceive when it gets implemented\n");
1899 status = I_RpcReceive(pStubMsg->RpcMsg);
1900 if (status != RPC_S_OK)
1902 pStubMsg->BufferLength = pStubMsg->RpcMsg->BufferLength;
1903 pStubMsg->BufferStart = pStubMsg->RpcMsg->Buffer;
1904 pStubMsg->BufferEnd = pStubMsg->BufferStart + pStubMsg->BufferLength;
1905 pStubMsg->Buffer = pStubMsg->BufferStart;
1908 /* convert strings, floating point values and endianess into our
1909 * preferred format */
1911 if ((pStubMsg->RpcMsg.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)
1912 NdrConvert(pStubMsg, pFormat);
1916 case PROXY_UNMARSHAL:
1918 client_do_args(pStubMsg, async_call_data->pParamFormat, phase, pStubMsg->StackTop,
1919 async_call_data->number_of_params, Reply);
1921 client_do_args_old_format(pStubMsg, async_call_data->pParamFormat, phase,
1922 pStubMsg->StackTop, async_call_data->stack_size, Reply, FALSE, FALSE);
1925 ERR("shouldn't reach here. phase %d\n", phase);
1931 if (pStubMsg->fHasNewCorrDesc)
1933 /* free extra correlation package */
1934 NdrCorrelationFree(pStubMsg);
1937 /* free the full pointer translation tables */
1938 if (pProcHeader->Oi_flags & RPC_FC_PROC_OIF_FULLPTR)
1939 NdrFullPointerXlatFree(pStubMsg->FullPtrXlatTables);
1941 /* free marshalling buffer */
1942 NdrFreeBuffer(pStubMsg);
1943 client_free_handle(pStubMsg, pProcHeader, async_call_data->pHandleFormat, async_call_data->hBinding);
1945 I_RpcFree(pStubMsg->StackTop);
1946 I_RpcFree(async_call_data);
1948 TRACE("-- 0x%x\n", status);
1952 RPCRTAPI LONG RPC_ENTRY NdrAsyncStubCall(struct IRpcStubBuffer* pThis,
1953 struct IRpcChannelBuffer* pChannel, PRPC_MESSAGE pRpcMsg,
1954 DWORD * pdwStubPhase)
1956 FIXME("unimplemented, expect crash!\n");