Use Pipes for IPC (Inter Process Communications)
A pipe is a data communication conduit for connected 2 processes.
Like a pip stuff can go in one end, and come out the other.
There are 2 types of pipes
- Named Pipes - Very flexible and can connect processes across a network.
- Anonymous Pipes - Simpler and for local machine only.
- A pipe server connects one or more pipe client. One or two way communications.
- Pipe server - a process that creates a named pipe.
- Pipe client - a process that connects to an instance of a
- For Local PC - deny access to NT AUTHORITY\NETWORK or switch to local RPC.
- Server app names a pipe using
CreateNamedPipe to create one or more instances of a named pipe.
- Using access mode: PIPE_ACCESS_INBOUND or PIPE_ACCESS_OUTBOUND or PIPE_ACCESS_DUPLEX
- Pipe clients specify the pipe name when they call the
CallNamedPipe function to connect to an instance of the named pipe.
- Using Equivalent generic access right - GENERIC_WRITE or GENERIC_READ or GENERIC_READ | GENERIC_WRITE
CallNamedPipe function requires a pipename
- in the form \\ServerName\pipe\PipeName
- or for local PC only use a . for the server name - \\.\pipe\PipeName
- Pipe attributes
- FILE_READ_ATTRIBUTES - allows clients to read access right
- FILE_WRITE_ATTRIBUTES - allows you to change attributes.
- A pipe server often passes the pipe name to its pipe clients so they
can connect to the pipe. Otherwise, the clients must know the pipe name
at compile time.
- Overlapped mode allows messages to be sent simultaneously
- The CreateFile function allows the pipe client to set overlapped mode (FILE_FLAG_OVERLAPPED) .