添加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; 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) private List<Entry>? ProcessV1(BinaryReader br)
{ {
m_seed = br.ReadUInt32(); m_seed = br.ReadUInt32();
@ -127,7 +146,6 @@ namespace EscudeTools
Buffer.BlockCopy(buffer, 0, data, 0, data.Length); Buffer.BlockCopy(buffer, 0, data, 0, data.Length);
} }
private uint NextKey() private uint NextKey()
{ {
m_seed ^= 0x65AC9365; m_seed ^= 0x65AC9365;
@ -163,8 +181,10 @@ namespace EscudeTools
return true; 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); GeneratePItem(path);
m_seed = isLoaded ? LoadedKey : 2210579460; m_seed = isLoaded ? LoadedKey : 2210579460;
string outputPath = Path.Combine(Path.GetDirectoryName(path), Path.GetFileName(path) + ".bin"); string outputPath = Path.Combine(Path.GetDirectoryName(path), Path.GetFileName(path) + ".bin");
@ -231,7 +251,6 @@ namespace EscudeTools
return true; return true;
} }
private void GeneratePItem(string path) private void GeneratePItem(string path)
{ {
pItem.Clear(); pItem.Clear();

View File

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

View File

@ -2,7 +2,7 @@
"profiles": { "profiles": {
"EscudeTools": { "EscudeTools": {
"commandName": "Project", "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"
} }
} }
} }