You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
apphost-extract/src/apphost-extract/apphost-extract-v2/Program.cs

63 lines
1.8 KiB

using System;
using System.Diagnostics;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Reflection;
namespace apphost_extract_v2
{
class Program
{
static void Main(string[] args)
{
Log.Info("apphost-extract-v2 by VollRagm\n", ConsoleColor.Yellow);
var fileInfo = GetFileInfo(args);
var apphostAnalyzer = new Analyzer(fileInfo);
var apphost = apphostAnalyzer.Open();
if(apphost == null)
Log.Fatal("Unable to determine apphost version.");
Log.Info("File parsed successfully, extracting contents...");
Console.WriteLine();
var directory = Path.Combine(fileInfo.DirectoryName, fileInfo.Name.Remove(fileInfo.Name.Length - fileInfo.Extension.Length) + "_extracted");
apphost.ExtractAll(directory);
Log.Info("Done.");
Console.ReadLine();
}
static FileInfo GetFileInfo(string[] args)
{
try
{
var fileName = new FileInfo(Assembly.GetExecutingAssembly().Location).Name;
if (args.Length > 0)
{
if (File.Exists(args[0]))
{
return new FileInfo(args[0]);
}
else
{
Log.Fatal($"{args[0]} could not be found. Usage: {fileName} <path>");
}
}
else
{
Log.Fatal($"No File provided. Usage: {fileName} <path>");
}
}
catch (Exception ex)
{
Log.Fatal($"Could not get file: {ex.Message}");
}
return null;
}
}
}