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