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

76 lines
2.3 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)
{
var file = "net31-fd.exe";
var fs = new FileStream(file, FileMode.Open, FileAccess.Read);
var d = new Analyzer(fs).GetTextSectionVA();
var pattern = new byte[] { 0x4c, 0x8D, 0x5, 0xE2, 0x8A, 0x00, 0x00 };
string mask = "xxxxxxx";
Log.Info("Scanning for pattern...");
Stopwatch sw = Stopwatch.StartNew();
var res = Util.PatternScan(fs, 0, (int)fs.Length, pattern, mask);
sw.Stop();
Log.Info("Found pattern at " + res[0].ToString("X8") + $" in {sw.ElapsedMilliseconds}ms");
/* Log.Info("apphost-extract by VollRagm\n", ConsoleColor.Yellow);
var path = GetPath(args);
// var file = AppHostFile.Open(path2);//path.FullName);
// Log.Info($"{file.Header.Manifest.FileEntries.Count} embedded file(s) found.");
var directory = Path.Combine(path.DirectoryName, path.Name.Remove(path.Name.Length - path.Extension.Length) + "_extracted");
Console.WriteLine();
Log.Info("Extracting...");
//file.ExtractAll(directory);
Console.WriteLine();
Log.Info("Done.");
// file.Close();
Console.ReadLine();*/
}
static FileInfo GetPath(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;
}
}
}