Files
niko c12fbe3fc6 m
2026-04-12 16:51:38 +02:00

267 lines
10 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using BestHTTP.Extensions;
using BestHTTP.WebSocket.Extensions;
using Cpp2IlInjected;
namespace BestHTTP.WebSocket.Frames
{
// Token: 0x020019AE RID: 6574
[Token(Token = "0x20019AE")]
public struct WebSocketFrameReader
{
// Token: 0x1700185C RID: 6236
// (get) Token: 0x06009925 RID: 39205 RVA: 0x0000220F File Offset: 0x0000040F
// (set) Token: 0x06009926 RID: 39206 RVA: 0x001F4D18 File Offset: 0x001F2F18
[Token(Token = "0x1700185C")]
public byte Header
{
[Token(Token = "0x6009925")]
[Address(RVA = "0x634740", Offset = "0x633740", VA = "0x180634740")]
[CompilerGenerated]
get
{
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
}
[Token(Token = "0x6009926")]
[Address(RVA = "0x634790", Offset = "0x633790", VA = "0x180634790")]
[CompilerGenerated]
private set
{
this.<Header>k__BackingField = value;
}
}
// Token: 0x1700185D RID: 6237
// (get) Token: 0x06009927 RID: 39207 RVA: 0x001F4D2C File Offset: 0x001F2F2C
// (set) Token: 0x06009928 RID: 39208 RVA: 0x001F4D40 File Offset: 0x001F2F40
[Token(Token = "0x1700185D")]
public bool IsFinal
{
[Token(Token = "0x6009927")]
[Address(RVA = "0x634750", Offset = "0x633750", VA = "0x180634750")]
get;
[Token(Token = "0x6009928")]
[Address(RVA = "0x6347A0", Offset = "0x6337A0", VA = "0x1806347A0")]
private set;
}
// Token: 0x1700185E RID: 6238
// (get) Token: 0x06009929 RID: 39209 RVA: 0x001F4D54 File Offset: 0x001F2F54
// (set) Token: 0x0600992A RID: 39210 RVA: 0x001F4D68 File Offset: 0x001F2F68
[Token(Token = "0x1700185E")]
public WebSocketFrameTypes Type
{
[Token(Token = "0x6009929")]
[Address(RVA = "0x634770", Offset = "0x633770", VA = "0x180634770")]
get;
[Token(Token = "0x600992A")]
[Address(RVA = "0x6347C0", Offset = "0x6337C0", VA = "0x1806347C0")]
private set;
}
// Token: 0x1700185F RID: 6239
// (get) Token: 0x0600992B RID: 39211 RVA: 0x001F4D7C File Offset: 0x001F2F7C
// (set) Token: 0x0600992C RID: 39212 RVA: 0x001F4D90 File Offset: 0x001F2F90
[Token(Token = "0x1700185F")]
public bool HasMask
{
[Token(Token = "0x600992B")]
[Address(RVA = "0x634730", Offset = "0x633730", VA = "0x180634730")]
get;
[Token(Token = "0x600992C")]
[Address(RVA = "0x634780", Offset = "0x633780", VA = "0x180634780")]
private set;
}
// Token: 0x17001860 RID: 6240
// (get) Token: 0x0600992D RID: 39213 RVA: 0x001F4DA4 File Offset: 0x001F2FA4
// (set) Token: 0x0600992E RID: 39214 RVA: 0x001F4DB8 File Offset: 0x001F2FB8
[Token(Token = "0x17001860")]
public ulong Length
{
[Token(Token = "0x600992D")]
[Address(RVA = "0x634760", Offset = "0x633760", VA = "0x180634760")]
get;
[Token(Token = "0x600992E")]
[Address(RVA = "0x6347B0", Offset = "0x6337B0", VA = "0x1806347B0")]
private set;
}
// Token: 0x17001861 RID: 6241
// (get) Token: 0x0600992F RID: 39215 RVA: 0x001F4DCC File Offset: 0x001F2FCC
// (set) Token: 0x06009930 RID: 39216 RVA: 0x001F4DE0 File Offset: 0x001F2FE0
[Token(Token = "0x17001861")]
public byte[] Data
{
[Token(Token = "0x600992F")]
[Address(RVA = "0x411530", Offset = "0x410530", VA = "0x180411530")]
get;
[Token(Token = "0x6009930")]
[Address(RVA = "0x415800", Offset = "0x414800", VA = "0x180415800")]
private set;
}
// Token: 0x17001862 RID: 6242
// (get) Token: 0x06009931 RID: 39217 RVA: 0x001F4DF4 File Offset: 0x001F2FF4
// (set) Token: 0x06009932 RID: 39218 RVA: 0x001F4E08 File Offset: 0x001F3008
[Token(Token = "0x17001862")]
public string DataAsText
{
[Token(Token = "0x6009931")]
[Address(RVA = "0x4157B0", Offset = "0x4147B0", VA = "0x1804157B0")]
get;
[Token(Token = "0x6009932")]
[Address(RVA = "0x4157F0", Offset = "0x4147F0", VA = "0x1804157F0")]
private set;
}
// Token: 0x06009933 RID: 39219 RVA: 0x001F4E1C File Offset: 0x001F301C
[Token(Token = "0x6009933")]
[Address(RVA = "0x6341E0", Offset = "0x6331E0", VA = "0x1806341E0")]
internal void Read(Stream stream)
{
int num;
this.<Header>k__BackingField = (byte)num;
this.<IsFinal>k__BackingField = stream != null;
this.<Type>k__BackingField = (WebSocketFrameTypes)num;
this.<HasMask>k__BackingField = stream != null;
int num2;
this.<Length>k__BackingField = (ulong)num2;
if (num2 != 126)
{
if (num2 != 127)
{
goto IL_81;
}
byte[] array;
stream.ReadBuffer(array, 8);
int num3 = 0;
Array.Reverse(array, num3, 8);
int num4 = 0;
ulong num5 = BitConverter.ToUInt64(array, num4);
}
byte[] array2;
stream.ReadBuffer(array2, 2);
int num6 = 0;
Array.Reverse(array2, num6, 2);
int num7 = 0;
ushort num8 = BitConverter.ToUInt16(array2, num7);
this.<Length>k__BackingField = (ulong)num8;
VariableSizedBufferPool.Release(array2);
IL_81:
int num9 = 0;
if ((this.<HasMask>k__BackingField ? 1 : 0) != num9)
{
}
ulong num10 = this.<Length>k__BackingField;
if (num10 != (ulong)0L)
{
ulong num11;
if (num10 > num11)
{
throw new OverflowException();
}
byte[] array3 = new byte[num10];
}
ulong num12;
byte[] array4 = VariableSizedBufferPool.Get((long)this.<Length>k__BackingField, num12 != 0UL);
this.<Data>k__BackingField = array4;
ulong num13 = this.<Length>k__BackingField;
if (num13 != (ulong)0L)
{
num13 -= (ulong)num9;
ulong num14 = this.<Length>k__BackingField;
if ((this.<HasMask>k__BackingField ? 1 : 0) != num9)
{
if (num14 != (ulong)0L)
{
byte[] array5 = this.<Data>k__BackingField;
num9++;
}
byte[] array6;
VariableSizedBufferPool.Release(array6);
}
}
}
// Token: 0x06009934 RID: 39220 RVA: 0x001F4F3C File Offset: 0x001F313C
[Token(Token = "0x6009934")]
[Address(RVA = "0x634170", Offset = "0x633170", VA = "0x180634170")]
private byte ReadByte(Stream stream)
{
/*
An exception occurred when decompiling this method (06009934)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Byte BestHTTP.WebSocket.Frames.WebSocketFrameReader::ReadByte(System.IO.Stream)
---> System.Exception: Basic block has to end with unconditional control flow.
{
Block_0:
stloc:Exception(var_2_07, call:Exception(ExceptionHelper::ServerClosedTCPStream))
}
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1852
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.Optimize(DecompilerContext context, ILBlock method, AutoPropertyProvider autoPropertyProvider, StateMachineKind& stateMachineKind, MethodDef& inlinedMethod, AsyncMethodDebugInfo& asyncInfo, ILAstOptimizationStep abortBeforeStep) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 355
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(IEnumerable`1 parameters, MethodDebugInfoBuilder& builder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 123
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 88
--- End of inner exception stack trace ---
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 92
at ICSharpCode.Decompiler.Ast.AstBuilder.AddMethodBody(EntityDeclaration methodNode, EntityDeclaration& updatedNode, MethodDef method, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, MethodKind methodKind) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstBuilder.cs:line 1663
*/;
}
// Token: 0x06009935 RID: 39221 RVA: 0x0000220F File Offset: 0x0000040F
[Token(Token = "0x6009935")]
[Address(RVA = "0x633D00", Offset = "0x632D00", VA = "0x180633D00")]
public void Assemble(List<WebSocketFrameReader> fragments)
{
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
}
// Token: 0x06009936 RID: 39222 RVA: 0x001F4F50 File Offset: 0x001F3150
[Token(Token = "0x6009936")]
[Address(RVA = "0x633FC0", Offset = "0x632FC0", VA = "0x180633FC0")]
public void DecodeWithExtensions(WebSocket webSocket)
{
if (webSocket.<Extensions>k__BackingField != (ulong)0L)
{
int num = 0;
int num2 = 0;
IExtension[] <Extensions>k__BackingField = webSocket.<Extensions>k__BackingField;
int length = <Extensions>k__BackingField.Length;
if (num2 < length)
{
if (<Extensions>k__BackingField[num] != 0)
{
ulong num3 = this.<Length>k__BackingField;
byte[] array = this.<Data>k__BackingField;
byte[] array2 = this.<Data>k__BackingField;
if (array2 != array)
{
VariableSizedBufferPool.Release(array2);
this.<Data>k__BackingField = array;
int length2 = array.Length;
this.<Length>k__BackingField = (ulong)length2;
}
}
num++;
}
}
if (this.<Data>k__BackingField != (ulong)0L)
{
Encoding utf = Encoding.UTF8;
byte[] array3 = this.<Data>k__BackingField;
string @string = utf.GetString(array3);
byte[] array4 = this.<Data>k__BackingField;
this.<DataAsText>k__BackingField = @string;
VariableSizedBufferPool.Release(array4);
this.<Data>k__BackingField = (ulong)0L;
}
}
}
}