this is causing problems with Compression/Modules/LZX/LZXCompressionModule.cs for some reason

This commit is contained in:
Michael Becker 2023-06-25 00:40:23 -04:00
parent 3a638f60e0
commit 1d11e89897
3 changed files with 69 additions and 22 deletions

View File

@ -13,10 +13,10 @@ repos:
args: [--fix, auto] args: [--fix, auto]
- id: fix-byte-order-marker - id: fix-byte-order-marker
- id: trailing-whitespace - id: trailing-whitespace
- repo: https://github.com/jumanjihouse/pre-commit-hooks #- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 2.1.5 # rev: 2.1.5
hooks: # hooks:
- id: forbid-space-in-indent # - id: forbid-space-in-indent
language: script # language: script
exclude: (^.*\.(csproj|glade|resx|svg|yaml|txt|uexml|cxxproj)$)|LICENSE # exclude: (^.*\.(csproj|glade|resx|svg|yaml|txt|uexml|cxxproj)$)|LICENSE
exclude_types: ['binary'] # exclude_types: ['binary']

View File

@ -18,6 +18,36 @@ using UniversalEditor.Compression.Modules.LZX.Internal;
// Original source code: // Original source code:
// https://code.google.com/p/monoxna/source/browse/trunk/src/Microsoft.Xna.Framework/HelperCode/LzxDecoder.cs // https://code.google.com/p/monoxna/source/browse/trunk/src/Microsoft.Xna.Framework/HelperCode/LzxDecoder.cs
/***************************************************************************
* lzx.c - LZX decompression routines *
* ------------------- *
* *
* maintainer: Jed Wing <jedwin@ugcs.caltech.edu> *
* source: modified lzx.c from cabextract v0.5 *
* notes: This file was taken from cabextract v0.5, which was, *
* itself, a modified version of the lzx decompression code *
* from unlzx. *
* *
* platforms: In its current incarnation, this file has been tested on *
* two different Linux platforms (one, redhat-based, with a *
* 2.1.2 glibc and gcc 2.95.x, and the other, Debian, with *
* 2.2.4 glibc and both gcc 2.95.4 and gcc 3.0.2). Both were *
* Intel x86 compatible machines. *
***************************************************************************/
/***************************************************************************
* *
* This program 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 2 of the License, or *
* (at your option) any later version. Note that an exemption to this *
* license has been granted by Stuart Caie for the purposes of *
* distribution with chmlib. This does not, to the best of my *
* knowledge, constitute a change in the license of this (the LZX) code *
* in general. *
* *
***************************************************************************/
namespace UniversalEditor.Compression.Modules.LZX namespace UniversalEditor.Compression.Modules.LZX
{ {
public class LZXCompressionModule : CompressionModule public class LZXCompressionModule : CompressionModule
@ -501,15 +531,32 @@ namespace UniversalEditor.Compression.Modules.LZX
uint filesize = (uint)m_state.intel_filesize; uint filesize = (uint)m_state.intel_filesize;
uint abs_off, rel_off; uint abs_off, rel_off;
m_state.intel_curpos = (int)curpos + outputLength; m_state.intel_curpos = (int)(curpos + outputLength);
while (outputStream.Position < dataend) while (outputStream.Position < dataend)
{ {
if (outputStream.ReadByte() != 0xE8) { curpos++; continue; } if (outputStream.ReadByte() != 0xE8)
//abs_off = {
curpos++;
continue;
}
byte[] data = new byte[4];
outputStream.Read(data, 0, 4);
abs_off = (uint)data[0] | ((uint)data[1] << 8) | ((uint)data[2] << 16) | ((uint)data[3] << 24);
if ((abs_off >= -curpos) && (abs_off < filesize))
{
rel_off = (abs_off >= 0) ? abs_off - curpos : abs_off + filesize;
data[0] = (byte)rel_off;
data[1] = (byte)(rel_off >> 8);
data[2] = (byte)(rel_off >> 16);
data[3] = (byte)(rel_off >> 24);
}
//data += 4;
curpos += 5;
} }
} }
throw new NotImplementedException("intel e8 decoding not finished");
} }
#endregion #endregion
} }

View File

@ -210,11 +210,11 @@ namespace UniversalEditor.DataFormats.FileSystem.Microsoft.Cabinet
case CABCompressionMethod.LZX: case CABCompressionMethod.LZX:
{ {
file.Properties["CompressionMethod"] = Compression.CompressionMethod.LZX; file.Properties["CompressionMethod"] = Compression.CompressionMethod.LZX;
decompressedData = CompressionModule.FromKnownCompressionMethod(CompressionMethod.LZX).Decompress(data.data); decompressedData = CompressionModule.FromKnownCompressionMethod(CompressionMethod.LZX).Decompress(data.data, data.decompressedLength);
// no compression // no compression
Array.Copy(data.data, 0, decompressedData, j, data.data.Length); //Array.Copy(data.data, 0, decompressedData, j, data.data.Length);
j += data.data.Length; j += decompressedData.Length;
break; break;
} }
default: default: