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
28 WINE_DEFAULT_DEBUG_CHANNEL(rpc
);
30 #define NDR_TABLE_MASK 127
32 static inline BOOL
is_oicf_stubdesc(const PMIDL_STUB_DESC pStubDesc
)
34 return pStubDesc
->Version
>= 0x20000;
37 static inline void call_buffer_sizer(PMIDL_STUB_MESSAGE pStubMsg
, unsigned char *pMemory
,
38 const NDR_PARAM_OIF
*param
)
40 PFORMAT_STRING pFormat
;
43 if (param
->attr
.IsBasetype
)
45 pFormat
= ¶m
->u
.type_format_char
;
46 if (param
->attr
.IsSimpleRef
) pMemory
= *(unsigned char **)pMemory
;
50 pFormat
= &pStubMsg
->StubDesc
->pFormatTypes
[param
->u
.type_offset
];
51 if (!param
->attr
.IsByValue
) pMemory
= *(unsigned char **)pMemory
;
54 m
= NdrBufferSizer
[pFormat
[0] & NDR_TABLE_MASK
];
55 if (m
) m(pStubMsg
, pMemory
, pFormat
);
58 FIXME("format type 0x%x not implemented\n", pFormat
[0]);
59 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
63 static inline unsigned char *call_marshaller(PMIDL_STUB_MESSAGE pStubMsg
, unsigned char *pMemory
,
64 const NDR_PARAM_OIF
*param
)
66 PFORMAT_STRING pFormat
;
69 if (param
->attr
.IsBasetype
)
71 pFormat
= ¶m
->u
.type_format_char
;
72 if (param
->attr
.IsSimpleRef
) pMemory
= *(unsigned char **)pMemory
;
76 pFormat
= &pStubMsg
->StubDesc
->pFormatTypes
[param
->u
.type_offset
];
77 if (!param
->attr
.IsByValue
) pMemory
= *(unsigned char **)pMemory
;
80 m
= NdrMarshaller
[pFormat
[0] & NDR_TABLE_MASK
];
81 if (m
) return m(pStubMsg
, pMemory
, pFormat
);
84 FIXME("format type 0x%x not implemented\n", pFormat
[0]);
85 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
90 static inline unsigned char *call_unmarshaller(PMIDL_STUB_MESSAGE pStubMsg
, unsigned char **ppMemory
,
91 const NDR_PARAM_OIF
*param
, unsigned char fMustAlloc
)
93 PFORMAT_STRING pFormat
;
96 if (param
->attr
.IsBasetype
)
98 pFormat
= ¶m
->u
.type_format_char
;
99 if (param
->attr
.IsSimpleRef
) ppMemory
= (unsigned char **)*ppMemory
;
103 pFormat
= &pStubMsg
->StubDesc
->pFormatTypes
[param
->u
.type_offset
];
104 if (!param
->attr
.IsByValue
) ppMemory
= (unsigned char **)*ppMemory
;
107 m
= NdrUnmarshaller
[pFormat
[0] & NDR_TABLE_MASK
];
108 if (m
) return m(pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
111 FIXME("format type 0x%x not implemented\n", pFormat
[0]);
112 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
117 static inline void call_freer(PMIDL_STUB_MESSAGE pStubMsg
, unsigned char *pMemory
,
118 const NDR_PARAM_OIF
*param
)
120 PFORMAT_STRING pFormat
;
123 if (param
->attr
.IsBasetype
) return; /* nothing to do */
124 pFormat
= &pStubMsg
->StubDesc
->pFormatTypes
[param
->u
.type_offset
];
125 if (!param
->attr
.IsByValue
) pMemory
= *(unsigned char **)pMemory
;
127 m
= NdrFreer
[pFormat
[0] & NDR_TABLE_MASK
];
128 if (m
) m(pStubMsg
, pMemory
, pFormat
);
131 static DWORD
calc_arg_size(MIDL_STUB_MESSAGE
*pStubMsg
, PFORMAT_STRING pFormat
)
137 if (pFormat
[1] & RPC_FC_P_SIMPLEPOINTER
)
139 FIXME("Simple reference pointer (type %#x).\n", pFormat
[2]);
140 size
= sizeof(void *);
143 size
= calc_arg_size(pStubMsg
, &pFormat
[2] + *(const SHORT
*)&pFormat
[2]);
147 size
= *(const WORD
*)(pFormat
+ 2);
149 case RPC_FC_BOGUS_STRUCT
:
150 size
= *(const WORD
*)(pFormat
+ 2);
151 if(*(const WORD
*)(pFormat
+ 4))
152 FIXME("Unhandled conformant description\n");
156 size
= *(const WORD
*)(pFormat
+ 2);
157 ComputeConformance(pStubMsg
, NULL
, pFormat
+ 4, 0);
158 size
*= pStubMsg
->MaxCount
;
160 case RPC_FC_SMFARRAY
:
161 case RPC_FC_SMVARRAY
:
162 size
= *(const WORD
*)(pFormat
+ 2);
164 case RPC_FC_LGFARRAY
:
165 case RPC_FC_LGVARRAY
:
166 size
= *(const DWORD
*)(pFormat
+ 2);
168 case RPC_FC_BOGUS_ARRAY
:
169 pFormat
= ComputeConformance(pStubMsg
, NULL
, pFormat
+ 4, *(const WORD
*)&pFormat
[2]);
170 TRACE("conformance = %ld\n", pStubMsg
->MaxCount
);
171 pFormat
= ComputeVariance(pStubMsg
, NULL
, pFormat
, pStubMsg
->MaxCount
);
172 size
= ComplexStructSize(pStubMsg
, pFormat
);
173 size
*= pStubMsg
->MaxCount
;
175 case RPC_FC_USER_MARSHAL
:
176 size
= *(const WORD
*)(pFormat
+ 4);
179 size
= *(const WORD
*)(pFormat
+ 2);
182 size
= *(const WORD
*)(pFormat
+ 2) * sizeof(WCHAR
);
184 case RPC_FC_C_CSTRING
:
185 case RPC_FC_C_WSTRING
:
186 if (*pFormat
== RPC_FC_C_CSTRING
)
189 size
= sizeof(WCHAR
);
190 if (pFormat
[1] == RPC_FC_STRING_SIZED
)
191 ComputeConformance(pStubMsg
, NULL
, pFormat
+ 2, 0);
193 pStubMsg
->MaxCount
= 0;
194 size
*= pStubMsg
->MaxCount
;
197 FIXME("Unhandled type %02x\n", *pFormat
);
200 size
= sizeof(void *);
206 void WINAPI
NdrRpcSmSetClientToOsf(PMIDL_STUB_MESSAGE pMessage
)
208 #if 0 /* these functions are not defined yet */
209 pMessage
->pfnAllocate
= NdrRpcSmClientAllocate
;
210 pMessage
->pfnFree
= NdrRpcSmClientFree
;
214 static const char *debugstr_PROC_PF(PARAM_ATTRIBUTES param_attributes
)
219 if (param_attributes
.MustSize
) strcat(buffer
, " MustSize");
220 if (param_attributes
.MustFree
) strcat(buffer
, " MustFree");
221 if (param_attributes
.IsPipe
) strcat(buffer
, " IsPipe");
222 if (param_attributes
.IsIn
) strcat(buffer
, " IsIn");
223 if (param_attributes
.IsOut
) strcat(buffer
, " IsOut");
224 if (param_attributes
.IsReturn
) strcat(buffer
, " IsReturn");
225 if (param_attributes
.IsBasetype
) strcat(buffer
, " IsBasetype");
226 if (param_attributes
.IsByValue
) strcat(buffer
, " IsByValue");
227 if (param_attributes
.IsSimpleRef
) strcat(buffer
, " IsSimpleRef");
228 if (param_attributes
.IsDontCallFreeInst
) strcat(buffer
, " IsDontCallFreeInst");
229 if (param_attributes
.SaveForAsyncFinish
) strcat(buffer
, " SaveForAsyncFinish");
230 if (param_attributes
.ServerAllocSize
)
231 sprintf( buffer
+ strlen(buffer
), " ServerAllocSize = %d", param_attributes
.ServerAllocSize
* 8);
232 return buffer
[0] ? wine_dbg_sprintf( "%s", buffer
+ 1 ) : "";
235 static const char *debugstr_INTERPRETER_OPT_FLAGS(INTERPRETER_OPT_FLAGS Oi2Flags
)
240 if (Oi2Flags
.ServerMustSize
) strcat(buffer
, " ServerMustSize");
241 if (Oi2Flags
.ClientMustSize
) strcat(buffer
, " ClientMustSize");
242 if (Oi2Flags
.HasReturn
) strcat(buffer
, " HasReturn");
243 if (Oi2Flags
.HasPipes
) strcat(buffer
, " HasPipes");
244 if (Oi2Flags
.Unused
) strcat(buffer
, " Unused");
245 if (Oi2Flags
.HasAsyncUuid
) strcat(buffer
, " HasAsyncUuid");
246 if (Oi2Flags
.HasExtensions
) strcat(buffer
, " HasExtensions");
247 if (Oi2Flags
.HasAsyncHandle
) strcat(buffer
, " HasAsyncHandle");
248 return buffer
[0] ? wine_dbg_sprintf( "%s", buffer
+ 1 ) : "";
251 #define ARG_FROM_OFFSET(args, offset) ((args) + (offset))
253 static PFORMAT_STRING
client_get_handle(
254 PMIDL_STUB_MESSAGE pStubMsg
, const NDR_PROC_HEADER
*pProcHeader
,
255 PFORMAT_STRING pFormat
, handle_t
*phBinding
)
258 switch (pProcHeader
->handle_type
)
260 /* explicit binding: parse additional section */
261 case RPC_FC_BIND_EXPLICIT
:
262 switch (*pFormat
) /* handle_type */
264 case RPC_FC_BIND_PRIMITIVE
: /* explicit primitive */
266 const NDR_EHD_PRIMITIVE
*pDesc
= (const NDR_EHD_PRIMITIVE
*)pFormat
;
268 TRACE("Explicit primitive handle @ %d\n", pDesc
->offset
);
270 if (pDesc
->flag
) /* pointer to binding */
271 *phBinding
= **(handle_t
**)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
273 *phBinding
= *(handle_t
*)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
274 return pFormat
+ sizeof(NDR_EHD_PRIMITIVE
);
276 case RPC_FC_BIND_GENERIC
: /* explicit generic */
278 const NDR_EHD_GENERIC
*pDesc
= (const NDR_EHD_GENERIC
*)pFormat
;
279 void *pObject
= NULL
;
281 const GENERIC_BINDING_ROUTINE_PAIR
*pGenPair
;
283 TRACE("Explicit generic binding handle #%d\n", pDesc
->binding_routine_pair_index
);
285 if (pDesc
->flag_and_size
& HANDLE_PARAM_IS_VIA_PTR
)
286 pArg
= *(void **)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
288 pArg
= ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
289 memcpy(&pObject
, pArg
, pDesc
->flag_and_size
& 0xf);
290 pGenPair
= &pStubMsg
->StubDesc
->aGenericBindingRoutinePairs
[pDesc
->binding_routine_pair_index
];
291 *phBinding
= pGenPair
->pfnBind(pObject
);
292 return pFormat
+ sizeof(NDR_EHD_GENERIC
);
294 case RPC_FC_BIND_CONTEXT
: /* explicit context */
296 const NDR_EHD_CONTEXT
*pDesc
= (const NDR_EHD_CONTEXT
*)pFormat
;
297 NDR_CCONTEXT context_handle
;
298 TRACE("Explicit bind context\n");
299 if (pDesc
->flags
& HANDLE_PARAM_IS_VIA_PTR
)
301 TRACE("\tHANDLE_PARAM_IS_VIA_PTR\n");
302 context_handle
= **(NDR_CCONTEXT
**)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
305 context_handle
= *(NDR_CCONTEXT
*)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
307 if (context_handle
) *phBinding
= NDRCContextBinding(context_handle
);
308 else if (pDesc
->flags
& NDR_CONTEXT_HANDLE_CANNOT_BE_NULL
)
310 ERR("null context handle isn't allowed\n");
311 RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT
);
314 /* FIXME: should we store this structure in stubMsg.pContext? */
315 return pFormat
+ sizeof(NDR_EHD_CONTEXT
);
318 ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
319 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
322 case RPC_FC_BIND_GENERIC
: /* implicit generic */
323 FIXME("RPC_FC_BIND_GENERIC\n");
324 RpcRaiseException(RPC_X_BAD_STUB_DATA
); /* FIXME: remove when implemented */
326 case RPC_FC_BIND_PRIMITIVE
: /* implicit primitive */
327 TRACE("Implicit primitive handle\n");
328 *phBinding
= *pStubMsg
->StubDesc
->IMPLICIT_HANDLE_INFO
.pPrimitiveHandle
;
330 case RPC_FC_CALLBACK_HANDLE
: /* implicit callback */
331 TRACE("RPC_FC_CALLBACK_HANDLE\n");
332 /* server calls callback procedures only in response to remote call, and most recent
333 binding handle is used. Calling back to a client can potentially result in another
334 callback with different current handle. */
335 *phBinding
= I_RpcGetCurrentCallHandle();
337 case RPC_FC_AUTO_HANDLE
: /* implicit auto handle */
338 /* strictly speaking, it isn't necessary to set hBinding here
339 * since it isn't actually used (hence the automatic in its name),
340 * but then why does MIDL generate a valid entry in the
341 * MIDL_STUB_DESC for it? */
342 TRACE("Implicit auto handle\n");
343 *phBinding
= *pStubMsg
->StubDesc
->IMPLICIT_HANDLE_INFO
.pAutoHandle
;
346 ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
347 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
352 static void client_free_handle(
353 PMIDL_STUB_MESSAGE pStubMsg
, const NDR_PROC_HEADER
*pProcHeader
,
354 PFORMAT_STRING pFormat
, handle_t hBinding
)
357 switch (pProcHeader
->handle_type
)
359 /* explicit binding: parse additional section */
360 case RPC_FC_BIND_EXPLICIT
:
361 switch (*pFormat
) /* handle_type */
363 case RPC_FC_BIND_GENERIC
: /* explicit generic */
365 const NDR_EHD_GENERIC
*pDesc
= (const NDR_EHD_GENERIC
*)pFormat
;
366 void *pObject
= NULL
;
368 const GENERIC_BINDING_ROUTINE_PAIR
*pGenPair
;
370 TRACE("Explicit generic binding handle #%d\n", pDesc
->binding_routine_pair_index
);
372 if (pDesc
->flag_and_size
& HANDLE_PARAM_IS_VIA_PTR
)
373 pArg
= *(void **)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
375 pArg
= ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
376 memcpy(&pObject
, pArg
, pDesc
->flag_and_size
& 0xf);
377 pGenPair
= &pStubMsg
->StubDesc
->aGenericBindingRoutinePairs
[pDesc
->binding_routine_pair_index
];
378 pGenPair
->pfnUnbind(pObject
, hBinding
);
381 case RPC_FC_BIND_CONTEXT
: /* explicit context */
382 case RPC_FC_BIND_PRIMITIVE
: /* explicit primitive */
385 ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
386 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
389 case RPC_FC_BIND_GENERIC
: /* implicit generic */
390 FIXME("RPC_FC_BIND_GENERIC\n");
391 RpcRaiseException(RPC_X_BAD_STUB_DATA
); /* FIXME: remove when implemented */
393 case RPC_FC_CALLBACK_HANDLE
: /* implicit callback */
394 case RPC_FC_BIND_PRIMITIVE
: /* implicit primitive */
395 case RPC_FC_AUTO_HANDLE
: /* implicit auto handle */
398 ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
399 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
403 void client_do_args( PMIDL_STUB_MESSAGE pStubMsg
, PFORMAT_STRING pFormat
, enum stubless_phase phase
,
404 void **fpu_args
, unsigned short number_of_params
, unsigned char *pRetVal
)
406 const NDR_PARAM_OIF
*params
= (const NDR_PARAM_OIF
*)pFormat
;
409 for (i
= 0; i
< number_of_params
; i
++)
411 unsigned char *pArg
= pStubMsg
->StackTop
+ params
[i
].stack_offset
;
412 PFORMAT_STRING pTypeFormat
= (PFORMAT_STRING
)&pStubMsg
->StubDesc
->pFormatTypes
[params
[i
].u
.type_offset
];
414 #ifdef __x86_64__ /* floats are passed as doubles through varargs functions */
417 if (params
[i
].attr
.IsBasetype
&&
418 params
[i
].u
.type_format_char
== RPC_FC_FLOAT
&&
419 !params
[i
].attr
.IsSimpleRef
&&
423 pArg
= (unsigned char *)&f
;
427 TRACE("param[%d]: %p type %02x %s\n", i
, pArg
,
428 params
[i
].attr
.IsBasetype
? params
[i
].u
.type_format_char
: *pTypeFormat
,
429 debugstr_PROC_PF( params
[i
].attr
));
433 case STUBLESS_INITOUT
:
434 if (!params
[i
].attr
.IsBasetype
&& params
[i
].attr
.IsOut
&&
435 !params
[i
].attr
.IsIn
&& !params
[i
].attr
.IsByValue
)
437 memset( *(unsigned char **)pArg
, 0, calc_arg_size( pStubMsg
, pTypeFormat
));
440 case STUBLESS_CALCSIZE
:
441 if (params
[i
].attr
.IsSimpleRef
&& !*(unsigned char **)pArg
)
442 RpcRaiseException(RPC_X_NULL_REF_POINTER
);
443 if (params
[i
].attr
.IsIn
) call_buffer_sizer(pStubMsg
, pArg
, ¶ms
[i
]);
445 case STUBLESS_MARSHAL
:
446 if (params
[i
].attr
.IsIn
) call_marshaller(pStubMsg
, pArg
, ¶ms
[i
]);
448 case STUBLESS_UNMARSHAL
:
449 if (params
[i
].attr
.IsOut
)
451 if (params
[i
].attr
.IsReturn
&& pRetVal
) pArg
= pRetVal
;
452 call_unmarshaller(pStubMsg
, &pArg
, ¶ms
[i
], 0);
456 if (!params
[i
].attr
.IsBasetype
&& params
[i
].attr
.IsOut
&& !params
[i
].attr
.IsByValue
)
457 NdrClearOutParameters( pStubMsg
, pTypeFormat
, *(unsigned char **)pArg
);
460 RpcRaiseException(RPC_S_INTERNAL_ERROR
);
465 static unsigned int type_stack_size(unsigned char fc
)
479 case RPC_FC_UINT3264
:
483 case RPC_FC_ERROR_STATUS_T
:
485 return sizeof(void *);
487 return sizeof(double);
489 return sizeof(ULONGLONG
);
491 ERR("invalid base type 0x%x\n", fc
);
492 RpcRaiseException(RPC_S_INTERNAL_ERROR
);
496 static BOOL
is_by_value( PFORMAT_STRING format
)
500 case RPC_FC_USER_MARSHAL
:
504 case RPC_FC_CPSTRUCT
:
505 case RPC_FC_CVSTRUCT
:
506 case RPC_FC_BOGUS_STRUCT
:
513 PFORMAT_STRING
convert_old_args( PMIDL_STUB_MESSAGE pStubMsg
, PFORMAT_STRING pFormat
,
514 unsigned int stack_size
, BOOL object_proc
,
515 void *buffer
, unsigned int size
, unsigned int *count
)
517 NDR_PARAM_OIF
*args
= buffer
;
518 unsigned int i
, stack_offset
= object_proc
? sizeof(void *) : 0;
520 for (i
= 0; stack_offset
< stack_size
; i
++)
522 const NDR_PARAM_OI_BASETYPE
*param
= (const NDR_PARAM_OI_BASETYPE
*)pFormat
;
523 const NDR_PARAM_OI_OTHER
*other
= (const NDR_PARAM_OI_OTHER
*)pFormat
;
525 if (i
+ 1 > size
/ sizeof(*args
))
527 FIXME( "%u args not supported\n", i
);
528 RpcRaiseException( RPC_S_INTERNAL_ERROR
);
531 args
[i
].stack_offset
= stack_offset
;
532 memset( &args
[i
].attr
, 0, sizeof(args
[i
].attr
) );
534 switch (param
->param_direction
)
536 case RPC_FC_IN_PARAM_BASETYPE
:
537 args
[i
].attr
.IsIn
= 1;
538 args
[i
].attr
.IsBasetype
= 1;
540 case RPC_FC_RETURN_PARAM_BASETYPE
:
541 args
[i
].attr
.IsOut
= 1;
542 args
[i
].attr
.IsReturn
= 1;
543 args
[i
].attr
.IsBasetype
= 1;
545 case RPC_FC_IN_PARAM
:
546 args
[i
].attr
.IsIn
= 1;
547 args
[i
].attr
.MustFree
= 1;
549 case RPC_FC_IN_PARAM_NO_FREE_INST
:
550 args
[i
].attr
.IsIn
= 1;
551 args
[i
].attr
.IsDontCallFreeInst
= 1;
553 case RPC_FC_IN_OUT_PARAM
:
554 args
[i
].attr
.IsIn
= 1;
555 args
[i
].attr
.IsOut
= 1;
556 args
[i
].attr
.MustFree
= 1;
558 case RPC_FC_OUT_PARAM
:
559 args
[i
].attr
.IsOut
= 1;
561 case RPC_FC_RETURN_PARAM
:
562 args
[i
].attr
.IsOut
= 1;
563 args
[i
].attr
.IsReturn
= 1;
566 if (args
[i
].attr
.IsBasetype
)
568 args
[i
].u
.type_format_char
= param
->type_format_char
;
569 stack_offset
+= type_stack_size( param
->type_format_char
);
570 pFormat
+= sizeof(NDR_PARAM_OI_BASETYPE
);
574 args
[i
].u
.type_offset
= other
->type_offset
;
575 args
[i
].attr
.IsByValue
= is_by_value( &pStubMsg
->StubDesc
->pFormatTypes
[other
->type_offset
] );
576 stack_offset
+= other
->stack_size
* sizeof(void *);
577 pFormat
+= sizeof(NDR_PARAM_OI_OTHER
);
581 return (PFORMAT_STRING
)args
;
584 LONG_PTR CDECL
ndr_client_call( PMIDL_STUB_DESC pStubDesc
, PFORMAT_STRING pFormat
,
585 void **stack_top
, void **fpu_stack
)
587 /* pointer to start of stack where arguments start */
589 MIDL_STUB_MESSAGE stubMsg
;
590 handle_t hBinding
= NULL
;
591 /* procedure number */
592 unsigned short procedure_number
;
594 unsigned short stack_size
;
595 /* number of parameters. optional for client to give it to us */
596 unsigned int number_of_params
;
597 /* cache of Oif_flags from v2 procedure header */
598 INTERPRETER_OPT_FLAGS Oif_flags
= { 0 };
599 /* cache of extension flags from NDR_PROC_HEADER_EXTS */
600 INTERPRETER_OPT_FLAGS2 ext_flags
= { 0 };
601 /* header for procedure string */
602 const NDR_PROC_HEADER
* pProcHeader
= (const NDR_PROC_HEADER
*)&pFormat
[0];
603 /* the value to return to the client from the remote procedure */
605 /* the pointer to the object when in OLE mode */
607 PFORMAT_STRING pHandleFormat
;
608 /* correlation cache */
609 ULONG_PTR NdrCorrCache
[256];
611 TRACE("pStubDesc %p, pFormat %p, ...\n", pStubDesc
, pFormat
);
613 TRACE("NDR Version: 0x%x\n", pStubDesc
->Version
);
615 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCFLAGS
)
617 const NDR_PROC_HEADER_RPC
*header_rpc
= (const NDR_PROC_HEADER_RPC
*)&pFormat
[0];
618 stack_size
= header_rpc
->stack_size
;
619 procedure_number
= header_rpc
->proc_num
;
620 pFormat
+= sizeof(NDR_PROC_HEADER_RPC
);
624 stack_size
= pProcHeader
->stack_size
;
625 procedure_number
= pProcHeader
->proc_num
;
626 pFormat
+= sizeof(NDR_PROC_HEADER
);
628 TRACE("stack size: 0x%x\n", stack_size
);
629 TRACE("proc num: %d\n", procedure_number
);
631 /* create the full pointer translation tables, if requested */
632 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_FULLPTR
)
633 stubMsg
.FullPtrXlatTables
= NdrFullPointerXlatInit(0,XLAT_CLIENT
);
635 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
637 /* object is always the first argument */
639 NdrProxyInitialize(This
, &rpcMsg
, &stubMsg
, pStubDesc
, procedure_number
);
642 NdrClientInitializeNew(&rpcMsg
, &stubMsg
, pStubDesc
, procedure_number
);
644 TRACE("Oi_flags = 0x%02x\n", pProcHeader
->Oi_flags
);
645 TRACE("MIDL stub version = 0x%x\n", pStubDesc
->MIDLVersion
);
647 stubMsg
.StackTop
= (unsigned char *)stack_top
;
648 pHandleFormat
= pFormat
;
650 /* we only need a handle if this isn't an object method */
651 if (!(pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
))
653 pFormat
= client_get_handle(&stubMsg
, pProcHeader
, pHandleFormat
, &hBinding
);
654 if (!pFormat
) goto done
;
657 if (is_oicf_stubdesc(pStubDesc
)) /* -Oicf format */
659 const NDR_PROC_PARTIAL_OIF_HEADER
*pOIFHeader
=
660 (const NDR_PROC_PARTIAL_OIF_HEADER
*)pFormat
;
662 Oif_flags
= pOIFHeader
->Oi2Flags
;
663 number_of_params
= pOIFHeader
->number_of_params
;
665 pFormat
+= sizeof(NDR_PROC_PARTIAL_OIF_HEADER
);
667 TRACE("Oif_flags = %s\n", debugstr_INTERPRETER_OPT_FLAGS(Oif_flags
) );
669 if (Oif_flags
.HasExtensions
)
671 const NDR_PROC_HEADER_EXTS
*pExtensions
= (const NDR_PROC_HEADER_EXTS
*)pFormat
;
672 ext_flags
= pExtensions
->Flags2
;
673 pFormat
+= pExtensions
->Size
;
675 if (pExtensions
->Size
> sizeof(*pExtensions
) && fpu_stack
)
678 unsigned short fpu_mask
= *(unsigned short *)(pExtensions
+ 1);
679 for (i
= 0; i
< 4; i
++, fpu_mask
>>= 2)
680 switch (fpu_mask
& 3)
682 case 1: *(float *)&stack_top
[i
] = *(float *)&fpu_stack
[i
]; break;
683 case 2: *(double *)&stack_top
[i
] = *(double *)&fpu_stack
[i
]; break;
691 pFormat
= convert_old_args( &stubMsg
, pFormat
, stack_size
,
692 pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
,
693 /* reuse the correlation cache, it's not needed for v1 format */
694 NdrCorrCache
, sizeof(NdrCorrCache
), &number_of_params
);
697 stubMsg
.BufferLength
= 0;
699 /* store the RPC flags away */
700 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCFLAGS
)
701 rpcMsg
.RpcFlags
= ((const NDR_PROC_HEADER_RPC
*)pProcHeader
)->rpc_flags
;
703 /* use alternate memory allocation routines */
704 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCSSALLOC
)
705 NdrRpcSmSetClientToOsf(&stubMsg
);
707 if (Oif_flags
.HasPipes
)
709 FIXME("pipes not supported yet\n");
710 RpcRaiseException(RPC_X_WRONG_STUB_VERSION
); /* FIXME: remove when implemented */
711 /* init pipes package */
712 /* NdrPipesInitialize(...) */
714 if (ext_flags
.HasNewCorrDesc
)
716 /* initialize extra correlation package */
717 NdrCorrelationInitialize(&stubMsg
, NdrCorrCache
, sizeof(NdrCorrCache
), 0);
718 if (ext_flags
.Unused
& 0x2) /* has range on conformance */
719 stubMsg
.CorrDespIncrement
= 12;
723 * 1. INITOUT - zero [out] parameters (proxies only)
724 * 2. CALCSIZE - calculate the buffer size
725 * 3. GETBUFFER - allocate the buffer
726 * 4. MARSHAL - marshal [in] params into the buffer
727 * 5. SENDRECEIVE - send/receive buffer
728 * 6. UNMARSHAL - unmarshal [out] params from buffer
729 * 7. FREE - clear [out] parameters (for proxies, and only on error)
731 if ((pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
) ||
732 (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_HAS_COMM_OR_FAULT
))
735 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
737 TRACE( "INITOUT\n" );
738 client_do_args(&stubMsg
, pFormat
, STUBLESS_INITOUT
, fpu_stack
,
739 number_of_params
, (unsigned char *)&RetVal
);
745 TRACE( "CALCSIZE\n" );
746 client_do_args(&stubMsg
, pFormat
, STUBLESS_CALCSIZE
, fpu_stack
,
747 number_of_params
, (unsigned char *)&RetVal
);
750 TRACE( "GETBUFFER\n" );
751 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
753 /* allocate the buffer */
754 NdrProxyGetBuffer(This
, &stubMsg
);
758 /* allocate the buffer */
759 if (Oif_flags
.HasPipes
)
760 /* NdrGetPipeBuffer(...) */
761 FIXME("pipes not supported yet\n");
764 if (pProcHeader
->handle_type
== RPC_FC_AUTO_HANDLE
)
766 NdrNsGetBuffer(&stubMsg
, stubMsg
.BufferLength
, hBinding
);
768 FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
771 NdrGetBuffer(&stubMsg
, stubMsg
.BufferLength
, hBinding
);
776 TRACE( "MARSHAL\n" );
777 client_do_args(&stubMsg
, pFormat
, STUBLESS_MARSHAL
, fpu_stack
,
778 number_of_params
, (unsigned char *)&RetVal
);
781 TRACE( "SENDRECEIVE\n" );
782 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
784 /* send the [in] params and receive the [out] and [retval]
786 NdrProxySendReceive(This
, &stubMsg
);
790 /* send the [in] params and receive the [out] and [retval]
792 if (Oif_flags
.HasPipes
)
793 /* NdrPipesSendReceive(...) */
794 FIXME("pipes not supported yet\n");
797 if (pProcHeader
->handle_type
== RPC_FC_AUTO_HANDLE
)
799 NdrNsSendReceive(&stubMsg
, stubMsg
.Buffer
, pStubDesc
->IMPLICIT_HANDLE_INFO
.pAutoHandle
);
801 FIXME("using auto handle - call NdrNsSendReceive when it gets implemented\n");
804 NdrSendReceive(&stubMsg
, stubMsg
.Buffer
);
808 /* convert strings, floating point values and endianness into our
809 * preferred format */
810 if ((rpcMsg
.DataRepresentation
& 0x0000FFFFUL
) != NDR_LOCAL_DATA_REPRESENTATION
)
811 NdrConvert(&stubMsg
, pFormat
);
814 TRACE( "UNMARSHAL\n" );
815 client_do_args(&stubMsg
, pFormat
, STUBLESS_UNMARSHAL
, fpu_stack
,
816 number_of_params
, (unsigned char *)&RetVal
);
820 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
824 client_do_args(&stubMsg
, pFormat
, STUBLESS_FREE
, fpu_stack
,
825 number_of_params
, (unsigned char *)&RetVal
);
826 RetVal
= NdrProxyErrorHandler(GetExceptionCode());
830 const COMM_FAULT_OFFSETS
*comm_fault_offsets
= &pStubDesc
->CommFaultOffsets
[procedure_number
];
834 TRACE("comm_fault_offsets = {0x%hx, 0x%hx}\n", comm_fault_offsets
->CommOffset
, comm_fault_offsets
->FaultOffset
);
836 if (comm_fault_offsets
->CommOffset
== -1)
837 comm_status
= (ULONG
*)&RetVal
;
838 else if (comm_fault_offsets
->CommOffset
>= 0)
839 comm_status
= *(ULONG
**)ARG_FROM_OFFSET(stubMsg
.StackTop
, comm_fault_offsets
->CommOffset
);
843 if (comm_fault_offsets
->FaultOffset
== -1)
844 fault_status
= (ULONG
*)&RetVal
;
845 else if (comm_fault_offsets
->FaultOffset
>= 0)
846 fault_status
= *(ULONG
**)ARG_FROM_OFFSET(stubMsg
.StackTop
, comm_fault_offsets
->FaultOffset
);
850 NdrMapCommAndFaultStatus(&stubMsg
, comm_status
, fault_status
,
859 TRACE( "CALCSIZE\n" );
860 client_do_args(&stubMsg
, pFormat
, STUBLESS_CALCSIZE
, fpu_stack
,
861 number_of_params
, (unsigned char *)&RetVal
);
864 TRACE( "GETBUFFER\n" );
865 if (Oif_flags
.HasPipes
)
866 /* NdrGetPipeBuffer(...) */
867 FIXME("pipes not supported yet\n");
870 if (pProcHeader
->handle_type
== RPC_FC_AUTO_HANDLE
)
872 NdrNsGetBuffer(&stubMsg
, stubMsg
.BufferLength
, hBinding
);
874 FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
877 NdrGetBuffer(&stubMsg
, stubMsg
.BufferLength
, hBinding
);
881 TRACE( "MARSHAL\n" );
882 client_do_args(&stubMsg
, pFormat
, STUBLESS_MARSHAL
, fpu_stack
,
883 number_of_params
, (unsigned char *)&RetVal
);
886 TRACE( "SENDRECEIVE\n" );
887 if (Oif_flags
.HasPipes
)
888 /* NdrPipesSendReceive(...) */
889 FIXME("pipes not supported yet\n");
892 if (pProcHeader
->handle_type
== RPC_FC_AUTO_HANDLE
)
894 NdrNsSendReceive(&stubMsg
, stubMsg
.Buffer
, pStubDesc
->IMPLICIT_HANDLE_INFO
.pAutoHandle
);
896 FIXME("using auto handle - call NdrNsSendReceive when it gets implemented\n");
899 NdrSendReceive(&stubMsg
, stubMsg
.Buffer
);
902 /* convert strings, floating point values and endianness into our
903 * preferred format */
904 if ((rpcMsg
.DataRepresentation
& 0x0000FFFFUL
) != NDR_LOCAL_DATA_REPRESENTATION
)
905 NdrConvert(&stubMsg
, pFormat
);
908 TRACE( "UNMARSHAL\n" );
909 client_do_args(&stubMsg
, pFormat
, STUBLESS_UNMARSHAL
, fpu_stack
,
910 number_of_params
, (unsigned char *)&RetVal
);
913 if (ext_flags
.HasNewCorrDesc
)
915 /* free extra correlation package */
916 NdrCorrelationFree(&stubMsg
);
919 if (Oif_flags
.HasPipes
)
921 /* NdrPipesDone(...) */
924 /* free the full pointer translation tables */
925 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_FULLPTR
)
926 NdrFullPointerXlatFree(stubMsg
.FullPtrXlatTables
);
928 /* free marshalling buffer */
929 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
930 NdrProxyFreeBuffer(This
, &stubMsg
);
933 NdrFreeBuffer(&stubMsg
);
934 client_free_handle(&stubMsg
, pProcHeader
, pHandleFormat
, hBinding
);
938 TRACE("RetVal = 0x%lx\n", RetVal
);
944 __ASM_GLOBAL_FUNC( NdrClientCall2
,
945 "movq %r8,0x18(%rsp)\n\t"
946 "movq %r9,0x20(%rsp)\n\t"
947 "leaq 0x18(%rsp),%r8\n\t"
949 "subq $0x28,%rsp\n\t"
950 __ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t")
951 "call " __ASM_NAME("ndr_client_call") "\n\t"
952 "addq $0x28,%rsp\n\t"
953 __ASM_CFI(".cfi_adjust_cfa_offset -0x28\n\t")
956 #else /* __x86_64__ */
958 /***********************************************************************
959 * NdrClientCall2 [RPCRT4.@]
961 CLIENT_CALL_RETURN WINAPIV
NdrClientCall2( PMIDL_STUB_DESC desc
, PFORMAT_STRING format
, ... )
966 __ms_va_start( args
, format
);
967 ret
= ndr_client_call( desc
, format
, va_arg( args
, void ** ), NULL
);
969 return *(CLIENT_CALL_RETURN
*)&ret
;
972 #endif /* __x86_64__ */
974 /* Calls a function with the specified arguments, restoring the stack
975 * properly afterwards as we don't know the calling convention of the
977 #if defined __i386__ && defined _MSC_VER
978 __declspec(naked
) LONG_PTR __cdecl
call_server_func(SERVER_ROUTINE func
, unsigned char * args
, unsigned int stack_size
)
984 push edi
; Save registers
986 mov eax
, [ebp
+16] ; Get stack size
987 sub esp
, eax
; Make room in stack
for arguments
994 rep movsd
; Copy dword blocks
995 call
[ebp
+8] ; Call function
996 lea esp
, [ebp
-8] ; Restore stack
997 pop esi
; Restore registers
1003 #elif defined __i386__ && defined __GNUC__
1004 LONG_PTR __cdecl
call_server_func(SERVER_ROUTINE func
, unsigned char * args
, unsigned int stack_size
);
1005 __ASM_GLOBAL_FUNC(call_server_func
,
1007 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
1008 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
1009 "movl %esp,%ebp\n\t"
1010 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
1011 "pushl %edi\n\t" /* Save registers */
1012 __ASM_CFI(".cfi_rel_offset %edi,-4\n\t")
1014 __ASM_CFI(".cfi_rel_offset %esi,-8\n\t")
1015 "movl 16(%ebp), %eax\n\t" /* Get stack size */
1016 "subl %eax, %esp\n\t" /* Make room in stack for arguments */
1017 "andl $~15, %esp\n\t" /* Make sure stack has 16-byte alignment for Mac OS X */
1018 "movl %esp, %edi\n\t"
1019 "movl %eax, %ecx\n\t"
1020 "movl 12(%ebp), %esi\n\t"
1021 "shrl $2, %ecx\n\t" /* divide by 4 */
1023 "rep; movsl\n\t" /* Copy dword blocks */
1024 "call *8(%ebp)\n\t" /* Call function */
1025 "leal -8(%ebp), %esp\n\t" /* Restore stack */
1026 "popl %esi\n\t" /* Restore registers */
1027 __ASM_CFI(".cfi_same_value %esi\n\t")
1029 __ASM_CFI(".cfi_same_value %edi\n\t")
1031 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
1032 __ASM_CFI(".cfi_same_value %ebp\n\t")
1034 #elif defined __x86_64__
1035 LONG_PTR __cdecl
call_server_func(SERVER_ROUTINE func
, unsigned char * args
, unsigned int stack_size
);
1036 __ASM_GLOBAL_FUNC( call_server_func
,
1038 __ASM_CFI(".cfi_adjust_cfa_offset 8\n\t")
1039 __ASM_CFI(".cfi_rel_offset %rbp,0\n\t")
1040 "movq %rsp,%rbp\n\t"
1041 __ASM_CFI(".cfi_def_cfa_register %rbp\n\t")
1043 __ASM_CFI(".cfi_rel_offset %rsi,-8\n\t")
1045 __ASM_CFI(".cfi_rel_offset %rdi,-16\n\t")
1046 "movq %rcx,%rax\n\t" /* function to call */
1047 "movq $32,%rcx\n\t" /* allocate max(32,stack_size) bytes of stack space */
1049 "cmovgq %r8,%rcx\n\t"
1050 "subq %rcx,%rsp\n\t"
1051 "andq $~15,%rsp\n\t"
1054 "movq %rsp,%rdi\n\t"
1055 "movq %rdx,%rsi\n\t"
1056 "rep; movsq\n\t" /* copy arguments */
1057 "movq 0(%rsp),%rcx\n\t"
1058 "movq 8(%rsp),%rdx\n\t"
1059 "movq 16(%rsp),%r8\n\t"
1060 "movq 24(%rsp),%r9\n\t"
1061 "movq 0(%rsp),%xmm0\n\t"
1062 "movq 8(%rsp),%xmm1\n\t"
1063 "movq 16(%rsp),%xmm2\n\t"
1064 "movq 24(%rsp),%xmm3\n\t"
1066 "leaq -16(%rbp),%rsp\n\t" /* restore stack */
1068 __ASM_CFI(".cfi_same_value %rdi\n\t")
1070 __ASM_CFI(".cfi_same_value %rsi\n\t")
1071 __ASM_CFI(".cfi_def_cfa_register %rsp\n\t")
1073 __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t")
1074 __ASM_CFI(".cfi_same_value %rbp\n\t")
1076 #elif defined __arm__
1077 LONG_PTR __cdecl
call_server_func(SERVER_ROUTINE func
, unsigned char *args
, unsigned int stack_size
);
1078 __ASM_GLOBAL_FUNC( call_server_func
,
1080 "push {r4, r5, LR}\n\t"
1083 "lsr r3, r2, #2\n\t"
1086 "sub SP, SP, r2\n\t"
1088 "subeq SP, SP, #4\n\t"
1089 "1:\tsub r2, r2, #4\n\t"
1090 "ldr r0, [r1, r2]\n\t"
1091 "str r0, [SP, r2]\n\t"
1098 "2:\tcmp r3, #2\n\t"
1102 "3:\tcmp r3, #3\n\t"
1106 "4:\tpop {r0-r3}\n\t"
1109 "pop {r4, r5, PC}" )
1111 #warning call_server_func not implemented for your architecture
1112 LONG_PTR __cdecl
call_server_func(SERVER_ROUTINE func
, unsigned char * args
, unsigned short stack_size
)
1114 FIXME("Not implemented for your architecture\n");
1119 static LONG_PTR
*stub_do_args(MIDL_STUB_MESSAGE
*pStubMsg
,
1120 PFORMAT_STRING pFormat
, enum stubless_phase phase
,
1121 unsigned short number_of_params
)
1123 const NDR_PARAM_OIF
*params
= (const NDR_PARAM_OIF
*)pFormat
;
1125 LONG_PTR
*retval_ptr
= NULL
;
1127 for (i
= 0; i
< number_of_params
; i
++)
1129 unsigned char *pArg
= pStubMsg
->StackTop
+ params
[i
].stack_offset
;
1130 const unsigned char *pTypeFormat
= &pStubMsg
->StubDesc
->pFormatTypes
[params
[i
].u
.type_offset
];
1132 TRACE("param[%d]: %p -> %p type %02x %s\n", i
,
1133 pArg
, *(unsigned char **)pArg
,
1134 params
[i
].attr
.IsBasetype
? params
[i
].u
.type_format_char
: *pTypeFormat
,
1135 debugstr_PROC_PF( params
[i
].attr
));
1139 case STUBLESS_MARSHAL
:
1140 if (params
[i
].attr
.IsOut
|| params
[i
].attr
.IsReturn
)
1141 call_marshaller(pStubMsg
, pArg
, ¶ms
[i
]);
1143 case STUBLESS_MUSTFREE
:
1144 if (params
[i
].attr
.MustFree
)
1146 call_freer(pStubMsg
, pArg
, ¶ms
[i
]);
1150 if (params
[i
].attr
.ServerAllocSize
)
1152 HeapFree(GetProcessHeap(), 0, *(void **)pArg
);
1154 else if (params
[i
].attr
.IsOut
&&
1155 !params
[i
].attr
.IsIn
&&
1156 !params
[i
].attr
.IsBasetype
&&
1157 !params
[i
].attr
.IsByValue
)
1159 if (*pTypeFormat
!= RPC_FC_BIND_CONTEXT
) pStubMsg
->pfnFree(*(void **)pArg
);
1162 case STUBLESS_INITOUT
:
1163 if (!params
[i
].attr
.IsIn
&&
1164 params
[i
].attr
.IsOut
&&
1165 !params
[i
].attr
.IsBasetype
&&
1166 !params
[i
].attr
.ServerAllocSize
&&
1167 !params
[i
].attr
.IsByValue
)
1169 if (*pTypeFormat
== RPC_FC_BIND_CONTEXT
)
1171 NDR_SCONTEXT ctxt
= NdrContextHandleInitialize(pStubMsg
, pTypeFormat
);
1172 *(void **)pArg
= NDRSContextValue(ctxt
);
1176 DWORD size
= calc_arg_size(pStubMsg
, pTypeFormat
);
1179 *(void **)pArg
= NdrAllocate(pStubMsg
, size
);
1180 memset(*(void **)pArg
, 0, size
);
1185 case STUBLESS_UNMARSHAL
:
1186 if (params
[i
].attr
.ServerAllocSize
)
1187 *(void **)pArg
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
1188 params
[i
].attr
.ServerAllocSize
* 8);
1190 if (params
[i
].attr
.IsIn
)
1191 call_unmarshaller(pStubMsg
, &pArg
, ¶ms
[i
], 0);
1193 case STUBLESS_CALCSIZE
:
1194 if (params
[i
].attr
.IsOut
|| params
[i
].attr
.IsReturn
)
1195 call_buffer_sizer(pStubMsg
, pArg
, ¶ms
[i
]);
1198 RpcRaiseException(RPC_S_INTERNAL_ERROR
);
1200 TRACE("\tmemory addr (after): %p -> %p\n", pArg
, *(unsigned char **)pArg
);
1202 /* make a note of the address of the return value parameter for later */
1203 if (params
[i
].attr
.IsReturn
) retval_ptr
= (LONG_PTR
*)pArg
;
1208 /***********************************************************************
1209 * NdrStubCall2 [RPCRT4.@]
1211 * Unmarshals [in] parameters, calls either a method in an object or a server
1212 * function, marshals any [out] parameters and frees any allocated data.
1215 * Used by stubless MIDL-generated code.
1217 LONG WINAPI
NdrStubCall2(
1218 struct IRpcStubBuffer
* pThis
,
1219 struct IRpcChannelBuffer
* pChannel
,
1220 PRPC_MESSAGE pRpcMsg
,
1221 DWORD
* pdwStubPhase
)
1223 const MIDL_SERVER_INFO
*pServerInfo
;
1224 const MIDL_STUB_DESC
*pStubDesc
;
1225 PFORMAT_STRING pFormat
;
1226 MIDL_STUB_MESSAGE stubMsg
;
1227 /* pointer to start of stack to pass into stub implementation */
1228 unsigned char * args
;
1230 unsigned short stack_size
;
1231 /* number of parameters. optional for client to give it to us */
1232 unsigned int number_of_params
;
1233 /* cache of Oif_flags from v2 procedure header */
1234 INTERPRETER_OPT_FLAGS Oif_flags
= { 0 };
1235 /* cache of extension flags from NDR_PROC_HEADER_EXTS */
1236 INTERPRETER_OPT_FLAGS2 ext_flags
= { 0 };
1237 /* the type of pass we are currently doing */
1238 enum stubless_phase phase
;
1239 /* header for procedure string */
1240 const NDR_PROC_HEADER
*pProcHeader
;
1241 /* location to put retval into */
1242 LONG_PTR
*retval_ptr
= NULL
;
1243 /* correlation cache */
1244 ULONG_PTR NdrCorrCache
[256];
1246 TRACE("pThis %p, pChannel %p, pRpcMsg %p, pdwStubPhase %p\n", pThis
, pChannel
, pRpcMsg
, pdwStubPhase
);
1249 pServerInfo
= CStdStubBuffer_GetServerInfo(pThis
);
1251 pServerInfo
= ((RPC_SERVER_INTERFACE
*)pRpcMsg
->RpcInterfaceInformation
)->InterpreterInfo
;
1253 pStubDesc
= pServerInfo
->pStubDesc
;
1254 pFormat
= pServerInfo
->ProcString
+ pServerInfo
->FmtStringOffset
[pRpcMsg
->ProcNum
];
1255 pProcHeader
= (const NDR_PROC_HEADER
*)&pFormat
[0];
1257 TRACE("NDR Version: 0x%x\n", pStubDesc
->Version
);
1259 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCFLAGS
)
1261 const NDR_PROC_HEADER_RPC
*header_rpc
= (const NDR_PROC_HEADER_RPC
*)&pFormat
[0];
1262 stack_size
= header_rpc
->stack_size
;
1263 pFormat
+= sizeof(NDR_PROC_HEADER_RPC
);
1268 stack_size
= pProcHeader
->stack_size
;
1269 pFormat
+= sizeof(NDR_PROC_HEADER
);
1272 TRACE("Oi_flags = 0x%02x\n", pProcHeader
->Oi_flags
);
1275 switch (pProcHeader
->handle_type
)
1277 /* explicit binding: parse additional section */
1278 case RPC_FC_BIND_EXPLICIT
:
1279 switch (*pFormat
) /* handle_type */
1281 case RPC_FC_BIND_PRIMITIVE
: /* explicit primitive */
1282 pFormat
+= sizeof(NDR_EHD_PRIMITIVE
);
1284 case RPC_FC_BIND_GENERIC
: /* explicit generic */
1285 pFormat
+= sizeof(NDR_EHD_GENERIC
);
1287 case RPC_FC_BIND_CONTEXT
: /* explicit context */
1288 pFormat
+= sizeof(NDR_EHD_CONTEXT
);
1291 ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
1292 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
1295 case RPC_FC_BIND_GENERIC
: /* implicit generic */
1296 case RPC_FC_BIND_PRIMITIVE
: /* implicit primitive */
1297 case RPC_FC_CALLBACK_HANDLE
: /* implicit callback */
1298 case RPC_FC_AUTO_HANDLE
: /* implicit auto handle */
1301 ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
1302 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
1305 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
1306 NdrStubInitialize(pRpcMsg
, &stubMsg
, pStubDesc
, pChannel
);
1308 NdrServerInitializeNew(pRpcMsg
, &stubMsg
, pStubDesc
);
1310 /* create the full pointer translation tables, if requested */
1311 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_FULLPTR
)
1312 stubMsg
.FullPtrXlatTables
= NdrFullPointerXlatInit(0,XLAT_SERVER
);
1314 /* store the RPC flags away */
1315 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCFLAGS
)
1316 pRpcMsg
->RpcFlags
= ((const NDR_PROC_HEADER_RPC
*)pProcHeader
)->rpc_flags
;
1318 /* use alternate memory allocation routines */
1319 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCSSALLOC
)
1321 NdrRpcSsEnableAllocate(&stubMsg
);
1323 FIXME("Set RPCSS memory allocation routines\n");
1326 TRACE("allocating memory for stack of size %x\n", stack_size
);
1328 args
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, stack_size
);
1329 stubMsg
.StackTop
= args
; /* used by conformance of top-level objects */
1331 /* add the implicit This pointer as the first arg to the function if we
1332 * are calling an object method */
1334 *(void **)args
= ((CStdStubBuffer
*)pThis
)->pvServerObject
;
1336 if (is_oicf_stubdesc(pStubDesc
))
1338 const NDR_PROC_PARTIAL_OIF_HEADER
*pOIFHeader
= (const NDR_PROC_PARTIAL_OIF_HEADER
*)pFormat
;
1340 Oif_flags
= pOIFHeader
->Oi2Flags
;
1341 number_of_params
= pOIFHeader
->number_of_params
;
1343 pFormat
+= sizeof(NDR_PROC_PARTIAL_OIF_HEADER
);
1345 TRACE("Oif_flags = %s\n", debugstr_INTERPRETER_OPT_FLAGS(Oif_flags
) );
1347 if (Oif_flags
.HasExtensions
)
1349 const NDR_PROC_HEADER_EXTS
*pExtensions
= (const NDR_PROC_HEADER_EXTS
*)pFormat
;
1350 ext_flags
= pExtensions
->Flags2
;
1351 pFormat
+= pExtensions
->Size
;
1354 if (Oif_flags
.HasPipes
)
1356 FIXME("pipes not supported yet\n");
1357 RpcRaiseException(RPC_X_WRONG_STUB_VERSION
); /* FIXME: remove when implemented */
1358 /* init pipes package */
1359 /* NdrPipesInitialize(...) */
1361 if (ext_flags
.HasNewCorrDesc
)
1363 /* initialize extra correlation package */
1364 NdrCorrelationInitialize(&stubMsg
, NdrCorrCache
, sizeof(NdrCorrCache
), 0);
1365 if (ext_flags
.Unused
& 0x2) /* has range on conformance */
1366 stubMsg
.CorrDespIncrement
= 12;
1371 pFormat
= convert_old_args( &stubMsg
, pFormat
, stack_size
,
1372 pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
,
1373 /* reuse the correlation cache, it's not needed for v1 format */
1374 NdrCorrCache
, sizeof(NdrCorrCache
), &number_of_params
);
1377 /* convert strings, floating point values and endianness into our
1378 * preferred format */
1379 if ((pRpcMsg
->DataRepresentation
& 0x0000FFFFUL
) != NDR_LOCAL_DATA_REPRESENTATION
)
1380 NdrConvert(&stubMsg
, pFormat
);
1382 for (phase
= STUBLESS_UNMARSHAL
; phase
<= STUBLESS_FREE
; phase
++)
1384 TRACE("phase = %d\n", phase
);
1387 case STUBLESS_CALLSERVER
:
1388 /* call the server function */
1389 if (pServerInfo
->ThunkTable
&& pServerInfo
->ThunkTable
[pRpcMsg
->ProcNum
])
1390 pServerInfo
->ThunkTable
[pRpcMsg
->ProcNum
](&stubMsg
);
1393 SERVER_ROUTINE func
;
1396 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
1398 SERVER_ROUTINE
*vtbl
= *(SERVER_ROUTINE
**)((CStdStubBuffer
*)pThis
)->pvServerObject
;
1399 func
= vtbl
[pRpcMsg
->ProcNum
];
1402 func
= pServerInfo
->DispatchTable
[pRpcMsg
->ProcNum
];
1404 /* FIXME: what happens with return values that don't fit into a single register on x86? */
1405 retval
= call_server_func(func
, args
, stack_size
);
1409 TRACE("stub implementation returned 0x%lx\n", retval
);
1410 *retval_ptr
= retval
;
1413 TRACE("void stub implementation\n");
1416 stubMsg
.Buffer
= NULL
;
1417 stubMsg
.BufferLength
= 0;
1420 case STUBLESS_GETBUFFER
:
1421 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
1422 NdrStubGetBuffer(pThis
, pChannel
, &stubMsg
);
1427 pRpcMsg
->BufferLength
= stubMsg
.BufferLength
;
1428 /* allocate buffer for [out] and [ret] params */
1429 Status
= I_RpcGetBuffer(pRpcMsg
);
1431 RpcRaiseException(Status
);
1432 stubMsg
.Buffer
= pRpcMsg
->Buffer
;
1435 case STUBLESS_UNMARSHAL
:
1436 case STUBLESS_INITOUT
:
1437 case STUBLESS_CALCSIZE
:
1438 case STUBLESS_MARSHAL
:
1439 case STUBLESS_MUSTFREE
:
1441 retval_ptr
= stub_do_args(&stubMsg
, pFormat
, phase
, number_of_params
);
1444 ERR("shouldn't reach here. phase %d\n", phase
);
1449 pRpcMsg
->BufferLength
= (unsigned int)(stubMsg
.Buffer
- (unsigned char *)pRpcMsg
->Buffer
);
1451 if (ext_flags
.HasNewCorrDesc
)
1453 /* free extra correlation package */
1454 NdrCorrelationFree(&stubMsg
);
1457 if (Oif_flags
.HasPipes
)
1459 /* NdrPipesDone(...) */
1462 /* free the full pointer translation tables */
1463 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_FULLPTR
)
1464 NdrFullPointerXlatFree(stubMsg
.FullPtrXlatTables
);
1466 /* free server function stack */
1467 HeapFree(GetProcessHeap(), 0, args
);
1472 /***********************************************************************
1473 * NdrServerCall2 [RPCRT4.@]
1475 void WINAPI
NdrServerCall2(PRPC_MESSAGE pRpcMsg
)
1478 NdrStubCall2(NULL
, NULL
, pRpcMsg
, &dwPhase
);
1481 /***********************************************************************
1482 * NdrStubCall [RPCRT4.@]
1484 LONG WINAPI
NdrStubCall( struct IRpcStubBuffer
*This
, struct IRpcChannelBuffer
*channel
,
1485 PRPC_MESSAGE msg
, DWORD
*phase
)
1487 return NdrStubCall2( This
, channel
, msg
, phase
);
1490 /***********************************************************************
1491 * NdrServerCall [RPCRT4.@]
1493 void WINAPI
NdrServerCall( PRPC_MESSAGE msg
)
1496 NdrStubCall( NULL
, NULL
, msg
, &phase
);
1499 struct async_call_data
1501 MIDL_STUB_MESSAGE
*pStubMsg
;
1502 const NDR_PROC_HEADER
*pProcHeader
;
1503 PFORMAT_STRING pHandleFormat
;
1504 PFORMAT_STRING pParamFormat
;
1505 RPC_BINDING_HANDLE hBinding
;
1507 unsigned short stack_size
;
1508 /* number of parameters. optional for client to give it to us */
1509 unsigned int number_of_params
;
1510 /* correlation cache */
1511 ULONG_PTR NdrCorrCache
[256];
1514 LONG_PTR CDECL
ndr_async_client_call( PMIDL_STUB_DESC pStubDesc
, PFORMAT_STRING pFormat
, void **stack_top
)
1516 /* pointer to start of stack where arguments start */
1517 PRPC_MESSAGE pRpcMsg
;
1518 PMIDL_STUB_MESSAGE pStubMsg
;
1519 RPC_ASYNC_STATE
*pAsync
;
1520 struct async_call_data
*async_call_data
;
1521 /* procedure number */
1522 unsigned short procedure_number
;
1523 /* cache of Oif_flags from v2 procedure header */
1524 INTERPRETER_OPT_FLAGS Oif_flags
= { 0 };
1525 /* cache of extension flags from NDR_PROC_HEADER_EXTS */
1526 INTERPRETER_OPT_FLAGS2 ext_flags
= { 0 };
1527 /* header for procedure string */
1528 const NDR_PROC_HEADER
* pProcHeader
= (const NDR_PROC_HEADER
*)&pFormat
[0];
1531 TRACE("pStubDesc %p, pFormat %p, ...\n", pStubDesc
, pFormat
);
1533 /* Later NDR language versions probably won't be backwards compatible */
1534 if (pStubDesc
->Version
> 0x50002)
1536 FIXME("Incompatible stub description version: 0x%x\n", pStubDesc
->Version
);
1537 RpcRaiseException(RPC_X_WRONG_STUB_VERSION
);
1540 async_call_data
= I_RpcAllocate(sizeof(*async_call_data
) + sizeof(MIDL_STUB_MESSAGE
) + sizeof(RPC_MESSAGE
));
1541 if (!async_call_data
) RpcRaiseException(RPC_X_NO_MEMORY
);
1542 async_call_data
->pProcHeader
= pProcHeader
;
1544 async_call_data
->pStubMsg
= pStubMsg
= (PMIDL_STUB_MESSAGE
)(async_call_data
+ 1);
1545 pRpcMsg
= (PRPC_MESSAGE
)(pStubMsg
+ 1);
1547 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCFLAGS
)
1549 const NDR_PROC_HEADER_RPC
*header_rpc
= (const NDR_PROC_HEADER_RPC
*)&pFormat
[0];
1550 async_call_data
->stack_size
= header_rpc
->stack_size
;
1551 procedure_number
= header_rpc
->proc_num
;
1552 pFormat
+= sizeof(NDR_PROC_HEADER_RPC
);
1556 async_call_data
->stack_size
= pProcHeader
->stack_size
;
1557 procedure_number
= pProcHeader
->proc_num
;
1558 pFormat
+= sizeof(NDR_PROC_HEADER
);
1560 TRACE("stack size: 0x%x\n", async_call_data
->stack_size
);
1561 TRACE("proc num: %d\n", procedure_number
);
1563 /* create the full pointer translation tables, if requested */
1564 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_FULLPTR
)
1565 pStubMsg
->FullPtrXlatTables
= NdrFullPointerXlatInit(0,XLAT_CLIENT
);
1567 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
)
1569 ERR("objects not supported\n");
1570 I_RpcFree(async_call_data
);
1571 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
1574 NdrClientInitializeNew(pRpcMsg
, pStubMsg
, pStubDesc
, procedure_number
);
1576 TRACE("Oi_flags = 0x%02x\n", pProcHeader
->Oi_flags
);
1577 TRACE("MIDL stub version = 0x%x\n", pStubDesc
->MIDLVersion
);
1579 /* needed for conformance of top-level objects */
1580 pStubMsg
->StackTop
= I_RpcAllocate(async_call_data
->stack_size
);
1581 memcpy(pStubMsg
->StackTop
, stack_top
, async_call_data
->stack_size
);
1583 pAsync
= *(RPC_ASYNC_STATE
**)pStubMsg
->StackTop
;
1584 pAsync
->StubInfo
= async_call_data
;
1585 async_call_data
->pHandleFormat
= pFormat
;
1587 pFormat
= client_get_handle(pStubMsg
, pProcHeader
, async_call_data
->pHandleFormat
, &async_call_data
->hBinding
);
1588 if (!pFormat
) goto done
;
1590 if (is_oicf_stubdesc(pStubDesc
))
1592 const NDR_PROC_PARTIAL_OIF_HEADER
*pOIFHeader
=
1593 (const NDR_PROC_PARTIAL_OIF_HEADER
*)pFormat
;
1595 Oif_flags
= pOIFHeader
->Oi2Flags
;
1596 async_call_data
->number_of_params
= pOIFHeader
->number_of_params
;
1598 pFormat
+= sizeof(NDR_PROC_PARTIAL_OIF_HEADER
);
1600 TRACE("Oif_flags = %s\n", debugstr_INTERPRETER_OPT_FLAGS(Oif_flags
) );
1602 if (Oif_flags
.HasExtensions
)
1604 const NDR_PROC_HEADER_EXTS
*pExtensions
=
1605 (const NDR_PROC_HEADER_EXTS
*)pFormat
;
1606 ext_flags
= pExtensions
->Flags2
;
1607 pFormat
+= pExtensions
->Size
;
1612 pFormat
= convert_old_args( pStubMsg
, pFormat
, async_call_data
->stack_size
,
1613 pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_OBJECT
,
1614 async_call_data
->NdrCorrCache
, sizeof(async_call_data
->NdrCorrCache
),
1615 &async_call_data
->number_of_params
);
1618 async_call_data
->pParamFormat
= pFormat
;
1620 pStubMsg
->BufferLength
= 0;
1622 /* store the RPC flags away */
1623 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCFLAGS
)
1624 pRpcMsg
->RpcFlags
= ((const NDR_PROC_HEADER_RPC
*)pProcHeader
)->rpc_flags
;
1626 /* use alternate memory allocation routines */
1627 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_RPCSSALLOC
)
1628 NdrRpcSmSetClientToOsf(pStubMsg
);
1630 if (Oif_flags
.HasPipes
)
1632 FIXME("pipes not supported yet\n");
1633 RpcRaiseException(RPC_X_WRONG_STUB_VERSION
); /* FIXME: remove when implemented */
1634 /* init pipes package */
1635 /* NdrPipesInitialize(...) */
1637 if (ext_flags
.HasNewCorrDesc
)
1639 /* initialize extra correlation package */
1640 NdrCorrelationInitialize(pStubMsg
, async_call_data
->NdrCorrCache
, sizeof(async_call_data
->NdrCorrCache
), 0);
1641 if (ext_flags
.Unused
& 0x2) /* has range on conformance */
1642 pStubMsg
->CorrDespIncrement
= 12;
1646 * 1. CALCSIZE - calculate the buffer size
1647 * 2. GETBUFFER - allocate the buffer
1648 * 3. MARSHAL - marshal [in] params into the buffer
1649 * 4. SENDRECEIVE - send buffer
1650 * Then in NdrpCompleteAsyncClientCall:
1651 * 1. SENDRECEIVE - receive buffer
1652 * 2. UNMARSHAL - unmarshal [out] params from buffer
1656 TRACE( "CALCSIZE\n" );
1657 client_do_args(pStubMsg
, pFormat
, STUBLESS_CALCSIZE
, NULL
, async_call_data
->number_of_params
, NULL
);
1660 TRACE( "GETBUFFER\n" );
1661 if (Oif_flags
.HasPipes
)
1662 /* NdrGetPipeBuffer(...) */
1663 FIXME("pipes not supported yet\n");
1666 if (pProcHeader
->handle_type
== RPC_FC_AUTO_HANDLE
)
1668 NdrNsGetBuffer(pStubMsg
, pStubMsg
->BufferLength
, async_call_data
->hBinding
);
1670 FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
1673 NdrGetBuffer(pStubMsg
, pStubMsg
->BufferLength
, async_call_data
->hBinding
);
1675 pRpcMsg
->RpcFlags
|= RPC_BUFFER_ASYNC
;
1676 status
= I_RpcAsyncSetHandle(pRpcMsg
, pAsync
);
1677 if (status
!= RPC_S_OK
)
1678 RpcRaiseException(status
);
1681 TRACE( "MARSHAL\n" );
1682 client_do_args(pStubMsg
, pFormat
, STUBLESS_MARSHAL
, NULL
, async_call_data
->number_of_params
, NULL
);
1684 /* 4. SENDRECEIVE */
1686 pRpcMsg
->RpcFlags
|= RPC_BUFFER_ASYNC
;
1687 /* send the [in] params only */
1688 if (Oif_flags
.HasPipes
)
1689 /* NdrPipesSend(...) */
1690 FIXME("pipes not supported yet\n");
1693 if (pProcHeader
->handle_type
== RPC_FC_AUTO_HANDLE
)
1695 NdrNsSend(&stubMsg
, stubMsg
.Buffer
, pStubDesc
->IMPLICIT_HANDLE_INFO
.pAutoHandle
);
1697 FIXME("using auto handle - call NdrNsSend when it gets implemented\n");
1701 pStubMsg
->RpcMsg
->BufferLength
= pStubMsg
->Buffer
- (unsigned char *)pStubMsg
->RpcMsg
->Buffer
;
1702 status
= I_RpcSend(pStubMsg
->RpcMsg
);
1703 if (status
!= RPC_S_OK
)
1704 RpcRaiseException(status
);
1709 TRACE("returning 0\n");
1713 RPC_STATUS
NdrpCompleteAsyncClientCall(RPC_ASYNC_STATE
*pAsync
, void *Reply
)
1715 /* pointer to start of stack where arguments start */
1716 PMIDL_STUB_MESSAGE pStubMsg
;
1717 struct async_call_data
*async_call_data
;
1718 /* header for procedure string */
1719 const NDR_PROC_HEADER
* pProcHeader
;
1720 RPC_STATUS status
= RPC_S_OK
;
1722 if (!pAsync
->StubInfo
)
1723 return RPC_S_INVALID_ASYNC_HANDLE
;
1725 async_call_data
= pAsync
->StubInfo
;
1726 pStubMsg
= async_call_data
->pStubMsg
;
1727 pProcHeader
= async_call_data
->pProcHeader
;
1730 * 1. CALCSIZE - calculate the buffer size
1731 * 2. GETBUFFER - allocate the buffer
1732 * 3. MARSHAL - marshal [in] params into the buffer
1733 * 4. SENDRECEIVE - send buffer
1734 * Then in NdrpCompleteAsyncClientCall:
1735 * 1. SENDRECEIVE - receive buffer
1736 * 2. UNMARSHAL - unmarshal [out] params from buffer
1739 /* 1. SENDRECEIVE */
1740 TRACE( "RECEIVE\n" );
1741 pStubMsg
->RpcMsg
->RpcFlags
|= RPC_BUFFER_ASYNC
;
1742 /* receive the [out] params */
1743 if (pProcHeader
->handle_type
== RPC_FC_AUTO_HANDLE
)
1745 NdrNsReceive(&stubMsg
, stubMsg
.Buffer
, pStubDesc
->IMPLICIT_HANDLE_INFO
.pAutoHandle
);
1747 FIXME("using auto handle - call NdrNsReceive when it gets implemented\n");
1751 status
= I_RpcReceive(pStubMsg
->RpcMsg
);
1752 if (status
!= RPC_S_OK
)
1754 pStubMsg
->BufferLength
= pStubMsg
->RpcMsg
->BufferLength
;
1755 pStubMsg
->BufferStart
= pStubMsg
->RpcMsg
->Buffer
;
1756 pStubMsg
->BufferEnd
= pStubMsg
->BufferStart
+ pStubMsg
->BufferLength
;
1757 pStubMsg
->Buffer
= pStubMsg
->BufferStart
;
1760 /* convert strings, floating point values and endianness into our
1761 * preferred format */
1763 if ((pStubMsg
->RpcMsg
.DataRepresentation
& 0x0000FFFFUL
) != NDR_LOCAL_DATA_REPRESENTATION
)
1764 NdrConvert(pStubMsg
, pFormat
);
1768 TRACE( "UNMARSHAL\n" );
1769 client_do_args(pStubMsg
, async_call_data
->pParamFormat
, STUBLESS_UNMARSHAL
,
1770 NULL
, async_call_data
->number_of_params
, Reply
);
1773 if (pStubMsg
->fHasNewCorrDesc
)
1775 /* free extra correlation package */
1776 NdrCorrelationFree(pStubMsg
);
1779 /* free the full pointer translation tables */
1780 if (pProcHeader
->Oi_flags
& RPC_FC_PROC_OIF_FULLPTR
)
1781 NdrFullPointerXlatFree(pStubMsg
->FullPtrXlatTables
);
1783 /* free marshalling buffer */
1784 NdrFreeBuffer(pStubMsg
);
1785 client_free_handle(pStubMsg
, pProcHeader
, async_call_data
->pHandleFormat
, async_call_data
->hBinding
);
1787 I_RpcFree(pStubMsg
->StackTop
);
1788 I_RpcFree(async_call_data
);
1790 TRACE("-- 0x%x\n", status
);
1796 __ASM_GLOBAL_FUNC( NdrAsyncClientCall
,
1797 "movq %r8,0x18(%rsp)\n\t"
1798 "movq %r9,0x20(%rsp)\n\t"
1799 "leaq 0x18(%rsp),%r8\n\t"
1800 "subq $0x28,%rsp\n\t"
1801 __ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t")
1802 "call " __ASM_NAME("ndr_async_client_call") "\n\t"
1803 "addq $0x28,%rsp\n\t"
1804 __ASM_CFI(".cfi_adjust_cfa_offset -0x28\n\t")
1807 #else /* __x86_64__ */
1809 /***********************************************************************
1810 * NdrAsyncClientCall [RPCRT4.@]
1812 CLIENT_CALL_RETURN WINAPIV
NdrAsyncClientCall( PMIDL_STUB_DESC desc
, PFORMAT_STRING format
, ... )
1817 __ms_va_start( args
, format
);
1818 ret
= ndr_async_client_call( desc
, format
, va_arg( args
, void ** ));
1819 __ms_va_end( args
);
1820 return *(CLIENT_CALL_RETURN
*)&ret
;
1823 #endif /* __x86_64__ */
1825 RPCRTAPI LONG RPC_ENTRY
NdrAsyncStubCall(struct IRpcStubBuffer
* pThis
,
1826 struct IRpcChannelBuffer
* pChannel
, PRPC_MESSAGE pRpcMsg
,
1827 DWORD
* pdwStubPhase
)
1829 FIXME("unimplemented, expect crash!\n");