cxml-decompiler/AppInfoCli/Program.cs

154 lines
6.2 KiB
C#
Raw Normal View History

2019-05-06 12:53:11 +00:00
using General;
using System;
2019-04-27 14:43:27 +00:00
using System.IO;
2019-04-28 18:32:20 +00:00
using System.Reflection;
2019-04-27 14:43:27 +00:00
2019-05-03 20:18:55 +00:00
namespace CXMLCli
2019-04-27 14:43:27 +00:00
{
class Program
{
static void Main(string[] args)
{
2019-05-07 14:06:18 +00:00
//args = "src20.vag -iv".Split(' ');
2019-05-03 20:18:55 +00:00
bool Check = true;
2019-04-28 18:32:20 +00:00
if (args.Length == 0)
{
Console.WriteLine("-- app.info/CXML Decompiler --");
Console.WriteLine("I like to see girls die :3");
Console.WriteLine("Required Arguments:");
2019-05-06 12:53:11 +00:00
Console.WriteLine("\t<input_filename>");
2019-04-28 18:32:20 +00:00
Console.WriteLine("Optional Arguments:");
2019-05-06 12:53:11 +00:00
Console.WriteLine("\t-iv --is-vag File is HE-VAG audio and NOT CXML");
2019-05-03 20:18:55 +00:00
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.");
2019-05-03 20:18:55 +00:00
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.");
2021-08-11 09:30:50 +00:00
Console.WriteLine("\t-p --process-files Process Extracted Files");
Console.WriteLine("\t-w --wait-exit Wait for keypress before exiting");
2019-05-03 20:18:55 +00:00
Console.WriteLine("\t-d --decompile Decompile CXML.");
2019-04-28 18:32:20 +00:00
Console.WriteLine("Example: " + Path.GetFileName(Assembly.GetEntryAssembly().Location) + " app.info -f -s -t -f -d");
2021-08-11 13:03:30 +00:00
Console.WriteLine("Default functonality is to Decompile,\nThis is canceled if any other arguments passed.");
2019-04-28 18:32:20 +00:00
return;
}
2019-04-27 14:43:27 +00:00
2019-04-28 18:32:20 +00:00
String ArgsFull = String.Join(" ", args);
String path = args[0];
2019-05-06 12:53:11 +00:00
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;
}
2021-08-11 09:30:50 +00:00
CXML.CXMLParser cxmlParser = new CXML.CXMLParser();
cxmlParser.Init(path, Check);
2019-05-06 12:53:11 +00:00
2021-08-11 09:30:50 +00:00
if (args.Length == 1)
{
ArgsFull += "-d -p -w";
}
2019-05-06 12:53:11 +00:00
2019-04-28 18:32:20 +00:00
if (ArgsFull.Contains("-f") || ArgsFull.Contains("--force"))
2019-04-27 14:43:27 +00:00
{
2019-04-28 18:32:20 +00:00
Check = false;
2019-04-27 14:43:27 +00:00
}
2019-04-28 18:32:20 +00:00
2019-05-03 20:18:55 +00:00
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.");
2021-08-11 09:30:50 +00:00
File.WriteAllBytes("tree-table.bin", cxmlParser.GetTreeTable());
2019-05-03 20:18:55 +00:00
}
if (ArgsFull.Contains("-ist") || ArgsFull.Contains("--dump-string-id"))
{
Console.WriteLine("Dumping string ID table.");
2021-08-11 09:30:50 +00:00
File.WriteAllBytes("string-id-table.bin", cxmlParser.GetStringIDTable());
2019-05-03 20:18:55 +00:00
}
if (ArgsFull.Contains("-iit") || ArgsFull.Contains("--dump-int-id"))
{
Console.WriteLine("Dumping int ID table.");
2021-08-11 09:30:50 +00:00
File.WriteAllBytes("int-id-table.bin", cxmlParser.GetIntIDTable());
2019-05-03 20:18:55 +00:00
}
2019-04-28 18:32:20 +00:00
2019-05-03 20:18:55 +00:00
if (ArgsFull.Contains("-st") || ArgsFull.Contains("--dump-string"))
2019-04-27 14:43:27 +00:00
{
2019-04-28 18:32:20 +00:00
Console.WriteLine("Dumping string table.");
2021-08-11 09:30:50 +00:00
File.WriteAllBytes("string-table.bin",cxmlParser.GetStringTable());
2019-04-28 18:32:20 +00:00
2019-04-27 14:43:27 +00:00
}
2019-05-03 20:18:55 +00:00
if (ArgsFull.Contains("-ct") || ArgsFull.Contains("--dump-char"))
{
Console.WriteLine("Dumping char table.");
2021-08-11 09:30:50 +00:00
File.WriteAllBytes("char-table.bin", cxmlParser.GetCharTable());
2019-05-03 20:18:55 +00:00
}
2019-04-27 14:43:27 +00:00
if ((ArgsFull.Contains("-sit") || ArgsFull.Contains("--dump-style-id")) /*kept for backwards comp*/ || (ArgsFull.Contains("-hit") || ArgsFull.Contains("--dump-hash-id")))
2019-04-28 18:32:20 +00:00
{
Console.WriteLine("Dumping hash ID table.");
2021-08-11 09:30:50 +00:00
File.WriteAllBytes("hash-id-table.bin", cxmlParser.GetHashIDTable());
2019-05-03 20:18:55 +00:00
}
if (ArgsFull.Contains("-iat") || ArgsFull.Contains("--dump-int-array"))
{
Console.WriteLine("Dumping int array table.");
2021-08-11 09:30:50 +00:00
File.WriteAllBytes("int-array-table.bin", cxmlParser.GetIntArrayTable());
2019-04-28 18:32:20 +00:00
}
2019-05-03 20:18:55 +00:00
if (ArgsFull.Contains("-fat") || ArgsFull.Contains("--dump-float-array"))
{
Console.WriteLine("Dumping float array table.");
2021-08-11 09:30:50 +00:00
File.WriteAllBytes("float-array-table.bin", cxmlParser.GetFloatArrayTable());
2019-05-03 20:18:55 +00:00
}
2019-04-28 18:32:20 +00:00
if (ArgsFull.Contains("-ft") || ArgsFull.Contains("--dump-tree"))
{
Console.WriteLine("Dumping file table.");
2021-08-11 09:30:50 +00:00
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;
2019-04-28 18:32:20 +00:00
}
2019-04-27 14:43:27 +00:00
2021-08-11 09:30:50 +00:00
if (ArgsFull.Contains("-d") || ArgsFull.Contains("--decompile"))
2019-04-28 18:32:20 +00:00
{
Console.WriteLine("Decompiling.");
2021-08-11 09:30:50 +00:00
cxmlParser.DecompileCXML(path, Check);
2019-05-03 20:18:55 +00:00
Console.WriteLine("\n\nDECOMPILATION COMPLETE!");
2021-08-11 09:30:50 +00:00
if(cxmlParser.WaitExit)
Console.ReadKey();
2019-04-28 18:32:20 +00:00
}
2021-08-11 13:03:30 +00:00
return 0;
2019-04-27 14:43:27 +00:00
}
}
}