MalwareSourceCode/MSIL/Trojan-Ransom/Win32/G/Trojan-Ransom.Win32.Gimemo.ayt-624a52079bf1703bcd3bcc9d2d3716b6126fd05655e25289d19142f9aae02eb5/Compression/RangeCoder/BitDecoder.cs
2022-08-18 06:28:56 -05:00

52 lines
1.6 KiB
C#

// Decompiled with JetBrains decompiler
// Type: SevenZip.Compression.RangeCoder.BitDecoder
// Assembly: P4CTEMP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 7BE4E538-8555-4C2E-974B-99E556F5462C
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\Trojan-Ransom.Win32.Gimemo.ayt-624a52079bf1703bcd3bcc9d2d3716b6126fd05655e25289d19142f9aae02eb5.exe
namespace SevenZip.Compression.RangeCoder
{
internal struct BitDecoder
{
public const int kNumBitModelTotalBits = 11;
public const uint kBitModelTotal = 2048;
private const int kNumMoveBits = 5;
private uint Prob;
public void UpdateModel(int numMoveBits, uint symbol)
{
if (symbol == 0U)
this.Prob += 2048U - this.Prob >> numMoveBits;
else
this.Prob -= this.Prob >> numMoveBits;
}
public void Init() => this.Prob = 1024U;
public uint Decode(Decoder rangeDecoder)
{
uint num = (rangeDecoder.Range >> 11) * this.Prob;
if (rangeDecoder.Code < num)
{
rangeDecoder.Range = num;
this.Prob += 2048U - this.Prob >> 5;
if (rangeDecoder.Range < 16777216U)
{
rangeDecoder.Code = rangeDecoder.Code << 8 | (uint) (byte) rangeDecoder.Stream.ReadByte();
rangeDecoder.Range <<= 8;
}
return 0;
}
rangeDecoder.Range -= num;
rangeDecoder.Code -= num;
this.Prob -= this.Prob >> 5;
if (rangeDecoder.Range < 16777216U)
{
rangeDecoder.Code = rangeDecoder.Code << 8 | (uint) (byte) rangeDecoder.Stream.ReadByte();
rangeDecoder.Range <<= 8;
}
return 1;
}
}
}