mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-03 18:35:36 +08:00
Fix logic error.
This commit is contained in:
parent
6a90018798
commit
738b2950f6
@ -70,7 +70,7 @@ namespace GameRes.Formats.DxLib
|
|||||||
internal enum DXA8Flags : UInt32
|
internal enum DXA8Flags : UInt32
|
||||||
{
|
{
|
||||||
DXA_FLAG_NO_KEY=1, //file is not encrypted
|
DXA_FLAG_NO_KEY=1, //file is not encrypted
|
||||||
DXA_FLAG_NO_HEAD_PRESS=1<<1, //do not compress the entire file after compressing individual entries
|
DXA_FLAG_NO_HEAD_PRESS=1<<1, //do not compress the header after compressing individual entries
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
@ -127,28 +127,30 @@ namespace GameRes.Formats.DxLib
|
|||||||
DxKey8 key = null;
|
DxKey8 key = null;
|
||||||
|
|
||||||
//FIXME: ReadBytes sets hard cap of filesize to 4GB.
|
//FIXME: ReadBytes sets hard cap of filesize to 4GB.
|
||||||
var bodyBuffer = file.View.ReadBytes(dx.BaseOffset, (uint)(file.MaxOffset-dx.BaseOffset));
|
var headerBuffer = file.View.ReadBytes(dx.IndexOffset, (uint)(file.MaxOffset-dx.IndexOffset));
|
||||||
bool isencrypted = (dx.Flags & DXA8Flags.DXA_FLAG_NO_KEY) == 0;
|
bool isencrypted = (dx.Flags & DXA8Flags.DXA_FLAG_NO_KEY) == 0;
|
||||||
|
|
||||||
if (isencrypted)
|
if (isencrypted)
|
||||||
{
|
{
|
||||||
var keyStr = Query<DXAOpts>(arcStrings.ZIPEncryptedNotice).Keyword;
|
var keyStr = Query<DXAOpts>(arcStrings.ZIPEncryptedNotice).Keyword;
|
||||||
key = new DxKey8(keyStr);
|
key = new DxKey8(keyStr);
|
||||||
Decrypt(bodyBuffer, 0, bodyBuffer.Length, 0, key.Key);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Decrypt(headerBuffer, 0, headerBuffer.Length, 0, key.Key);
|
||||||
//Decrypted but might be compressed
|
//Decrypted but might be compressed
|
||||||
if ((dx.Flags & DXA8Flags.DXA_FLAG_NO_HEAD_PRESS) == 0)
|
if ((dx.Flags & DXA8Flags.DXA_FLAG_NO_HEAD_PRESS) == 0)
|
||||||
{
|
{
|
||||||
//IndexSize refers to uncompressed
|
//IndexSize refers to uncompressed size of the header (that is FileName + File + Dir buffers)
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
var readyStr = new MemoryStream(bodyBuffer);
|
|
||||||
ArcView arcView = new ArcView(readyStr, "body",(uint) bodyBuffer.LongLength);
|
var readyStr = new MemoryStream(headerBuffer);
|
||||||
|
ArcView arcView = new ArcView(readyStr, "hdr",(uint)headerBuffer.LongLength);
|
||||||
List<Entry> entries;
|
List<Entry> entries;
|
||||||
using (var indexStr = arcView.CreateStream(dx.IndexOffset,dx.IndexSize))
|
using (var indexStr = arcView.CreateStream(dx.IndexOffset, dx.IndexSize))
|
||||||
using (var reader = IndexReader.Create(dx, 8, indexStr))
|
using (var reader = IndexReader.Create(dx, 8, indexStr))
|
||||||
{
|
{
|
||||||
entries = reader.Read();
|
entries = reader.Read();
|
||||||
|
Loading…
Reference in New Issue
Block a user