Summary of the takeaway: the GetNamedPipeClientProcessId function returns the PID of the process that opened the pipe, not the one that is currently communicating. However, the client PID can sometimes be specified manually, and even when it can't, handle duplication followed by PID recycling can make this PID point to an arbitrary process (hence it should not be used for security checks).