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.
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 2e84d64bba5..b4d7ede2d0a 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)
Can you please add a test for this? I *think* it should be possible to extend the existing server.idl with another function.
It turns out that, somewhat surprisingly, FC_BIND_PRIMITIVE really is different from FC_BIND_GENERIC and FC_BIND_CONTEXT. The latter two are written into the proc format string (and so are handled during unmarshalling), whereas FC_BIND_PRIMITIVE isn't. It may be worth adding a comment to that effect.
There's a whitespace error in one of the added lines (space before semicolon).
On Mon Nov 20 10:35:29 2023 +0000, Zebediah Figura wrote:
Can you please add a test for this? I *think* it should be possible to extend the existing server.idl with another function. It turns out that, somewhat surprisingly, FC_BIND_PRIMITIVE really is different from FC_BIND_GENERIC and FC_BIND_CONTEXT. The latter two are written into the proc format string (and so are handled during unmarshalling), whereas FC_BIND_PRIMITIVE isn't. It may be worth adding a comment to that effect. There's a whitespace error in one of the added lines (space before semicolon).
Hi, There is a space that need to be removed. I wrote a test that may be a little lacking. Take a look at it.[1.diff](/uploads/e9ee2eb7558eaabe6b3c984d38dc18dc/1.diff)
On Mon Nov 20 10:35:29 2023 +0000, Haoyang Chen wrote:
Hi, There is a space that need to be removed. I wrote a test that may be a little lacking. Take a look at it.[1.diff](/uploads/e9ee2eb7558eaabe6b3c984d38dc18dc/1.diff)
Yes, that looks mostly good, thanks. Note that your EXTRAIDLFLAGS are broken though.
This merge request was closed by Haoyang Chen.
I will send v2 patch.