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"
46 #include "ndr_stubless.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(rpc
);
50 #define NDR_TABLE_MASK 127
52 static inline BOOL
is_oicf_stubdesc(const PMIDL_STUB_DESC pStubDesc
)
54 return pStubDesc
->Version
>= 0x20000;
57 static inline void call_buffer_sizer(PMIDL_STUB_MESSAGE pStubMsg
, unsigned char *pMemory
,
58 const NDR_PARAM_OIF
*param
)
60 PFORMAT_STRING pFormat
;
63 if (param
->attr
.IsBasetype
)
65 pFormat
= ¶m
->u
.type_format_char
;
66 if (param
->attr
.IsSimpleRef
) pMemory
= *(unsigned char **)pMemory
;
70 pFormat
= &pStubMsg
->StubDesc
->pFormatTypes
[param
->u
.type_offset
];
71 if (!param
->attr
.IsByValue
) pMemory
= *(unsigned char **)pMemory
;
74 m
= NdrBufferSizer
[pFormat
[0] & NDR_TABLE_MASK
];
75 if (m
) m(pStubMsg
, pMemory
, pFormat
);
78 FIXME("format type 0x%x not implemented\n", pFormat
[0]);
79 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
83 static inline unsigned char *call_marshaller(PMIDL_STUB_MESSAGE pStubMsg
, unsigned char *pMemory
,
84 const NDR_PARAM_OIF
*param
)
86 PFORMAT_STRING pFormat
;
89 if (param
->attr
.IsBasetype
)
91 pFormat
= ¶m
->u
.type_format_char
;
92 if (param
->attr
.IsSimpleRef
) pMemory
= *(unsigned char **)pMemory
;
96 pFormat
= &pStubMsg
->StubDesc
->pFormatTypes
[param
->u
.type_offset
];
97 if (!param
->attr
.IsByValue
) pMemory
= *(unsigned char **)pMemory
;
100 m
= NdrMarshaller
[pFormat
[0] & NDR_TABLE_MASK
];
101 if (m
) return m(pStubMsg
, pMemory
, pFormat
);
104 FIXME("format type 0x%x not implemented\n", pFormat
[0]);
105 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
110 static inline unsigned char *call_unmarshaller(PMIDL_STUB_MESSAGE pStubMsg
, unsigned char **ppMemory
,
111 const NDR_PARAM_OIF
*param
, unsigned char fMustAlloc
)
113 PFORMAT_STRING pFormat
;
116 if (param
->attr
.IsBasetype
)
118 pFormat
= ¶m
->u
.type_format_char
;
119 if (param
->attr
.IsSimpleRef
) ppMemory
= (unsigned char **)*ppMemory
;
123 pFormat
= &pStubMsg
->StubDesc
->pFormatTypes
[param
->u
.type_offset
];
124 if (!param
->attr
.IsByValue
) ppMemory
= (unsigned char **)*ppMemory
;
127 m
= NdrUnmarshaller
[pFormat
[0] & NDR_TABLE_MASK
];
128 if (m
) return m(pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
131 FIXME("format type 0x%x not implemented\n", pFormat
[0]);
132 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
137 static inline void call_freer(PMIDL_STUB_MESSAGE pStubMsg
, unsigned char *pMemory
,
138 const NDR_PARAM_OIF
*param
)
140 PFORMAT_STRING pFormat
;
143 if (param
->attr
.IsBasetype
) return; /* nothing to do */
144 pFormat
= &pStubMsg
->StubDesc
->pFormatTypes
[param
->u
.type_offset
];
145 if (!param
->attr
.IsByValue
) pMemory
= *(unsigned char **)pMemory
;
147 m
= NdrFreer
[pFormat
[0] & NDR_TABLE_MASK
];
148 if (m
) m(pStubMsg
, pMemory
, pFormat
);
151 static DWORD
calc_arg_size(MIDL_STUB_MESSAGE
*pStubMsg
, PFORMAT_STRING pFormat
)
157 if (pFormat
[1] & FC_SIMPLE_POINTER
)
162 size
= calc_arg_size(pStubMsg
, &pFormat
[2] + *(const SHORT
*)&pFormat
[2]);
166 size
= *(const WORD
*)(pFormat
+ 2);
168 case FC_BOGUS_STRUCT
:
169 size
= *(const WORD
*)(pFormat
+ 2);
170 if(*(const WORD
*)(pFormat
+ 4))
171 FIXME("Unhandled conformant description\n");
175 size
= *(const WORD
*)(pFormat
+ 2);
176 ComputeConformance(pStubMsg
, NULL
, pFormat
+ 4, 0);
177 size
*= pStubMsg
->MaxCount
;
181 size
= *(const WORD
*)(pFormat
+ 2);
185 size
= *(const DWORD
*)(pFormat
+ 2);
188 pFormat
= ComputeConformance(pStubMsg
, NULL
, pFormat
+ 4, *(const WORD
*)&pFormat
[2]);
189 TRACE("conformance = %ld\n", pStubMsg
->MaxCount
);
190 pFormat
= ComputeVariance(pStubMsg
, NULL
, pFormat
, pStubMsg
->MaxCount
);
191 size
= ComplexStructSize(pStubMsg
, pFormat
);
192 size
*= pStubMsg
->MaxCount
;
194 case FC_USER_MARSHAL
:
195 size
= *(const WORD
*)(pFormat
+ 4);
198 size
= *(const WORD
*)(pFormat
+ 2);
201 size
= *(const WORD
*)(pFormat
+ 2) * sizeof(WCHAR
);
205 if (*pFormat
== FC_C_CSTRING
)
208 size
= sizeof(WCHAR
);
209 if (pFormat
[1] == FC_STRING_SIZED
)
210 ComputeConformance(pStubMsg
, NULL
, pFormat
+ 2, 0);
212 pStubMsg
->MaxCount
= 0;
213 size
*= pStubMsg
->MaxCount
;
216 FIXME("Unhandled type %02x\n", *pFormat
);
222 size
= sizeof(void *);
228 void WINAPI
NdrRpcSmSetClientToOsf(PMIDL_STUB_MESSAGE pMessage
)
230 #if 0 /* these functions are not defined yet */
231 pMessage
->pfnAllocate
= NdrRpcSmClientAllocate
;
232 pMessage
->pfnFree
= NdrRpcSmClientFree
;
236 static const char *debugstr_PROC_PF(PARAM_ATTRIBUTES param_attributes
)
241 if (param_attributes
.MustSize
) strcat(buffer
, " MustSize");
242 if (param_attributes
.MustFree
) strcat(buffer
, " MustFree");
243 if (param_attributes
.IsPipe
) strcat(buffer
, " IsPipe");
244 if (param_attributes
.IsIn
) strcat(buffer
, " IsIn");
245 if (param_attributes
.IsOut
) strcat(buffer
, " IsOut");
246 if (param_attributes
.IsReturn
) strcat(buffer
, " IsReturn");
247 if (param_attributes
.IsBasetype
) strcat(buffer
, " IsBasetype");
248 if (param_attributes
.IsByValue
) strcat(buffer
, " IsByValue");
249 if (param_attributes
.IsSimpleRef
) strcat(buffer
, " IsSimpleRef");
250 if (param_attributes
.IsDontCallFreeInst
) strcat(buffer
, " IsDontCallFreeInst");
251 if (param_attributes
.SaveForAsyncFinish
) strcat(buffer
, " SaveForAsyncFinish");
252 if (param_attributes
.ServerAllocSize
)
253 sprintf( buffer
+ strlen(buffer
), " ServerAllocSize = %d", param_attributes
.ServerAllocSize
* 8);
254 return buffer
[0] ? wine_dbg_sprintf( "%s", buffer
+ 1 ) : "";
257 static const char *debugstr_INTERPRETER_OPT_FLAGS(INTERPRETER_OPT_FLAGS Oi2Flags
)
262 if (Oi2Flags
.ServerMustSize
) strcat(buffer
, " ServerMustSize");
263 if (Oi2Flags
.ClientMustSize
) strcat(buffer
, " ClientMustSize");
264 if (Oi2Flags
.HasReturn
) strcat(buffer
, " HasReturn");
265 if (Oi2Flags
.HasPipes
) strcat(buffer
, " HasPipes");
266 if (Oi2Flags
.Unused
) strcat(buffer
, " Unused");
267 if (Oi2Flags
.HasAsyncUuid
) strcat(buffer
, " HasAsyncUuid");
268 if (Oi2Flags
.HasExtensions
) strcat(buffer
, " HasExtensions");
269 if (Oi2Flags
.HasAsyncHandle
) strcat(buffer
, " HasAsyncHandle");
270 return buffer
[0] ? wine_dbg_sprintf( "%s", buffer
+ 1 ) : "";
273 #define ARG_FROM_OFFSET(args, offset) ((args) + (offset))
275 static PFORMAT_STRING
client_get_handle(
276 PMIDL_STUB_MESSAGE pStubMsg
, const NDR_PROC_HEADER
*pProcHeader
,
277 PFORMAT_STRING pFormat
, handle_t
*phBinding
)
280 switch (pProcHeader
->handle_type
)
282 /* explicit binding: parse additional section */
284 switch (*pFormat
) /* handle_type */
286 case FC_BIND_PRIMITIVE
: /* explicit primitive */
288 const NDR_EHD_PRIMITIVE
*pDesc
= (const NDR_EHD_PRIMITIVE
*)pFormat
;
290 TRACE("Explicit primitive handle @ %d\n", pDesc
->offset
);
292 if (pDesc
->flag
) /* pointer to binding */
293 *phBinding
= **(handle_t
**)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
295 *phBinding
= *(handle_t
*)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
296 return pFormat
+ sizeof(NDR_EHD_PRIMITIVE
);
298 case FC_BIND_GENERIC
: /* explicit generic */
300 const NDR_EHD_GENERIC
*pDesc
= (const NDR_EHD_GENERIC
*)pFormat
;
301 void *pObject
= NULL
;
303 const GENERIC_BINDING_ROUTINE_PAIR
*pGenPair
;
305 TRACE("Explicit generic binding handle #%d\n", pDesc
->binding_routine_pair_index
);
307 if (pDesc
->flag_and_size
& HANDLE_PARAM_IS_VIA_PTR
)
308 pArg
= *(void **)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
310 pArg
= ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
311 memcpy(&pObject
, pArg
, pDesc
->flag_and_size
& 0xf);
312 pGenPair
= &pStubMsg
->StubDesc
->aGenericBindingRoutinePairs
[pDesc
->binding_routine_pair_index
];
313 *phBinding
= pGenPair
->pfnBind(pObject
);
314 return pFormat
+ sizeof(NDR_EHD_GENERIC
);
316 case FC_BIND_CONTEXT
: /* explicit context */
318 const NDR_EHD_CONTEXT
*pDesc
= (const NDR_EHD_CONTEXT
*)pFormat
;
319 NDR_CCONTEXT context_handle
;
320 TRACE("Explicit bind context\n");
321 if (pDesc
->flags
& HANDLE_PARAM_IS_VIA_PTR
)
323 TRACE("\tHANDLE_PARAM_IS_VIA_PTR\n");
324 context_handle
= **(NDR_CCONTEXT
**)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
327 context_handle
= *(NDR_CCONTEXT
*)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
329 if (context_handle
) *phBinding
= NDRCContextBinding(context_handle
);
330 else if (pDesc
->flags
& NDR_CONTEXT_HANDLE_CANNOT_BE_NULL
)
332 ERR("null context handle isn't allowed\n");
333 RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT
);
336 /* FIXME: should we store this structure in stubMsg.pContext? */
337 return pFormat
+ sizeof(NDR_EHD_CONTEXT
);
340 ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
341 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
344 case FC_BIND_GENERIC
: /* implicit generic */
345 FIXME("FC_BIND_GENERIC\n");
346 RpcRaiseException(RPC_X_BAD_STUB_DATA
); /* FIXME: remove when implemented */
348 case FC_BIND_PRIMITIVE
: /* implicit primitive */
349 TRACE("Implicit primitive handle\n");
350 *phBinding
= *pStubMsg
->StubDesc
->IMPLICIT_HANDLE_INFO
.pPrimitiveHandle
;
352 case FC_CALLBACK_HANDLE
: /* implicit callback */
353 TRACE("FC_CALLBACK_HANDLE\n");
354 /* server calls callback procedures only in response to remote call, and most recent
355 binding handle is used. Calling back to a client can potentially result in another
356 callback with different current handle. */
357 *phBinding
= I_RpcGetCurrentCallHandle();
359 case FC_AUTO_HANDLE
: /* implicit auto handle */
360 /* strictly speaking, it isn't necessary to set hBinding here
361 * since it isn't actually used (hence the automatic in its name),
362 * but then why does MIDL generate a valid entry in the
363 * MIDL_STUB_DESC for it? */
364 TRACE("Implicit auto handle\n");
365 *phBinding
= *pStubMsg
->StubDesc
->IMPLICIT_HANDLE_INFO
.pAutoHandle
;
368 ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
369 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
374 static void client_free_handle(
375 PMIDL_STUB_MESSAGE pStubMsg
, const NDR_PROC_HEADER
*pProcHeader
,
376 PFORMAT_STRING pFormat
, handle_t hBinding
)
379 switch (pProcHeader
->handle_type
)
381 /* explicit binding: parse additional section */
383 switch (*pFormat
) /* handle_type */
385 case FC_BIND_GENERIC
: /* explicit generic */
387 const NDR_EHD_GENERIC
*pDesc
= (const NDR_EHD_GENERIC
*)pFormat
;
388 void *pObject
= NULL
;
390 const GENERIC_BINDING_ROUTINE_PAIR
*pGenPair
;
392 TRACE("Explicit generic binding handle #%d\n", pDesc
->binding_routine_pair_index
);
394 if (pDesc
->flag_and_size
& HANDLE_PARAM_IS_VIA_PTR
)
395 pArg
= *(void **)ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
397 pArg
= ARG_FROM_OFFSET(pStubMsg
->StackTop
, pDesc
->offset
);
398 memcpy(&pObject
, pArg
, pDesc
->flag_and_size
& 0xf);
399 pGenPair
= &pStubMsg
->StubDesc
->aGenericBindingRoutinePairs
[pDesc
->binding_routine_pair_index
];
400 pGenPair
->pfnUnbind(pObject
, hBinding
);
403 case FC_BIND_CONTEXT
: /* explicit context */
404 case FC_BIND_PRIMITIVE
: /* explicit primitive */
407 ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
408 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
411 case FC_BIND_GENERIC
: /* implicit generic */
412 FIXME("FC_BIND_GENERIC\n");
413 RpcRaiseException(RPC_X_BAD_STUB_DATA
); /* FIXME: remove when implemented */
415 case FC_CALLBACK_HANDLE
: /* implicit callback */
416 case FC_BIND_PRIMITIVE
: /* implicit primitive */
417 case FC_AUTO_HANDLE
: /* implicit auto handle */
420 ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
421 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
425 static inline BOOL
param_needs_alloc( PARAM_ATTRIBUTES attr
)
427 return attr
.IsOut
&& !attr
.IsIn
&& !attr
.IsBasetype
&& !attr
.IsByValue
;
430 static inline BOOL
param_is_out_basetype( PARAM_ATTRIBUTES attr
)
432 return attr
.IsOut
&& !attr
.IsIn
&& attr
.IsBasetype
&& attr
.IsSimpleRef
;
435 static size_t basetype_arg_size( unsigned char fc
)
447 return sizeof(short);
452 case FC_ERROR_STATUS_T
:
455 return sizeof(float);
457 return sizeof(LONGLONG
);
459 return sizeof(double);
462 return sizeof(INT_PTR
);
464 FIXME("Unhandled basetype %#x.\n", fc
);
469 void client_do_args( PMIDL_STUB_MESSAGE pStubMsg
, PFORMAT_STRING pFormat
, enum stubless_phase phase
,
470 void **fpu_args
, unsigned short number_of_params
, unsigned char *pRetVal
)
472 const NDR_PARAM_OIF
*params
= (const NDR_PARAM_OIF
*)pFormat
;
475 for (i
= 0; i
< number_of_params
; i
++)
477 unsigned char *pArg
= pStubMsg
->StackTop
+ params
[i
].stack_offset
;
478 PFORMAT_STRING pTypeFormat
= (PFORMAT_STRING
)&pStubMsg
->StubDesc
->pFormatTypes
[params
[i
].u
.type_offset
];
480 #ifdef __x86_64__ /* floats are passed as doubles through varargs functions */
483 if (params
[i
].attr
.IsBasetype
&&
484 params
[i
].u
.type_format_char
== FC_FLOAT
&&
485 !params
[i
].attr
.IsSimpleRef
&&
489 pArg
= (unsigned char *)&f
;
493 TRACE("param[%d]: %p type %02x %s\n", i
, pArg
,
494 params
[i
].attr
.IsBasetype
? params
[i
].u
.type_format_char
: *pTypeFormat
,
495 debugstr_PROC_PF( params
[i
].attr
));
499 case STUBLESS_INITOUT
:
500 if (*(unsigned char **)pArg
)
502 if (param_needs_alloc(params
[i
].attr
))
503 memset( *(unsigned char **)pArg
, 0, calc_arg_size( pStubMsg
, pTypeFormat
));
504 else if (param_is_out_basetype(params
[i
].attr
))
505 memset( *(unsigned char **)pArg
, 0, basetype_arg_size( params
[i
].u
.type_format_char
));
508 case STUBLESS_CALCSIZE
:
509 if (params
[i
].attr
.IsSimpleRef
&& !*(unsigned char **)pArg
)
510 RpcRaiseException(RPC_X_NULL_REF_POINTER
);
511 if (params
[i
].attr
.IsIn
) call_buffer_sizer(pStubMsg
, pArg
, ¶ms
[i
]);
513 case STUBLESS_MARSHAL
:
514 if (params
[i
].attr
.IsIn
) call_marshaller(pStubMsg
, pArg
, ¶ms
[i
]);
516 case STUBLESS_UNMARSHAL
:
517 if (params
[i
].attr
.IsOut
)
519 if (params
[i
].attr
.IsReturn
&& pRetVal
) pArg
= pRetVal
;
520 call_unmarshaller(pStubMsg
, &pArg
, ¶ms
[i
], 0);
524 if (!params
[i
].attr
.IsBasetype
&& params
[i
].attr
.IsOut
&& !params
[i
].attr
.IsByValue
)
525 NdrClearOutParameters( pStubMsg
, pTypeFormat
, *(unsigned char **)pArg
);
528 RpcRaiseException(RPC_S_INTERNAL_ERROR
);
533 static unsigned int type_stack_size(unsigned char fc
)
551 case FC_ERROR_STATUS_T
:
553 return sizeof(void *);
555 return sizeof(double);
557 return sizeof(ULONGLONG
);
559 ERR("invalid base type 0x%x\n", fc
);
560 RpcRaiseException(RPC_S_INTERNAL_ERROR
);
564 static BOOL
is_by_value( PFORMAT_STRING format
)
568 case FC_USER_MARSHAL
:
574 case FC_BOGUS_STRUCT
:
581 PFORMAT_STRING
convert_old_args( PMIDL_STUB_MESSAGE pStubMsg
, PFORMAT_STRING pFormat
,
582 unsigned int stack_size
, BOOL object_proc
,
583 void *buffer
, unsigned int size
, unsigned int *count
)
585 NDR_PARAM_OIF
*args
= buffer
;
586 unsigned int i
, stack_offset
= object_proc
? sizeof(void *) : 0;
588 for (i
= 0; stack_offset
< stack_size
; i
++)
590 const NDR_PARAM_OI_BASETYPE
*param
= (const NDR_PARAM_OI_BASETYPE
*)pFormat
;
591 const NDR_PARAM_OI_OTHER
*other
= (const NDR_PARAM_OI_OTHER
*)pFormat
;
593 if (i
+ 1 > size
/ sizeof(*args
))
595 FIXME( "%u args not supported\n", i
);
596 RpcRaiseException( RPC_S_INTERNAL_ERROR
);
599 args
[i
].stack_offset
= stack_offset
;
600 memset( &args
[i
].attr
, 0, sizeof(args
[i
].attr
) );
602 switch (param
->param_direction
)
604 case FC_IN_PARAM_BASETYPE
:
605 args
[i
].attr
.IsIn
= 1;
606 args
[i
].attr
.IsBasetype
= 1;
608 case FC_RETURN_PARAM_BASETYPE
:
609 args
[i
].attr
.IsOut
= 1;
610 args
[i
].attr
.IsReturn
= 1;
611 args
[i
].attr
.IsBasetype
= 1;
614 args
[i
].attr
.IsIn
= 1;
615 args
[i
].attr
.MustFree
= 1;
617 case FC_IN_PARAM_NO_FREE_INST
:
618 args
[i
].attr
.IsIn
= 1;
619 args
[i
].attr
.IsDontCallFreeInst
= 1;
621 case FC_IN_OUT_PARAM
:
622 args
[i
].attr
.IsIn
= 1;
623 args
[i
].attr
.IsOut
= 1;
624 args
[i
].attr
.MustFree
= 1;
627 args
[i
].attr
.IsOut
= 1;
629 case FC_RETURN_PARAM
:
630 args
[i
].attr
.IsOut
= 1;
631 args
[i
].attr
.IsReturn
= 1;
634 if (args
[i
].attr
.IsBasetype
)
636 args
[i
].u
.type_format_char
= param
->type_format_char
;
637 stack_offset
+= type_stack_size( param
->type_format_char
);
638 pFormat
+= sizeof(NDR_PARAM_OI_BASETYPE
);
642 args
[i
].u
.type_offset
= other
->type_offset
;
643 args
[i
].attr
.IsByValue
= is_by_value( &pStubMsg
->StubDesc
->pFormatTypes
[other
->type_offset
] );
644 stack_offset
+= other
->stack_size
* sizeof(void *);
645 pFormat
+= sizeof(NDR_PARAM_OI_OTHER
);
649 return (PFORMAT_STRING
)args
;
652 LONG_PTR CDECL DECLSPEC_HIDDEN
ndr_client_call( PMIDL_STUB_DESC pStubDesc
, PFORMAT_STRING pFormat
,
653 void **stack_top
, void **fpu_stack
)
655 /* pointer to start of stack where arguments start */
657 MIDL_STUB_MESSAGE stubMsg
;
658 handle_t hBinding
= NULL
;
659 /* procedure number */
660 unsigned short procedure_number
;
662 unsigned short stack_size
;
663 /* number of parameters. optional for client to give it to us */
664 unsigned int number_of_params
;
665 /* cache of Oif_flags from v2 procedure header */
666 INTERPRETER_OPT_FLAGS Oif_flags
= { 0 };
667 /* cache of extension flags from NDR_PROC_HEADER_EXTS */
668 INTERPRETER_OPT_FLAGS2 ext_flags
= { 0 };
669 /* header for procedure string */
670 const NDR_PROC_HEADER
* pProcHeader
= (const NDR_PROC_HEADER
*)&pFormat
[0];
671 /* the value to return to the client from the remote procedure */
673 /* the pointer to the object when in OLE mode */
675 PFORMAT_STRING pHandleFormat
;
676 /* correlation cache */
677 ULONG_PTR NdrCorrCache
[256];
679 TRACE("pStubDesc %p, pFormat %p, ...\n", pStubDesc
, pFormat
);
681 TRACE("NDR Version: 0x%x\n", pStubDesc
->Version
);
683 if (pProcHeader
->Oi_flags
& Oi_HAS_RPCFLAGS
)
685 const NDR_PROC_HEADER_RPC
*header_rpc
= (const NDR_PROC_HEADER_RPC
*)&pFormat
[0];
686 stack_size
= header_rpc
->stack_size
;
687 procedure_number
= header_rpc
->proc_num
;
688 pFormat
+= sizeof(NDR_PROC_HEADER_RPC
);
692 stack_size
= pProcHeader
->stack_size
;
693 procedure_number
= pProcHeader
->proc_num
;
694 pFormat
+= sizeof(NDR_PROC_HEADER
);
696 TRACE("stack size: 0x%x\n", stack_size
);
697 TRACE("proc num: %d\n", procedure_number
);
699 /* create the full pointer translation tables, if requested */
700 if (pProcHeader
->Oi_flags
& Oi_FULL_PTR_USED
)
701 stubMsg
.FullPtrXlatTables
= NdrFullPointerXlatInit(0,XLAT_CLIENT
);
703 if (pProcHeader
->Oi_flags
& Oi_OBJECT_PROC
)
705 /* object is always the first argument */
707 NdrProxyInitialize(This
, &rpcMsg
, &stubMsg
, pStubDesc
, procedure_number
);
710 NdrClientInitializeNew(&rpcMsg
, &stubMsg
, pStubDesc
, procedure_number
);
712 TRACE("Oi_flags = 0x%02x\n", pProcHeader
->Oi_flags
);
713 TRACE("MIDL stub version = 0x%x\n", pStubDesc
->MIDLVersion
);
715 stubMsg
.StackTop
= (unsigned char *)stack_top
;
716 pHandleFormat
= pFormat
;
718 /* we only need a handle if this isn't an object method */
719 if (!(pProcHeader
->Oi_flags
& Oi_OBJECT_PROC
))
721 pFormat
= client_get_handle(&stubMsg
, pProcHeader
, pHandleFormat
, &hBinding
);
722 if (!pFormat
) goto done
;
725 if (is_oicf_stubdesc(pStubDesc
)) /* -Oicf format */
727 const NDR_PROC_PARTIAL_OIF_HEADER
*pOIFHeader
=
728 (const NDR_PROC_PARTIAL_OIF_HEADER
*)pFormat
;
730 Oif_flags
= pOIFHeader
->Oi2Flags
;
731 number_of_params
= pOIFHeader
->number_of_params
;
733 pFormat
+= sizeof(NDR_PROC_PARTIAL_OIF_HEADER
);
735 TRACE("Oif_flags = %s\n", debugstr_INTERPRETER_OPT_FLAGS(Oif_flags
) );
737 if (Oif_flags
.HasExtensions
)
739 const NDR_PROC_HEADER_EXTS
*pExtensions
= (const NDR_PROC_HEADER_EXTS
*)pFormat
;
740 ext_flags
= pExtensions
->Flags2
;
741 pFormat
+= pExtensions
->Size
;
743 if (pExtensions
->Size
> sizeof(*pExtensions
) && fpu_stack
)
746 unsigned short fpu_mask
= *(unsigned short *)(pExtensions
+ 1);
747 for (i
= 0; i
< 4; i
++, fpu_mask
>>= 2)
748 switch (fpu_mask
& 3)
750 case 1: *(float *)&stack_top
[i
] = *(float *)&fpu_stack
[i
]; break;
751 case 2: *(double *)&stack_top
[i
] = *(double *)&fpu_stack
[i
]; break;
759 pFormat
= convert_old_args( &stubMsg
, pFormat
, stack_size
,
760 pProcHeader
->Oi_flags
& Oi_OBJECT_PROC
,
761 /* reuse the correlation cache, it's not needed for v1 format */
762 NdrCorrCache
, sizeof(NdrCorrCache
), &number_of_params
);
765 stubMsg
.BufferLength
= 0;
767 /* store the RPC flags away */
768 if (pProcHeader
->Oi_flags
& Oi_HAS_RPCFLAGS
)
769 rpcMsg
.RpcFlags
= ((const NDR_PROC_HEADER_RPC
*)pProcHeader
)->rpc_flags
;
771 /* use alternate memory allocation routines */
772 if (pProcHeader
->Oi_flags
& Oi_RPCSS_ALLOC_USED
)
773 NdrRpcSmSetClientToOsf(&stubMsg
);
775 if (Oif_flags
.HasPipes
)
777 FIXME("pipes not supported yet\n");
778 RpcRaiseException(RPC_X_WRONG_STUB_VERSION
); /* FIXME: remove when implemented */
779 /* init pipes package */
780 /* NdrPipesInitialize(...) */
782 if (ext_flags
.HasNewCorrDesc
)
784 /* initialize extra correlation package */
785 NdrCorrelationInitialize(&stubMsg
, NdrCorrCache
, sizeof(NdrCorrCache
), 0);
786 if (ext_flags
.Unused
& 0x2) /* has range on conformance */
787 stubMsg
.CorrDespIncrement
= 12;
791 * 1. INITOUT - zero [out] parameters (proxies only)
792 * 2. CALCSIZE - calculate the buffer size
793 * 3. GETBUFFER - allocate the buffer
794 * 4. MARSHAL - marshal [in] params into the buffer
795 * 5. SENDRECEIVE - send/receive buffer
796 * 6. UNMARSHAL - unmarshal [out] params from buffer
797 * 7. FREE - clear [out] parameters (for proxies, and only on error)
799 if ((pProcHeader
->Oi_flags
& Oi_OBJECT_PROC
) ||
800 (pProcHeader
->Oi_flags
& Oi_HAS_COMM_OR_FAULT
))
803 if (pProcHeader
->Oi_flags
& Oi_OBJECT_PROC
)
805 TRACE( "INITOUT\n" );
806 client_do_args(&stubMsg
, pFormat
, STUBLESS_INITOUT
, fpu_stack
,
807 number_of_params
, (unsigned char *)&RetVal
);
813 TRACE( "CALCSIZE\n" );
814 client_do_args(&stubMsg
, pFormat
, STUBLESS_CALCSIZE
, fpu_stack
,
815 number_of_params
, (unsigned char *)&RetVal
);
818 TRACE( "GETBUFFER\n" );
819 if (pProcHeader
->Oi_flags
& Oi_OBJECT_PROC
)
821 /* allocate the buffer */
822 NdrProxyGetBuffer(This
, &stubMsg
);
826 /* allocate the buffer */
827 if (Oif_flags
.HasPipes
)
828 /* NdrGetPipeBuffer(...) */
829 FIXME("pipes not supported yet\n");
832 if (pProcHeader
->handle_type
== FC_AUTO_HANDLE
)
834 NdrNsGetBuffer(&stubMsg
, stubMsg
.BufferLength
, hBinding
);
836 FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
839 NdrGetBuffer(&stubMsg
, stubMsg
.BufferLength
, hBinding
);
844 TRACE( "MARSHAL\n" );
845 client_do_args(&stubMsg
, pFormat
, STUBLESS_MARSHAL
, fpu_stack
,
846 number_of_params
, (unsigned char *)&RetVal
);
849 TRACE( "SENDRECEIVE\n" );
850 if (pProcHeader
->Oi_flags
& Oi_OBJECT_PROC
)
852 /* send the [in] params and receive the [out] and [retval]
854 NdrProxySendReceive(This
, &stubMsg
);
858 /* send the [in] params and receive the [out] and [retval]
860 if (Oif_flags
.HasPipes
)
861 /* NdrPipesSendReceive(...) */
862 FIXME("pipes not supported yet\n");
865 if (pProcHeader
->handle_type
== FC_AUTO_HANDLE
)
867 NdrNsSendReceive(&stubMsg
, stubMsg
.Buffer
, pStubDesc
->IMPLICIT_HANDLE_INFO
.pAutoHandle
);
869 FIXME("using auto handle - call NdrNsSendReceive when it gets implemented\n");
872 NdrSendReceive(&stubMsg
, stubMsg
.Buffer
);
876 /* convert strings, floating point values and endianness into our
877 * preferred format */
878 if ((rpcMsg
.DataRepresentation
& 0x0000FFFFUL
) != NDR_LOCAL_DATA_REPRESENTATION
)
879 NdrConvert(&stubMsg
, pFormat
);
882 TRACE( "UNMARSHAL\n" );
883 client_do_args(&stubMsg
, pFormat
, STUBLESS_UNMARSHAL
, fpu_stack
,
884 number_of_params
, (unsigned char *)&RetVal
);
888 if (pProcHeader
->Oi_flags
& Oi_OBJECT_PROC
)
892 client_do_args(&stubMsg
, pFormat
, STUBLESS_FREE
, fpu_stack
,
893 number_of_params
, (unsigned char *)&RetVal
);
894 RetVal
= NdrProxyErrorHandler(GetExceptionCode());
898 const COMM_FAULT_OFFSETS
*comm_fault_offsets
= &pStubDesc
->CommFaultOffsets
[procedure_number
];
902 TRACE("comm_fault_offsets = {0x%hx, 0x%hx}\n", comm_fault_offsets
->CommOffset
, comm_fault_offsets
->FaultOffset
);
904 if (comm_fault_offsets
->CommOffset
== -1)
905 comm_status
= (ULONG
*)&RetVal
;
906 else if (comm_fault_offsets
->CommOffset
>= 0)
907 comm_status
= *(ULONG
**)ARG_FROM_OFFSET(stubMsg
.StackTop
, comm_fault_offsets
->CommOffset
);
911 if (comm_fault_offsets
->FaultOffset
== -1)
912 fault_status
= (ULONG
*)&RetVal
;
913 else if (comm_fault_offsets
->FaultOffset
>= 0)
914 fault_status
= *(ULONG
**)ARG_FROM_OFFSET(stubMsg
.StackTop
, comm_fault_offsets
->FaultOffset
);
918 NdrMapCommAndFaultStatus(&stubMsg
, comm_status
, fault_status
,
927 TRACE( "CALCSIZE\n" );
928 client_do_args(&stubMsg
, pFormat
, STUBLESS_CALCSIZE
, fpu_stack
,
929 number_of_params
, (unsigned char *)&RetVal
);
932 TRACE( "GETBUFFER\n" );
933 if (Oif_flags
.HasPipes
)
934 /* NdrGetPipeBuffer(...) */
935 FIXME("pipes not supported yet\n");
938 if (pProcHeader
->handle_type
== FC_AUTO_HANDLE
)
940 NdrNsGetBuffer(&stubMsg
, stubMsg
.BufferLength
, hBinding
);
942 FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
945 NdrGetBuffer(&stubMsg
, stubMsg
.BufferLength
, hBinding
);
949 TRACE( "MARSHAL\n" );
950 client_do_args(&stubMsg
, pFormat
, STUBLESS_MARSHAL
, fpu_stack
,
951 number_of_params
, (unsigned char *)&RetVal
);
954 TRACE( "SENDRECEIVE\n" );
955 if (Oif_flags
.HasPipes
)
956 /* NdrPipesSendReceive(...) */
957 FIXME("pipes not supported yet\n");
960 if (pProcHeader
->handle_type
== FC_AUTO_HANDLE
)
962 NdrNsSendReceive(&stubMsg
, stubMsg
.Buffer
, pStubDesc
->IMPLICIT_HANDLE_INFO
.pAutoHandle
);
964 FIXME("using auto handle - call NdrNsSendReceive when it gets implemented\n");
967 NdrSendReceive(&stubMsg
, stubMsg
.Buffer
);
970 /* convert strings, floating point values and endianness into our
971 * preferred format */
972 if ((rpcMsg
.DataRepresentation
& 0x0000FFFFUL
) != NDR_LOCAL_DATA_REPRESENTATION
)
973 NdrConvert(&stubMsg
, pFormat
);
976 TRACE( "UNMARSHAL\n" );
977 client_do_args(&stubMsg
, pFormat
, STUBLESS_UNMARSHAL
, fpu_stack
,
978 number_of_params
, (unsigned char *)&RetVal
);
981 if (ext_flags
.HasNewCorrDesc
)
983 /* free extra correlation package */
984 NdrCorrelationFree(&stubMsg
);
987 if (Oif_flags
.HasPipes
)
989 /* NdrPipesDone(...) */
992 /* free the full pointer translation tables */
993 if (pProcHeader
->Oi_flags
& Oi_FULL_PTR_USED
)
994 NdrFullPointerXlatFree(stubMsg
.FullPtrXlatTables
);
996 /* free marshalling buffer */
997 if (pProcHeader
->Oi_flags
& Oi_OBJECT_PROC
)
998 NdrProxyFreeBuffer(This
, &stubMsg
);
1001 NdrFreeBuffer(&stubMsg
);
1002 client_free_handle(&stubMsg
, pProcHeader
, pHandleFormat
, hBinding
);
1006 TRACE("RetVal = 0x%lx\n", RetVal
);
1012 __ASM_GLOBAL_FUNC( NdrClientCall2
,
1013 "movq %r8,0x18(%rsp)\n\t"
1014 "movq %r9,0x20(%rsp)\n\t"
1015 "leaq 0x18(%rsp),%r8\n\t"
1017 "subq $0x28,%rsp\n\t"
1018 __ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t")
1019 "call " __ASM_NAME("ndr_client_call") "\n\t"
1020 "addq $0x28,%rsp\n\t"
1021 __ASM_CFI(".cfi_adjust_cfa_offset -0x28\n\t")
1024 #else /* __x86_64__ */
1026 /***********************************************************************
1027 * NdrClientCall2 [RPCRT4.@]
1029 CLIENT_CALL_RETURN WINAPIV
NdrClientCall2( PMIDL_STUB_DESC desc
, PFORMAT_STRING format
, ... )
1034 __ms_va_start( args
, format
);
1035 ret
= ndr_client_call( desc
, format
, va_arg( args
, void ** ), NULL
);
1036 __ms_va_end( args
);
1037 return *(CLIENT_CALL_RETURN
*)&ret
;
1040 #endif /* __x86_64__ */
1042 /* Calls a function with the specified arguments, restoring the stack
1043 * properly afterwards as we don't know the calling convention of the
1045 #if defined __i386__ && defined _MSC_VER
1046 __declspec(naked
) LONG_PTR __cdecl
call_server_func(SERVER_ROUTINE func
, unsigned char * args
, unsigned int stack_size
)
1052 push edi
; Save registers
1054 mov eax
, [ebp
+16] ; Get stack size
1055 sub esp
, eax
; Make room in stack
for arguments
1062 rep movsd
; Copy dword blocks
1063 call
[ebp
+8] ; Call function
1064 lea esp
, [ebp
-8] ; Restore stack
1065 pop esi
; Restore registers
1071 #elif defined __i386__ && defined __GNUC__
1072 LONG_PTR __cdecl
call_server_func(SERVER_ROUTINE func
, unsigned char * args
, unsigned int stack_size
);
1073 __ASM_GLOBAL_FUNC(call_server_func
,
1075 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
1076 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
1077 "movl %esp,%ebp\n\t"
1078 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
1079 "pushl %edi\n\t" /* Save registers */
1080 __ASM_CFI(".cfi_rel_offset %edi,-4\n\t")
1082 __ASM_CFI(".cfi_rel_offset %esi,-8\n\t")
1083 "movl 16(%ebp), %eax\n\t" /* Get stack size */
1084 "subl %eax, %esp\n\t" /* Make room in stack for arguments */
1085 "andl $~15, %esp\n\t" /* Make sure stack has 16-byte alignment for Mac OS X */
1086 "movl %esp, %edi\n\t"
1087 "movl %eax, %ecx\n\t"
1088 "movl 12(%ebp), %esi\n\t"
1089 "shrl $2, %ecx\n\t" /* divide by 4 */
1091 "rep; movsl\n\t" /* Copy dword blocks */
1092 "call *8(%ebp)\n\t" /* Call function */
1093 "leal -8(%ebp), %esp\n\t" /* Restore stack */
1094 "popl %esi\n\t" /* Restore registers */
1095 __ASM_CFI(".cfi_same_value %esi\n\t")
1097 __ASM_CFI(".cfi_same_value %edi\n\t")
1099 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
1100 __ASM_CFI(".cfi_same_value %ebp\n\t")
1102 #elif defined __x86_64__
1103 LONG_PTR __cdecl
call_server_func(SERVER_ROUTINE func
, unsigned char * args
, unsigned int stack_size
);
1104 __ASM_GLOBAL_FUNC( call_server_func
,
1106 __ASM_CFI(".cfi_adjust_cfa_offset 8\n\t")
1107 __ASM_CFI(".cfi_rel_offset %rbp,0\n\t")
1108 "movq %rsp,%rbp\n\t"
1109 __ASM_CFI(".cfi_def_cfa_register %rbp\n\t")
1111 __ASM_CFI(".cfi_rel_offset %rsi,-8\n\t")
1113 __ASM_CFI(".cfi_rel_offset %rdi,-16\n\t")
1114 "movq %rcx,%rax\n\t" /* function to call */
1115 "movq $32,%rcx\n\t" /* allocate max(32,stack_size) bytes of stack space */
1117 "cmovgq %r8,%rcx\n\t"
1118 "subq %rcx,%rsp\n\t"
1119 "andq $~15,%rsp\n\t"
1122 "movq %rsp,%rdi\n\t"
1123 "movq %rdx,%rsi\n\t"
1124 "rep; movsq\n\t" /* copy arguments */
1125 "movq 0(%rsp),%rcx\n\t"
1126 "movq 8(%rsp),%rdx\n\t"
1127 "movq 16(%rsp),%r8\n\t"
1128 "movq 24(%rsp),%r9\n\t"
1129 "movq 0(%rsp),%xmm0\n\t"
1130 "movq 8(%rsp),%xmm1\n\t"
1131 "movq 16(%rsp),%xmm2\n\t"
1132 "movq 24(%rsp),%xmm3\n\t"
1134 "leaq -16(%rbp),%rsp\n\t" /* restore stack */
1136 __ASM_CFI(".cfi_same_value %rdi\n\t")
1138 __ASM_CFI(".cfi_same_value %rsi\n\t")
1139 __ASM_CFI(".cfi_def_cfa_register %rsp\n\t")
1141 __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t")
1142 __ASM_CFI(".cfi_same_value %rbp\n\t")
1144 #elif defined __arm__
1145 LONG_PTR __cdecl
call_server_func(SERVER_ROUTINE func
, unsigned char *args
, unsigned int stack_size
);
1146 __ASM_GLOBAL_FUNC( call_server_func
,
1148 "push {r4, r5, LR}\n\t"
1151 "lsr r3, r2, #2\n\t"
1154 "sub SP, SP, r2\n\t"
1156 "subeq SP, SP, #4\n\t"
1157 "1:\tsub r2, r2, #4\n\t"
1158 "ldr r0, [r1, r2]\n\t"
1159 "str r0, [SP, r2]\n\t"
1166 "2:\tcmp r3, #2\n\t"
1170 "3:\tcmp r3, #3\n\t"
1174 "4:\tpop {r0-r3}\n\t"
1177 "pop {r4, r5, PC}" )
1179 #warning call_server_func not implemented for your architecture
1180 LONG_PTR __cdecl
call_server_func(SERVER_ROUTINE func
, unsigned char * args
, unsigned short stack_size
)
1182 FIXME("Not implemented for your architecture\n");
1187 static LONG_PTR
*stub_do_args(MIDL_STUB_MESSAGE
*pStubMsg
,
1188 PFORMAT_STRING pFormat
, enum stubless_phase phase
,
1189 unsigned short number_of_params
)
1191 const NDR_PARAM_OIF
*params
= (const NDR_PARAM_OIF
*)pFormat
;
1193 LONG_PTR
*retval_ptr
= NULL
;
1195 for (i
= 0; i
< number_of_params
; i
++)
1197 unsigned char *pArg
= pStubMsg
->StackTop
+ params
[i
].stack_offset
;
1198 const unsigned char *pTypeFormat
= &pStubMsg
->StubDesc
->pFormatTypes
[params
[i
].u
.type_offset
];
1200 TRACE("param[%d]: %p -> %p type %02x %s\n", i
,
1201 pArg
, *(unsigned char **)pArg
,
1202 params
[i
].attr
.IsBasetype
? params
[i
].u
.type_format_char
: *pTypeFormat
,
1203 debugstr_PROC_PF( params
[i
].attr
));
1207 case STUBLESS_MARSHAL
:
1208 if (params
[i
].attr
.IsOut
|| params
[i
].attr
.IsReturn
)
1209 call_marshaller(pStubMsg
, pArg
, ¶ms
[i
]);
1211 case STUBLESS_MUSTFREE
:
1212 if (params
[i
].attr
.MustFree
)
1214 call_freer(pStubMsg
, pArg
, ¶ms
[i
]);
1218 if (params
[i
].attr
.ServerAllocSize
)
1220 HeapFree(GetProcessHeap(), 0, *(void **)pArg
);
1222 else if (param_needs_alloc(params
[i
].attr
) &&
1223 (!params
[i
].attr
.MustFree
|| params
[i
].attr
.IsSimpleRef
))
1225 if (*pTypeFormat
!= FC_BIND_CONTEXT
) pStubMsg
->pfnFree(*(void **)pArg
);
1228 case STUBLESS_INITOUT
:
1229 if (param_needs_alloc(params
[i
].attr
) && !params
[i
].attr
.ServerAllocSize
)
1231 if (*pTypeFormat
== FC_BIND_CONTEXT
)
1233 NDR_SCONTEXT ctxt
= NdrContextHandleInitialize(pStubMsg
, pTypeFormat
);
1234 *(void **)pArg
= NDRSContextValue(ctxt
);
1238 DWORD size
= calc_arg_size(pStubMsg
, pTypeFormat
);
1241 *(void **)pArg
= NdrAllocate(pStubMsg
, size
);
1242 memset(*(void **)pArg
, 0, size
);
1247 case STUBLESS_UNMARSHAL
:
1248 if (params
[i
].attr
.ServerAllocSize
)
1249 *(void **)pArg
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
1250 params
[i
].attr
.ServerAllocSize
* 8);
1252 if (params
[i
].attr
.IsIn
)
1253 call_unmarshaller(pStubMsg
, &pArg
, ¶ms
[i
], 0);
1255 case STUBLESS_CALCSIZE
:
1256 if (params
[i
].attr
.IsOut
|| params
[i
].attr
.IsReturn
)
1257 call_buffer_sizer(pStubMsg
, pArg
, ¶ms
[i
]);
1260 RpcRaiseException(RPC_S_INTERNAL_ERROR
);
1262 TRACE("\tmemory addr (after): %p -> %p\n", pArg
, *(unsigned char **)pArg
);
1264 /* make a note of the address of the return value parameter for later */
1265 if (params
[i
].attr
.IsReturn
) retval_ptr
= (LONG_PTR
*)pArg
;
1270 /***********************************************************************
1271 * NdrStubCall2 [RPCRT4.@]
1273 * Unmarshals [in] parameters, calls either a method in an object or a server
1274 * function, marshals any [out] parameters and frees any allocated data.
1277 * Used by stubless MIDL-generated code.
1279 LONG WINAPI
NdrStubCall2(
1280 struct IRpcStubBuffer
* pThis
,
1281 struct IRpcChannelBuffer
* pChannel
,
1282 PRPC_MESSAGE pRpcMsg
,
1283 DWORD
* pdwStubPhase
)
1285 const MIDL_SERVER_INFO
*pServerInfo
;
1286 const MIDL_STUB_DESC
*pStubDesc
;
1287 PFORMAT_STRING pFormat
;
1288 MIDL_STUB_MESSAGE stubMsg
;
1289 /* pointer to start of stack to pass into stub implementation */
1290 unsigned char * args
;
1292 unsigned short stack_size
;
1293 /* number of parameters. optional for client to give it to us */
1294 unsigned int number_of_params
;
1295 /* cache of Oif_flags from v2 procedure header */
1296 INTERPRETER_OPT_FLAGS Oif_flags
= { 0 };
1297 /* cache of extension flags from NDR_PROC_HEADER_EXTS */
1298 INTERPRETER_OPT_FLAGS2 ext_flags
= { 0 };
1299 /* the type of pass we are currently doing */
1300 enum stubless_phase phase
;
1301 /* header for procedure string */
1302 const NDR_PROC_HEADER
*pProcHeader
;
1303 /* location to put retval into */
1304 LONG_PTR
*retval_ptr
= NULL
;
1305 /* correlation cache */
1306 ULONG_PTR NdrCorrCache
[256];
1308 TRACE("pThis %p, pChannel %p, pRpcMsg %p, pdwStubPhase %p\n", pThis
, pChannel
, pRpcMsg
, pdwStubPhase
);
1311 pServerInfo
= CStdStubBuffer_GetServerInfo(pThis
);
1313 pServerInfo
= ((RPC_SERVER_INTERFACE
*)pRpcMsg
->RpcInterfaceInformation
)->InterpreterInfo
;
1315 pStubDesc
= pServerInfo
->pStubDesc
;
1316 pFormat
= pServerInfo
->ProcString
+ pServerInfo
->FmtStringOffset
[pRpcMsg
->ProcNum
];
1317 pProcHeader
= (const NDR_PROC_HEADER
*)&pFormat
[0];
1319 TRACE("NDR Version: 0x%x\n", pStubDesc
->Version
);
1321 if (pProcHeader
->Oi_flags
& Oi_HAS_RPCFLAGS
)
1323 const NDR_PROC_HEADER_RPC
*header_rpc
= (const NDR_PROC_HEADER_RPC
*)&pFormat
[0];
1324 stack_size
= header_rpc
->stack_size
;
1325 pFormat
+= sizeof(NDR_PROC_HEADER_RPC
);
1330 stack_size
= pProcHeader
->stack_size
;
1331 pFormat
+= sizeof(NDR_PROC_HEADER
);
1334 TRACE("Oi_flags = 0x%02x\n", pProcHeader
->Oi_flags
);
1337 switch (pProcHeader
->handle_type
)
1339 /* explicit binding: parse additional section */
1341 switch (*pFormat
) /* handle_type */
1343 case FC_BIND_PRIMITIVE
: /* explicit primitive */
1344 pFormat
+= sizeof(NDR_EHD_PRIMITIVE
);
1346 case FC_BIND_GENERIC
: /* explicit generic */
1347 pFormat
+= sizeof(NDR_EHD_GENERIC
);
1349 case FC_BIND_CONTEXT
: /* explicit context */
1350 pFormat
+= sizeof(NDR_EHD_CONTEXT
);
1353 ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
1354 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
1357 case FC_BIND_GENERIC
: /* implicit generic */
1358 case FC_BIND_PRIMITIVE
: /* implicit primitive */
1359 case FC_CALLBACK_HANDLE
: /* implicit callback */
1360 case FC_AUTO_HANDLE
: /* implicit auto handle */
1363 ERR("bad implicit binding handle type (0x%02x)\n", pProcHeader
->handle_type
);
1364 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
1367 if (pProcHeader
->Oi_flags
& Oi_OBJECT_PROC
)
1368 NdrStubInitialize(pRpcMsg
, &stubMsg
, pStubDesc
, pChannel
);
1370 NdrServerInitializeNew(pRpcMsg
, &stubMsg
, pStubDesc
);
1372 /* create the full pointer translation tables, if requested */
1373 if (pProcHeader
->Oi_flags
& Oi_FULL_PTR_USED
)
1374 stubMsg
.FullPtrXlatTables
= NdrFullPointerXlatInit(0,XLAT_SERVER
);
1376 /* store the RPC flags away */
1377 if (pProcHeader
->Oi_flags
& Oi_HAS_RPCFLAGS
)
1378 pRpcMsg
->RpcFlags
= ((const NDR_PROC_HEADER_RPC
*)pProcHeader
)->rpc_flags
;
1380 /* use alternate memory allocation routines */
1381 if (pProcHeader
->Oi_flags
& Oi_RPCSS_ALLOC_USED
)
1383 NdrRpcSsEnableAllocate(&stubMsg
);
1385 FIXME("Set RPCSS memory allocation routines\n");
1388 TRACE("allocating memory for stack of size %x\n", stack_size
);
1390 args
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, stack_size
);
1391 stubMsg
.StackTop
= args
; /* used by conformance of top-level objects */
1393 /* add the implicit This pointer as the first arg to the function if we
1394 * are calling an object method */
1396 *(void **)args
= ((CStdStubBuffer
*)pThis
)->pvServerObject
;
1398 if (is_oicf_stubdesc(pStubDesc
))
1400 const NDR_PROC_PARTIAL_OIF_HEADER
*pOIFHeader
= (const NDR_PROC_PARTIAL_OIF_HEADER
*)pFormat
;
1402 Oif_flags
= pOIFHeader
->Oi2Flags
;
1403 number_of_params
= pOIFHeader
->number_of_params
;
1405 pFormat
+= sizeof(NDR_PROC_PARTIAL_OIF_HEADER
);
1407 TRACE("Oif_flags = %s\n", debugstr_INTERPRETER_OPT_FLAGS(Oif_flags
) );
1409 if (Oif_flags
.HasExtensions
)
1411 const NDR_PROC_HEADER_EXTS
*pExtensions
= (const NDR_PROC_HEADER_EXTS
*)pFormat
;
1412 ext_flags
= pExtensions
->Flags2
;
1413 pFormat
+= pExtensions
->Size
;
1416 if (Oif_flags
.HasPipes
)
1418 FIXME("pipes not supported yet\n");
1419 RpcRaiseException(RPC_X_WRONG_STUB_VERSION
); /* FIXME: remove when implemented */
1420 /* init pipes package */
1421 /* NdrPipesInitialize(...) */
1423 if (ext_flags
.HasNewCorrDesc
)
1425 /* initialize extra correlation package */
1426 NdrCorrelationInitialize(&stubMsg
, NdrCorrCache
, sizeof(NdrCorrCache
), 0);
1427 if (ext_flags
.Unused
& 0x2) /* has range on conformance */
1428 stubMsg
.CorrDespIncrement
= 12;
1433 pFormat
= convert_old_args( &stubMsg
, pFormat
, stack_size
,
1434 pProcHeader
->Oi_flags
& Oi_OBJECT_PROC
,
1435 /* reuse the correlation cache, it's not needed for v1 format */
1436 NdrCorrCache
, sizeof(NdrCorrCache
), &number_of_params
);
1439 /* convert strings, floating point values and endianness into our
1440 * preferred format */
1441 if ((pRpcMsg
->DataRepresentation
& 0x0000FFFFUL
) != NDR_LOCAL_DATA_REPRESENTATION
)
1442 NdrConvert(&stubMsg
, pFormat
);
1444 for (phase
= STUBLESS_UNMARSHAL
; phase
<= STUBLESS_FREE
; phase
++)
1446 TRACE("phase = %d\n", phase
);
1449 case STUBLESS_CALLSERVER
:
1450 /* call the server function */
1451 if (pServerInfo
->ThunkTable
&& pServerInfo
->ThunkTable
[pRpcMsg
->ProcNum
])
1452 pServerInfo
->ThunkTable
[pRpcMsg
->ProcNum
](&stubMsg
);
1455 SERVER_ROUTINE func
;
1458 if (pProcHeader
->Oi_flags
& Oi_OBJECT_PROC
)
1460 SERVER_ROUTINE
*vtbl
= *(SERVER_ROUTINE
**)((CStdStubBuffer
*)pThis
)->pvServerObject
;
1461 func
= vtbl
[pRpcMsg
->ProcNum
];
1464 func
= pServerInfo
->DispatchTable
[pRpcMsg
->ProcNum
];
1466 /* FIXME: what happens with return values that don't fit into a single register on x86? */
1467 retval
= call_server_func(func
, args
, stack_size
);
1471 TRACE("stub implementation returned 0x%lx\n", retval
);
1472 *retval_ptr
= retval
;
1475 TRACE("void stub implementation\n");
1478 stubMsg
.Buffer
= NULL
;
1479 stubMsg
.BufferLength
= 0;
1482 case STUBLESS_GETBUFFER
:
1483 if (pProcHeader
->Oi_flags
& Oi_OBJECT_PROC
)
1484 NdrStubGetBuffer(pThis
, pChannel
, &stubMsg
);
1489 pRpcMsg
->BufferLength
= stubMsg
.BufferLength
;
1490 /* allocate buffer for [out] and [ret] params */
1491 Status
= I_RpcGetBuffer(pRpcMsg
);
1493 RpcRaiseException(Status
);
1494 stubMsg
.Buffer
= pRpcMsg
->Buffer
;
1497 case STUBLESS_UNMARSHAL
:
1498 case STUBLESS_INITOUT
:
1499 case STUBLESS_CALCSIZE
:
1500 case STUBLESS_MARSHAL
:
1501 case STUBLESS_MUSTFREE
:
1503 retval_ptr
= stub_do_args(&stubMsg
, pFormat
, phase
, number_of_params
);
1506 ERR("shouldn't reach here. phase %d\n", phase
);
1511 pRpcMsg
->BufferLength
= (unsigned int)(stubMsg
.Buffer
- (unsigned char *)pRpcMsg
->Buffer
);
1513 if (ext_flags
.HasNewCorrDesc
)
1515 /* free extra correlation package */
1516 NdrCorrelationFree(&stubMsg
);
1519 if (Oif_flags
.HasPipes
)
1521 /* NdrPipesDone(...) */
1524 /* free the full pointer translation tables */
1525 if (pProcHeader
->Oi_flags
& Oi_FULL_PTR_USED
)
1526 NdrFullPointerXlatFree(stubMsg
.FullPtrXlatTables
);
1528 /* free server function stack */
1529 HeapFree(GetProcessHeap(), 0, args
);
1534 /***********************************************************************
1535 * NdrServerCall2 [RPCRT4.@]
1537 void WINAPI
NdrServerCall2(PRPC_MESSAGE pRpcMsg
)
1540 NdrStubCall2(NULL
, NULL
, pRpcMsg
, &dwPhase
);
1543 /***********************************************************************
1544 * NdrStubCall [RPCRT4.@]
1546 LONG WINAPI
NdrStubCall( struct IRpcStubBuffer
*This
, struct IRpcChannelBuffer
*channel
,
1547 PRPC_MESSAGE msg
, DWORD
*phase
)
1549 return NdrStubCall2( This
, channel
, msg
, phase
);
1552 /***********************************************************************
1553 * NdrServerCall [RPCRT4.@]
1555 void WINAPI
NdrServerCall( PRPC_MESSAGE msg
)
1558 NdrStubCall( NULL
, NULL
, msg
, &phase
);
1561 struct async_call_data
1563 MIDL_STUB_MESSAGE
*pStubMsg
;
1564 const NDR_PROC_HEADER
*pProcHeader
;
1565 PFORMAT_STRING pHandleFormat
;
1566 PFORMAT_STRING pParamFormat
;
1567 RPC_BINDING_HANDLE hBinding
;
1569 unsigned short stack_size
;
1570 /* number of parameters. optional for client to give it to us */
1571 unsigned int number_of_params
;
1572 /* correlation cache */
1573 ULONG_PTR NdrCorrCache
[256];
1576 LONG_PTR CDECL DECLSPEC_HIDDEN
ndr_async_client_call( PMIDL_STUB_DESC pStubDesc
, PFORMAT_STRING pFormat
,
1579 /* pointer to start of stack where arguments start */
1580 PRPC_MESSAGE pRpcMsg
;
1581 PMIDL_STUB_MESSAGE pStubMsg
;
1582 RPC_ASYNC_STATE
*pAsync
;
1583 struct async_call_data
*async_call_data
;
1584 /* procedure number */
1585 unsigned short procedure_number
;
1586 /* cache of Oif_flags from v2 procedure header */
1587 INTERPRETER_OPT_FLAGS Oif_flags
= { 0 };
1588 /* cache of extension flags from NDR_PROC_HEADER_EXTS */
1589 INTERPRETER_OPT_FLAGS2 ext_flags
= { 0 };
1590 /* header for procedure string */
1591 const NDR_PROC_HEADER
* pProcHeader
= (const NDR_PROC_HEADER
*)&pFormat
[0];
1594 TRACE("pStubDesc %p, pFormat %p, ...\n", pStubDesc
, pFormat
);
1596 /* Later NDR language versions probably won't be backwards compatible */
1597 if (pStubDesc
->Version
> 0x50002)
1599 FIXME("Incompatible stub description version: 0x%x\n", pStubDesc
->Version
);
1600 RpcRaiseException(RPC_X_WRONG_STUB_VERSION
);
1603 async_call_data
= I_RpcAllocate(sizeof(*async_call_data
) + sizeof(MIDL_STUB_MESSAGE
) + sizeof(RPC_MESSAGE
));
1604 if (!async_call_data
) RpcRaiseException(RPC_X_NO_MEMORY
);
1605 async_call_data
->pProcHeader
= pProcHeader
;
1607 async_call_data
->pStubMsg
= pStubMsg
= (PMIDL_STUB_MESSAGE
)(async_call_data
+ 1);
1608 pRpcMsg
= (PRPC_MESSAGE
)(pStubMsg
+ 1);
1610 if (pProcHeader
->Oi_flags
& Oi_HAS_RPCFLAGS
)
1612 const NDR_PROC_HEADER_RPC
*header_rpc
= (const NDR_PROC_HEADER_RPC
*)&pFormat
[0];
1613 async_call_data
->stack_size
= header_rpc
->stack_size
;
1614 procedure_number
= header_rpc
->proc_num
;
1615 pFormat
+= sizeof(NDR_PROC_HEADER_RPC
);
1619 async_call_data
->stack_size
= pProcHeader
->stack_size
;
1620 procedure_number
= pProcHeader
->proc_num
;
1621 pFormat
+= sizeof(NDR_PROC_HEADER
);
1623 TRACE("stack size: 0x%x\n", async_call_data
->stack_size
);
1624 TRACE("proc num: %d\n", procedure_number
);
1626 /* create the full pointer translation tables, if requested */
1627 if (pProcHeader
->Oi_flags
& Oi_FULL_PTR_USED
)
1628 pStubMsg
->FullPtrXlatTables
= NdrFullPointerXlatInit(0,XLAT_CLIENT
);
1630 if (pProcHeader
->Oi_flags
& Oi_OBJECT_PROC
)
1632 ERR("objects not supported\n");
1633 I_RpcFree(async_call_data
);
1634 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
1637 NdrClientInitializeNew(pRpcMsg
, pStubMsg
, pStubDesc
, procedure_number
);
1639 TRACE("Oi_flags = 0x%02x\n", pProcHeader
->Oi_flags
);
1640 TRACE("MIDL stub version = 0x%x\n", pStubDesc
->MIDLVersion
);
1642 /* needed for conformance of top-level objects */
1643 pStubMsg
->StackTop
= I_RpcAllocate(async_call_data
->stack_size
);
1644 memcpy(pStubMsg
->StackTop
, stack_top
, async_call_data
->stack_size
);
1646 pAsync
= *(RPC_ASYNC_STATE
**)pStubMsg
->StackTop
;
1647 pAsync
->StubInfo
= async_call_data
;
1648 async_call_data
->pHandleFormat
= pFormat
;
1650 pFormat
= client_get_handle(pStubMsg
, pProcHeader
, async_call_data
->pHandleFormat
, &async_call_data
->hBinding
);
1651 if (!pFormat
) goto done
;
1653 if (is_oicf_stubdesc(pStubDesc
))
1655 const NDR_PROC_PARTIAL_OIF_HEADER
*pOIFHeader
=
1656 (const NDR_PROC_PARTIAL_OIF_HEADER
*)pFormat
;
1658 Oif_flags
= pOIFHeader
->Oi2Flags
;
1659 async_call_data
->number_of_params
= pOIFHeader
->number_of_params
;
1661 pFormat
+= sizeof(NDR_PROC_PARTIAL_OIF_HEADER
);
1663 TRACE("Oif_flags = %s\n", debugstr_INTERPRETER_OPT_FLAGS(Oif_flags
) );
1665 if (Oif_flags
.HasExtensions
)
1667 const NDR_PROC_HEADER_EXTS
*pExtensions
=
1668 (const NDR_PROC_HEADER_EXTS
*)pFormat
;
1669 ext_flags
= pExtensions
->Flags2
;
1670 pFormat
+= pExtensions
->Size
;
1675 pFormat
= convert_old_args( pStubMsg
, pFormat
, async_call_data
->stack_size
,
1676 pProcHeader
->Oi_flags
& Oi_OBJECT_PROC
,
1677 async_call_data
->NdrCorrCache
, sizeof(async_call_data
->NdrCorrCache
),
1678 &async_call_data
->number_of_params
);
1681 async_call_data
->pParamFormat
= pFormat
;
1683 pStubMsg
->BufferLength
= 0;
1685 /* store the RPC flags away */
1686 if (pProcHeader
->Oi_flags
& Oi_HAS_RPCFLAGS
)
1687 pRpcMsg
->RpcFlags
= ((const NDR_PROC_HEADER_RPC
*)pProcHeader
)->rpc_flags
;
1689 /* use alternate memory allocation routines */
1690 if (pProcHeader
->Oi_flags
& Oi_RPCSS_ALLOC_USED
)
1691 NdrRpcSmSetClientToOsf(pStubMsg
);
1693 if (Oif_flags
.HasPipes
)
1695 FIXME("pipes not supported yet\n");
1696 RpcRaiseException(RPC_X_WRONG_STUB_VERSION
); /* FIXME: remove when implemented */
1697 /* init pipes package */
1698 /* NdrPipesInitialize(...) */
1700 if (ext_flags
.HasNewCorrDesc
)
1702 /* initialize extra correlation package */
1703 NdrCorrelationInitialize(pStubMsg
, async_call_data
->NdrCorrCache
, sizeof(async_call_data
->NdrCorrCache
), 0);
1704 if (ext_flags
.Unused
& 0x2) /* has range on conformance */
1705 pStubMsg
->CorrDespIncrement
= 12;
1709 * 1. CALCSIZE - calculate the buffer size
1710 * 2. GETBUFFER - allocate the buffer
1711 * 3. MARSHAL - marshal [in] params into the buffer
1712 * 4. SENDRECEIVE - send buffer
1713 * Then in NdrpCompleteAsyncClientCall:
1714 * 1. SENDRECEIVE - receive buffer
1715 * 2. UNMARSHAL - unmarshal [out] params from buffer
1719 TRACE( "CALCSIZE\n" );
1720 client_do_args(pStubMsg
, pFormat
, STUBLESS_CALCSIZE
, NULL
, async_call_data
->number_of_params
, NULL
);
1723 TRACE( "GETBUFFER\n" );
1724 if (Oif_flags
.HasPipes
)
1725 /* NdrGetPipeBuffer(...) */
1726 FIXME("pipes not supported yet\n");
1729 if (pProcHeader
->handle_type
== FC_AUTO_HANDLE
)
1731 NdrNsGetBuffer(pStubMsg
, pStubMsg
->BufferLength
, async_call_data
->hBinding
);
1733 FIXME("using auto handle - call NdrNsGetBuffer when it gets implemented\n");
1736 NdrGetBuffer(pStubMsg
, pStubMsg
->BufferLength
, async_call_data
->hBinding
);
1738 pRpcMsg
->RpcFlags
|= RPC_BUFFER_ASYNC
;
1739 status
= I_RpcAsyncSetHandle(pRpcMsg
, pAsync
);
1740 if (status
!= RPC_S_OK
)
1741 RpcRaiseException(status
);
1744 TRACE( "MARSHAL\n" );
1745 client_do_args(pStubMsg
, pFormat
, STUBLESS_MARSHAL
, NULL
, async_call_data
->number_of_params
, NULL
);
1747 /* 4. SENDRECEIVE */
1749 pRpcMsg
->RpcFlags
|= RPC_BUFFER_ASYNC
;
1750 /* send the [in] params only */
1751 if (Oif_flags
.HasPipes
)
1752 /* NdrPipesSend(...) */
1753 FIXME("pipes not supported yet\n");
1756 if (pProcHeader
->handle_type
== FC_AUTO_HANDLE
)
1758 NdrNsSend(&stubMsg
, stubMsg
.Buffer
, pStubDesc
->IMPLICIT_HANDLE_INFO
.pAutoHandle
);
1760 FIXME("using auto handle - call NdrNsSend when it gets implemented\n");
1764 pStubMsg
->RpcMsg
->BufferLength
= pStubMsg
->Buffer
- (unsigned char *)pStubMsg
->RpcMsg
->Buffer
;
1765 status
= I_RpcSend(pStubMsg
->RpcMsg
);
1766 if (status
!= RPC_S_OK
)
1767 RpcRaiseException(status
);
1772 TRACE("returning 0\n");
1776 RPC_STATUS
NdrpCompleteAsyncClientCall(RPC_ASYNC_STATE
*pAsync
, void *Reply
)
1778 /* pointer to start of stack where arguments start */
1779 PMIDL_STUB_MESSAGE pStubMsg
;
1780 struct async_call_data
*async_call_data
;
1781 /* header for procedure string */
1782 const NDR_PROC_HEADER
* pProcHeader
;
1783 RPC_STATUS status
= RPC_S_OK
;
1785 if (!pAsync
->StubInfo
)
1786 return RPC_S_INVALID_ASYNC_HANDLE
;
1788 async_call_data
= pAsync
->StubInfo
;
1789 pStubMsg
= async_call_data
->pStubMsg
;
1790 pProcHeader
= async_call_data
->pProcHeader
;
1793 * 1. CALCSIZE - calculate the buffer size
1794 * 2. GETBUFFER - allocate the buffer
1795 * 3. MARSHAL - marshal [in] params into the buffer
1796 * 4. SENDRECEIVE - send buffer
1797 * Then in NdrpCompleteAsyncClientCall:
1798 * 1. SENDRECEIVE - receive buffer
1799 * 2. UNMARSHAL - unmarshal [out] params from buffer
1802 /* 1. SENDRECEIVE */
1803 TRACE( "RECEIVE\n" );
1804 pStubMsg
->RpcMsg
->RpcFlags
|= RPC_BUFFER_ASYNC
;
1805 /* receive the [out] params */
1806 if (pProcHeader
->handle_type
== FC_AUTO_HANDLE
)
1808 NdrNsReceive(&stubMsg
, stubMsg
.Buffer
, pStubDesc
->IMPLICIT_HANDLE_INFO
.pAutoHandle
);
1810 FIXME("using auto handle - call NdrNsReceive when it gets implemented\n");
1814 status
= I_RpcReceive(pStubMsg
->RpcMsg
);
1815 if (status
!= RPC_S_OK
)
1817 pStubMsg
->BufferLength
= pStubMsg
->RpcMsg
->BufferLength
;
1818 pStubMsg
->BufferStart
= pStubMsg
->RpcMsg
->Buffer
;
1819 pStubMsg
->BufferEnd
= pStubMsg
->BufferStart
+ pStubMsg
->BufferLength
;
1820 pStubMsg
->Buffer
= pStubMsg
->BufferStart
;
1823 /* convert strings, floating point values and endianness into our
1824 * preferred format */
1826 if ((pStubMsg
->RpcMsg
.DataRepresentation
& 0x0000FFFFUL
) != NDR_LOCAL_DATA_REPRESENTATION
)
1827 NdrConvert(pStubMsg
, pFormat
);
1831 TRACE( "UNMARSHAL\n" );
1832 client_do_args(pStubMsg
, async_call_data
->pParamFormat
, STUBLESS_UNMARSHAL
,
1833 NULL
, async_call_data
->number_of_params
, Reply
);
1836 if (pStubMsg
->fHasNewCorrDesc
)
1838 /* free extra correlation package */
1839 NdrCorrelationFree(pStubMsg
);
1842 /* free the full pointer translation tables */
1843 if (pProcHeader
->Oi_flags
& Oi_FULL_PTR_USED
)
1844 NdrFullPointerXlatFree(pStubMsg
->FullPtrXlatTables
);
1846 /* free marshalling buffer */
1847 NdrFreeBuffer(pStubMsg
);
1848 client_free_handle(pStubMsg
, pProcHeader
, async_call_data
->pHandleFormat
, async_call_data
->hBinding
);
1850 I_RpcFree(pStubMsg
->StackTop
);
1851 I_RpcFree(async_call_data
);
1853 TRACE("-- 0x%x\n", status
);
1859 __ASM_GLOBAL_FUNC( NdrAsyncClientCall
,
1860 "movq %r8,0x18(%rsp)\n\t"
1861 "movq %r9,0x20(%rsp)\n\t"
1862 "leaq 0x18(%rsp),%r8\n\t"
1863 "subq $0x28,%rsp\n\t"
1864 __ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t")
1865 "call " __ASM_NAME("ndr_async_client_call") "\n\t"
1866 "addq $0x28,%rsp\n\t"
1867 __ASM_CFI(".cfi_adjust_cfa_offset -0x28\n\t")
1870 #else /* __x86_64__ */
1872 /***********************************************************************
1873 * NdrAsyncClientCall [RPCRT4.@]
1875 CLIENT_CALL_RETURN WINAPIV
NdrAsyncClientCall( PMIDL_STUB_DESC desc
, PFORMAT_STRING format
, ... )
1880 __ms_va_start( args
, format
);
1881 ret
= ndr_async_client_call( desc
, format
, va_arg( args
, void ** ));
1882 __ms_va_end( args
);
1883 return *(CLIENT_CALL_RETURN
*)&ret
;
1886 #endif /* __x86_64__ */
1888 RPCRTAPI LONG RPC_ENTRY
NdrAsyncStubCall(struct IRpcStubBuffer
* pThis
,
1889 struct IRpcChannelBuffer
* pChannel
, PRPC_MESSAGE pRpcMsg
,
1890 DWORD
* pdwStubPhase
)
1892 FIXME("unimplemented, expect crash!\n");
1896 void RPC_ENTRY
NdrAsyncServerCall(PRPC_MESSAGE pRpcMsg
)
1898 FIXME("unimplemented, %p\n", pRpcMsg
);