de4dot-cex/de4dot.code/deobfuscators/Spices_Net/QclzDecompressor.cs

51 lines
1.6 KiB
C#
Raw Normal View History

2012-02-02 13:56:14 +08:00
/*
2015-10-30 05:45:26 +08:00
Copyright (C) 2011-2015 de4dot@gmail.com
2012-02-02 13:56:14 +08:00
This file is part of de4dot.
de4dot is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
de4dot is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with de4dot. If not, see <http://www.gnu.org/licenses/>.
*/
namespace de4dot.code.deobfuscators.Spices_Net {
class QclzDecompressor : QuickLZBase {
static int SPICES_QCLZ_SIG = 0x3952534E; // "9RSN"
2013-01-19 20:03:57 +08:00
public static byte[] Decompress(byte[] data) {
if (Read32(data, 0) == SPICES_QCLZ_SIG)
return QuickLZ.Decompress(data, SPICES_QCLZ_SIG);
2012-02-02 13:56:14 +08:00
2017-01-05 20:46:04 +08:00
int headerLength, decompressedLength/*, compressedLength*/;
2012-02-02 13:56:14 +08:00
if ((data[0] & 2) != 0) {
headerLength = 9;
2017-01-05 20:46:04 +08:00
/*compressedLength = (int)*/Read32(data, 1);
2013-01-19 20:03:57 +08:00
decompressedLength = (int)Read32(data, 5);
2012-02-02 13:56:14 +08:00
}
else {
headerLength = 3;
2017-01-05 20:46:04 +08:00
//compressedLength = data[1];
2012-02-02 13:56:14 +08:00
decompressedLength = data[2];
}
bool isCompressed = (data[0] & 1) != 0;
byte[] decompressed = new byte[decompressedLength];
if (isCompressed)
2013-01-19 20:03:57 +08:00
Decompress(data, headerLength, decompressed);
2012-02-02 13:56:14 +08:00
else
2013-01-19 20:03:57 +08:00
Copy(data, headerLength, decompressed, 0, decompressed.Length);
2012-02-02 13:56:14 +08:00
return decompressed;
}
}
}