本文整理汇总了C#中ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Inflate方法的典型用法代码示例。如果您正苦于以下问题:C# Inflater.Inflate方法的具体用法?C# Inflater.Inflate怎么用?C# Inflater.Inflate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.SharpZipLib.Zip.Compression.Inflater
的用法示例。
在下文中一共展示了Inflater.Inflate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Inflate
protected override int Inflate(int pos, byte[] dstbuf, int dstoff, Inflater inf)
{
while (!inf.IsFinished)
{
if (inf.IsNeedingInput)
{
inf.SetInput(_array, pos, _array.Length - pos);
break;
}
dstoff += inf.Inflate(dstbuf, dstoff, dstbuf.Length - dstoff);
}
while (!inf.IsFinished && !inf.IsNeedingInput)
dstoff += inf.Inflate(dstbuf, dstoff, dstbuf.Length - dstoff);
return dstoff;
}
示例2: inflate
internal override int inflate(int pos, byte[] b, int o, Inflater inf)
{
while (!inf.IsFinished)
{
if (inf.IsNeedingInput)
{
inf.SetInput(array, pos, array.Length - pos);
break;
}
o += inf.Inflate(b, o, b.Length - o);
}
while (!inf.IsFinished && !inf.IsNeedingInput)
o += inf.Inflate(b, o, b.Length - o);
return o;
}
示例3: DecompressZLib
/// <summary>
/// Performs inflate decompression on the given data.
/// </summary>
/// <param name="input">the data to decompress</param>
/// <param name="output">the decompressed data</param>
public static void DecompressZLib(byte[] input, byte[] output)
{
Inflater item = new Inflater();
item.SetInput(input, 0, input.Length);
item.Inflate(output, 0, output.Length);
}
示例4: Decrypt
byte[] Decrypt(byte[] encryptedData) {
var reader = new BinaryReader(new MemoryStream(encryptedData));
int headerMagic = reader.ReadInt32();
if (headerMagic == 0x04034B50)
throw new NotImplementedException("Not implemented yet since I haven't seen anyone use it.");
byte encryption = (byte)(headerMagic >> 24);
if ((headerMagic & 0x00FFFFFF) != 0x007D7A7B) // Check if "{z}"
throw new ApplicationException(string.Format("Invalid SA header magic 0x{0:X8}", headerMagic));
switch (encryption) {
case 1:
int totalInflatedLength = reader.ReadInt32();
if (totalInflatedLength < 0)
throw new ApplicationException("Invalid length");
var inflatedBytes = new byte[totalInflatedLength];
int partInflatedLength;
for (int inflateOffset = 0; inflateOffset < totalInflatedLength; inflateOffset += partInflatedLength) {
int partLength = reader.ReadInt32();
partInflatedLength = reader.ReadInt32();
if (partLength < 0 || partInflatedLength < 0)
throw new ApplicationException("Invalid length");
var inflater = new Inflater(true);
inflater.SetInput(encryptedData, checked((int)reader.BaseStream.Position), partLength);
reader.BaseStream.Seek(partLength, SeekOrigin.Current);
int realInflatedLen = inflater.Inflate(inflatedBytes, inflateOffset, inflatedBytes.Length - inflateOffset);
if (realInflatedLen != partInflatedLength)
throw new ApplicationException("Could not inflate");
}
return inflatedBytes;
case 2:
if (resourceDecrypterInfo.DES_Key == null || resourceDecrypterInfo.DES_IV == null)
throw new ApplicationException("DES key / iv have not been set yet");
using (var provider = new DESCryptoServiceProvider()) {
provider.Key = resourceDecrypterInfo.DES_Key;
provider.IV = resourceDecrypterInfo.DES_IV;
using (var transform = provider.CreateDecryptor()) {
return Decrypt(transform.TransformFinalBlock(encryptedData, 4, encryptedData.Length - 4));
}
}
case 3:
if (resourceDecrypterInfo.AES_Key == null || resourceDecrypterInfo.AES_IV == null)
throw new ApplicationException("AES key / iv have not been set yet");
using (var provider = new RijndaelManaged()) {
provider.Key = resourceDecrypterInfo.AES_Key;
provider.IV = resourceDecrypterInfo.AES_IV;
using (var transform = provider.CreateDecryptor()) {
return Decrypt(transform.TransformFinalBlock(encryptedData, 4, encryptedData.Length - 4));
}
}
default:
throw new ApplicationException(string.Format("Unknown encryption type 0x{0:X2}", encryption));
}
}
示例5: Inflate
protected override int Inflate(int pos, byte[] dstbuf, int dstoff, Inflater inf)
{
var tmp = new byte[512];
var s = _stream;
s.Position=pos;
while ((s.Length-s.Position) > 0 && !inf.IsFinished)
{
if (inf.IsNeedingInput)
{
var n = (int)Math.Min((s.Length - s.Position), tmp.Length);
s.Read(tmp, 0, n);
inf.SetInput(tmp, 0, n);
}
dstoff += inf.Inflate(dstbuf, dstoff, dstbuf.Length - dstoff);
}
while (!inf.IsFinished && !inf.IsNeedingInput)
dstoff += inf.Inflate(dstbuf, dstoff, dstbuf.Length - dstoff);
return dstoff;
}
示例6: DecompressDeflate
public static byte[] DecompressDeflate(byte[] data, int decompSize)
{
var decompData = new byte[decompSize];
var inflater = new Inflater(true);
inflater.SetInput(data);
inflater.Inflate(decompData);
return decompData;
}
示例7: DecompressAlphaValues
public static byte[] DecompressAlphaValues(byte[] alphaValues, int width, int height)
{
var data = new byte[width * height];
var inflater = new Inflater();
inflater.SetInput(alphaValues);
if (inflater.Inflate(data) != data.Length)
throw new ArgumentException("Alpha values are not in valid compressed format!");
return data;
}
示例8: HandleReqUpdateAccountData
public static void HandleReqUpdateAccountData(Packet packet)
{
packet.ReadEnum<AccountDataType>("Type");
packet.ReadTime("Time");
int inflatedSize = packet.ReadInt32("Size");
byte[] compressedData = packet.ReadBytes((int)packet.GetLength() - (int)packet.GetPosition());
byte[] data = new byte[inflatedSize];
var inflater = new Inflater();
inflater.SetInput(compressedData, 0, compressedData.Length);
inflater.Inflate(data, 0, inflatedSize);
Console.WriteLine("Data: {0}", encoder.GetString(data));
}
示例9: Decompress
public static byte[] Decompress(byte[] compressed, uint unzippedSize)
{
byte[] result = new byte[unzippedSize];
Inflater inf = new Inflater();
inf.SetInput(compressed);
int error = inf.Inflate(result, 0, (int)unzippedSize);
if (error == 0)
{
throw new FileLoadException("The a section of the swf file could not be decompressed.");
}
return result;
}
示例10: CodecInputStream
public CodecInputStream(Stream baseStream)
{
BinaryReader br = new BinaryReader(baseStream);
decompressedSize = br.ReadInt32();
compressedSize = br.ReadInt32();
byte[] inbuf = new byte[compressedSize];
baseStream.Read(inbuf, 0, compressedSize);
Inflater inflater = new Inflater(false);
inflater.SetInput(inbuf);
byte[] buf = new byte[decompressedSize];
inflater.Inflate(buf);
this.iis = new MemoryStream(buf);
}
示例11: Decompress
public static byte[] Decompress(byte[] input, int uncompressedLength, bool header = true)
{
Contract.Requires(input != null);
Contract.Requires(uncompressedLength >= 0);
Contract.Ensures(Contract.Result<byte[]>() != null);
Contract.Ensures(Contract.Result<byte[]>().Length == uncompressedLength);
var inflater = new Inflater(!header);
var output = new byte[uncompressedLength];
inflater.SetInput(input, 0, input.Length);
inflater.Inflate(output);
return output;
}
示例12: Decompress
public static byte[] Decompress(byte[] content, int offset, int count)
{
//return content;
Inflater decompressor = new Inflater();
decompressor.SetInput(content, offset, count);
using (MemoryStream bos = new MemoryStream(content.Length))
{
var buf = new byte[1024];
while (!decompressor.IsFinished)
{
int n = decompressor.Inflate(buf);
bos.Write(buf, 0, n);
}
return bos.ToArray();
}
}
示例13: Open
public Stream Open(Stream stream)
{
stream.Seek(DataOffset, SeekOrigin.Begin);
byte[] data;
if (DataCompression == 0)
{
data = stream.ReadBytes(DataSize);
}
else
{
var dataBuffer = stream.ReadBytes(DataCompressedSize);
var inflater = new Inflater(false);
inflater.SetInput(dataBuffer);
data = new Byte[DataSize];
inflater.Inflate(data);
}
return new MemoryStream(data);
}
示例14: Uncompress
public byte[] Uncompress(byte[] input)
{
Inflater decompressor = new Inflater();
decompressor.SetInput(input);
// Create an expandable byte array to hold the decompressed data
MemoryStream bos = new MemoryStream(input.Length);
// Decompress the data
byte[] buf = new byte[1024];
while (!decompressor.IsFinished)
{
int count = decompressor.Inflate(buf);
bos.Write(buf, 0, count);
}
// Get the decompressed data
return bos.ToArray();
}
示例15: Unpack
public byte[] Unpack() {
if (peImage.PEImage.Win32Resources == null)
return null;
var dataEntry = peImage.PEImage.Win32Resources.Find(10, "__", 0);
if (dataEntry == null)
return null;
var encryptedData = dataEntry.Data.ReadAllBytes();
var keyData = GetKeyData();
if (keyData == null)
return null;
var decrypter = new NativeFileDecrypter(keyData);
decrypter.Decrypt(encryptedData, 0, encryptedData.Length);
byte[] inflatedData;
if (isNet1x)
inflatedData = DeobUtils.Inflate(encryptedData, false);
else {
int inflatedSize = BitConverter.ToInt32(encryptedData, 0);
inflatedData = new byte[inflatedSize];
var inflater = new Inflater(false);
inflater.SetInput(encryptedData, 4, encryptedData.Length - 4);
int count = inflater.Inflate(inflatedData);
if (count != inflatedSize)
return null;
}
// CLR 1.x or DNR v4.0 - v4.4
if (BitConverter.ToInt16(inflatedData, 0) == 0x5A4D)
return inflatedData;
// DNR v4.5
if (BitConverter.ToInt16(inflatedData, loaderHeaderSizeV45) == 0x5A4D)
return UnpackLoader(inflatedData);
return null;
}