From a8dd4bb837e7f02e06170d6d4c1f3e237af4f8dc Mon Sep 17 00:00:00 2001 From: BahaBulle Date: Thu, 12 May 2016 21:52:32 +0200 Subject: [PATCH] SCRIPT - add functions to extract/insert card.dat and .evt files --- Hack.Xenosaga/App.config | 6 + Hack.Xenosaga/Common/Extension.cs | 44 + Hack.Xenosaga/Common/Functions.cs | 52 +- Hack.Xenosaga/Common/Variables.cs | 7 +- Hack.Xenosaga/Hack.Xenosaga.csproj | 13 +- Hack.Xenosaga/Process/JavaClass.cs | 1977 ++++++++++++++++++++++++++++ Hack.Xenosaga/Process/Scripts.cs | 472 +++++++ Hack.Xenosaga/Process/Unpack.cs | 26 +- Hack.Xenosaga/Xenosaga.cs | 14 +- README.md | 3 +- 10 files changed, 2583 insertions(+), 31 deletions(-) create mode 100644 Hack.Xenosaga/App.config create mode 100644 Hack.Xenosaga/Common/Extension.cs create mode 100644 Hack.Xenosaga/Process/JavaClass.cs create mode 100644 Hack.Xenosaga/Process/Scripts.cs diff --git a/Hack.Xenosaga/App.config b/Hack.Xenosaga/App.config new file mode 100644 index 0000000..8227adb --- /dev/null +++ b/Hack.Xenosaga/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/Hack.Xenosaga/Common/Extension.cs b/Hack.Xenosaga/Common/Extension.cs new file mode 100644 index 0000000..3df801f --- /dev/null +++ b/Hack.Xenosaga/Common/Extension.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Hack.Xenosaga.Common +{ + public static class Extension + { + /// + /// Ecrit un bloc d'octet dans le flux actuel en utilisant des données lues dans une mémoire tampon (la position du flux actuel reste inchangée). + /// + /// Mémoire tamon dans laquelle lire les données + /// Dans buffer, offset d'octet de base zéro d'où commencer la copie des octets dans le flux actuel + /// Nombre maximal d'octets à écrire + /// Position dans le flux actuel où écrire les données + public static void Write(this MemoryStream ms, byte[] buffer, int offset, int count, long position) + { + long pos = ms.Position; + + ms.Position = position; + + ms.Write(buffer, offset, count); + + ms.Position = pos; + } + + /// + /// Lit une séquence de 4 octets à partir du flux actuel et avance la position dans le flux du nombre d'octets lus. + /// + /// Valeur lue + public static UInt32 Read(this MemoryStream ms) + { + UInt32 value = 0; + + for (int i = 0; i < 4; i++) + value += (UInt32)(ms.ReadByte() << (i * 8) ); + + return value; + } + } +} diff --git a/Hack.Xenosaga/Common/Functions.cs b/Hack.Xenosaga/Common/Functions.cs index 8f67690..59bfc4b 100644 --- a/Hack.Xenosaga/Common/Functions.cs +++ b/Hack.Xenosaga/Common/Functions.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Text; @@ -9,17 +10,20 @@ namespace Hack.Xenosaga.Common public static void usage() { Trace.WriteLine(""); - Trace.WriteLine("xenosaga