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 BOOL
is_oicf_stubdesc(const PMIDL_STUB_DESC pStubDesc
)
55 return pStubDesc
->Version
>= 0x20000;
58 static inline void call_buffer_sizer(PMIDL_STUB_MESSAGE pStubMsg
, unsigned char *pMemory
,
59 const NDR_PARAM_OIF
*param
)
61 PFORMAT_STRING pFormat
;
64 if (param
->attr
.IsBasetype
)
66 pFormat
= ¶m
->u
.type_format_char
;
67 if (param
->attr
.IsSimpleRef
) pMemory
= *(unsigned char **)pMemory
;
71 pFormat
= &pStubMsg
->StubDesc
->pFormatTypes
[param
->u
.type_offset
];
72 if (!param
->attr
.IsByValue
) pMemory
= *(unsigned char **)pMemory
;
75 m
= NdrBufferSizer
[pFormat
[0] & NDR_TABLE_MASK
];
76 if (m
) m(pStubMsg
, pMemory
, pFormat
);
79 FIXME("format type 0x%x not implemented\n", pFormat
[0]);
80 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
84 static inline unsigned char *call_marshaller(PMIDL_STUB_MESSAGE pStubMsg
, unsigned char *pMemory
,
85 const NDR_PARAM_OIF
*param
)
87 PFORMAT_STRING pFormat
;
90 if (param
->attr
.IsBasetype
)
92 pFormat
= ¶m
->u
.type_format_char
;
93 if (param
->attr
.IsSimpleRef
) pMemory
= *(unsigned char **)pMemory
;
97 pFormat
= &pStubMsg
->StubDesc
->pFormatTypes
[param
->u
.type_offset
];
98 if (!param
->attr
.IsByValue
) pMemory
= *(unsigned char **)pMemory
;
101 m
= NdrMarshaller
[pFormat
[0] & NDR_TABLE_MASK
];
102 if (m
) return m(pStubMsg
, pMemory
, pFormat
);
105 FIXME("format type 0x%x not implemented\n", pFormat
[0]);
106 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
111 static inline unsigned char *call_unmarshaller(PMIDL_STUB_MESSAGE pStubMsg
, unsigned char **ppMemory
,
112 const NDR_PARAM_OIF
*param
, unsigned char fMustAlloc
)
114 PFORMAT_STRING pFormat
;
117 if (param
->attr
.IsBasetype
)
119 pFormat
= ¶m
->u
.type_format_char
;
120 if (param
->attr
.IsSimpleRef
) ppMemory
= (unsigned char **)*ppMemory
;
124 pFormat
= &pStubMsg
->StubDesc
->pFormatTypes
[param
->u
.type_offset
];
125 if (!param
->attr
.IsByValue
) ppMemory
= (unsigned char **)*ppMemory
;
128 m
= NdrUnmarshaller
[pFormat
[0] & NDR_TABLE_MASK
];
129 if (m
) return m(pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
132 FIXME("format type 0x%x not implemented\n", pFormat
[0]);
133 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
138 static inline void call_freer(PMIDL_STUB_MESSAGE pStubMsg
, unsigned char *pMemory
,
139 const NDR_PARAM_OIF
*param
)
141 PFORMAT_STRING pFormat
;
144 if (param
->attr
.IsBasetype
) return; /* nothing to do */
145 pFormat
= &pStubMsg
->StubDesc
->pFormatTypes
[param
->u
.type_offset
];
146 if (!param
->attr
.IsByValue
) pMemory
= *(unsigned char **)pMemory
;
148 m
= NdrFreer
[pFormat
[0] & NDR_TABLE_MASK
];
149 if (m
) m(pStubMsg
, pMemory
, pFormat
);
152 static DWORD
calc_arg_size(MIDL_STUB_MESSAGE
*pStubMsg
, PFORMAT_STRING pFormat
)
158 if (pFormat
[1] & RPC_FC_P_SIMPLEPOINTER
)
160 FIXME("Simple reference pointer (type %#x).\n", pFormat
[2]);
161 size
= sizeof(void *);
164 size
= calc_arg_size(pStubMsg
, &pFormat
[2] + *(const SHORT
*)&pFormat
[2]);
168 size
= *(const WORD
*)(pFormat
+ 2);
170 case RPC_FC_BOGUS_STRUCT
:
171 size
= *(const WORD
*)(pFormat
+ 2);
172 if(*(const WORD
*)(pFormat
+ 4))
173 FIXME("Unhandled conformant description\n");
177 size
= *(const WORD
*)(pFormat
+ 2);
178 ComputeConformance(pStubMsg
, NULL
, pFormat
+ 4, 0);
179 size
*= pStubMsg
->MaxCount
;
181 case RPC_FC_SMFARRAY
:
182 case RPC_FC_SMVARRAY
:
183 size
= *(const WORD
*)(pFormat
+ 2);
185 case RPC_FC_LGFARRAY
:
186 case RPC_FC_LGVARRAY
:
187 size
= *(const DWORD
*)(pFormat
+ 2);
189 case RPC_FC_BOGUS_ARRAY
:
190 pFormat
= ComputeConformance(pStubMsg
, NULL
, pFormat
+ 4, *(const WORD
*)&pFormat
[2]);
191 TRACE("conformance = %ld\n", pStubMsg
->MaxCount
);
192 pFormat
= ComputeVariance(pStubMsg
, NULL
, pFormat
, pStubMsg
->MaxCount
);
193 size
= ComplexStructSize(pStubMsg
, pFormat
);
194 size
*= pStubMsg
->MaxCount
;
196 case RPC_FC_USER_MARSHAL
:
197 size
= *(const WORD
*)(pFormat
+ 4);
200 size
= *(const WORD
*)(pFormat
+ 2);
203 size
= *(const WORD
*)(pFormat
+ 2) * sizeof(WCHAR
);
205 case RPC_FC_C_CSTRING
:
206 case RPC_FC_C_WSTRING
:
207 if (*pFormat
== RPC_FC_C_CSTRING
)
210 size
= sizeof(WCHAR
);
211 if (pFormat
[1] == RPC_FC_STRING_SIZED
)
212 ComputeConformance(pStubMsg
, NULL
, pFormat
+ 2, 0);
214 pStubMsg
->MaxCount
= 0;
215 size
*= pStubMsg
->MaxCount
;
218 FIXME("Unhandled type %02x\n", *pFormat
);
221 size
= sizeof(void *);
227 void WINAPI
NdrRpcSmSetClientToOsf(PMIDL_STUB_MESSAGE pMessage
)
229 #if 0 /* these functions are not defined yet */
230 pMessage
->pfnAllocate
= NdrRpcSmClientAllocate
;
231 pMessage
->pfnFree
= NdrRpcSmClientFree
;
235 static const char *debugstr_PROC_PF(PARAM_ATTRIBUTES param_attributes
)
240 if (param_attributes
.MustSize
) strcat(buffer
, " MustSize");
241 if (param_attributes
.MustFree
) strcat(buffer
, " MustFree");
242 if (param_attributes
.IsPipe
) strcat(buffer
, " IsPipe");
243 if (param_attributes
.IsIn
) strcat(buffer
, " IsIn");
244 if (param_attributes
.IsOut
) strcat(buffer
, " IsOut");
245 if (param_attributes
.IsReturn
) strcat(buffer
, " IsReturn");
246 if (param_attributes
.IsBasetype
) strcat(buffer
, " IsBasetype");
247 if (param_attributes
.IsByValue
) strcat(buffer
, " IsByValue");
248 if (param_attributes
.IsSimpleRef
) strcat(buffer
, " IsSimpleRef");
249 if (param_attributes
.IsDontCallFreeInst
) strcat(buffer
, " IsDontCallFreeInst");
250 if (param_attributes
.SaveForAsyncFinish
) strcat(buffer
, " SaveForAsyncFinish");
251 if (param_attributes
.ServerAllocSize
)
252 sprintf( buffer
+ strlen(buffer
), " ServerAllocSize = %d", param_attributes
.ServerAllocSize
* 8);
253 return buffer
[0] ? wine_dbg_sprintf( "%s", buffer
+ 1 ) : "";
256 static const char *debugstr_INTERPRETER_OPT_FLAGS(INTERPRETER_OPT_FLAGS Oi2Flags
)
261 if (Oi2Flags
.ServerMustSize
) strcat(buffer
, " ServerMustSize");
262 if (Oi2Flags
.ClientMustSize
) strcat(buffer
, " ClientMustSize");
263 if (Oi2Flags
.HasReturn
) strcat(buffer
, " HasReturn");
264 if (Oi2Flags
.HasPipes
) strcat(buffer
, " HasPipes");
265 if (Oi2Flags
.Unused
) strcat(buffer
, " Unused");
266 if (Oi2Flags
.HasAsyncUuid
) strcat(buffer
, " HasAsyncUuid");
267 if (Oi2Flags
.HasExtensions
) strcat(buffer
, " HasExtensions");
268 if (Oi2Flags
.HasAsyncHandle
) strcat(buffer
, " HasAsyncHandle");
269 return buffer
[0] ? wine_dbg_sprintf( "%s", buffer
+ 1 ) : "";
272 #define ARG_FROM_OFFSET(args, offset) ((args) + (offset))
274 static PFORMAT_STRING
client_get_handle(
275 PMIDL_STUB_MESSAGE pStubMsg
, const NDR_PROC_HEADER
*pProcHeader
,
276 PFORMAT_STRING pFormat
, handle_t
*phBinding
)
279 switch (pProcHeader
->handle_type
)
281 /* explicit binding: parse additional section */
282 case RPC_FC_BIND_EXPLICIT
:
283 switch (*pFormat
) /* handle_type */
285 case RPC_FC_BIND_PRIMITIVE
: /* explicit primitive */
287 const NDR_EHD_PRIMITIVE
*pDesc
= (const NDR_EHD_PRIMITIVE
*)pFormat
;
289 TRACE("Explicit primitive handle @ %d\n", pDesc
->offset
);
291 if (pDesc
->flag
) /* pointer to binding */
292 *phBinding
= **(handle_t
**)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
294 *phBinding
= *(handle_t
*)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
295 return pFormat
+ sizeof(NDR_EHD_PRIMITIVE
);
297 case RPC_FC_BIND_GENERIC
: /* explicit generic */
299 const NDR_EHD_GENERIC
*pDesc
= (const NDR_EHD_GENERIC
*)pFormat
;
300 void *pObject
= NULL
;
302 const GENERIC_BINDING_ROUTINE_PAIR
*pGenPair
;
304 TRACE("Explicit generic binding handle #%d\n", pDesc
->binding_routine_pair_index
);
306 if (pDesc
->flag_and_size
& HANDLE_PARAM_IS_VIA_PTR
)
307 pArg
= *(void **)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
309 pArg
= ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
310 memcpy(&pObject
, pArg
, pDesc
->flag_and_size
& 0xf);
311 pGenPair
= &pStubMsg
->StubDesc
->aGenericBindingRoutinePairs
[pDesc
->binding_routine_pair_index
];
312 *phBinding
= pGenPair
->pfnBind(pObject
);
313 return pFormat
+ sizeof(NDR_EHD_GENERIC
);
315 case RPC_FC_BIND_CONTEXT
: /* explicit context */
317 const NDR_EHD_CONTEXT
*pDesc
= (const NDR_EHD_CONTEXT
*)pFormat
;
318 NDR_CCONTEXT context_handle
;
319 TRACE("Explicit bind context\n");
320 if (pDesc
->flags
& HANDLE_PARAM_IS_VIA_PTR
)
322 TRACE("\tHANDLE_PARAM_IS_VIA_PTR\n");
323 context_handle
= **(NDR_CCONTEXT
**)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
326 context_handle
= *(NDR_CCONTEXT
*)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
328 if (context_handle
) *phBinding
= NDRCContextBinding(context_handle
);
329 else if (pDesc
->flags
& NDR_CONTEXT_HANDLE_CANNOT_BE_NULL
)
331 ERR("null context handle isn't allowed\n");
332 RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT
);
335 /* FIXME: should we store this structure in stubMsg.pContext? */
336 return pFormat
+ sizeof(NDR_EHD_CONTEXT
);
339 ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
340 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
343 case RPC_FC_BIND_GENERIC
: /* implicit generic */
344 FIXME("RPC_FC_BIND_GENERIC\n");
345 RpcRaiseException(RPC_X_BAD_STUB_DATA
); /* FIXME: remove when implemented */
347 case RPC_FC_BIND_PRIMITIVE
: /* implicit primitive */
348 TRACE("Implicit primitive handle\n");
349 *phBinding
= *pStubMsg
->StubDesc
->IMPLICIT_HANDLE_INFO
.pPrimitiveHandle
;
351 case RPC_FC_CALLBACK_HANDLE
: /* implicit callback */
352 TRACE("RPC_FC_CALLBACK_HANDLE\n");
353 /* server calls callback procedures only in response to remote call, and most recent
354 binding handle is used. Calling back to a client can potentially result in another
355 callback with different current handle. */
356 *phBinding
= I_RpcGetCurrentCallHandle();
358 case RPC_FC_AUTO_HANDLE
: /* implicit auto handle */
359 /* strictly speaking, it isn't necessary to set hBinding here
360 * since it isn't actually used (hence the automatic in its name),
361 * but then why does MIDL generate a valid entry in the
362 * MIDL_STUB_DESC for it? */
363 TRACE("Implicit auto handle\n");
364 *phBinding
= *pStubMsg
->StubDesc
->IMPLICIT_HANDLE_INFO
.pAutoHandle
;
367 ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
368 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
373 static void client_free_handle(
374 PMIDL_STUB_MESSAGE pStubMsg
, const NDR_PROC_HEADER
*pProcHeader
,
375 PFORMAT_STRING pFormat
, handle_t hBinding
)
378 switch (pProcHeader
->handle_type
)
380 /* explicit binding: parse additional section */
381 case RPC_FC_BIND_EXPLICIT
:
382 switch (*pFormat
) /* handle_type */
384 case RPC_FC_BIND_GENERIC
: /* explicit generic */
386 const NDR_EHD_GENERIC
*pDesc
= (const NDR_EHD_GENERIC
*)pFormat
;
387 void *pObject
= NULL
;
389 const GENERIC_BINDING_ROUTINE_PAIR
*pGenPair
;
391 TRACE("Explicit generic binding handle #%d\n", pDesc
->binding_routine_pair_index
);
393 if (pDesc
->flag_and_size
& HANDLE_PARAM_IS_VIA_PTR
)
394 pArg
= *(void **)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
396 pArg
= ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
397 memcpy(&pObject
, pArg
, pDesc
->flag_and_size
& 0xf);
398 pGenPair
= &pStubMsg
->StubDesc
->aGenericBindingRoutinePairs
[pDesc
->binding_routine_pair_index
];
399 pGenPair
->pfnUnbind(pObject
, hBinding
);
402 case RPC_FC_BIND_CONTEXT
: /* explicit context */
403 case RPC_FC_BIND_PRIMITIVE
: /* explicit primitive */
406 ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
407 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
410 case RPC_FC_BIND_GENERIC
: /* implicit generic */
411 FIXME("RPC_FC_BIND_GENERIC\n");
412 RpcRaiseException(RPC_X_BAD_STUB_DATA
); /* FIXME: remove when implemented */
414 case RPC_FC_CALLBACK_HANDLE
: /* implicit callback */
415 case RPC_FC_BIND_PRIMITIVE
: /* implicit primitive */
416 case RPC_FC_AUTO_HANDLE
: /* implicit auto handle */
419 ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
420 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
424 void client_do_args( PMIDL_STUB_MESSAGE pStubMsg
, PFORMAT_STRING pFormat
, enum stubless_phase phase
,
425 void **fpu_args
, unsigned short number_of_params
, unsigned char *pRetVal
)
427 const NDR_PARAM_OIF
*params
= (const NDR_PARAM_OIF
*)pFormat
;
430 for (i
= 0; i
< number_of_params
; i
++)
432 unsigned char *pArg
= pStubMsg
->StackTop
+ params
[i
].stack_offset
;
433 PFORMAT_STRING pTypeFormat
= (PFORMAT_STRING
)&pStubMsg
->StubDesc
->pFormatTypes
[params
[i
].u
.type_offset
];
435 #ifdef __x86_64__ /* floats are passed as doubles through varargs functions */
438 if (params
[i
].attr
.IsBasetype
&&
439 params
[i
].u
.type_format_char
== RPC_FC_FLOAT
&&
440 !params
[i
].attr
.IsSimpleRef
&&
444 pArg
= (unsigned char *)&f
;
448 TRACE("param[%d]: %p type %02x %s\n", i
, pArg
,
449 params
[i
].attr
.IsBasetype
? params
[i
].u
.type_format_char
: *pTypeFormat
,
450 debugstr_PROC_PF( params
[i
].attr
));
454 case STUBLESS_INITOUT
:
455 if (!params
[i
].attr
.IsBasetype
&& params
[i
].attr
.IsOut
&&
456 !params
[i
].attr
.IsIn
&& !params
[i
].attr
.IsByValue
)
458 memset( *(unsigned char **)pArg
, 0, calc_arg_size( pStubMsg
, pTypeFormat
));
461 case STUBLESS_CALCSIZE
:
462 if (params
[i
].attr
.IsSimpleRef
&& !*(unsigned char **)pArg
)
463 RpcRaiseException(RPC_X_NULL_REF_POINTER
);
464 if (params
[i
].attr
.IsIn
) call_buffer_sizer(pStubMsg
, pArg
, ¶ms
[i
]);
466 case STUBLESS_MARSHAL
:
467 if (params
[i
].attr
.IsIn
) call_marshaller(pStubMsg
, pArg
, ¶ms
[i
]);
469 case STUBLESS_UNMARSHAL
:
470 if (params
[i
].attr
.IsOut
)
472 if (params
[i
].attr
.IsReturn
&& pRetVal
) pArg
= pRetVal
;
473 call_unmarshaller(pStubMsg
, &pArg
, ¶ms
[i
], 0);
477 if (!params
[i
].attr
.IsBasetype
&& params
[i
].attr
.IsOut
&& !params
[i
].attr
.IsByValue
)
478 NdrClearOutParameters( pStubMsg
, pTypeFormat
, *(unsigned char **)pArg
);
481 RpcRaiseException(RPC_S_INTERNAL_ERROR
);
486 static unsigned int type_stack_size(unsigned char fc
)
500 case RPC_FC_UINT3264
:
504 case RPC_FC_ERROR_STATUS_T
:
506 return sizeof(void *);
508 return sizeof(double);
510 return sizeof(ULONGLONG
);
512 ERR("invalid base type 0x%x\n", fc
);
513 RpcRaiseException(RPC_S_INTERNAL_ERROR
);
517 static BOOL
is_by_value( PFORMAT_STRING format
)
521 case RPC_FC_USER_MARSHAL
:
525 case RPC_FC_CPSTRUCT
:
526 case RPC_FC_CVSTRUCT
:
527 case RPC_FC_BOGUS_STRUCT
:
534 PFORMAT_STRING
convert_old_args( PMIDL_STUB_MESSAGE pStubMsg
, PFORMAT_STRING pFormat
,
535 unsigned int stack_size
, BOOL object_proc
,
536 void *buffer
, unsigned int size
, unsigned int *count
)
538 NDR_PARAM_OIF
*args
= buffer
;
539 unsigned int i
, stack_offset
= object_proc
? sizeof(void *) : 0;
541 for (i
= 0; stack_offset
< stack_size
; i
++)
543 const NDR_PARAM_OI_BASETYPE
*param
= (const NDR_PARAM_OI_BASETYPE
*)pFormat
;
544 const NDR_PARAM_OI_OTHER
*other
= (const NDR_PARAM_OI_OTHER
*)pFormat
;
546 if (i
+ 1 > size
/ sizeof(*args
))
548 FIXME( "%u args not supported\n", i
);
549 RpcRaiseException( RPC_S_INTERNAL_ERROR
);
552 args
[i
].stack_offset
= stack_offset
;
553 memset( &args
[i
].attr
, 0, sizeof(args
[i
].attr
) );
555 switch (param
->param_direction
)
557 case RPC_FC_IN_PARAM_BASETYPE
:
558 args
[i
].attr
.IsIn
= 1;
559 args
[i
].attr
.IsBasetype
= 1;
561 case RPC_FC_RETURN_PARAM_BASETYPE
:
562 args
[i
].attr
.IsOut
= 1;
563 args
[i
].attr
.IsReturn
= 1;
564 args
[i
].attr
.IsBasetype
= 1;
566 case RPC_FC_IN_PARAM
:
567 args
[i
].attr
.IsIn
= 1;
568 args
[i
].attr
.MustFree
= 1;
570 case RPC_FC_IN_PARAM_NO_FREE_INST
:
571 args
[i
].attr
.IsIn
= 1;
572 args
[i
].attr
.IsDontCallFreeInst
= 1;
574 case RPC_FC_IN_OUT_PARAM
:
575 args
[i
].attr
.IsIn
= 1;
576 args
[i
].attr
.IsOut
= 1;
577 args
[i
].attr
.MustFree
= 1;
579 case RPC_FC_OUT_PARAM
:
580 args
[i
].attr
.IsOut
= 1;
582 case RPC_FC_RETURN_PARAM
:
583 args
[i
].attr
.IsOut
= 1;
584 args
[i
].attr
.IsReturn
= 1;
587 if (args
[i
].attr
.IsBasetype
)
589 args
[i
].u
.type_format_char
= param
->type_format_char
;
590 stack_offset
+= type_stack_size( param
->type_format_char
);
591 pFormat
+= sizeof(NDR_PARAM_OI_BASETYPE
);
595 args
[i
].u
.type_offset
= other
->type_offset
;
596 args
[i
].attr
.IsByValue
= is_by_value( &pStubMsg
->StubDesc
->pFormatTypes
[other
->type_offset
] );
597 stack_offset
+= other
->stack_size
* sizeof(void *);
598 pFormat
+= sizeof(NDR_PARAM_OI_OTHER
);
602 return (PFORMAT_STRING
)args
;
605 LONG_PTR CDECL DECLSPEC_HIDDEN
ndr_client_call( PMIDL_STUB_DESC pStubDesc
, PFORMAT_STRING pFormat
,
606 void **stack_top
, void **fpu_stack
)
608 /* pointer to start of stack where arguments start */
610 MIDL_STUB_MESSAGE stubMsg
;
611 handle_t hBinding
= NULL
;
612 /* procedure number */
613 unsigned short procedure_number
;
615 unsigned short stack_size
;
616 /* number of parameters. optional for client to give it to us */
617 unsigned int number_of_params
;
618 /* cache of Oif_flags from v2 procedure header */
619 INTERPRETER_OPT_FLAGS Oif_flags
= { 0 };
620 /* cache of extension flags from NDR_PROC_HEADER_EXTS */
621 INTERPRETER_OPT_FLAGS2 ext_flags
= { 0 };
622 /* header for procedure string */
623 const NDR_PROC_HEADER
* pProcHeader
= (const NDR_PROC_HEADER
*)&pFormat
[0];
624 /* the value to return to the client from the remote procedure */
626 /* the pointer to the object when in OLE mode */
628 PFORMAT_STRING pHandleFormat
;
629 /* correlation cache */
630 ULONG_PTR NdrCorrCache
[256];
632 TRACE("pStubDesc %p, pFormat %p, ...\n", pStubDesc
, pFormat
);
634 TRACE("NDR Version: 0x%x\n", pStubDesc
->Version
);
636 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCFLAGS
)
638 const NDR_PROC_HEADER_RPC
*header_rpc
= (const NDR_PROC_HEADER_RPC
*)&pFormat
[0];
639 stack_size
= header_rpc
->stack_size
;
640 procedure_number
= header_rpc
->proc_num
;
641 pFormat
+= sizeof(NDR_PROC_HEADER_RPC
);
645 stack_size
= pProcHeader
->stack_size
;
646 procedure_number
= pProcHeader
->proc_num
;
647 pFormat
+= sizeof(NDR_PROC_HEADER
);
649 TRACE("stack size: 0x%x\n", stack_size
);
650 TRACE("proc num: %d\n", procedure_number
);
652 /* create the full pointer translation tables, if requested */
653 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_FULLPTR
)
654 stubMsg
.FullPtrXlatTables
= NdrFullPointerXlatInit(0,XLAT_CLIENT
);
656 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
658 /* object is always the first argument */
660 NdrProxyInitialize(This
, &rpcMsg
, &stubMsg
, pStubDesc
, procedure_number
);
663 NdrClientInitializeNew(&rpcMsg
, &stubMsg
, pStubDesc
, procedure_number
);
665 TRACE("Oi_flags = 0x%02x\n", pProcHeader
->Oi_flags
);
666 TRACE("MIDL stub version = 0x%x\n", pStubDesc
->MIDLVersion
);
668 stubMsg
.StackTop
= (unsigned char *)stack_top
;
669 pHandleFormat
= pFormat
;
671 /* we only need a handle if this isn't an object method */
672 if (!(pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
))
674 pFormat
= client_get_handle(&stubMsg
, pProcHeader
, pHandleFormat
, &hBinding
);
675 if (!pFormat
) goto done
;
678 if (is_oicf_stubdesc(pStubDesc
)) /* -Oicf format */
680 const NDR_PROC_PARTIAL_OIF_HEADER
*pOIFHeader
=
681 (const NDR_PROC_PARTIAL_OIF_HEADER
*)pFormat
;
683 Oif_flags
= pOIFHeader
->Oi2Flags
;
684 number_of_params
= pOIFHeader
->number_of_params
;
686 pFormat
+= sizeof(NDR_PROC_PARTIAL_OIF_HEADER
);
688 TRACE("Oif_flags = %s\n", debugstr_INTERPRETER_OPT_FLAGS(Oif_flags
) );
690 if (Oif_flags
.HasExtensions
)
692 const NDR_PROC_HEADER_EXTS
*pExtensions
= (const NDR_PROC_HEADER_EXTS
*)pFormat
;
693 ext_flags
= pExtensions
->Flags2
;
694 pFormat
+= pExtensions
->Size
;
696 if (pExtensions
->Size
> sizeof(*pExtensions
) && fpu_stack
)
699 unsigned short fpu_mask
= *(unsigned short *)(pExtensions
+ 1);
700 for (i
= 0; i
< 4; i
++, fpu_mask
>>= 2)
701 switch (fpu_mask
& 3)
703 case 1: *(float *)&stack_top
[i
] = *(float *)&fpu_stack
[i
]; break;
704 case 2: *(double *)&stack_top
[i
] = *(double *)&fpu_stack
[i
]; break;
712 pFormat
= convert_old_args( &stubMsg
, pFormat
, stack_size
,
713 pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
,
714 /* reuse the correlation cache, it's not needed for v1 format */
715 NdrCorrCache
, sizeof(NdrCorrCache
), &number_of_params
);
718 stubMsg
.BufferLength
= 0;
720 /* store the RPC flags away */
721 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCFLAGS
)
722 rpcMsg
.RpcFlags
= ((const NDR_PROC_HEADER_RPC
*)pProcHeader
)->rpc_flags
;
724 /* use alternate memory allocation routines */
725 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCSSALLOC
)
726 NdrRpcSmSetClientToOsf(&stubMsg
);
728 if (Oif_flags
.HasPipes
)
730 FIXME("pipes not supported yet\n");
731 RpcRaiseException(RPC_X_WRONG_STUB_VERSION
); /* FIXME: remove when implemented */
732 /* init pipes package */
733 /* NdrPipesInitialize(...) */
735 if (ext_flags
.HasNewCorrDesc
)
737 /* initialize extra correlation package */
738 NdrCorrelationInitialize(&stubMsg
, NdrCorrCache
, sizeof(NdrCorrCache
), 0);
739 if (ext_flags
.Unused
& 0x2) /* has range on conformance */
740 stubMsg
.CorrDespIncrement
= 12;
744 * 1. INITOUT - zero [out] parameters (proxies only)
745 * 2. CALCSIZE - calculate the buffer size
746 * 3. GETBUFFER - allocate the buffer
747 * 4. MARSHAL - marshal [in] params into the buffer
748 * 5. SENDRECEIVE - send/receive buffer
749 * 6. UNMARSHAL - unmarshal [out] params from buffer
750 * 7. FREE - clear [out] parameters (for proxies, and only on error)
752 if ((pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
) ||
753 (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_HAS_COMM_OR_FAULT
))
756 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
758 TRACE( "INITOUT\n" );
759 client_do_args(&stubMsg
, pFormat
, STUBLESS_INITOUT
, fpu_stack
,
760 number_of_params
, (unsigned char *)&RetVal
);
766 TRACE( "CALCSIZE\n" );
767 client_do_args(&stubMsg
, pFormat
, STUBLESS_CALCSIZE
, fpu_stack
,
768 number_of_params
, (unsigned char *)&RetVal
);
771 TRACE( "GETBUFFER\n" );
772 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
774 /* allocate the buffer */
775 NdrProxyGetBuffer(This
, &stubMsg
);
779 /* allocate the buffer */
780 if (Oif_flags
.HasPipes
)
781 /* NdrGetPipeBuffer(...) */
782 FIXME("pipes not supported yet\n");
785 if (pProcHeader
->handle_type
== RPC_FC_AUTO_HANDLE
)
787 NdrNsGetBuffer(&stubMsg
, stubMsg
.BufferLength
, hBinding
);
789 FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
792 NdrGetBuffer(&stubMsg
, stubMsg
.BufferLength
, hBinding
);
797 TRACE( "MARSHAL\n" );
798 client_do_args(&stubMsg
, pFormat
, STUBLESS_MARSHAL
, fpu_stack
,
799 number_of_params
, (unsigned char *)&RetVal
);
802 TRACE( "SENDRECEIVE\n" );
803 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
805 /* send the [in] params and receive the [out] and [retval]
807 NdrProxySendReceive(This
, &stubMsg
);
811 /* send the [in] params and receive the [out] and [retval]
813 if (Oif_flags
.HasPipes
)
814 /* NdrPipesSendReceive(...) */
815 FIXME("pipes not supported yet\n");
818 if (pProcHeader
->handle_type
== RPC_FC_AUTO_HANDLE
)
820 NdrNsSendReceive(&stubMsg
, stubMsg
.Buffer
, pStubDesc
->IMPLICIT_HANDLE_INFO
.pAutoHandle
);
822 FIXME("using auto handle - call NdrNsSendReceive when it gets implemented\n");
825 NdrSendReceive(&stubMsg
, stubMsg
.Buffer
);
829 /* convert strings, floating point values and endianness into our
830 * preferred format */
831 if ((rpcMsg
.DataRepresentation
& 0x0000FFFFUL
) != NDR_LOCAL_DATA_REPRESENTATION
)
832 NdrConvert(&stubMsg
, pFormat
);
835 TRACE( "UNMARSHAL\n" );
836 client_do_args(&stubMsg
, pFormat
, STUBLESS_UNMARSHAL
, fpu_stack
,
837 number_of_params
, (unsigned char *)&RetVal
);
841 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
845 client_do_args(&stubMsg
, pFormat
, STUBLESS_FREE
, fpu_stack
,
846 number_of_params
, (unsigned char *)&RetVal
);
847 RetVal
= NdrProxyErrorHandler(GetExceptionCode());
851 const COMM_FAULT_OFFSETS
*comm_fault_offsets
= &pStubDesc
->CommFaultOffsets
[procedure_number
];
855 TRACE("comm_fault_offsets = {0x%hx, 0x%hx}\n", comm_fault_offsets
->CommOffset
, comm_fault_offsets
->FaultOffset
);
857 if (comm_fault_offsets
->CommOffset
== -1)
858 comm_status
= (ULONG
*)&RetVal
;
859 else if (comm_fault_offsets
->CommOffset
>= 0)
860 comm_status
= *(ULONG
**)ARG_FROM_OFFSET(stubMsg
.StackTop
, comm_fault_offsets
->CommOffset
);
864 if (comm_fault_offsets
->FaultOffset
== -1)
865 fault_status
= (ULONG
*)&RetVal
;
866 else if (comm_fault_offsets
->FaultOffset
>= 0)
867 fault_status
= *(ULONG
**)ARG_FROM_OFFSET(stubMsg
.StackTop
, comm_fault_offsets
->FaultOffset
);
871 NdrMapCommAndFaultStatus(&stubMsg
, comm_status
, fault_status
,
880 TRACE( "CALCSIZE\n" );
881 client_do_args(&stubMsg
, pFormat
, STUBLESS_CALCSIZE
, fpu_stack
,
882 number_of_params
, (unsigned char *)&RetVal
);
885 TRACE( "GETBUFFER\n" );
886 if (Oif_flags
.HasPipes
)
887 /* NdrGetPipeBuffer(...) */
888 FIXME("pipes not supported yet\n");
891 if (pProcHeader
->handle_type
== RPC_FC_AUTO_HANDLE
)
893 NdrNsGetBuffer(&stubMsg
, stubMsg
.BufferLength
, hBinding
);
895 FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
898 NdrGetBuffer(&stubMsg
, stubMsg
.BufferLength
, hBinding
);
902 TRACE( "MARSHAL\n" );
903 client_do_args(&stubMsg
, pFormat
, STUBLESS_MARSHAL
, fpu_stack
,
904 number_of_params
, (unsigned char *)&RetVal
);
907 TRACE( "SENDRECEIVE\n" );
908 if (Oif_flags
.HasPipes
)
909 /* NdrPipesSendReceive(...) */
910 FIXME("pipes not supported yet\n");
913 if (pProcHeader
->handle_type
== RPC_FC_AUTO_HANDLE
)
915 NdrNsSendReceive(&stubMsg
, stubMsg
.Buffer
, pStubDesc
->IMPLICIT_HANDLE_INFO
.pAutoHandle
);
917 FIXME("using auto handle - call NdrNsSendReceive when it gets implemented\n");
920 NdrSendReceive(&stubMsg
, stubMsg
.Buffer
);
923 /* convert strings, floating point values and endianness into our
924 * preferred format */
925 if ((rpcMsg
.DataRepresentation
& 0x0000FFFFUL
) != NDR_LOCAL_DATA_REPRESENTATION
)
926 NdrConvert(&stubMsg
, pFormat
);
929 TRACE( "UNMARSHAL\n" );
930 client_do_args(&stubMsg
, pFormat
, STUBLESS_UNMARSHAL
, fpu_stack
,
931 number_of_params
, (unsigned char *)&RetVal
);
934 if (ext_flags
.HasNewCorrDesc
)
936 /* free extra correlation package */
937 NdrCorrelationFree(&stubMsg
);
940 if (Oif_flags
.HasPipes
)
942 /* NdrPipesDone(...) */
945 /* free the full pointer translation tables */
946 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_FULLPTR
)
947 NdrFullPointerXlatFree(stubMsg
.FullPtrXlatTables
);
949 /* free marshalling buffer */
950 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
951 NdrProxyFreeBuffer(This
, &stubMsg
);
954 NdrFreeBuffer(&stubMsg
);
955 client_free_handle(&stubMsg
, pProcHeader
, pHandleFormat
, hBinding
);
959 TRACE("RetVal = 0x%lx\n", RetVal
);
965 __ASM_GLOBAL_FUNC( NdrClientCall2
,
966 "movq %r8,0x18(%rsp)\n\t"
967 "movq %r9,0x20(%rsp)\n\t"
968 "leaq 0x18(%rsp),%r8\n\t"
970 "subq $0x28,%rsp\n\t"
971 __ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t")
972 "call " __ASM_NAME("ndr_client_call") "\n\t"
973 "addq $0x28,%rsp\n\t"
974 __ASM_CFI(".cfi_adjust_cfa_offset -0x28\n\t")
977 #else /* __x86_64__ */
979 /***********************************************************************
980 * NdrClientCall2 [RPCRT4.@]
982 CLIENT_CALL_RETURN WINAPIV
NdrClientCall2( PMIDL_STUB_DESC desc
, PFORMAT_STRING format
, ... )
987 __ms_va_start( args
, format
);
988 ret
= ndr_client_call( desc
, format
, va_arg( args
, void ** ), NULL
);
990 return *(CLIENT_CALL_RETURN
*)&ret
;
993 #endif /* __x86_64__ */
995 /* Calls a function with the specified arguments, restoring the stack
996 * properly afterwards as we don't know the calling convention of the
998 #if defined __i386__ && defined _MSC_VER
999 __declspec(naked
) LONG_PTR __cdecl
call_server_func(SERVER_ROUTINE func
, unsigned char * args
, unsigned int stack_size
)
1005 push edi
; Save registers
1007 mov eax
, [ebp
+16] ; Get stack size
1008 sub esp
, eax
; Make room in stack
for arguments
1015 rep movsd
; Copy dword blocks
1016 call
[ebp
+8] ; Call function
1017 lea esp
, [ebp
-8] ; Restore stack
1018 pop esi
; Restore registers
1024 #elif defined __i386__ && defined __GNUC__
1025 LONG_PTR __cdecl
call_server_func(SERVER_ROUTINE func
, unsigned char * args
, unsigned int stack_size
);
1026 __ASM_GLOBAL_FUNC(call_server_func
,
1028 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
1029 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
1030 "movl %esp,%ebp\n\t"
1031 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
1032 "pushl %edi\n\t" /* Save registers */
1033 __ASM_CFI(".cfi_rel_offset %edi,-4\n\t")
1035 __ASM_CFI(".cfi_rel_offset %esi,-8\n\t")
1036 "movl 16(%ebp), %eax\n\t" /* Get stack size */
1037 "subl %eax, %esp\n\t" /* Make room in stack for arguments */
1038 "andl $~15, %esp\n\t" /* Make sure stack has 16-byte alignment for Mac OS X */
1039 "movl %esp, %edi\n\t"
1040 "movl %eax, %ecx\n\t"
1041 "movl 12(%ebp), %esi\n\t"
1042 "shrl $2, %ecx\n\t" /* divide by 4 */
1044 "rep; movsl\n\t" /* Copy dword blocks */
1045 "call *8(%ebp)\n\t" /* Call function */
1046 "leal -8(%ebp), %esp\n\t" /* Restore stack */
1047 "popl %esi\n\t" /* Restore registers */
1048 __ASM_CFI(".cfi_same_value %esi\n\t")
1050 __ASM_CFI(".cfi_same_value %edi\n\t")
1052 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
1053 __ASM_CFI(".cfi_same_value %ebp\n\t")
1055 #elif defined __x86_64__
1056 LONG_PTR __cdecl
call_server_func(SERVER_ROUTINE func
, unsigned char * args
, unsigned int stack_size
);
1057 __ASM_GLOBAL_FUNC( call_server_func
,
1059 __ASM_CFI(".cfi_adjust_cfa_offset 8\n\t")
1060 __ASM_CFI(".cfi_rel_offset %rbp,0\n\t")
1061 "movq %rsp,%rbp\n\t"
1062 __ASM_CFI(".cfi_def_cfa_register %rbp\n\t")
1064 __ASM_CFI(".cfi_rel_offset %rsi,-8\n\t")
1066 __ASM_CFI(".cfi_rel_offset %rdi,-16\n\t")
1067 "movq %rcx,%rax\n\t" /* function to call */
1068 "movq $32,%rcx\n\t" /* allocate max(32,stack_size) bytes of stack space */
1070 "cmovgq %r8,%rcx\n\t"
1071 "subq %rcx,%rsp\n\t"
1072 "andq $~15,%rsp\n\t"
1075 "movq %rsp,%rdi\n\t"
1076 "movq %rdx,%rsi\n\t"
1077 "rep; movsq\n\t" /* copy arguments */
1078 "movq 0(%rsp),%rcx\n\t"
1079 "movq 8(%rsp),%rdx\n\t"
1080 "movq 16(%rsp),%r8\n\t"
1081 "movq 24(%rsp),%r9\n\t"
1082 "movq 0(%rsp),%xmm0\n\t"
1083 "movq 8(%rsp),%xmm1\n\t"
1084 "movq 16(%rsp),%xmm2\n\t"
1085 "movq 24(%rsp),%xmm3\n\t"
1087 "leaq -16(%rbp),%rsp\n\t" /* restore stack */
1089 __ASM_CFI(".cfi_same_value %rdi\n\t")
1091 __ASM_CFI(".cfi_same_value %rsi\n\t")
1092 __ASM_CFI(".cfi_def_cfa_register %rsp\n\t")
1094 __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t")
1095 __ASM_CFI(".cfi_same_value %rbp\n\t")
1097 #elif defined __arm__
1098 LONG_PTR __cdecl
call_server_func(SERVER_ROUTINE func
, unsigned char *args
, unsigned int stack_size
);
1099 __ASM_GLOBAL_FUNC( call_server_func
,
1101 "push {r4, r5, LR}\n\t"
1104 "lsr r3, r2, #2\n\t"
1107 "sub SP, SP, r2\n\t"
1109 "subeq SP, SP, #4\n\t"
1110 "1:\tsub r2, r2, #4\n\t"
1111 "ldr r0, [r1, r2]\n\t"
1112 "str r0, [SP, r2]\n\t"
1119 "2:\tcmp r3, #2\n\t"
1123 "3:\tcmp r3, #3\n\t"
1127 "4:\tpop {r0-r3}\n\t"
1130 "pop {r4, r5, PC}" )
1132 #warning call_server_func not implemented for your architecture
1133 LONG_PTR __cdecl
call_server_func(SERVER_ROUTINE func
, unsigned char * args
, unsigned short stack_size
)
1135 FIXME("Not implemented for your architecture\n");
1140 static LONG_PTR
*stub_do_args(MIDL_STUB_MESSAGE
*pStubMsg
,
1141 PFORMAT_STRING pFormat
, enum stubless_phase phase
,
1142 unsigned short number_of_params
)
1144 const NDR_PARAM_OIF
*params
= (const NDR_PARAM_OIF
*)pFormat
;
1146 LONG_PTR
*retval_ptr
= NULL
;
1148 for (i
= 0; i
< number_of_params
; i
++)
1150 unsigned char *pArg
= pStubMsg
->StackTop
+ params
[i
].stack_offset
;
1151 const unsigned char *pTypeFormat
= &pStubMsg
->StubDesc
->pFormatTypes
[params
[i
].u
.type_offset
];
1153 TRACE("param[%d]: %p -> %p type %02x %s\n", i
,
1154 pArg
, *(unsigned char **)pArg
,
1155 params
[i
].attr
.IsBasetype
? params
[i
].u
.type_format_char
: *pTypeFormat
,
1156 debugstr_PROC_PF( params
[i
].attr
));
1160 case STUBLESS_MARSHAL
:
1161 if (params
[i
].attr
.IsOut
|| params
[i
].attr
.IsReturn
)
1162 call_marshaller(pStubMsg
, pArg
, ¶ms
[i
]);
1164 case STUBLESS_MUSTFREE
:
1165 if (params
[i
].attr
.MustFree
)
1167 call_freer(pStubMsg
, pArg
, ¶ms
[i
]);
1171 if (params
[i
].attr
.ServerAllocSize
)
1173 HeapFree(GetProcessHeap(), 0, *(void **)pArg
);
1175 else if (params
[i
].attr
.IsOut
&&
1176 !params
[i
].attr
.IsIn
&&
1177 !params
[i
].attr
.IsBasetype
&&
1178 !params
[i
].attr
.IsByValue
)
1180 if (*pTypeFormat
!= RPC_FC_BIND_CONTEXT
) pStubMsg
->pfnFree(*(void **)pArg
);
1183 case STUBLESS_INITOUT
:
1184 if (!params
[i
].attr
.IsIn
&&
1185 params
[i
].attr
.IsOut
&&
1186 !params
[i
].attr
.IsBasetype
&&
1187 !params
[i
].attr
.ServerAllocSize
&&
1188 !params
[i
].attr
.IsByValue
)
1190 if (*pTypeFormat
== RPC_FC_BIND_CONTEXT
)
1192 NDR_SCONTEXT ctxt
= NdrContextHandleInitialize(pStubMsg
, pTypeFormat
);
1193 *(void **)pArg
= NDRSContextValue(ctxt
);
1197 DWORD size
= calc_arg_size(pStubMsg
, pTypeFormat
);
1200 *(void **)pArg
= NdrAllocate(pStubMsg
, size
);
1201 memset(*(void **)pArg
, 0, size
);
1206 case STUBLESS_UNMARSHAL
:
1207 if (params
[i
].attr
.ServerAllocSize
)
1208 *(void **)pArg
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
1209 params
[i
].attr
.ServerAllocSize
* 8);
1211 if (params
[i
].attr
.IsIn
)
1212 call_unmarshaller(pStubMsg
, &pArg
, ¶ms
[i
], 0);
1214 case STUBLESS_CALCSIZE
:
1215 if (params
[i
].attr
.IsOut
|| params
[i
].attr
.IsReturn
)
1216 call_buffer_sizer(pStubMsg
, pArg
, ¶ms
[i
]);
1219 RpcRaiseException(RPC_S_INTERNAL_ERROR
);
1221 TRACE("\tmemory addr (after): %p -> %p\n", pArg
, *(unsigned char **)pArg
);
1223 /* make a note of the address of the return value parameter for later */
1224 if (params
[i
].attr
.IsReturn
) retval_ptr
= (LONG_PTR
*)pArg
;
1229 /***********************************************************************
1230 * NdrStubCall2 [RPCRT4.@]
1232 * Unmarshals [in] parameters, calls either a method in an object or a server
1233 * function, marshals any [out] parameters and frees any allocated data.
1236 * Used by stubless MIDL-generated code.
1238 LONG WINAPI
NdrStubCall2(
1239 struct IRpcStubBuffer
* pThis
,
1240 struct IRpcChannelBuffer
* pChannel
,
1241 PRPC_MESSAGE pRpcMsg
,
1242 DWORD
* pdwStubPhase
)
1244 const MIDL_SERVER_INFO
*pServerInfo
;
1245 const MIDL_STUB_DESC
*pStubDesc
;
1246 PFORMAT_STRING pFormat
;
1247 MIDL_STUB_MESSAGE stubMsg
;
1248 /* pointer to start of stack to pass into stub implementation */
1249 unsigned char * args
;
1251 unsigned short stack_size
;
1252 /* number of parameters. optional for client to give it to us */
1253 unsigned int number_of_params
;
1254 /* cache of Oif_flags from v2 procedure header */
1255 INTERPRETER_OPT_FLAGS Oif_flags
= { 0 };
1256 /* cache of extension flags from NDR_PROC_HEADER_EXTS */
1257 INTERPRETER_OPT_FLAGS2 ext_flags
= { 0 };
1258 /* the type of pass we are currently doing */
1259 enum stubless_phase phase
;
1260 /* header for procedure string */
1261 const NDR_PROC_HEADER
*pProcHeader
;
1262 /* location to put retval into */
1263 LONG_PTR
*retval_ptr
= NULL
;
1264 /* correlation cache */
1265 ULONG_PTR NdrCorrCache
[256];
1267 TRACE("pThis %p, pChannel %p, pRpcMsg %p, pdwStubPhase %p\n", pThis
, pChannel
, pRpcMsg
, pdwStubPhase
);
1270 pServerInfo
= CStdStubBuffer_GetServerInfo(pThis
);
1272 pServerInfo
= ((RPC_SERVER_INTERFACE
*)pRpcMsg
->RpcInterfaceInformation
)->InterpreterInfo
;
1274 pStubDesc
= pServerInfo
->pStubDesc
;
1275 pFormat
= pServerInfo
->ProcString
+ pServerInfo
->FmtStringOffset
[pRpcMsg
->ProcNum
];
1276 pProcHeader
= (const NDR_PROC_HEADER
*)&pFormat
[0];
1278 TRACE("NDR Version: 0x%x\n", pStubDesc
->Version
);
1280 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCFLAGS
)
1282 const NDR_PROC_HEADER_RPC
*header_rpc
= (const NDR_PROC_HEADER_RPC
*)&pFormat
[0];
1283 stack_size
= header_rpc
->stack_size
;
1284 pFormat
+= sizeof(NDR_PROC_HEADER_RPC
);
1289 stack_size
= pProcHeader
->stack_size
;
1290 pFormat
+= sizeof(NDR_PROC_HEADER
);
1293 TRACE("Oi_flags = 0x%02x\n", pProcHeader
->Oi_flags
);
1296 switch (pProcHeader
->handle_type
)
1298 /* explicit binding: parse additional section */
1299 case RPC_FC_BIND_EXPLICIT
:
1300 switch (*pFormat
) /* handle_type */
1302 case RPC_FC_BIND_PRIMITIVE
: /* explicit primitive */
1303 pFormat
+= sizeof(NDR_EHD_PRIMITIVE
);
1305 case RPC_FC_BIND_GENERIC
: /* explicit generic */
1306 pFormat
+= sizeof(NDR_EHD_GENERIC
);
1308 case RPC_FC_BIND_CONTEXT
: /* explicit context */
1309 pFormat
+= sizeof(NDR_EHD_CONTEXT
);
1312 ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
1313 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
1316 case RPC_FC_BIND_GENERIC
: /* implicit generic */
1317 case RPC_FC_BIND_PRIMITIVE
: /* implicit primitive */
1318 case RPC_FC_CALLBACK_HANDLE
: /* implicit callback */
1319 case RPC_FC_AUTO_HANDLE
: /* implicit auto handle */
1322 ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
1323 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
1326 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
1327 NdrStubInitialize(pRpcMsg
, &stubMsg
, pStubDesc
, pChannel
);
1329 NdrServerInitializeNew(pRpcMsg
, &stubMsg
, pStubDesc
);
1331 /* create the full pointer translation tables, if requested */
1332 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_FULLPTR
)
1333 stubMsg
.FullPtrXlatTables
= NdrFullPointerXlatInit(0,XLAT_SERVER
);
1335 /* store the RPC flags away */
1336 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCFLAGS
)
1337 pRpcMsg
->RpcFlags
= ((const NDR_PROC_HEADER_RPC
*)pProcHeader
)->rpc_flags
;
1339 /* use alternate memory allocation routines */
1340 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCSSALLOC
)
1342 NdrRpcSsEnableAllocate(&stubMsg
);
1344 FIXME("Set RPCSS memory allocation routines\n");
1347 TRACE("allocating memory for stack of size %x\n", stack_size
);
1349 args
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, stack_size
);
1350 stubMsg
.StackTop
= args
; /* used by conformance of top-level objects */
1352 /* add the implicit This pointer as the first arg to the function if we
1353 * are calling an object method */
1355 *(void **)args
= ((CStdStubBuffer
*)pThis
)->pvServerObject
;
1357 if (is_oicf_stubdesc(pStubDesc
))
1359 const NDR_PROC_PARTIAL_OIF_HEADER
*pOIFHeader
= (const NDR_PROC_PARTIAL_OIF_HEADER
*)pFormat
;
1361 Oif_flags
= pOIFHeader
->Oi2Flags
;
1362 number_of_params
= pOIFHeader
->number_of_params
;
1364 pFormat
+= sizeof(NDR_PROC_PARTIAL_OIF_HEADER
);
1366 TRACE("Oif_flags = %s\n", debugstr_INTERPRETER_OPT_FLAGS(Oif_flags
) );
1368 if (Oif_flags
.HasExtensions
)
1370 const NDR_PROC_HEADER_EXTS
*pExtensions
= (const NDR_PROC_HEADER_EXTS
*)pFormat
;
1371 ext_flags
= pExtensions
->Flags2
;
1372 pFormat
+= pExtensions
->Size
;
1375 if (Oif_flags
.HasPipes
)
1377 FIXME("pipes not supported yet\n");
1378 RpcRaiseException(RPC_X_WRONG_STUB_VERSION
); /* FIXME: remove when implemented */
1379 /* init pipes package */
1380 /* NdrPipesInitialize(...) */
1382 if (ext_flags
.HasNewCorrDesc
)
1384 /* initialize extra correlation package */
1385 NdrCorrelationInitialize(&stubMsg
, NdrCorrCache
, sizeof(NdrCorrCache
), 0);
1386 if (ext_flags
.Unused
& 0x2) /* has range on conformance */
1387 stubMsg
.CorrDespIncrement
= 12;
1392 pFormat
= convert_old_args( &stubMsg
, pFormat
, stack_size
,
1393 pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
,
1394 /* reuse the correlation cache, it's not needed for v1 format */
1395 NdrCorrCache
, sizeof(NdrCorrCache
), &number_of_params
);
1398 /* convert strings, floating point values and endianness into our
1399 * preferred format */
1400 if ((pRpcMsg
->DataRepresentation
& 0x0000FFFFUL
) != NDR_LOCAL_DATA_REPRESENTATION
)
1401 NdrConvert(&stubMsg
, pFormat
);
1403 for (phase
= STUBLESS_UNMARSHAL
; phase
<= STUBLESS_FREE
; phase
++)
1405 TRACE("phase = %d\n", phase
);
1408 case STUBLESS_CALLSERVER
:
1409 /* call the server function */
1410 if (pServerInfo
->ThunkTable
&& pServerInfo
->ThunkTable
[pRpcMsg
->ProcNum
])
1411 pServerInfo
->ThunkTable
[pRpcMsg
->ProcNum
](&stubMsg
);
1414 SERVER_ROUTINE func
;
1417 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
1419 SERVER_ROUTINE
*vtbl
= *(SERVER_ROUTINE
**)((CStdStubBuffer
*)pThis
)->pvServerObject
;
1420 func
= vtbl
[pRpcMsg
->ProcNum
];
1423 func
= pServerInfo
->DispatchTable
[pRpcMsg
->ProcNum
];
1425 /* FIXME: what happens with return values that don't fit into a single register on x86? */
1426 retval
= call_server_func(func
, args
, stack_size
);
1430 TRACE("stub implementation returned 0x%lx\n", retval
);
1431 *retval_ptr
= retval
;
1434 TRACE("void stub implementation\n");
1437 stubMsg
.Buffer
= NULL
;
1438 stubMsg
.BufferLength
= 0;
1441 case STUBLESS_GETBUFFER
:
1442 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
1443 NdrStubGetBuffer(pThis
, pChannel
, &stubMsg
);
1448 pRpcMsg
->BufferLength
= stubMsg
.BufferLength
;
1449 /* allocate buffer for [out] and [ret] params */
1450 Status
= I_RpcGetBuffer(pRpcMsg
);
1452 RpcRaiseException(Status
);
1453 stubMsg
.Buffer
= pRpcMsg
->Buffer
;
1456 case STUBLESS_UNMARSHAL
:
1457 case STUBLESS_INITOUT
:
1458 case STUBLESS_CALCSIZE
:
1459 case STUBLESS_MARSHAL
:
1460 case STUBLESS_MUSTFREE
:
1462 retval_ptr
= stub_do_args(&stubMsg
, pFormat
, phase
, number_of_params
);
1465 ERR("shouldn't reach here. phase %d\n", phase
);
1470 pRpcMsg
->BufferLength
= (unsigned int)(stubMsg
.Buffer
- (unsigned char *)pRpcMsg
->Buffer
);
1472 if (ext_flags
.HasNewCorrDesc
)
1474 /* free extra correlation package */
1475 NdrCorrelationFree(&stubMsg
);
1478 if (Oif_flags
.HasPipes
)
1480 /* NdrPipesDone(...) */
1483 /* free the full pointer translation tables */
1484 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_FULLPTR
)
1485 NdrFullPointerXlatFree(stubMsg
.FullPtrXlatTables
);
1487 /* free server function stack */
1488 HeapFree(GetProcessHeap(), 0, args
);
1493 /***********************************************************************
1494 * NdrServerCall2 [RPCRT4.@]
1496 void WINAPI
NdrServerCall2(PRPC_MESSAGE pRpcMsg
)
1499 NdrStubCall2(NULL
, NULL
, pRpcMsg
, &dwPhase
);
1502 /***********************************************************************
1503 * NdrStubCall [RPCRT4.@]
1505 LONG WINAPI
NdrStubCall( struct IRpcStubBuffer
*This
, struct IRpcChannelBuffer
*channel
,
1506 PRPC_MESSAGE msg
, DWORD
*phase
)
1508 return NdrStubCall2( This
, channel
, msg
, phase
);
1511 /***********************************************************************
1512 * NdrServerCall [RPCRT4.@]
1514 void WINAPI
NdrServerCall( PRPC_MESSAGE msg
)
1517 NdrStubCall( NULL
, NULL
, msg
, &phase
);
1520 struct async_call_data
1522 MIDL_STUB_MESSAGE
*pStubMsg
;
1523 const NDR_PROC_HEADER
*pProcHeader
;
1524 PFORMAT_STRING pHandleFormat
;
1525 PFORMAT_STRING pParamFormat
;
1526 RPC_BINDING_HANDLE hBinding
;
1528 unsigned short stack_size
;
1529 /* number of parameters. optional for client to give it to us */
1530 unsigned int number_of_params
;
1531 /* correlation cache */
1532 ULONG_PTR NdrCorrCache
[256];
1535 LONG_PTR CDECL DECLSPEC_HIDDEN
ndr_async_client_call( PMIDL_STUB_DESC pStubDesc
, PFORMAT_STRING pFormat
,
1538 /* pointer to start of stack where arguments start */
1539 PRPC_MESSAGE pRpcMsg
;
1540 PMIDL_STUB_MESSAGE pStubMsg
;
1541 RPC_ASYNC_STATE
*pAsync
;
1542 struct async_call_data
*async_call_data
;
1543 /* procedure number */
1544 unsigned short procedure_number
;
1545 /* cache of Oif_flags from v2 procedure header */
1546 INTERPRETER_OPT_FLAGS Oif_flags
= { 0 };
1547 /* cache of extension flags from NDR_PROC_HEADER_EXTS */
1548 INTERPRETER_OPT_FLAGS2 ext_flags
= { 0 };
1549 /* header for procedure string */
1550 const NDR_PROC_HEADER
* pProcHeader
= (const NDR_PROC_HEADER
*)&pFormat
[0];
1553 TRACE("pStubDesc %p, pFormat %p, ...\n", pStubDesc
, pFormat
);
1555 /* Later NDR language versions probably won't be backwards compatible */
1556 if (pStubDesc
->Version
> 0x50002)
1558 FIXME("Incompatible stub description version: 0x%x\n", pStubDesc
->Version
);
1559 RpcRaiseException(RPC_X_WRONG_STUB_VERSION
);
1562 async_call_data
= I_RpcAllocate(sizeof(*async_call_data
) + sizeof(MIDL_STUB_MESSAGE
) + sizeof(RPC_MESSAGE
));
1563 if (!async_call_data
) RpcRaiseException(RPC_X_NO_MEMORY
);
1564 async_call_data
->pProcHeader
= pProcHeader
;
1566 async_call_data
->pStubMsg
= pStubMsg
= (PMIDL_STUB_MESSAGE
)(async_call_data
+ 1);
1567 pRpcMsg
= (PRPC_MESSAGE
)(pStubMsg
+ 1);
1569 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCFLAGS
)
1571 const NDR_PROC_HEADER_RPC
*header_rpc
= (const NDR_PROC_HEADER_RPC
*)&pFormat
[0];
1572 async_call_data
->stack_size
= header_rpc
->stack_size
;
1573 procedure_number
= header_rpc
->proc_num
;
1574 pFormat
+= sizeof(NDR_PROC_HEADER_RPC
);
1578 async_call_data
->stack_size
= pProcHeader
->stack_size
;
1579 procedure_number
= pProcHeader
->proc_num
;
1580 pFormat
+= sizeof(NDR_PROC_HEADER
);
1582 TRACE("stack size: 0x%x\n", async_call_data
->stack_size
);
1583 TRACE("proc num: %d\n", procedure_number
);
1585 /* create the full pointer translation tables, if requested */
1586 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_FULLPTR
)
1587 pStubMsg
->FullPtrXlatTables
= NdrFullPointerXlatInit(0,XLAT_CLIENT
);
1589 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
1591 ERR("objects not supported\n");
1592 I_RpcFree(async_call_data
);
1593 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
1596 NdrClientInitializeNew(pRpcMsg
, pStubMsg
, pStubDesc
, procedure_number
);
1598 TRACE("Oi_flags = 0x%02x\n", pProcHeader
->Oi_flags
);
1599 TRACE("MIDL stub version = 0x%x\n", pStubDesc
->MIDLVersion
);
1601 /* needed for conformance of top-level objects */
1602 pStubMsg
->StackTop
= I_RpcAllocate(async_call_data
->stack_size
);
1603 memcpy(pStubMsg
->StackTop
, stack_top
, async_call_data
->stack_size
);
1605 pAsync
= *(RPC_ASYNC_STATE
**)pStubMsg
->StackTop
;
1606 pAsync
->StubInfo
= async_call_data
;
1607 async_call_data
->pHandleFormat
= pFormat
;
1609 pFormat
= client_get_handle(pStubMsg
, pProcHeader
, async_call_data
->pHandleFormat
, &async_call_data
->hBinding
);
1610 if (!pFormat
) goto done
;
1612 if (is_oicf_stubdesc(pStubDesc
))
1614 const NDR_PROC_PARTIAL_OIF_HEADER
*pOIFHeader
=
1615 (const NDR_PROC_PARTIAL_OIF_HEADER
*)pFormat
;
1617 Oif_flags
= pOIFHeader
->Oi2Flags
;
1618 async_call_data
->number_of_params
= pOIFHeader
->number_of_params
;
1620 pFormat
+= sizeof(NDR_PROC_PARTIAL_OIF_HEADER
);
1622 TRACE("Oif_flags = %s\n", debugstr_INTERPRETER_OPT_FLAGS(Oif_flags
) );
1624 if (Oif_flags
.HasExtensions
)
1626 const NDR_PROC_HEADER_EXTS
*pExtensions
=
1627 (const NDR_PROC_HEADER_EXTS
*)pFormat
;
1628 ext_flags
= pExtensions
->Flags2
;
1629 pFormat
+= pExtensions
->Size
;
1634 pFormat
= convert_old_args( pStubMsg
, pFormat
, async_call_data
->stack_size
,
1635 pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
,
1636 async_call_data
->NdrCorrCache
, sizeof(async_call_data
->NdrCorrCache
),
1637 &async_call_data
->number_of_params
);
1640 async_call_data
->pParamFormat
= pFormat
;
1642 pStubMsg
->BufferLength
= 0;
1644 /* store the RPC flags away */
1645 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCFLAGS
)
1646 pRpcMsg
->RpcFlags
= ((const NDR_PROC_HEADER_RPC
*)pProcHeader
)->rpc_flags
;
1648 /* use alternate memory allocation routines */
1649 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCSSALLOC
)
1650 NdrRpcSmSetClientToOsf(pStubMsg
);
1652 if (Oif_flags
.HasPipes
)
1654 FIXME("pipes not supported yet\n");
1655 RpcRaiseException(RPC_X_WRONG_STUB_VERSION
); /* FIXME: remove when implemented */
1656 /* init pipes package */
1657 /* NdrPipesInitialize(...) */
1659 if (ext_flags
.HasNewCorrDesc
)
1661 /* initialize extra correlation package */
1662 NdrCorrelationInitialize(pStubMsg
, async_call_data
->NdrCorrCache
, sizeof(async_call_data
->NdrCorrCache
), 0);
1663 if (ext_flags
.Unused
& 0x2) /* has range on conformance */
1664 pStubMsg
->CorrDespIncrement
= 12;
1668 * 1. CALCSIZE - calculate the buffer size
1669 * 2. GETBUFFER - allocate the buffer
1670 * 3. MARSHAL - marshal [in] params into the buffer
1671 * 4. SENDRECEIVE - send buffer
1672 * Then in NdrpCompleteAsyncClientCall:
1673 * 1. SENDRECEIVE - receive buffer
1674 * 2. UNMARSHAL - unmarshal [out] params from buffer
1678 TRACE( "CALCSIZE\n" );
1679 client_do_args(pStubMsg
, pFormat
, STUBLESS_CALCSIZE
, NULL
, async_call_data
->number_of_params
, NULL
);
1682 TRACE( "GETBUFFER\n" );
1683 if (Oif_flags
.HasPipes
)
1684 /* NdrGetPipeBuffer(...) */
1685 FIXME("pipes not supported yet\n");
1688 if (pProcHeader
->handle_type
== RPC_FC_AUTO_HANDLE
)
1690 NdrNsGetBuffer(pStubMsg
, pStubMsg
->BufferLength
, async_call_data
->hBinding
);
1692 FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
1695 NdrGetBuffer(pStubMsg
, pStubMsg
->BufferLength
, async_call_data
->hBinding
);
1697 pRpcMsg
->RpcFlags
|= RPC_BUFFER_ASYNC
;
1698 status
= I_RpcAsyncSetHandle(pRpcMsg
, pAsync
);
1699 if (status
!= RPC_S_OK
)
1700 RpcRaiseException(status
);
1703 TRACE( "MARSHAL\n" );
1704 client_do_args(pStubMsg
, pFormat
, STUBLESS_MARSHAL
, NULL
, async_call_data
->number_of_params
, NULL
);
1706 /* 4. SENDRECEIVE */
1708 pRpcMsg
->RpcFlags
|= RPC_BUFFER_ASYNC
;
1709 /* send the [in] params only */
1710 if (Oif_flags
.HasPipes
)
1711 /* NdrPipesSend(...) */
1712 FIXME("pipes not supported yet\n");
1715 if (pProcHeader
->handle_type
== RPC_FC_AUTO_HANDLE
)
1717 NdrNsSend(&stubMsg
, stubMsg
.Buffer
, pStubDesc
->IMPLICIT_HANDLE_INFO
.pAutoHandle
);
1719 FIXME("using auto handle - call NdrNsSend when it gets implemented\n");
1723 pStubMsg
->RpcMsg
->BufferLength
= pStubMsg
->Buffer
- (unsigned char *)pStubMsg
->RpcMsg
->Buffer
;
1724 status
= I_RpcSend(pStubMsg
->RpcMsg
);
1725 if (status
!= RPC_S_OK
)
1726 RpcRaiseException(status
);
1731 TRACE("returning 0\n");
1735 RPC_STATUS
NdrpCompleteAsyncClientCall(RPC_ASYNC_STATE
*pAsync
, void *Reply
)
1737 /* pointer to start of stack where arguments start */
1738 PMIDL_STUB_MESSAGE pStubMsg
;
1739 struct async_call_data
*async_call_data
;
1740 /* header for procedure string */
1741 const NDR_PROC_HEADER
* pProcHeader
;
1742 RPC_STATUS status
= RPC_S_OK
;
1744 if (!pAsync
->StubInfo
)
1745 return RPC_S_INVALID_ASYNC_HANDLE
;
1747 async_call_data
= pAsync
->StubInfo
;
1748 pStubMsg
= async_call_data
->pStubMsg
;
1749 pProcHeader
= async_call_data
->pProcHeader
;
1752 * 1. CALCSIZE - calculate the buffer size
1753 * 2. GETBUFFER - allocate the buffer
1754 * 3. MARSHAL - marshal [in] params into the buffer
1755 * 4. SENDRECEIVE - send buffer
1756 * Then in NdrpCompleteAsyncClientCall:
1757 * 1. SENDRECEIVE - receive buffer
1758 * 2. UNMARSHAL - unmarshal [out] params from buffer
1761 /* 1. SENDRECEIVE */
1762 TRACE( "RECEIVE\n" );
1763 pStubMsg
->RpcMsg
->RpcFlags
|= RPC_BUFFER_ASYNC
;
1764 /* receive the [out] params */
1765 if (pProcHeader
->handle_type
== RPC_FC_AUTO_HANDLE
)
1767 NdrNsReceive(&stubMsg
, stubMsg
.Buffer
, pStubDesc
->IMPLICIT_HANDLE_INFO
.pAutoHandle
);
1769 FIXME("using auto handle - call NdrNsReceive when it gets implemented\n");
1773 status
= I_RpcReceive(pStubMsg
->RpcMsg
);
1774 if (status
!= RPC_S_OK
)
1776 pStubMsg
->BufferLength
= pStubMsg
->RpcMsg
->BufferLength
;
1777 pStubMsg
->BufferStart
= pStubMsg
->RpcMsg
->Buffer
;
1778 pStubMsg
->BufferEnd
= pStubMsg
->BufferStart
+ pStubMsg
->BufferLength
;
1779 pStubMsg
->Buffer
= pStubMsg
->BufferStart
;
1782 /* convert strings, floating point values and endianness into our
1783 * preferred format */
1785 if ((pStubMsg
->RpcMsg
.DataRepresentation
& 0x0000FFFFUL
) != NDR_LOCAL_DATA_REPRESENTATION
)
1786 NdrConvert(pStubMsg
, pFormat
);
1790 TRACE( "UNMARSHAL\n" );
1791 client_do_args(pStubMsg
, async_call_data
->pParamFormat
, STUBLESS_UNMARSHAL
,
1792 NULL
, async_call_data
->number_of_params
, Reply
);
1795 if (pStubMsg
->fHasNewCorrDesc
)
1797 /* free extra correlation package */
1798 NdrCorrelationFree(pStubMsg
);
1801 /* free the full pointer translation tables */
1802 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_FULLPTR
)
1803 NdrFullPointerXlatFree(pStubMsg
->FullPtrXlatTables
);
1805 /* free marshalling buffer */
1806 NdrFreeBuffer(pStubMsg
);
1807 client_free_handle(pStubMsg
, pProcHeader
, async_call_data
->pHandleFormat
, async_call_data
->hBinding
);
1809 I_RpcFree(pStubMsg
->StackTop
);
1810 I_RpcFree(async_call_data
);
1812 TRACE("-- 0x%x\n", status
);
1818 __ASM_GLOBAL_FUNC( NdrAsyncClientCall
,
1819 "movq %r8,0x18(%rsp)\n\t"
1820 "movq %r9,0x20(%rsp)\n\t"
1821 "leaq 0x18(%rsp),%r8\n\t"
1822 "subq $0x28,%rsp\n\t"
1823 __ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t")
1824 "call " __ASM_NAME("ndr_async_client_call") "\n\t"
1825 "addq $0x28,%rsp\n\t"
1826 __ASM_CFI(".cfi_adjust_cfa_offset -0x28\n\t")
1829 #else /* __x86_64__ */
1831 /***********************************************************************
1832 * NdrAsyncClientCall [RPCRT4.@]
1834 CLIENT_CALL_RETURN WINAPIV
NdrAsyncClientCall( PMIDL_STUB_DESC desc
, PFORMAT_STRING format
, ... )
1839 __ms_va_start( args
, format
);
1840 ret
= ndr_async_client_call( desc
, format
, va_arg( args
, void ** ));
1841 __ms_va_end( args
);
1842 return *(CLIENT_CALL_RETURN
*)&ret
;
1845 #endif /* __x86_64__ */
1847 RPCRTAPI LONG RPC_ENTRY
NdrAsyncStubCall(struct IRpcStubBuffer
* pThis
,
1848 struct IRpcChannelBuffer
* pChannel
, PRPC_MESSAGE pRpcMsg
,
1849 DWORD
* pdwStubPhase
)
1851 FIXME("unimplemented, expect crash!\n");
1855 void RPC_ENTRY
NdrAsyncServerCall(PRPC_MESSAGE pRpcMsg
)
1857 FIXME("unimplemented, %p\n", pRpcMsg
);