154 lines
6.2 KiB
C#
154 lines
6.2 KiB
C#
using General;
|
|
using System;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
|
|
namespace CXMLCli
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
//args = "src20.vag -iv".Split(' ');
|
|
|
|
bool Check = true;
|
|
|
|
if (args.Length == 0)
|
|
{
|
|
Console.WriteLine("-- app.info/CXML Decompiler --");
|
|
Console.WriteLine("I like to see girls die :3");
|
|
Console.WriteLine("Required Arguments:");
|
|
Console.WriteLine("\t<input_filename>");
|
|
Console.WriteLine("Optional Arguments:");
|
|
Console.WriteLine("\t-iv --is-vag File is HE-VAG audio and NOT CXML");
|
|
Console.WriteLine("\t-f --force Dont check magic number.");
|
|
Console.WriteLine("\t-dt --dump-tables Dump ALL tables.");
|
|
Console.WriteLine("\t-tt --dump-tree Dump tree table.");
|
|
Console.WriteLine("\t-ist --dump-string-id Dump string ID table.");
|
|
Console.WriteLine("\t-iit --dump-int-id Dump int ID table.");
|
|
Console.WriteLine("\t-st --dump-string Dump string table.");
|
|
Console.WriteLine("\t-ct --dump-char Dump char table.");
|
|
Console.WriteLine("\t-hit --dump-hash-id Dump hash ID table.");
|
|
Console.WriteLine("\t-iat --dump-int-array Dump int array table.");
|
|
Console.WriteLine("\t-fat --dump-float-array Dump float array table.");
|
|
Console.WriteLine("\t-ft --dump-file Dump file table.");
|
|
Console.WriteLine("\t-p --process-files Process Extracted Files");
|
|
Console.WriteLine("\t-w --wait-exit Wait for keypress before exiting");
|
|
Console.WriteLine("\t-d --decompile Decompile CXML.");
|
|
Console.WriteLine("Example: " + Path.GetFileName(Assembly.GetEntryAssembly().Location) + " app.info -f -s -t -f -d");
|
|
Console.WriteLine("Default functonality is to Decompile,\nThis is canceled if any other arguments passed.");
|
|
return;
|
|
}
|
|
|
|
String ArgsFull = String.Join(" ", args);
|
|
String path = args[0];
|
|
|
|
|
|
if (ArgsFull.Contains("-iv") || ArgsFull.Contains("--is-vag"))
|
|
{
|
|
byte[] WaveData = VAG.VAGAudio.Vag2Wav(path);
|
|
string FileName = Path.GetFileNameWithoutExtension(path) + "-" + VAG.VAGAudio.GetFilename(path) + ".wav";
|
|
Console.WriteLine("Writing "+FileName);
|
|
File.WriteAllBytes(FileName, WaveData);
|
|
return;
|
|
}
|
|
CXML.CXMLParser cxmlParser = new CXML.CXMLParser();
|
|
cxmlParser.Init(path, Check);
|
|
|
|
if (args.Length == 1)
|
|
{
|
|
ArgsFull += "-d -p -w";
|
|
}
|
|
|
|
if (ArgsFull.Contains("-f") || ArgsFull.Contains("--force"))
|
|
{
|
|
Check = false;
|
|
}
|
|
|
|
if (ArgsFull.Contains("-dt") || ArgsFull.Contains("--dump-tables"))
|
|
{
|
|
ArgsFull += "-tt -ist -iit -st -ct -sit -iat -fat -ft";
|
|
}
|
|
|
|
if (ArgsFull.Contains("-tt") || ArgsFull.Contains("--dump-tree"))
|
|
{
|
|
Console.WriteLine("Dumping tree table.");
|
|
File.WriteAllBytes("tree-table.bin", cxmlParser.GetTreeTable());
|
|
|
|
}
|
|
|
|
if (ArgsFull.Contains("-ist") || ArgsFull.Contains("--dump-string-id"))
|
|
{
|
|
Console.WriteLine("Dumping string ID table.");
|
|
File.WriteAllBytes("string-id-table.bin", cxmlParser.GetStringIDTable());
|
|
|
|
}
|
|
|
|
if (ArgsFull.Contains("-iit") || ArgsFull.Contains("--dump-int-id"))
|
|
{
|
|
Console.WriteLine("Dumping int ID table.");
|
|
File.WriteAllBytes("int-id-table.bin", cxmlParser.GetIntIDTable());
|
|
}
|
|
|
|
if (ArgsFull.Contains("-st") || ArgsFull.Contains("--dump-string"))
|
|
{
|
|
Console.WriteLine("Dumping string table.");
|
|
File.WriteAllBytes("string-table.bin",cxmlParser.GetStringTable());
|
|
|
|
}
|
|
|
|
if (ArgsFull.Contains("-ct") || ArgsFull.Contains("--dump-char"))
|
|
{
|
|
Console.WriteLine("Dumping char table.");
|
|
File.WriteAllBytes("char-table.bin", cxmlParser.GetCharTable());
|
|
}
|
|
|
|
if ((ArgsFull.Contains("-sit") || ArgsFull.Contains("--dump-style-id")) /*kept for backwards comp*/ || (ArgsFull.Contains("-hit") || ArgsFull.Contains("--dump-hash-id")))
|
|
{
|
|
Console.WriteLine("Dumping hash ID table.");
|
|
File.WriteAllBytes("hash-id-table.bin", cxmlParser.GetHashIDTable());
|
|
}
|
|
|
|
|
|
if (ArgsFull.Contains("-iat") || ArgsFull.Contains("--dump-int-array"))
|
|
{
|
|
Console.WriteLine("Dumping int array table.");
|
|
File.WriteAllBytes("int-array-table.bin", cxmlParser.GetIntArrayTable());
|
|
}
|
|
|
|
if (ArgsFull.Contains("-fat") || ArgsFull.Contains("--dump-float-array"))
|
|
{
|
|
Console.WriteLine("Dumping float array table.");
|
|
File.WriteAllBytes("float-array-table.bin", cxmlParser.GetFloatArrayTable());
|
|
}
|
|
|
|
|
|
if (ArgsFull.Contains("-ft") || ArgsFull.Contains("--dump-tree"))
|
|
{
|
|
Console.WriteLine("Dumping file table.");
|
|
File.WriteAllBytes("file-table.bin", cxmlParser.GetTreeTable());
|
|
}
|
|
|
|
if (ArgsFull.Contains("-p") || ArgsFull.Contains("--process-files"))
|
|
{
|
|
cxmlParser.ProcessFiles = true;
|
|
}
|
|
|
|
if (ArgsFull.Contains("-w") || ArgsFull.Contains("--wait-exit"))
|
|
{
|
|
cxmlParser.WaitExit = true;
|
|
}
|
|
|
|
if (ArgsFull.Contains("-d") || ArgsFull.Contains("--decompile"))
|
|
{
|
|
Console.WriteLine("Decompiling.");
|
|
cxmlParser.DecompileCXML(path, Check);
|
|
Console.WriteLine("\n\nDECOMPILATION COMPLETE!");
|
|
if(cxmlParser.WaitExit)
|
|
Console.ReadKey();
|
|
}
|
|
return 0;
|
|
}
|
|
}
|
|
}
|