diff --git a/DotNetCTFDumper/DotNetCTFDumper.csproj b/DotNetCTFDumper/DotNetCTFDumper.csproj index 1de74f2..8948fb5 100644 --- a/DotNetCTFDumper/DotNetCTFDumper.csproj +++ b/DotNetCTFDumper/DotNetCTFDumper.csproj @@ -129,6 +129,12 @@ + + Form + + + ErrorLogBox.cs + Form @@ -248,6 +254,9 @@ + + ErrorLogBox.cs + FrameViewer.cs diff --git a/DotNetCTFDumper/GUI/ErrorLogBox.cs b/DotNetCTFDumper/GUI/ErrorLogBox.cs new file mode 100644 index 0000000..5ed52b5 --- /dev/null +++ b/DotNetCTFDumper/GUI/ErrorLogBox.cs @@ -0,0 +1,32 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Windows.Forms; +using System.Windows.Forms.VisualStyles; + +namespace DotNetCTFDumper.GUI +{ + public partial class ErrorLogBox : Form + { + public ErrorLogBox(Exception e) + { + InitializeComponent(); + textBox1.Text += $"{e.Message}\r\n\r\n\r\n"; + StackTrace st = new StackTrace(true); + string stackIndent = ""; + for(int i =0; i< st.FrameCount; i++ ) + { + // Note that at this level, there are four + // stack frames, one for each method invocation. + StackFrame sf = st.GetFrame(i); + var filename = Path.GetFileNameWithoutExtension(sf.GetFileName()); + if (filename == null) filename = "UnknownFile"; + textBox1.Text += + $" {(filename)} : {sf.GetMethod()}: Line {sf.GetFileLineNumber()}\r\n\r\n"; + stackIndent += " "; + } + + //Console.ReadKey(); + } + } +} \ No newline at end of file diff --git a/DotNetCTFDumper/MMFParser/EXE/ChunkList.cs b/DotNetCTFDumper/MMFParser/EXE/ChunkList.cs index 8460ab9..4f2a1ce 100644 --- a/DotNetCTFDumper/MMFParser/EXE/ChunkList.cs +++ b/DotNetCTFDumper/MMFParser/EXE/ChunkList.cs @@ -70,6 +70,7 @@ namespace DotNetCTFDumper.MMFParser.EXE { RawData = exeReader.ReadBytes(Size); exeReader.BaseStream.Position -= Size; + //Saving raw data cuz why not } switch (Flag) @@ -88,13 +89,6 @@ namespace DotNetCTFDumper.MMFParser.EXE break; } - - int tempId=0; - int.TryParse(Name,out tempId); - if(tempId==Id) - { - //chunk_data.Log(true, "X2"); - } } @@ -134,32 +128,16 @@ namespace DotNetCTFDumper.MMFParser.EXE } public void BuildKey() { - string title = ""; - string copyright = ""; - string project = ""; - var titleChunk = _chunkList.GetChunk(); - if (titleChunk != null) title = titleChunk.Value; - - var copyrightChunk = _chunkList.GetChunk(); - if (copyrightChunk != null) copyright = copyrightChunk.Value; - - var projectChunk = _chunkList.GetChunk(); - if (projectChunk != null) project = projectChunk.Value; - Settings.AppName=title; - Settings.Copyright = copyright; - Settings.ProjectPath = project; + + + Settings.AppName=_chunkList.GetChunk()?.Value; + Settings.Copyright = _chunkList.GetChunk()?.Value; + Settings.ProjectPath = _chunkList.GetChunk()?.Value; - if (Exe.Instance.GameData.ProductBuild > 284) - { - Decryption.MakeKey(title, copyright, project); - } - else - { - Decryption.MakeKey(project, title, copyright); - } - + if (Exe.Instance.GameData.ProductBuild > 284)Decryption.MakeKey(Settings.AppName,Settings.Copyright,Settings.ProjectPath); + else Decryption.MakeKey(Settings.ProjectPath, Settings.AppName, Settings.Copyright); Logger.Log("New Key!"); diff --git a/DotNetCTFDumper/Program.cs b/DotNetCTFDumper/Program.cs index efb4797..666f3f8 100644 --- a/DotNetCTFDumper/Program.cs +++ b/DotNetCTFDumper/Program.cs @@ -29,12 +29,19 @@ namespace DotNetCTFDumper var verbose = false; var dumpImages = true; var dumpSounds = true; - + AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) => + { + var error = new ErrorLogBox(eventArgs.Exception); + Application.Run(error); + }; if (args.Length == 0) { - Settings.UseGUI = true; - MyForm = new MainForm(); - Application.Run(MyForm); + + Settings.UseGUI = true; + MyForm = new MainForm(); + Application.Run(MyForm); + + } diff --git a/DotNetCTFDumper/Utils/Decryption.cs b/DotNetCTFDumper/Utils/Decryption.cs index f25d750..e57524e 100644 --- a/DotNetCTFDumper/Utils/Decryption.cs +++ b/DotNetCTFDumper/Utils/Decryption.cs @@ -4,17 +4,17 @@ using System.Runtime.InteropServices; namespace DotNetCTFDumper.Utils { - class Decryption + static class Decryption { - public static byte[] DecryptionKey; + private static byte[] DecryptionKey; public static byte MagicChar = 54; - public static void MakeKey(string sTitle, string sCopyright, string sProject) + public static void MakeKey(string data1, string data2, string data3) { var rawKey = ""; - rawKey += sTitle; - rawKey += sCopyright; - rawKey += sProject; + rawKey += data1; + rawKey += data2; + rawKey += data3; Logger.Log("Combined data " + rawKey, true, ConsoleColor.Yellow); var rawKeyPtr = Marshal.StringToHGlobalAnsi(rawKey); @@ -24,6 +24,7 @@ namespace DotNetCTFDumper.Utils Marshal.Copy(ptr, key, 0, 256); Marshal.FreeHGlobal(rawKeyPtr); + DecryptionKey = key; Logger.Log($"First 16-Bytes of key: {DecryptionKey.GetHex(16)}", true, ConsoleColor.Yellow); File.WriteAllBytes($"{Settings.DumpPath}\\key.bin", DecryptionKey);