Reputation: 627
Using Win32 C++ API, I would like to known which IPC method, allows any end-point in a multi-process communication, to get the PID or HANDLE of the process which it is communicating with. In other words, if process A gets a message from process B:
The purpose of the communication is a simple remote procedure call. However, I don't want processes on remote systems/hosts calling the procedures offered by process running on the local host.
Of course I have found the RPC documentation on MSDN. However, I'm wondering if there are better ways than RPC of achieving what I want. Or, if you think RPC is the way to go, can you please tell me why and if you know of any other good references to learn from other than MSDN?
Upvotes: 1
Views: 2035
Reputation: 7620
If you implement your own RPC with Named Pipes, you will be able to use GetNamedPipeClientProcessId from the server process, to get the PID of the local end point client process.
EDIT: If you really are after security, First Rule is "you shalt not write your own system".
Upvotes: 1
Reputation: 3684
If you want to restrict the RPC to the local computer only, then you should bind your RPC system to "127.0.0.1". Then only local processes can communication with this port!
Upvotes: 3
Reputation: 50026
I'am not familiar with all the methods,
for WM_COPYDATA
method you have :
wParam
A handle to the window passing the data.
so you can use GetWindowThreadProcessID
on it, but WM_COPYDATA is for use on single PC
http://msdn.microsoft.com/en-us/library/windows/desktop/ms649011%28v=vs.85%29.aspx
To identify who has opened given handle you would have to use some low level tricks, like handle.exe program from SysInternals does (http://forum.sysinternals.com/topic18892.html).
Upvotes: 1