GARbro-mirror/SchemeTool/Program.cs

69 lines
2.4 KiB
C#
Raw Normal View History

2021-03-15 03:40:47 +08:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
2021-03-15 04:21:53 +08:00
using System.Runtime.InteropServices;
2021-03-15 03:40:47 +08:00
using System.Text;
using System.Threading.Tasks;
namespace SchemeTool
{
class Program
{
static void Main(string[] args)
{
// Load database
using (Stream stream = File.OpenRead(".\\GameData\\Formats.dat"))
{
GameRes.FormatCatalog.Instance.DeserializeScheme(stream);
}
GameRes.Formats.KiriKiri.Xp3Opener format = GameRes.FormatCatalog.Instance.ArcFormats
.FirstOrDefault(a => a is GameRes.Formats.KiriKiri.Xp3Opener) as GameRes.Formats.KiriKiri.Xp3Opener;
if (format != null)
{
GameRes.Formats.KiriKiri.Xp3Scheme scheme = format.Scheme as GameRes.Formats.KiriKiri.Xp3Scheme;
// Add scheme information here
2021-03-15 04:21:53 +08:00
#if false
byte[] cb = File.ReadAllBytes(@"MEM_10014628_00001000.mem");
var cb2 = MemoryMarshal.Cast<byte, uint>(cb);
for (int i = 0; i < cb2.Length; i++)
cb2[i] = ~cb2[i];
var cs = new GameRes.Formats.KiriKiri.CxScheme
{
Mask = 0x000,
Offset = 0x000,
PrologOrder = new byte[] { 0, 1, 2 },
OddBranchOrder = new byte[] { 0, 1, 2, 3, 4, 5 },
EvenBranchOrder = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 },
ControlBlock = cb2.ToArray()
};
GameRes.Formats.KiriKiri.ICrypt crypt = new GameRes.Formats.KiriKiri.CxEncryption(cs);
#else
2021-03-15 03:40:47 +08:00
GameRes.Formats.KiriKiri.ICrypt crypt = new GameRes.Formats.KiriKiri.XorCrypt(0x00);
2021-03-15 04:21:53 +08:00
#endif
2021-03-15 03:40:47 +08:00
scheme.KnownSchemes.Add("game title", crypt);
}
var gameMap = typeof(GameRes.FormatCatalog).GetField("m_game_map", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)
.GetValue(GameRes.FormatCatalog.Instance) as Dictionary<string, string>;
if (gameMap != null)
{
// Add file name here
2021-03-15 04:21:53 +08:00
gameMap.Add("game.exe", "game title");
2021-03-15 03:40:47 +08:00
}
// Save database
using (Stream stream = File.Create(".\\GameData\\Formats.dat"))
{
GameRes.FormatCatalog.Instance.SerializeScheme(stream);
}
}
}
}