rpcrt4: Implement I_RpcBindingInqLocalClientPID().

Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
This commit is contained in:
Zhiyi Zhang 2022-05-23 23:09:59 +08:00 committed by Alexandre Julliard
parent 056dbb04de
commit a0301f7db6
4 changed files with 26 additions and 9 deletions

View file

@ -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);
}

View file

@ -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 */

View file

@ -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
},
};

View file

@ -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");
}