添加ESC-ARC2封包测试用功能

This commit is contained in:
Chenx221 2024-10-18 18:36:20 +08:00
parent d558f9e2b4
commit 6516dbde44
3 changed files with 63 additions and 45 deletions

View File

@ -52,6 +52,25 @@ namespace EscudeTools
return true;
}
//测试用
private bool LoadKey(string path)
{
if (!File.Exists(path))
return false;
using (FileStream fs = new(path, FileMode.Open))
using (BinaryReader br = new(fs))
{
byte[] head = br.ReadBytes(fileSignature.Length);
if (!head.SequenceEqual(fileSignature))
return false;
br.ReadByte();
m_seed = br.ReadUInt32();
}
LoadedKey = m_seed;
isLoaded = true;
return true;
}
private List<Entry>? ProcessV1(BinaryReader br)
{
m_seed = br.ReadUInt32();
@ -127,7 +146,6 @@ namespace EscudeTools
Buffer.BlockCopy(buffer, 0, data, 0, data.Length);
}
private uint NextKey()
{
m_seed ^= 0x65AC9365;
@ -163,8 +181,10 @@ namespace EscudeTools
return true;
}
public bool Repack(string path, int version) //目前支持v2v1
public bool Repack(string path, int version, bool useCustomKey = false, string customKeyProviderPath = "") //目前支持v2v1
{
if (useCustomKey)
LoadKey(customKeyProviderPath);
GeneratePItem(path);
m_seed = isLoaded ? LoadedKey : 2210579460;
string outputPath = Path.Combine(Path.GetDirectoryName(path), Path.GetFileName(path) + ".bin");
@ -231,7 +251,6 @@ namespace EscudeTools
return true;
}
private void GeneratePItem(string path)
{
pItem.Clear();

View File

@ -5,50 +5,49 @@
static void Main(string[] args)
{
////Batch Unpack
//if (Directory.Exists(args[0]))
//{
// string[] files = Directory.GetFiles(args[0], "*.bin");
// PackManager pm = new();
// foreach (string file in files)
// {
// //if (pm.Load(file))
// //{
// // Console.WriteLine($"Load {file} Success");
// //}
// //else
// //{
// // Console.WriteLine($"Load {file} Failed");
// // return;
// //}
// //if (pm.Extract())
// // Console.WriteLine("Extract Package Success");
// //else
// //{
// // Console.WriteLine("Extract Package Failed");
// // return;
// //}
// if (pm.Repack(args[1], 2))
// Console.WriteLine("Repack Package Success");
// if (pm.Load(file))
// {
// Console.WriteLine($"Load {file} Success");
// }
// else
// {
// Console.WriteLine("Repack Package Failed");
// return;
// }
// Console.WriteLine($"Load {file} Failed");
// }
//}
//PackManager pm = new();
//if (pm.Repack(args[1]))
// Console.WriteLine("Export Database Success");
// if (pm.Extract())
// Console.WriteLine("Extract Package Success");
// else
// {
// Console.WriteLine("Export Database Failed");
// return;
// Console.WriteLine("Extract Package Failed");
// }
// }
//}
if (Directory.Exists(args[0]) && Directory.Exists(args[1]))
{
string[] directories = Directory.GetDirectories(args[0]);
foreach (string directory in directories)
{
PackManager pm = new();
string providerFilePath = Path.Combine(args[1], Path.GetFileName(directory) + ".bin");
if (pm.Repack(directory, 2,true, providerFilePath))
Console.WriteLine("Export Database Success");
else
{
Console.WriteLine("Export Database Failed");
return;
}
}
}
//if (Directory.Exists(args[0]))
//{
@ -96,16 +95,16 @@
//return;
if (Directory.Exists(args[0]))
{
string[] files = Directory.GetFiles(args[0], "*.db");
//if (Directory.Exists(args[0]))
//{
// string[] files = Directory.GetFiles(args[0], "*.db");
foreach (string file in files)
{
DatabaseManager.ExportMDB(file);
// foreach (string file in files)
// {
// DatabaseManager.ExportMDB(file);
}
}
// }
//}
//if (Directory.Exists(args[0]))
//{

View File

@ -2,7 +2,7 @@
"profiles": {
"EscudeTools": {
"commandName": "Project",
"commandLineArgs": "G:\\x221.local\\lab\\sqlite"
"commandLineArgs": "G:\\x221.local\\lab\\unpack_pack\\orgin\\output\r\nG:\\x221.local\\lab\\unpack_pack\\1"
}
}
}