理论上支持ESC-ARC1重新封包

未测试,手头上没有老版本
This commit is contained in:
Chenx221 2024-10-17 01:24:13 +08:00
parent 6505ac4862
commit d3abca73ad

View File

@ -177,6 +177,25 @@ namespace EscudeTools
bw.Write(m_seed); bw.Write(m_seed);
m_count = (uint)pItem.Count; m_count = (uint)pItem.Count;
bw.Write(m_count ^ NextKey()); bw.Write(m_count ^ NextKey());
EncodingProvider provider = CodePagesEncodingProvider.Instance;
Encoding? shiftJis = provider.GetEncoding("shift-jis");
if (version == 1) //未经测试
{
long storeOffset = 0x10 + m_count * 0x88;
for (int i = 0; i < m_count; i++)
{
byte[] strbytes = shiftJis.GetBytes(pItem[i].Name);
byte[] result = new byte[80];
int lengthToCopy = Math.Min(strbytes.Length, 78);
Array.Copy(strbytes, result, lengthToCopy);
bw.Write(result);
bw.Write(storeOffset);
bw.Write(pItem[i].Size);
storeOffset += pItem[i].Size;
}
}
else
{
uint namesSize = (uint)pItem.Sum(e => e.Name.Length + 1); uint namesSize = (uint)pItem.Sum(e => e.Name.Length + 1);
bw.Write(namesSize ^ NextKey()); bw.Write(namesSize ^ NextKey());
uint filenameOffset = 0; uint filenameOffset = 0;
@ -196,14 +215,14 @@ namespace EscudeTools
} }
Decrypt(ref index); Decrypt(ref index);
bw.Write(index); bw.Write(index);
EncodingProvider provider = CodePagesEncodingProvider.Instance;
Encoding? shiftJis = provider.GetEncoding("shift-jis");
foreach (Entry entry in pItem) foreach (Entry entry in pItem)
{ {
byte[] nameBytes = shiftJis.GetBytes(entry.Name); byte[] nameBytes = shiftJis.GetBytes(entry.Name);
bw.Write(nameBytes); bw.Write(nameBytes);
bw.Write((byte)0); bw.Write((byte)0);
} }
}
foreach (Entry entry in pItem) foreach (Entry entry in pItem)
{ {
byte[] data = File.ReadAllBytes(Path.Combine(path, entry.Name)); byte[] data = File.ReadAllBytes(Path.Combine(path, entry.Name));