From 06f1ff39ec5b3e370b57dd689799cd9550665b69 Mon Sep 17 00:00:00 2001 From: Alexandru Macocian Date: Thu, 19 Feb 2026 17:10:55 +0100 Subject: [PATCH 1/3] Fix windows ready checker (Closes #1456) --- .../GuildWarsReadyChecker.cs | 82 ------------------- 1 file changed, 82 deletions(-) diff --git a/Daybreak.Windows/Services/ApplicationLauncher/GuildWarsReadyChecker.cs b/Daybreak.Windows/Services/ApplicationLauncher/GuildWarsReadyChecker.cs index 773f0077..3d291248 100644 --- a/Daybreak.Windows/Services/ApplicationLauncher/GuildWarsReadyChecker.cs +++ b/Daybreak.Windows/Services/ApplicationLauncher/GuildWarsReadyChecker.cs @@ -3,9 +3,6 @@ using System.Core.Extensions; using System.Diagnostics; using System.Extensions.Core; -using System.Runtime.InteropServices; -using System.Text; -using static Daybreak.Windows.Utils.NativeMethods; namespace Daybreak.Windows.Services.ApplicationLauncher; @@ -17,8 +14,6 @@ internal sealed class GuildWarsReadyChecker( ILogger logger ) : IGuildWarsReadyChecker { - private const double LaunchMemoryThreshold = 200000000; - private readonly ILogger logger = logger.ThrowIfNull(); public async Task WaitForReady(Process process, TimeSpan timeout, CancellationToken cancellationToken) @@ -41,87 +36,10 @@ public async Task WaitForReady(Process process, TimeSpan timeout, Cancella continue; } - var windows = GetRootWindowsOfProcess(process.Id) - .Select(root => (root, GetChildWindows(root))) - .SelectMany(tuple => - { - tuple.Item2.Add(tuple.root); - return tuple.Item2; - }) - .Select(GetWindowTitle).ToList(); - - /* - * Detect when the game window has shown. Because both the updater and the game window are called Guild Wars, - * we need to look at the other windows created by the process. Especially, we need to detect the input windows - * to check when the game is ready to accept input - */ - if (!windows.Contains("Guild Wars Reforged")) - { - continue; - } - - var virtualMemory = process.VirtualMemorySize64; - if (virtualMemory < LaunchMemoryThreshold) - { - continue; - } - return true; } scopedLogger.LogError("Timed out waiting for Guild Wars to be ready"); return false; } - - private static List GetRootWindowsOfProcess(int pid) - { - var rootWindows = GetChildWindows(IntPtr.Zero); - var dsProcRootWindows = new List(); - foreach (IntPtr hWnd in rootWindows) - { - _ = GetWindowThreadProcessId(hWnd, out var lpdwProcessId); - if (lpdwProcessId == pid) - dsProcRootWindows.Add(hWnd); - } - - return dsProcRootWindows; - } - - private static List GetChildWindows(IntPtr parent) - { - var result = new List(); - var listHandle = GCHandle.Alloc(result); - try - { - var childProc = new Win32Callback(EnumWindow); - EnumChildWindows(parent, childProc, GCHandle.ToIntPtr(listHandle)); - } - finally - { - if (listHandle.IsAllocated) - listHandle.Free(); - } - - return result; - } - - private static string GetWindowTitle(IntPtr hwnd) - { - var titleLength = GetWindowTextLength(hwnd); - var titleBuffer = new StringBuilder(titleLength); - _ = GetWindowText(hwnd, titleBuffer, titleLength + 1); - return titleBuffer.ToString(); - } - - private static bool EnumWindow(IntPtr handle, IntPtr pointer) - { - var gch = GCHandle.FromIntPtr(pointer); - if (gch.Target is not List list) - { - return false; - } - - list.Add(handle); - return true; - } } From 4a58fdf7f1ddd14110dd96d2eba443762308a5be Mon Sep 17 00:00:00 2001 From: Alexandru Macocian Date: Thu, 19 Feb 2026 17:11:53 +0100 Subject: [PATCH 2/3] Add extra debugging line --- .../Services/ApplicationLauncher/GuildWarsReadyChecker.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Daybreak.Windows/Services/ApplicationLauncher/GuildWarsReadyChecker.cs b/Daybreak.Windows/Services/ApplicationLauncher/GuildWarsReadyChecker.cs index 3d291248..e995e438 100644 --- a/Daybreak.Windows/Services/ApplicationLauncher/GuildWarsReadyChecker.cs +++ b/Daybreak.Windows/Services/ApplicationLauncher/GuildWarsReadyChecker.cs @@ -36,6 +36,7 @@ public async Task WaitForReady(Process process, TimeSpan timeout, Cancella continue; } + scopedLogger.LogInformation("Guild Wars process is ready and running"); return true; } From 4cbbbdb1810d6012ae28064e59856fa3b58f5c80 Mon Sep 17 00:00:00 2001 From: Alexandru Macocian Date: Thu, 19 Feb 2026 17:13:44 +0100 Subject: [PATCH 3/3] Extra debug info --- .../Services/ApplicationLauncher/ApplicationLauncher.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Daybreak.Core/Services/ApplicationLauncher/ApplicationLauncher.cs b/Daybreak.Core/Services/ApplicationLauncher/ApplicationLauncher.cs index e9d30055..52d73cc1 100644 --- a/Daybreak.Core/Services/ApplicationLauncher/ApplicationLauncher.cs +++ b/Daybreak.Core/Services/ApplicationLauncher/ApplicationLauncher.cs @@ -439,6 +439,7 @@ is null return (default, []); } + scopedLogger.LogDebug("Waiting for Guild Wars to be ready..."); var sw = Stopwatch.StartNew(); var isReady = await this.guildWarsReadyChecker.WaitForReady( process,