Zhiyi Zhang : rpcrt4: Implement I_RpcBindingInqLocalClientPID().

Alexandre Julliard julliard at winehq.org
Mon Jul 18 15:47:02 CDT 2022


Module: wine
Branch: master
Commit: a0301f7db6b58cb8aedd2bd0e862f89cbdb984c5
URL:    https://gitlab.winehq.org/wine/wine/-/commit/a0301f7db6b58cb8aedd2bd0e862f89cbdb984c5

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Mon May 23 23:09:59 2022 +0800

rpcrt4: Implement I_RpcBindingInqLocalClientPID().

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>

---

 dlls/rpcrt4/rpc_binding.c   | 16 ++++++++++++++--
 dlls/rpcrt4/rpc_binding.h   |  1 +
 dlls/rpcrt4/rpc_transport.c | 11 +++++++++++
 dlls/rpcrt4/tests/server.c  |  7 -------
 4 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/dlls/rpcrt4/rpc_binding.c b/dlls/rpcrt4/rpc_binding.c
index ba7ef418419..8c2d34f8a21 100644
--- a/dlls/rpcrt4/rpc_binding.c
+++ b/dlls/rpcrt4/rpc_binding.c
@@ -1981,6 +1981,18 @@ RPC_STATUS WINAPI RpcBindingSetOption(RPC_BINDING_HANDLE BindingHandle, ULONG Op
 
 RPC_STATUS WINAPI I_RpcBindingInqLocalClientPID(RPC_BINDING_HANDLE ClientBinding, ULONG *ClientPID)
 {
-    FIXME("%p %p: stub\n", ClientBinding, ClientPID);
-    return RPC_S_INVALID_BINDING;
+    RpcConnection *connection = NULL;
+    RpcBinding *binding;
+
+    TRACE("%p %p\n", ClientBinding, ClientPID);
+
+    binding = ClientBinding ? ClientBinding : RPCRT4_GetThreadCurrentCallHandle();
+    if (!binding)
+        return RPC_S_NO_CALL_ACTIVE;
+
+    connection = binding->FromConn;
+    if (!connection->ops->inquire_client_pid)
+        return RPC_S_INVALID_BINDING;
+
+    return connection->ops->inquire_client_pid(connection, ClientPID);
 }
diff --git a/dlls/rpcrt4/rpc_binding.h b/dlls/rpcrt4/rpc_binding.h
index 8faacbd66e2..c79451f4894 100644
--- a/dlls/rpcrt4/rpc_binding.h
+++ b/dlls/rpcrt4/rpc_binding.h
@@ -118,6 +118,7 @@ struct connection_ops {
   RPC_STATUS (*impersonate_client)(RpcConnection *conn);
   RPC_STATUS (*revert_to_self)(RpcConnection *conn);
   RPC_STATUS (*inquire_auth_client)(RpcConnection *, RPC_AUTHZ_HANDLE *, RPC_WSTR *, ULONG *, ULONG *, ULONG *, ULONG);
+  RPC_STATUS (*inquire_client_pid)(RpcConnection *conn, ULONG *pid);
 };
 
 /* don't know what MS's structure looks like */
diff --git a/dlls/rpcrt4/rpc_transport.c b/dlls/rpcrt4/rpc_transport.c
index 82798a5a80d..8c615b71dd9 100644
--- a/dlls/rpcrt4/rpc_transport.c
+++ b/dlls/rpcrt4/rpc_transport.c
@@ -893,6 +893,13 @@ static RPC_STATUS rpcrt4_ncalrpc_inquire_auth_client(
     return RPC_S_OK;
 }
 
+static RPC_STATUS rpcrt4_ncalrpc_inquire_client_pid(RpcConnection *conn, ULONG *pid)
+{
+    RpcConnection_np *connection = (RpcConnection_np *)conn;
+
+    return GetNamedPipeClientProcessId(connection->pipe, pid) ? RPC_S_OK : RPC_S_INVALID_BINDING;
+}
+
 /**** ncacn_ip_tcp support ****/
 
 static size_t rpcrt4_ip_tcp_get_top_of_tower(unsigned char *tower_data,
@@ -3134,6 +3141,7 @@ static const struct connection_ops conn_protseq_list[] = {
     rpcrt4_conn_np_impersonate_client,
     rpcrt4_conn_np_revert_to_self,
     RPCRT4_default_inquire_auth_client,
+    NULL
   },
   { "ncalrpc",
     { EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_PIPE },
@@ -3156,6 +3164,7 @@ static const struct connection_ops conn_protseq_list[] = {
     rpcrt4_conn_np_impersonate_client,
     rpcrt4_conn_np_revert_to_self,
     rpcrt4_ncalrpc_inquire_auth_client,
+    rpcrt4_ncalrpc_inquire_client_pid
   },
   { "ncacn_ip_tcp",
     { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_TCP },
@@ -3178,6 +3187,7 @@ static const struct connection_ops conn_protseq_list[] = {
     RPCRT4_default_impersonate_client,
     RPCRT4_default_revert_to_self,
     RPCRT4_default_inquire_auth_client,
+    NULL
   },
   { "ncacn_http",
     { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_HTTP },
@@ -3200,6 +3210,7 @@ static const struct connection_ops conn_protseq_list[] = {
     RPCRT4_default_impersonate_client,
     RPCRT4_default_revert_to_self,
     RPCRT4_default_inquire_auth_client,
+    NULL
   },
 };
 
diff --git a/dlls/rpcrt4/tests/server.c b/dlls/rpcrt4/tests/server.c
index 7fdb076bc73..5fe803e5a1d 100644
--- a/dlls/rpcrt4/tests/server.c
+++ b/dlls/rpcrt4/tests/server.c
@@ -1140,16 +1140,13 @@ static DWORD CALLBACK test_I_RpcBindingInqLocalClientPID_thread_func(void *args)
     winetest_push_context("%s", client_test_name);
 
     status = I_RpcBindingInqLocalClientPID(NULL, &pid);
-    todo_wine
     ok(status == RPC_S_NO_CALL_ACTIVE, "Got unexpected %ld.\n", status);
 
     /* Other protocol sequences throw exceptions */
     if (params->protseq == RPC_PROTSEQ_LRPC)
     {
         status = I_RpcBindingInqLocalClientPID(params->binding, &pid);
-        todo_wine
         ok(status == RPC_S_OK, "Got unexpected %ld.\n", status);
-        todo_wine
         ok(pid == client_info.dwProcessId, "Got unexpected pid.\n");
     }
 
@@ -1179,9 +1176,7 @@ void __cdecl s_test_I_RpcBindingInqLocalClientPID(unsigned int protseq, RPC_BIND
     status = I_RpcBindingInqLocalClientPID(NULL, &pid);
     if (protseq == RPC_PROTSEQ_LRPC)
     {
-        todo_wine
         ok(status == RPC_S_OK, "Got unexpected %ld.\n", status);
-        todo_wine
         ok(pid == client_info.dwProcessId, "Got unexpected pid.\n");
     }
     else
@@ -1192,9 +1187,7 @@ void __cdecl s_test_I_RpcBindingInqLocalClientPID(unsigned int protseq, RPC_BIND
     if (protseq == RPC_PROTSEQ_LRPC) /* Other protocol sequences throw exceptions */
     {
         status = I_RpcBindingInqLocalClientPID(binding, &pid);
-        todo_wine
         ok(status == RPC_S_OK, "Got unexpected %ld.\n", status);
-        todo_wine
         ok(pid == client_info.dwProcessId, "Got unexpected pid.\n");
     }
 




More information about the wine-cvs mailing list