MalwareSourceCode/MSIL/Trojan-Ransom/Win32/G/Trojan-Ransom.Win32.Gimemo.ayt-7cb020d260d835f80919399a58563918f73757689e39ba851e89cc00a05535da/Compression/RangeCoder/BitDecoder.cs

52 lines
1.6 KiB
C#
Raw Normal View History

2022-08-18 11:28:56 +00:00
// Decompiled with JetBrains decompiler
// Type: SevenZip.Compression.RangeCoder.BitDecoder
// Assembly: crypted, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 316F25AB-9DC5-41B1-B1CB-0BB9D97AEA6A
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\Trojan-Ransom.Win32.Gimemo.ayt-7cb020d260d835f80919399a58563918f73757689e39ba851e89cc00a05535da.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;
}
}
}