From 8936f90f1055dd9074f1e628d98ee5112f245845 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Dec 2024 14:20:06 +0700 Subject: [PATCH] suspend launch before dlls are injected --- GW Launcher/MulticlientPatch.cs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/GW Launcher/MulticlientPatch.cs b/GW Launcher/MulticlientPatch.cs index 48f2f8b..8cd22b1 100644 --- a/GW Launcher/MulticlientPatch.cs +++ b/GW Launcher/MulticlientPatch.cs @@ -129,18 +129,9 @@ private static IntPtr GetProcessModuleBase(IntPtr process) memory = new GWCAMemory(process); - foreach (var dll in ModManager.GetDlls(account)) - { - var load_module_result = memory.LoadModule(dll); - if (load_module_result != GWCAMemory.LoadModuleResult.SUCCESSFUL) - { - err = GetErrorMessage($"memory.LoadModule({dll})", Marshal.GetLastWin32Error()); - goto cleanup; - } - } - + var VK_SHIFT = 0x10; //NB: Because account launching is done on another thread, we can't rely on WPF/WinForms API to tell us if shift is pressed - if ((GetAsyncKeyState(0x10) & 0x8000) != 0) { + if ((GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0) { DialogResult result = MessageBox.Show("Guild Wars is in a suspended state, plugins are not yet loaded.\n\nContinue?", "Launching paused", MessageBoxButtons.OKCancel); @@ -151,6 +142,16 @@ private static IntPtr GetProcessModuleBase(IntPtr process) } } + foreach (var dll in ModManager.GetDlls(account)) + { + var loadModuleResult = memory.LoadModule(dll); + if (loadModuleResult != GWCAMemory.LoadModuleResult.SUCCESSFUL) + { + err = GetErrorMessage($"memory.LoadModule({dll})", Marshal.GetLastWin32Error()); + goto cleanup; + } + } + if (procinfo.hThread != IntPtr.Zero) { try @@ -176,7 +177,7 @@ private static IntPtr GetProcessModuleBase(IntPtr process) cleanup: if (err != null) { - process?.Kill(); + // process?.Kill(); memory = null; } // Make sure to restore the modfile.txt file (blank string if in the gwlauncher dir, whatever was there before if in the gw dir)