Skip to content

Commit

Permalink
suspend launch before dlls are injected
Browse files Browse the repository at this point in the history
  • Loading branch information
DubbleClick committed Dec 18, 2024
1 parent 72df01b commit 8936f90
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions GW Launcher/MulticlientPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 8936f90

Please sign in to comment.