From 9b6bebf26cd3e8c4e9655d290dd7ecc77e2e6423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Sun, 8 Dec 2024 23:16:45 +0100 Subject: [PATCH] windows: Use GetProcessInformation() on Windows 11+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only Windows 11 or newer supports ProcessMachineTypeInfo with GetProcessInformation(). Ensure this function is only used on those versions. Co-authored-by: Håvard Sørbø --- gum/backend-windows/gumprocess-windows.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gum/backend-windows/gumprocess-windows.c b/gum/backend-windows/gumprocess-windows.c index b8a13e014..9ff3745fa 100644 --- a/gum/backend-windows/gumprocess-windows.c +++ b/gum/backend-windows/gumprocess-windows.c @@ -1242,6 +1242,26 @@ gum_windows_cpu_type_from_pid (guint pid, get_process_information = (GumGetProcessInformationFunc) GetProcAddress (kernel32, "GetProcessInformation"); + if (get_process_information != NULL) + { + NTSTATUS (WINAPI * rtl_get_version) (PRTL_OSVERSIONINFOW info); + RTL_OSVERSIONINFOW info = { 0, }; + gboolean win11_or_newer; + + rtl_get_version = (NTSTATUS (WINAPI *) (PRTL_OSVERSIONINFOW)) + GetProcAddress (GetModuleHandleW (L"ntdll.dll"), "RtlGetVersion"); + + info.dwOSVersionInfoSize = sizeof (info); + rtl_get_version (&info); + + win11_or_newer = + info.dwMajorVersion >= 11 || + (info.dwMajorVersion == 10 && + (info.dwMinorVersion > 0 || info.dwBuildNumber >= 22000)); + if (!win11_or_newer) + get_process_information = NULL; + } + g_once_init_leave (&initialized, TRUE); }