Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ValidateNativeBuffers()

void System.Net.WebSockets.WebSocketBuffer.ValidateNativeBuffers ( WebSocketProtocolComponent::Action action,
WebSocketProtocolComponent::BufferType bufferType,
global::Interop::WebSocket::Buffer[] dataBuffers,
uint dataBufferCount )
inlinepackage

Definition at line 292 of file WebSocketBuffer.cs.

293 {
295 if (dataBufferCount > dataBuffers.Length)
296 {
297 throw new AccessViolationException();
298 }
299 int num = dataBuffers.Length;
300 bool flag = action == WebSocketProtocolComponent.Action.IndicateSendComplete || action == WebSocketProtocolComponent.Action.SendToNetwork;
301 if (flag)
302 {
303 num = (int)dataBufferCount;
304 }
305 bool flag2 = false;
306 for (int i = 0; i < num; i++)
307 {
308 global::Interop.WebSocket.Buffer buffer = dataBuffers[i];
309 UnwrapWebSocketBuffer(buffer, bufferType, out var bufferData, out var bufferLength);
310 if (!(bufferData == IntPtr.Zero))
311 {
312 flag2 = true;
313 bool flag3 = IsPinnedSendPayloadBuffer(buffer, bufferType);
314 if (bufferLength > GetMaxBufferSize() && (!flag || !flag3))
315 {
316 throw new AccessViolationException();
317 }
318 if (!flag3 && !IsNativeBuffer(bufferData, bufferLength))
319 {
320 throw new AccessViolationException();
321 }
322 }
323 }
324 if (!flag2 && action != 0 && action != WebSocketProtocolComponent.Action.IndicateReceiveComplete)
325 {
326 _ = 2;
327 }
328 }
bool IsPinnedSendPayloadBuffer(byte[] buffer, int offset, int count)
static void UnwrapWebSocketBuffer(global::Interop.WebSocket.Buffer buffer, WebSocketProtocolComponent.BufferType bufferType, out IntPtr bufferData, out uint bufferLength)
bool IsNativeBuffer(IntPtr pBuffer, uint bufferSize)

References System.action, System.buffer, System.Net.WebSockets.WebSocketBuffer.GetMaxBufferSize(), System.Net.WebSockets.WebSocketBuffer.IsNativeBuffer(), System.Net.WebSockets.WebSocketBuffer.IsPinnedSendPayloadBuffer(), System.Net.WebSockets.WebSocketBuffer.ThrowIfDisposed(), System.Net.WebSockets.WebSocketBuffer.UnwrapWebSocketBuffer(), and System.IntPtr.Zero.

Referenced by System.Net.WebSockets.WebSocketBase.ValidateNativeBuffers().