X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windows%2Fwinhsock.c;h=f52d5211572f3ad1e98d6194dd6793e777f9b11e;hb=a063e522970946bf7d5dc052079d7773c0dee76d;hp=6b088bb8217336d10cb693e311d1ec99be600402;hpb=41f63b6e5dc8ff83306287ae702d875edff4586f;p=PuTTY.git diff --git a/windows/winhsock.c b/windows/winhsock.c index 6b088bb8..f52d5211 100644 --- a/windows/winhsock.c +++ b/windows/winhsock.c @@ -236,6 +236,26 @@ static const char *sk_handle_socket_error(Socket s) static char *sk_handle_peer_info(Socket s) { + Handle_Socket ps = (Handle_Socket) s; + ULONG pid; + static HMODULE kernel32_module; + DECL_WINDOWS_FUNCTION(static, BOOL, GetNamedPipeClientProcessId, + (HANDLE, PULONG)); + + if (!kernel32_module) { + kernel32_module = load_system32_dll("kernel32.dll"); + GET_WINDOWS_FUNCTION(kernel32_module, GetNamedPipeClientProcessId); + } + + /* + * Of course, not all handles managed by this module will be + * server ends of named pipes, but if they are, then it's useful + * to log what we can find out about the client end. + */ + if (p_GetNamedPipeClientProcessId && + p_GetNamedPipeClientProcessId(ps->send_H, &pid)) + return dupprintf("process id %lu", (unsigned long)pid); + return NULL; }