Remote Call Framework 3.2
Win32NamedPipeServerTransport.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2020, Delta V Software. All rights reserved.
6 // http://www.deltavsoft.com
7 //
8 // RCF is distributed under dual licenses - closed source or GPL.
9 // Consult your particular license for conditions of use.
10 //
11 // If you have not purchased a commercial license, you are using RCF
12 // under GPL terms.
13 //
14 // Version: 3.2
15 // Contact: support <at> deltavsoft.com
16 //
17 //******************************************************************************
18 
19 #ifndef INCLUDE_RCF_WIN32NAMEDPIPESERVERTRANSPORT_HPP
20 #define INCLUDE_RCF_WIN32NAMEDPIPESERVERTRANSPORT_HPP
21 
22 #include <RCF/AsioFwd.hpp>
23 #include <RCF/AsioServerTransport.hpp>
24 #include <RCF/Export.hpp>
25 #include <RCF/Tchar.hpp>
26 
27 namespace RCF {
28 
29  class Win32NamedPipeServerTransport;
30 
31  // Win32NamedPipeNetworkSession
32 
33  class RCF_EXPORT Win32NamedPipeNetworkSession : public AsioNetworkSession
34  {
35  public:
36  Win32NamedPipeNetworkSession(
37  Win32NamedPipeServerTransport & transport,
38  AsioIoService & ioService);
39 
40  ~Win32NamedPipeNetworkSession();
41 
42  const RemoteAddress & implGetRemoteAddress();
43 
44  void implRead(char * buffer, std::size_t bufferLen);
45 
46  void implWrite(const std::vector<ByteBuffer> & buffers);
47 
48  void implWrite(AsioNetworkSession &toBeNotified, const char * buffer, std::size_t bufferLen);
49 
50  void implAccept();
51 
52  bool implOnAccept();
53 
54  bool implIsConnected();
55 
56  void implClose();
57 
58  ClientTransportUniquePtr implCreateClientTransport();
59 
60  void implTransferNativeFrom(ClientTransport & clientTransport);
61 
62  static void closeSocket(AsioPipeHandlePtr socketPtr);
63 
64  HANDLE getNativeHandle();
65 
66  private:
67  AsioPipeHandlePtr mSocketPtr;
68  tstring mRemotePipeName;
69  NoRemoteAddress mRemoteAddress;
70 
71  friend class Win32NamedPipeServerTransport;
72  friend class Win32NamedPipeImpersonator;
73  };
74 
75  class RCF_EXPORT Win32NamedPipeServerTransport :
76  public AsioServerTransport
77  {
78  public:
79 
80  Win32NamedPipeServerTransport(const tstring & pipeName);
81  ~Win32NamedPipeServerTransport();
82 
83  TransportType getTransportType();
84 
85  ServerTransportPtr clone();
86 
87  AsioNetworkSessionPtr implCreateNetworkSession();
88  void implOpen();
89  ClientTransportUniquePtr implCreateClientTransport(
90  const Endpoint &endpoint);
91 
92  tstring getPipeName() const;
93 
94  void onServerStart(RcfServer & server);
95  void onServerStop(RcfServer & server);
96 
97  void setSecurityAttributes(LPSECURITY_ATTRIBUTES pSec);
98 
99  private:
100 
101  friend class Win32NamedPipeNetworkSession;
102 
103  tstring mPipeName;
104  HANDLE mPipeNameLock;
105 
106  LPSECURITY_ATTRIBUTES mpSec;
107  };
108 
110  class RCF_EXPORT Win32NamedPipeImpersonator
111  {
112  public:
115 
116  Win32NamedPipeImpersonator(Win32NamedPipeNetworkSession & pipeSession);
117 
120 
121  void impersonate();
122 
124  void revertToSelf() const;
125 
126  private:
127 
128  Win32NamedPipeNetworkSession & mPipeSession;
129  };
130 
131  class RCF_EXPORT NullDacl
132  {
133  public:
134  NullDacl();
135  SECURITY_ATTRIBUTES mSa;
136  SECURITY_DESCRIPTOR mSd;
137  };
138 
139 } // namespace RCF
140 
141 #endif // ! INCLUDE_RCF_WIN32NAMEDPIPESERVERTRANSPORT_HPP
Allows the server side of a Win32 named pipe to impersonate the client.
Definition: Win32NamedPipeServerTransport.hpp:110
Represents a server side session, associated with a client connection.
Definition: RcfSession.hpp:65
std::unique_ptr< ClientTransport > ClientTransportUniquePtr
Unique pointer wrapper for RCF::ClientTransport.
Definition: RcfFwd.hpp:44
Definition: AmiIoHandler.hpp:24
TransportType
Describes the transport types used by a RCF connection.
Definition: Enums.hpp:34
std::shared_ptr< ServerTransport > ServerTransportPtr
Unique pointer wrapper for RCF::ServerTransport.
Definition: RcfFwd.hpp:47