diff --git a/ExtremeDumper.Common.props b/ExtremeDumper.Common.props index 4171474..b6a9967 100644 --- a/ExtremeDumper.Common.props +++ b/ExtremeDumper.Common.props @@ -1,7 +1,7 @@ ExtremeDumper - 4.0.0.0 + 4.0.0.1 Copyright © 2018-2022 Wwh diff --git a/ExtremeDumper/AntiAntiDump/AADCoreInjector.cs b/ExtremeDumper/AntiAntiDump/AADCoreInjector.cs index 7bf4840..7e7a217 100644 --- a/ExtremeDumper/AntiAntiDump/AADCoreInjector.cs +++ b/ExtremeDumper/AntiAntiDump/AADCoreInjector.cs @@ -2,6 +2,7 @@ using System.IO; using dnlib.DotNet; using ExtremeDumper.Injecting; +using ExtremeDumper.Logging; namespace ExtremeDumper.AntiAntiDump; @@ -22,6 +23,7 @@ public static string GetAADCorePath() { var data = GetAADCore(true, out var name); dllPath = Path.Combine(Path.GetTempPath(), name); File.WriteAllBytes(dllPath, data); + Logger.Info($"ExtremeDumper.AntiAntiDump.dll has been released to '{dllPath}'"); return dllPath; } @@ -51,10 +53,12 @@ public static AADClient Inject(uint processId, InjectionClrVersion clrVersion, s bool b = Injector.InjectManaged(processId, GetAADCorePath(), "ExtremeDumper.AntiAntiDump.Injection", "Main", pipeName, clrVersion); if (!b) throw new InvalidOperationException("Can't inject ExtremeDumper.AntiAntiDump.dll to target process."); + Logger.Info($"ExtremeDumper.AntiAntiDump.dll has been injected into process {processId} and clr version is {clrVersion}"); var client = AADClient.Create(pipeName); if (client is null) throw new InvalidOperationException($"Can't create {nameof(AADClient)}."); + Logger.Info($"Create {nameof(AADClient)} of process {processId} successfully and clr version is {clrVersion}"); return client; } diff --git a/ExtremeDumper/Forms/FunctionsForm.cs b/ExtremeDumper/Forms/FunctionsForm.cs index 0645787..a807a07 100644 --- a/ExtremeDumper/Forms/FunctionsForm.cs +++ b/ExtremeDumper/Forms/FunctionsForm.cs @@ -1,6 +1,5 @@ using System; using System.Windows.Forms; -using ExtremeDumper.Logging; using NativeSharp; namespace ExtremeDumper.Forms; @@ -9,7 +8,7 @@ unsafe partial class FunctionsForm : Form { readonly NativeProcess process; readonly NativeModule module; - FunctionsForm(uint processId, nuint moduleHandle) { + public FunctionsForm(uint processId, nuint moduleHandle) { InitializeComponent(); Utils.ScaleByDpi(this); process = NativeProcess.Open(processId); @@ -22,23 +21,6 @@ unsafe partial class FunctionsForm : Form { RefreshFunctionList(); } - public static FunctionsForm? Create(uint processId, nuint moduleHandle) { - if (processId == 0) - throw new ArgumentNullException(nameof(processId)); - if (moduleHandle == 0) - throw new ArgumentNullException(nameof(moduleHandle)); - - try { - var form = new FunctionsForm(processId, moduleHandle); - form.FormClosed += (_, _) => form.Dispose(); - return form; - } - catch (Exception ex) { - Logger.Exception(ex); - return null; - } - } - #region Events void lvwFunctions_Resize(object sender, EventArgs e) { lvwFunctions.AutoResizeColumns(true); diff --git a/ExtremeDumper/Forms/InjectingForm.cs b/ExtremeDumper/Forms/InjectingForm.cs index 54b3b5e..27cafa7 100644 --- a/ExtremeDumper/Forms/InjectingForm.cs +++ b/ExtremeDumper/Forms/InjectingForm.cs @@ -23,21 +23,6 @@ public InjectingForm(ProcessInfo process) { cmbCLRVersion.SelectedIndex = 0; } - public static InjectingForm? Create(ProcessInfo process) { - if (process is null) - throw new ArgumentNullException(nameof(process)); - - try { - var form = new InjectingForm(process); - form.FormClosed += (_, _) => form.Dispose(); - return form; - } - catch (Exception ex) { - Logger.Exception(ex); - return null; - } - } - #region Events void InjectingForm_DragEnter(object sender, DragEventArgs e) { e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; diff --git a/ExtremeDumper/Forms/ModulesForm.cs b/ExtremeDumper/Forms/ModulesForm.cs index 00422bc..55a4a06 100644 --- a/ExtremeDumper/Forms/ModulesForm.cs +++ b/ExtremeDumper/Forms/ModulesForm.cs @@ -24,7 +24,7 @@ partial class ModulesForm : Form { readonly TitleComposer title; readonly List modules = new(); - ModulesForm(ProcessInfo process, StrongBox dumperType) { + public ModulesForm(ProcessInfo process, StrongBox dumperType) { InitializeComponent(); Utils.ScaleByDpi(this); this.process = process; @@ -40,23 +40,6 @@ partial class ModulesForm : Form { RefreshModuleList(); } - public static ModulesForm? Create(ProcessInfo process, StrongBox dumperType) { - if (process is null) - throw new ArgumentNullException(nameof(process)); - if (dumperType is null) - throw new ArgumentNullException(nameof(dumperType)); - - try { - var form = new ModulesForm(process, dumperType); - form.FormClosed += (_, _) => form.Dispose(); - return form; - } - catch (Exception ex) { - Logger.Exception(ex); - return null; - } - } - #region Events void lvwModules_Resize(object sender, EventArgs e) { lvwModules.AutoResizeColumns(true); @@ -122,11 +105,7 @@ void mnuViewFunctions_Click(object sender, EventArgs e) { if (!TryGetSelectedModule(out var module)) return; - var form = FunctionsForm.Create(process.Id, module.ImageBase); - if (form is not null) - form.Show(); - else - Logger.Error($"Can't create {nameof(FunctionsForm)}"); + new FunctionsForm(process.Id, module.ImageBase).Show(); } void mnuOnlyDotNetModule_Click(object sender, EventArgs e) { diff --git a/ExtremeDumper/Forms/ProcessesForm.cs b/ExtremeDumper/Forms/ProcessesForm.cs index 56717de..460db6b 100644 --- a/ExtremeDumper/Forms/ProcessesForm.cs +++ b/ExtremeDumper/Forms/ProcessesForm.cs @@ -15,7 +15,6 @@ namespace ExtremeDumper.Forms; partial class ProcessesForm : Form { - static readonly LoaderHookForm loaderHookForm = new(); static readonly bool IsAdministrator = new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator); static bool hasSeDebugPrivilege; @@ -71,7 +70,7 @@ void mnuDebugPrivilege_Click(object sender, EventArgs e) { } void mnuOpenLoaderHook_Click(object sender, EventArgs e) { - loaderHookForm.Show(); + new LoaderHookForm().Show(); } void lvwProcesses_Resize(object sender, EventArgs e) { @@ -117,11 +116,7 @@ void mnuViewModules_Click(object sender, EventArgs e) { return; } - var form = ModulesForm.Create(process, dumperType); - if (form is not null) - form.Show(); - else - Logger.Error($"Can't create {nameof(ModulesForm)}"); + new ModulesForm(process, dumperType).Show(); } void mnuRefreshProcessList_Click(object sender, EventArgs e) { @@ -144,11 +139,7 @@ void mnuInjectDll_Click(object sender, EventArgs e) { if (!TryGetSelectedProcess(out var process)) return; - var form = InjectingForm.Create(process); - if (form is not null) - form.Show(); - else - Logger.Error($"Can't create {nameof(InjectingForm)}"); + new InjectingForm(process).Show(); } void mnuGotoLocation_Click(object sender, EventArgs e) { diff --git a/ExtremeDumper/GlobalExceptionCatcher.cs b/ExtremeDumper/GlobalExceptionCatcher.cs index ff49961..889e93c 100644 --- a/ExtremeDumper/GlobalExceptionCatcher.cs +++ b/ExtremeDumper/GlobalExceptionCatcher.cs @@ -1,6 +1,4 @@ using System; -using System.Reflection; -using System.Text; using System.Windows.Forms; using ExtremeDumper.Logging; @@ -17,31 +15,9 @@ static class GlobalExceptionCatcher { /// public static void Catch() { if (!isStarted) { - Application.ThreadException += (sender, e) => ShowDetailException(e.Exception); - AppDomain.CurrentDomain.UnhandledException += (sender, e) => ShowDetailException((Exception)e.ExceptionObject); + Application.ThreadException += (sender, e) => Logger.Exception(e.Exception); + AppDomain.CurrentDomain.UnhandledException += (sender, e) => Logger.Exception(e.ExceptionObject as Exception); isStarted = true; } } - - static void ShowDetailException(Exception exception) { - var sb = new StringBuilder(); - DumpException(exception, sb); - Logger.Error(sb.ToString()); - } - - static void DumpException(Exception exception, StringBuilder sb) { - exception ??= new ArgumentNullException(nameof(exception), ""); - sb.AppendLine($"Type: {Environment.NewLine}{exception.GetType().FullName}"); - sb.AppendLine($"Message: {Environment.NewLine}{exception.Message}"); - sb.AppendLine($"Source: {Environment.NewLine}{exception.Source}"); - sb.AppendLine($"StackTrace: {Environment.NewLine}{exception.StackTrace}"); - sb.AppendLine($"TargetSite: {Environment.NewLine}{exception.TargetSite}"); - sb.AppendLine("----------------------------------------"); - if (exception.InnerException is not null) - DumpException(exception.InnerException, sb); - if (exception is ReflectionTypeLoadException reflectionTypeLoadException) { - foreach (var loaderException in reflectionTypeLoadException.LoaderExceptions) - DumpException(loaderException, sb); - } - } }