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.
And add a test for explicit_handle.
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)
From: Haoyang Chen chenhaoyang@kylinos.cn
--- dlls/rpcrt4/tests/Makefile.in | 3 +- dlls/rpcrt4/tests/explicit_handle.idl | 14 +++++ dlls/rpcrt4/tests/server.c | 78 +++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 dlls/rpcrt4/tests/explicit_handle.idl
diff --git a/dlls/rpcrt4/tests/Makefile.in b/dlls/rpcrt4/tests/Makefile.in index f46ff49219a..dcfc4d8f2e3 100644 --- a/dlls/rpcrt4/tests/Makefile.in +++ b/dlls/rpcrt4/tests/Makefile.in @@ -15,4 +15,5 @@ SOURCES = \ rpc_async.c \ server.c \ server.idl \ - server_interp.idl + server_interp.idl \ + explicit_handle.idl diff --git a/dlls/rpcrt4/tests/explicit_handle.idl b/dlls/rpcrt4/tests/explicit_handle.idl new file mode 100644 index 00000000000..4366e68108e --- /dev/null +++ b/dlls/rpcrt4/tests/explicit_handle.idl @@ -0,0 +1,14 @@ +#pragma makedep client +#pragma makedep server + +[ + uuid(00000000-4114-0704-2301-000000000002), + explicit_handle +] + +interface RPCExplicitHandle +{ + int add([in] handle_t hBinding,[in] int a, [in] int b ); + int getNum([in] int a,[in] handle_t hBinding ); + void Shutdown([in] handle_t hBinding); +} diff --git a/dlls/rpcrt4/tests/server.c b/dlls/rpcrt4/tests/server.c index 8e87a468f86..c963e15aaab 100644 --- a/dlls/rpcrt4/tests/server.c +++ b/dlls/rpcrt4/tests/server.c @@ -30,6 +30,7 @@ #define SKIP_TYPE_DECLS #include "server_interp.h" #include "server_defines.h" +#include "explicit_handle.h"
#include <stddef.h> #include <stdio.h> @@ -1202,6 +1203,30 @@ void __cdecl s_test_I_RpcBindingInqLocalClientPID(unsigned int protseq, RPC_BIND winetest_pop_context(); }
+int __cdecl s_add(handle_t binding, int a, int b) +{ + ok(binding != NULL, "explicit handle is NULL\n"); + return a + b; +} + +int __cdecl s_getNum(int a, handle_t binding) +{ + ok(binding != NULL, "explicit handle is NULL\n"); + return a + 2; +} + +void __cdecl s_Shutdown(handle_t binding) +{ + RPC_STATUS status; + ULONG pid = 0; + ok(binding != NULL, "explicit handle is NULL\n"); + + status = I_RpcBindingInqLocalClientPID(binding, &pid); + ok(status == RPC_S_OK, "Got unexpected %ld.\n", status); + ok(pid == client_info.dwProcessId, "Got unexpected pid: %ld client pid: %ld.\n", pid, client_info.dwProcessId); + ok(SetEvent(stop_event), "SetEvent\n"); +} + void __RPC_USER ctx_handle_t_rundown(ctx_handle_t ctx_handle) { ok(ctx_handle == (ctx_handle_t)0xdeadbeef, "Unexpected ctx_handle %p\n", ctx_handle); @@ -2138,6 +2163,23 @@ client(const char *test) ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); ok(RPC_S_OK == RpcBindingFree(&IInterpServer_IfHandle), "RpcBindingFree\n"); } + else if (strcmp(test, "explicit_handle") == 0) + { + + IMixedServer_IfHandle = NULL; + ok(RPC_S_OK == RpcStringBindingComposeA(NULL, ncalrpc, NULL, guid, NULL, &binding), "RpcStringBindingCompose\n"); + ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IMixedServer_IfHandle), "RpcBindingFromStringBinding\n"); + + test_is_server_listening(IMixedServer_IfHandle, RPC_S_OK); + + ok(add(IMixedServer_IfHandle, 2, 3) == 5, "RPC add\n"); + ok(getNum(7, IMixedServer_IfHandle) == 9, "RPC getNum\n"); + Shutdown(IMixedServer_IfHandle); + + ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); + ok(RPC_S_OK == RpcBindingFree(&IMixedServer_IfHandle), "RpcBindingFree\n"); + + } }
static void @@ -2247,6 +2289,42 @@ server(void) ok(status == RPC_S_OK, "RpcServerUnregisterIf() failed: %lu\n", status); }
+ /* explicith andle */ + + stop_event = CreateEventW(NULL, FALSE, FALSE, NULL); + ok(stop_event != NULL, "CreateEvent failed with error %ld\n", GetLastError()); + + np_status = RpcServerUseProtseqEpA(ncalrpc, 0, guid, NULL); + if (np_status == RPC_S_PROTSEQ_NOT_SUPPORTED) + skip("Protocol sequence ncacn_np is not supported\n"); + else + ok(np_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_np) failed with status %ld\n", np_status); + + if (pRpcServerRegisterIfEx) + { + trace("Using RpcServerRegisterIfEx\n"); + status = pRpcServerRegisterIfEx(s_RPCExplicitHandle_v0_0_s_ifspec, NULL, NULL, + RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH, + RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL); + ok(status == RPC_S_OK, "RpcServerRegisterIfEx failed with status %ld\n", status); + } + else + { + status = RpcServerRegisterIf(s_RPCExplicitHandle_v0_0_s_ifspec, NULL, NULL); + ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %ld\n", status); + } + + run_client("explicit_handle"); + + ret = WaitForSingleObject(stop_event, 1000); + ok(WAIT_OBJECT_0 == ret, "WaitForSingleObject\n"); + + if (pRpcServerRegisterIfEx) + { + status = RpcServerUnregisterIf(s_RPCExplicitHandle_v0_0_s_ifspec, NULL, TRUE); + ok(status == RPC_S_OK, "RpcServerUnregisterIf() failed: %lu\n", status); + } + CoUninitialize(); }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=140094
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 0524:server: unhandled exception 000006bb at 74DA845D server.c:1253: unhandled exception 000006bb in child process 0524 server.c:2320: Test failed: WaitForSingleObject
=== w7u_el (32 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 0b40:server: unhandled exception 000006bb at 750E845D server.c:1253: unhandled exception 000006bb in child process 0b40 server.c:2320: Test failed: WaitForSingleObject
=== w8 (32 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 0cb8:server: unhandled exception 000006bb at 754C1A3A server.c:1253: unhandled exception 000006bb in child process 0cb8 server.c:2320: Test failed: WaitForSingleObject
=== w864 (32 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 0a9c:server: unhandled exception 000006bb at 75454128 server.c:1253: unhandled exception 000006bb in child process 0a9c server.c:2320: Test failed: WaitForSingleObject
=== w1064v1507 (32 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 0d94:server: unhandled exception 000006bb at 76C83E28 server.c:1253: unhandled exception 000006bb in child process 0d94 server.c:2320: Test failed: WaitForSingleObject
=== w1064v1809 (32 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 1f60:server: unhandled exception 000006bb at 774C2552 server.c:1253: unhandled exception 000006bb in child process 1f60 server.c:2320: Test failed: WaitForSingleObject
=== w1064_tsign (32 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 1e38:server: unhandled exception 000006bb at 7697E092 server.c:1253: unhandled exception 000006bb in child process 1e38 server.c:2320: Test failed: WaitForSingleObject server.c:2343: Test failed: RpcBindingFree
=== w10pro64 (32 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 21bc:server: unhandled exception 000006bb at 7562B982 server.c:1253: unhandled exception 000006bb in child process 21bc server.c:2320: Test failed: WaitForSingleObject
=== w10pro64_en_AE_u8 (32 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 2260:server: unhandled exception 000006bb at 76E3B982 server.c:1253: unhandled exception 000006bb in child process 2260 server.c:2320: Test failed: WaitForSingleObject
=== w11pro64 (32 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 1410:server: unhandled exception 000006bb at 769207B2 server.c:1253: unhandled exception 000006bb in child process 1410 server.c:2320: Test failed: WaitForSingleObject
=== w7pro64 (64 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 0abc:server: unhandled exception 000006bb at 000007FEFCDDB87D server.c:1253: unhandled exception 000006bb in child process 0abc server.c:2320: Test failed: WaitForSingleObject
=== w864 (64 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 0944:server: unhandled exception 000006bb at 00007FFA482B8D5C server.c:1253: unhandled exception 000006bb in child process 0944 server.c:2320: Test failed: WaitForSingleObject
=== w1064v1507 (64 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 0490:server: unhandled exception 000006bb at 00007FFADB3AA1C8 server.c:1253: unhandled exception 000006bb in child process 0490 server.c:2320: Test failed: WaitForSingleObject
=== w1064v1809 (64 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 1f90:server: unhandled exception 000006bb at 00007FFFC2849709 server.c:1253: unhandled exception 000006bb in child process 1f90 server.c:2320: Test failed: WaitForSingleObject
=== w1064_2qxl (64 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 1edc:server: unhandled exception 000006bb at 00007FFFFB10CD29 server.c:1253: unhandled exception 000006bb in child process 1edc server.c:2320: Test failed: WaitForSingleObject
=== w1064_tsign (64 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 18cc:server: unhandled exception 000006bb at 00007FF806EDCD29 server.c:1253: unhandled exception 000006bb in child process 18cc server.c:2320: Test failed: WaitForSingleObject
=== w10pro64 (64 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 21ac:server: unhandled exception 000006bb at 00007FFF2C874F69 server.c:1253: unhandled exception 000006bb in child process 21ac server.c:2320: Test failed: WaitForSingleObject
=== w10pro64_ar (64 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 2350:server: unhandled exception 000006bb at 00007FFA072F4F69 server.c:1253: unhandled exception 000006bb in child process 2350 server.c:2320: Test failed: WaitForSingleObject
=== w10pro64_ja (64 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 2120:server: unhandled exception 000006bb at 00007FF96EAF4F69 server.c:1253: unhandled exception 000006bb in child process 2120 server.c:2320: Test failed: WaitForSingleObject
=== w10pro64_zh_CN (64 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 226c:server: unhandled exception 000006bb at 00007FF8B5764F69 server.c:1253: unhandled exception 000006bb in child process 226c server.c:2320: Test failed: WaitForSingleObject
=== w11pro64_amd (64 bit report) ===
rpcrt4: server.c:2301: Test failed: RpcServerUseProtseqEp(ncacn_np) failed with status 1740 server.c:2173: Test failed: RpcMgmtIsServerListening returned 1715, expected 0 231c:server: unhandled exception 000006bb at 00007FFF0DF3428C server.c:1253: unhandled exception 000006bb in child process 231c server.c:2320: Test failed: WaitForSingleObject
Zebediah Figura (@zfigura) commented about dlls/rpcrt4/tests/Makefile.in:
rpc_async.c \ server.c \ server.idl \
- server_interp.idl
- server_interp.idl \
- explicit_handle.idl
This is out of alphabetical order.
Zebediah Figura (@zfigura) commented about dlls/rpcrt4/tests/explicit_handle.idl:
+#pragma makedep client +#pragma makedep server
Small as it is, this file does still need a copyright header.
Zebediah Figura (@zfigura) commented about dlls/rpcrt4/tests/server.c:
ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); ok(RPC_S_OK == RpcBindingFree(&IInterpServer_IfHandle), "RpcBindingFree\n");
}
- else if (strcmp(test, "explicit_handle") == 0)
- {
Let's get rid of these blank lines, please.
Zebediah Figura (@zfigura) commented about dlls/rpcrt4/tests/server.c:
ok(status == RPC_S_OK, "RpcServerUnregisterIf() failed: %lu\n", status);
}
- /* explicith andle */
Spelling error here.
Gitlab doesn't report it, but the tests are failing on Windows:
On Wed Nov 22 06:42:43 2023 +0000, Zebediah Figura wrote:
Gitlab doesn't report it, but the tests are failing on Windows: https://testbot.winehq.org/JobDetails.pl?Key=140094
Thanks a lot. I will send v3 patches.
This merge request was closed by Haoyang Chen.