Files
27Aug2021-Cpp2IL-Dump/Assembly-CSharp/BestHTTP/Decompression/Zlib/InflateBlocks.cs
T
niko c12fbe3fc6 m
2026-04-12 16:51:38 +02:00

353 lines
13 KiB
C#

using System;
using System.Runtime.CompilerServices;
using BestHTTP.Extensions;
using Cpp2IlInjected;
namespace BestHTTP.Decompression.Zlib
{
// Token: 0x02002088 RID: 8328
[Token(Token = "0x2002088")]
internal sealed class InflateBlocks
{
// Token: 0x0600D160 RID: 53600 RVA: 0x002FAD80 File Offset: 0x002F8F80
[Token(Token = "0x600D160")]
[Address(RVA = "0x24193C0", Offset = "0x24183C0", VA = "0x1824193C0")]
internal InflateBlocks(ZlibCodec codec, object checkfn, int w)
{
int[] array = new int[1];
this.bb = array;
int[] array2 = new int[1];
this.tb = array2;
InflateCodes inflateCodes = new InflateCodes();
this.codes = inflateCodes;
InfTree infTree = new InfTree();
this.inftree = infTree;
base..ctor();
this._codec = codec;
int[] array3 = new int[4320];
this.hufts = array3;
byte[] array4 = VariableSizedBufferPool.Get((long)w, true);
this.window = array4;
this.end = w;
this.checkfn = checkfn;
this.mode = (InflateBlocks.InflateBlockMode)((ulong)0L);
uint num = this.Reset();
}
// Token: 0x0600D161 RID: 53601 RVA: 0x002FAE14 File Offset: 0x002F9014
[Token(Token = "0x600D161")]
[Address(RVA = "0x2419250", Offset = "0x2418250", VA = "0x182419250")]
internal uint Reset()
{
uint num = this.check;
int num2 = 0;
this.mode = (InflateBlocks.InflateBlockMode)num2;
this.bitk = num2;
this.readAt = num2;
if (this.checkfn != num2)
{
ZlibCodec codec = this._codec;
this.check = (uint)((ulong)1L);
codec._Adler32 = (uint)((ulong)1L);
}
return num;
}
// Token: 0x0600D162 RID: 53602 RVA: 0x002FAE68 File Offset: 0x002F9068
[Token(Token = "0x600D162")]
[Address(RVA = "0x2417BD0", Offset = "0x2416BD0", VA = "0x182417BD0")]
internal int Process(int r)
{
/*
An exception occurred when decompiling this method (0600D162)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Int32 BestHTTP.Decompression.Zlib.InflateBlocks::Process(System.Int32)
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_B98:
stloc:ZlibCodec(var_179_B9E, ldfld:ZlibCodec(InflateBlocks::_codec, ldloc:InflateBlocks(this)))
stfld:int32(InflateBlocks::bitb, ldloc:InflateBlocks(this), ldc.i4:int32(0))
stfld:int32(InflateBlocks::bitk, ldloc:InflateBlocks(this), ldc.i4:int32(0))
stfld:int32(ZlibCodec::AvailableBytesIn, ldloc:ZlibCodec(var_179_B9E), ldc.i4:int32(0))
}
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: 0x0600D163 RID: 53603 RVA: 0x002FBA2C File Offset: 0x002F9C2C
[Token(Token = "0x600D163")]
[Address(RVA = "0x2417B50", Offset = "0x2416B50", VA = "0x182417B50")]
internal void Free()
{
uint num = this.Reset();
VariableSizedBufferPool.Release(this.window);
int num2 = 0;
this.window = num2;
this.hufts = num2;
}
// Token: 0x0600D164 RID: 53604 RVA: 0x002FBA5C File Offset: 0x002F9C5C
[Token(Token = "0x600D164")]
[Address(RVA = "0x2419310", Offset = "0x2418310", VA = "0x182419310")]
internal void SetDictionary(byte[] d, int start, int n)
{
byte[] array = this.window;
int num = 0;
Array.Copy(d, start, array, num, n);
this.writeAt = n;
this.readAt = n;
}
// Token: 0x0600D165 RID: 53605 RVA: 0x002FBA8C File Offset: 0x002F9C8C
[Token(Token = "0x600D165")]
[Address(RVA = "0x4EAF20", Offset = "0x4E9F20", VA = "0x1804EAF20")]
internal int SyncPoint()
{
/*
An exception occurred when decompiling this method (0600D165)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Int32 BestHTTP.Decompression.Zlib.InflateBlocks::SyncPoint()
---> System.Exception: Basic block has to end with unconditional control flow.
{
Block_0:
stloc:bool(var_0_09, ceq:bool(ldfld:InflateBlockMode(InflateBlocks::mode, ldloc:InflateBlocks(this)), ldc.i4:InflateBlockMode(1)))
}
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: 0x0600D166 RID: 53606 RVA: 0x002FBAA4 File Offset: 0x002F9CA4
[Token(Token = "0x600D166")]
[Address(RVA = "0x24179A0", Offset = "0x24169A0", VA = "0x1824179A0")]
internal int Flush(int r)
{
int num = this.readAt;
int num2 = 0;
int num3 = this.writeAt;
if (num2 != 0 || num > num3)
{
}
num3 -= num;
if (num3 != 0)
{
ZlibCodec codec = this._codec;
int num4 = codec.AvailableBytesOut;
if (num3 > num4)
{
num3 = num4;
}
if (num3 != 0)
{
}
num4 -= num3;
codec.AvailableBytesOut = num4;
ZlibCodec codec2 = this._codec;
if (this.checkfn != num2)
{
int num5 = this.readAt;
ZlibCodec codec3 = this._codec;
uint num6 = this.check;
byte[] array = this.window;
uint num7 = Adler.Adler32(num6, array, num5, num3);
this.check = num7;
codec3._Adler32 = num7;
}
ZlibCodec codec4 = this._codec;
int nextOut = codec4.NextOut;
byte[] outputBuffer = codec4.OutputBuffer;
int num8 = this.readAt;
Array.Copy(this.window, num8, outputBuffer, nextOut, num3);
ZlibCodec codec5 = this._codec;
int num9 = this.readAt;
int num10 = this.end;
num9 += num3;
this.readAt = num9;
if (num9 == num10 && num2 == 0)
{
this.readAt = num2;
if (this.writeAt != num10)
{
goto IL_11C;
}
this.writeAt = num2;
}
num2++;
IL_11C:
num2++;
}
return num2;
}
// Token: 0x0600D167 RID: 53607 RVA: 0x002FBBD8 File Offset: 0x002F9DD8
// Note: this type is marked as 'beforefieldinit'.
[Token(Token = "0x600D167")]
[Address(RVA = "0x2419360", Offset = "0x2418360", VA = "0x182419360")]
static InflateBlocks()
{
int[] array = new int[19];
RuntimeHelpers.InitializeArray(array, fieldof(<PrivateImplementationDetails>.1FDC8DB567F5AAA7068D0D2A601CD71657CBDF38).FieldHandle);
InflateBlocks.border = array;
}
// Token: 0x040084C5 RID: 33989
[Token(Token = "0x40084C5")]
private const int MANY = 1440;
// Token: 0x040084C6 RID: 33990
[Token(Token = "0x40084C6")]
internal static readonly int[] border;
// Token: 0x040084C7 RID: 33991
[FieldOffset(Offset = "0x10")]
[Token(Token = "0x40084C7")]
private InflateBlocks.InflateBlockMode mode;
// Token: 0x040084C8 RID: 33992
[FieldOffset(Offset = "0x14")]
[Token(Token = "0x40084C8")]
internal int left;
// Token: 0x040084C9 RID: 33993
[FieldOffset(Offset = "0x18")]
[Token(Token = "0x40084C9")]
internal int table;
// Token: 0x040084CA RID: 33994
[FieldOffset(Offset = "0x1C")]
[Token(Token = "0x40084CA")]
internal int index;
// Token: 0x040084CB RID: 33995
[FieldOffset(Offset = "0x20")]
[Token(Token = "0x40084CB")]
internal int[] blens;
// Token: 0x040084CC RID: 33996
[FieldOffset(Offset = "0x28")]
[Token(Token = "0x40084CC")]
internal int[] bb;
// Token: 0x040084CD RID: 33997
[FieldOffset(Offset = "0x30")]
[Token(Token = "0x40084CD")]
internal int[] tb;
// Token: 0x040084CE RID: 33998
[FieldOffset(Offset = "0x38")]
[Token(Token = "0x40084CE")]
internal InflateCodes codes;
// Token: 0x040084CF RID: 33999
[FieldOffset(Offset = "0x40")]
[Token(Token = "0x40084CF")]
internal int last;
// Token: 0x040084D0 RID: 34000
[FieldOffset(Offset = "0x48")]
[Token(Token = "0x40084D0")]
internal ZlibCodec _codec;
// Token: 0x040084D1 RID: 34001
[FieldOffset(Offset = "0x50")]
[Token(Token = "0x40084D1")]
internal int bitk;
// Token: 0x040084D2 RID: 34002
[FieldOffset(Offset = "0x54")]
[Token(Token = "0x40084D2")]
internal int bitb;
// Token: 0x040084D3 RID: 34003
[FieldOffset(Offset = "0x58")]
[Token(Token = "0x40084D3")]
internal int[] hufts;
// Token: 0x040084D4 RID: 34004
[FieldOffset(Offset = "0x60")]
[Token(Token = "0x40084D4")]
internal byte[] window;
// Token: 0x040084D5 RID: 34005
[FieldOffset(Offset = "0x68")]
[Token(Token = "0x40084D5")]
internal int end;
// Token: 0x040084D6 RID: 34006
[FieldOffset(Offset = "0x6C")]
[Token(Token = "0x40084D6")]
internal int readAt;
// Token: 0x040084D7 RID: 34007
[FieldOffset(Offset = "0x70")]
[Token(Token = "0x40084D7")]
internal int writeAt;
// Token: 0x040084D8 RID: 34008
[FieldOffset(Offset = "0x78")]
[Token(Token = "0x40084D8")]
internal object checkfn;
// Token: 0x040084D9 RID: 34009
[FieldOffset(Offset = "0x80")]
[Token(Token = "0x40084D9")]
internal uint check;
// Token: 0x040084DA RID: 34010
[FieldOffset(Offset = "0x88")]
[Token(Token = "0x40084DA")]
internal InfTree inftree;
// Token: 0x02002089 RID: 8329
[Token(Token = "0x2002089")]
private enum InflateBlockMode
{
// Token: 0x040084DC RID: 34012
[Token(Token = "0x40084DC")]
TYPE,
// Token: 0x040084DD RID: 34013
[Token(Token = "0x40084DD")]
LENS,
// Token: 0x040084DE RID: 34014
[Token(Token = "0x40084DE")]
STORED,
// Token: 0x040084DF RID: 34015
[Token(Token = "0x40084DF")]
TABLE,
// Token: 0x040084E0 RID: 34016
[Token(Token = "0x40084E0")]
BTREE,
// Token: 0x040084E1 RID: 34017
[Token(Token = "0x40084E1")]
DTREE,
// Token: 0x040084E2 RID: 34018
[Token(Token = "0x40084E2")]
CODES,
// Token: 0x040084E3 RID: 34019
[Token(Token = "0x40084E3")]
DRY,
// Token: 0x040084E4 RID: 34020
[Token(Token = "0x40084E4")]
DONE,
// Token: 0x040084E5 RID: 34021
[Token(Token = "0x40084E5")]
BAD
}
}
}