mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-30 17:05:37 +08:00
Update ArcDX8.cs
Add anything that can be done without user input.
This commit is contained in:
parent
ddabe6d2f4
commit
2e8057aa54
@ -41,27 +41,64 @@ namespace GameRes.Formats.DxLib
|
|||||||
|
|
||||||
public Dx8Opener ()
|
public Dx8Opener ()
|
||||||
{
|
{
|
||||||
Extensions = new[] { "bin" };
|
Extensions = new string[] { "dxa", "hud", "usi", "med", "dat", "bin", "bcx", "wolf" };
|
||||||
Signatures = new[] { 0x00085844u };
|
Signatures = new[] { 0x00085844u };
|
||||||
}
|
}
|
||||||
|
|
||||||
static readonly byte[] DefaultKey = new byte[] { 0xBE, 0xC8, 0x8A, 0xF5, 0x28, 0x50, 0xC9 };
|
static readonly byte[] DefaultKey = new byte[] { 0xBE, 0xC8, 0x8A, 0xF5, 0x28, 0x50, 0xC9 };
|
||||||
|
|
||||||
|
|
||||||
|
DxScheme DefaultScheme = new DxScheme { KnownKeys = new List<IDxKey>() };
|
||||||
|
|
||||||
|
|
||||||
|
internal struct DxHeaderV8
|
||||||
|
{
|
||||||
|
public long BaseOffset;
|
||||||
|
public long IndexOffset;
|
||||||
|
public uint IndexSize;
|
||||||
|
public long FileTable;
|
||||||
|
public long DirTable;
|
||||||
|
public int CodePage;
|
||||||
|
public DXA8Flags Flags;
|
||||||
|
public byte HuffmanKB;
|
||||||
|
//15 bytes of padding.
|
||||||
|
}
|
||||||
|
|
||||||
|
internal enum DXA8Flags : UInt32
|
||||||
|
{
|
||||||
|
DXA_FLAG_NO_KEY=1, //file is not encrypted
|
||||||
|
DXA_FLAG_NO_HEAD_PRESS=1<<1, //do not compress headers
|
||||||
|
}
|
||||||
|
|
||||||
public override ArcFile TryOpen (ArcView file)
|
public override ArcFile TryOpen (ArcView file)
|
||||||
{
|
{
|
||||||
var dx = new DxHeader {
|
var dx = new DxHeaderV8 {
|
||||||
IndexSize = file.View.ReadUInt32 (4),
|
IndexSize = file.View.ReadUInt32 (4),
|
||||||
BaseOffset = file.View.ReadInt64 (8),
|
BaseOffset = file.View.ReadInt64 (8),
|
||||||
IndexOffset = file.View.ReadInt64 (0x10),
|
IndexOffset = file.View.ReadInt64 (0x10),
|
||||||
FileTable = (uint)file.View.ReadInt64 (0x18),
|
FileTable = file.View.ReadInt64 (0x18),
|
||||||
DirTable = (uint)file.View.ReadInt64 (0x20),
|
DirTable = file.View.ReadInt64 (0x20),
|
||||||
CodePage = file.View.ReadInt32 (0x28),
|
CodePage = file.View.ReadInt32 (0x28),
|
||||||
|
Flags = (DXA8Flags)file.View.ReadUInt32(0x2C),
|
||||||
|
HuffmanKB = file.View.ReadByte(0x30)
|
||||||
};
|
};
|
||||||
if (dx.DirTable >= dx.IndexSize || dx.FileTable >= dx.IndexSize)
|
if (dx.DirTable >= dx.IndexSize || dx.FileTable >= dx.IndexSize)
|
||||||
return null;
|
return null;
|
||||||
|
//at this point we cannot proceed without user input. If NO_HEAD_PRESS is set we could maybe restore the 7-byte key
|
||||||
|
//Otherwise (assuming the archive is encrypted) we have no way to continue without user input.
|
||||||
|
|
||||||
|
//TODO: Ask for key here.
|
||||||
|
|
||||||
var key = DefaultKey;
|
var key = DefaultKey;
|
||||||
|
if ((dx.Flags & DXA8Flags.DXA_FLAG_NO_HEAD_PRESS) != 0)
|
||||||
|
{
|
||||||
var index = file.View.ReadBytes(dx.IndexOffset, dx.IndexSize);
|
var index = file.View.ReadBytes(dx.IndexOffset, dx.IndexSize);
|
||||||
Decrypt(index, 0, index.Length, 0, key);
|
Decrypt(index, 0, index.Length, 0, key);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
//input is compressed. First by huffman then by LZ. if it's also encrypted then we're stuck.
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
// decrypt-2
|
// decrypt-2
|
||||||
// decompress
|
// decompress
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user