Update example code

This commit is contained in:
Crsky
2025-01-26 12:21:38 +08:00
parent c1cdedc08b
commit ca0ceacab9

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -27,7 +28,7 @@ namespace SchemeTool
// Add scheme information here // Add scheme information here
#if false #if true
byte[] cb = File.ReadAllBytes(@"MEM_10014628_00001000.mem"); byte[] cb = File.ReadAllBytes(@"MEM_10014628_00001000.mem");
var cb2 = MemoryMarshal.Cast<byte, uint>(cb); var cb2 = MemoryMarshal.Cast<byte, uint>(cb);
for (int i = 0; i < cb2.Length; i++) for (int i = 0; i < cb2.Length; i++)
@@ -41,12 +42,24 @@ namespace SchemeTool
EvenBranchOrder = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 }, EvenBranchOrder = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 },
ControlBlock = cb2.ToArray() ControlBlock = cb2.ToArray()
}; };
GameRes.Formats.KiriKiri.ICrypt crypt = new GameRes.Formats.KiriKiri.CxEncryption(cs); var crypt = new GameRes.Formats.KiriKiri.HxCrypt(cs);
crypt.RandomType = 0;
crypt.FilterKey = 0x0000000000000000;
crypt.NamesFile = "HxNames.lst";
var keyA1 = SoapHexBinary.Parse("0000000000000000000000000000000000000000000000000000000000000000").Value;
var keyA2 = SoapHexBinary.Parse("00000000000000000000000000000000").Value;
var keyB1 = SoapHexBinary.Parse("0000000000000000000000000000000000000000000000000000000000000000").Value;
var keyB2 = SoapHexBinary.Parse("00000000000000000000000000000000").Value;
crypt.IndexKeyDict = new Dictionary<string, GameRes.Formats.KiriKiri.HxIndexKey>()
{
{ "data.xp3", new GameRes.Formats.KiriKiri.HxIndexKey { Key1 = keyA1, Key2 = keyA2 } },
{ "update.xp3", new GameRes.Formats.KiriKiri.HxIndexKey { Key1 = keyB1, Key2 = keyB2 } },
};
#else #else
GameRes.Formats.KiriKiri.ICrypt crypt = new GameRes.Formats.KiriKiri.XorCrypt(0x00); GameRes.Formats.KiriKiri.ICrypt crypt = new GameRes.Formats.KiriKiri.XorCrypt(0x00);
#endif #endif
scheme.KnownSchemes.Add("game title", crypt); // scheme.KnownSchemes.Add("game title", crypt);
} }
var gameMap = typeof(GameRes.FormatCatalog).GetField("m_game_map", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic) var gameMap = typeof(GameRes.FormatCatalog).GetField("m_game_map", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)
@@ -55,7 +68,7 @@ namespace SchemeTool
if (gameMap != null) if (gameMap != null)
{ {
// Add file name here // Add file name here
gameMap.Add("game.exe", "game title"); // gameMap.Add("game.exe", "game title");
} }
// Save database // Save database