From: Haoyang Chen chenhaoyang@kylinos.cn
If explicit_handle is defined in the *.idl file, c/s are uses explicit handles, then an explicit handle must be passed in to the server-side interface --- dlls/rpcrt4/ndr_stubless.c | 63 +++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 28 deletions(-)
diff --git a/dlls/rpcrt4/ndr_stubless.c b/dlls/rpcrt4/ndr_stubless.c index 80cd0bbcb89..7aa2f79d10b 100644 --- a/dlls/rpcrt4/ndr_stubless.c +++ b/dlls/rpcrt4/ndr_stubless.c @@ -1365,6 +1365,32 @@ LONG WINAPI NdrStubCall2(
TRACE("Oi_flags = 0x%02x\n", pProcHeader->Oi_flags);
+ if (pProcHeader->Oi_flags & Oi_OBJECT_PROC) + NdrStubInitialize(pRpcMsg, &stubMsg, pStubDesc, pChannel); + else + NdrServerInitializeNew(pRpcMsg, &stubMsg, pStubDesc); + + /* create the full pointer translation tables, if requested */ + if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED) + stubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_SERVER); + + /* store the RPC flags away */ + if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS) + pRpcMsg->RpcFlags = ((const NDR_PROC_HEADER_RPC *)pProcHeader)->rpc_flags; + + /* use alternate memory allocation routines */ + if (pProcHeader->Oi_flags & Oi_RPCSS_ALLOC_USED) +#if 0 + NdrRpcSsEnableAllocate(&stubMsg); +#else + FIXME("Set RPCSS memory allocation routines\n"); +#endif + + TRACE("allocating memory for stack of size %x\n", stack_size); + + args = calloc(1, stack_size); + stubMsg.StackTop = args; /* used by conformance of top-level objects */ + /* binding */ switch (pProcHeader->handle_type) { @@ -1373,8 +1399,15 @@ LONG WINAPI NdrStubCall2( switch (*pFormat) /* handle_type */ { case FC_BIND_PRIMITIVE: /* explicit primitive */ - pFormat += sizeof(NDR_EHD_PRIMITIVE); - break; + { + const NDR_EHD_PRIMITIVE *pDesc = (const NDR_EHD_PRIMITIVE *)pFormat; + if (pDesc->flag) + **(handle_t **)ARG_FROM_OFFSET(stubMsg.StackTop, pDesc->offset) = pRpcMsg->Handle; + else + *(handle_t *)ARG_FROM_OFFSET(stubMsg.StackTop, pDesc->offset) = pRpcMsg->Handle; + pFormat += sizeof(NDR_EHD_PRIMITIVE); + break; + } case FC_BIND_GENERIC: /* explicit generic */ pFormat += sizeof(NDR_EHD_GENERIC); break; @@ -1396,32 +1429,6 @@ LONG WINAPI NdrStubCall2( RpcRaiseException(RPC_X_BAD_STUB_DATA); }
- if (pProcHeader->Oi_flags & Oi_OBJECT_PROC) - NdrStubInitialize(pRpcMsg, &stubMsg, pStubDesc, pChannel); - else - NdrServerInitializeNew(pRpcMsg, &stubMsg, pStubDesc); - - /* create the full pointer translation tables, if requested */ - if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED) - stubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_SERVER); - - /* store the RPC flags away */ - if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS) - pRpcMsg->RpcFlags = ((const NDR_PROC_HEADER_RPC *)pProcHeader)->rpc_flags; - - /* use alternate memory allocation routines */ - if (pProcHeader->Oi_flags & Oi_RPCSS_ALLOC_USED) -#if 0 - NdrRpcSsEnableAllocate(&stubMsg); -#else - FIXME("Set RPCSS memory allocation routines\n"); -#endif - - TRACE("allocating memory for stack of size %x\n", stack_size); - - args = calloc(1, stack_size); - stubMsg.StackTop = args; /* used by conformance of top-level objects */ - /* add the implicit This pointer as the first arg to the function if we * are calling an object method */ if (pThis)