Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
AnonymousPipeServerStream.cs
Go to the documentation of this file.
3
4namespace System.IO.Pipes;
5
7{
9
11
13 {
14 get
15 {
17 return _clientHandle;
18 }
19 }
20
22
24 {
25 set
26 {
28 switch (value)
29 {
30 default:
32 case PipeTransmissionMode.Message:
34 case PipeTransmissionMode.Byte:
35 break;
36 }
37 }
38 }
39
44
46 : this(direction, HandleInheritability.None, 0)
47 {
48 }
49
51 : this(direction, inheritability, 0)
52 {
53 }
54
55 public AnonymousPipeServerStream(PipeDirection direction, SafePipeHandle serverSafePipeHandle, SafePipeHandle clientSafePipeHandle)
56 : base(direction, 0)
57 {
58 if (direction == PipeDirection.InOut)
59 {
61 }
62 if (serverSafePipeHandle == null)
63 {
64 throw new ArgumentNullException("serverSafePipeHandle");
65 }
66 if (clientSafePipeHandle == null)
67 {
68 throw new ArgumentNullException("clientSafePipeHandle");
69 }
70 if (serverSafePipeHandle.IsInvalid)
71 {
72 throw new ArgumentException(System.SR.Argument_InvalidHandle, "serverSafePipeHandle");
73 }
74 if (clientSafePipeHandle.IsInvalid)
75 {
76 throw new ArgumentException(System.SR.Argument_InvalidHandle, "clientSafePipeHandle");
77 }
78 ValidateHandleIsPipe(serverSafePipeHandle);
79 ValidateHandleIsPipe(clientSafePipeHandle);
80 InitializeHandle(serverSafePipeHandle, isExposed: true, isAsync: false);
81 _clientHandle = clientSafePipeHandle;
83 base.State = PipeState.Connected;
84 }
85
86 public AnonymousPipeServerStream(PipeDirection direction, HandleInheritability inheritability, int bufferSize)
87 : base(direction, bufferSize)
88 {
89 if (direction == PipeDirection.InOut)
90 {
92 }
93 if (inheritability < HandleInheritability.None || inheritability > HandleInheritability.Inheritable)
94 {
96 }
97 Create(direction, inheritability, bufferSize);
98 }
99
101 {
102 Dispose(disposing: false);
103 }
104
111
113 {
114 if (_clientHandle != null && !_clientHandle.IsClosed)
115 {
117 }
118 }
119
120 protected override void Dispose(bool disposing)
121 {
122 try
123 {
125 {
127 }
128 }
129 finally
130 {
131 base.Dispose(disposing);
132 }
133 }
134
135 internal AnonymousPipeServerStream(PipeDirection direction, HandleInheritability inheritability, int bufferSize, PipeSecurity pipeSecurity)
136 : base(direction, bufferSize)
137 {
138 if (direction == PipeDirection.InOut)
139 {
141 }
142 if (inheritability < HandleInheritability.None || inheritability > HandleInheritability.Inheritable)
143 {
145 }
146 Create(direction, inheritability, bufferSize, pipeSecurity);
147 }
148
149 private void Create(PipeDirection direction, HandleInheritability inheritability, int bufferSize)
150 {
151 Create(direction, inheritability, bufferSize, null);
152 }
153
154 private void Create(PipeDirection direction, HandleInheritability inheritability, int bufferSize, PipeSecurity pipeSecurity)
155 {
156 GCHandle pinningHandle = default(GCHandle);
157 bool flag;
158 SafePipeHandle hWritePipe;
159 try
160 {
161 global::Interop.Kernel32.SECURITY_ATTRIBUTES lpPipeAttributes = PipeStream.GetSecAttrs(inheritability, pipeSecurity, ref pinningHandle);
162 flag = ((direction != PipeDirection.In) ? global::Interop.Kernel32.CreatePipe(out _clientHandle, out hWritePipe, ref lpPipeAttributes, bufferSize) : global::Interop.Kernel32.CreatePipe(out hWritePipe, out _clientHandle, ref lpPipeAttributes, bufferSize));
163 }
164 finally
165 {
166 if (pinningHandle.IsAllocated)
167 {
168 pinningHandle.Free();
169 }
170 }
171 if (!flag)
172 {
174 }
175 if (!global::Interop.Kernel32.DuplicateHandle(global::Interop.Kernel32.GetCurrentProcess(), hWritePipe, global::Interop.Kernel32.GetCurrentProcess(), out var lpTargetHandle, 0u, bInheritHandle: false, 2u))
176 {
178 }
179 hWritePipe.Dispose();
180 InitializeHandle(lpTargetHandle, isExposed: false, isAsync: false);
181 base.State = PipeState.Connected;
182 }
183}
static void SuppressFinalize(object obj)
Definition GC.cs:202
Definition GC.cs:8
AnonymousPipeServerStream(PipeDirection direction, HandleInheritability inheritability)
AnonymousPipeServerStream(PipeDirection direction, HandleInheritability inheritability, int bufferSize, PipeSecurity pipeSecurity)
AnonymousPipeServerStream(PipeDirection direction, HandleInheritability inheritability, int bufferSize)
AnonymousPipeServerStream(PipeDirection direction, SafePipeHandle serverSafePipeHandle, SafePipeHandle clientSafePipeHandle)
void Create(PipeDirection direction, HandleInheritability inheritability, int bufferSize)
void Create(PipeDirection direction, HandleInheritability inheritability, int bufferSize, PipeSecurity pipeSecurity)
void ValidateHandleIsPipe(SafePipeHandle safePipeHandle)
virtual void CheckPipePropertyOperations()
void InitializeHandle(SafePipeHandle? handle, bool isExposed, bool isAsync)
static unsafe global::Interop.Kernel32.SECURITY_ATTRIBUTES GetSecAttrs(HandleInheritability inheritability)
void Dispose()
Definition Stream.cs:639
static Exception GetExceptionForLastWin32Error(string path="")
static string NotSupported_AnonymousPipeMessagesNotSupported
Definition SR.cs:92
static string ArgumentOutOfRange_HandleInheritabilityNoneOrInheritable
Definition SR.cs:38
static string ArgumentOutOfRange_TransmissionModeByteOrMsg
Definition SR.cs:30
static string Argument_InvalidHandle
Definition SR.cs:24
static string NotSupported_AnonymousPipeUnidirectional
Definition SR.cs:90
Definition SR.cs:7
unsafe override string ToString()
Definition IntPtr.cs:247