aboutsummaryrefslogtreecommitdiff
path: root/gdb/nat/windows-nat.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/nat/windows-nat.c')
-rw-r--r--gdb/nat/windows-nat.c65
1 files changed, 18 insertions, 47 deletions
diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c
index f9f6848..7b0fbc5 100644
--- a/gdb/nat/windows-nat.c
+++ b/gdb/nat/windows-nat.c
@@ -1,5 +1,5 @@
/* Internal interfaces for the Windows code
- Copyright (C) 1995-2024 Free Software Foundation, Inc.
+ Copyright (C) 1995-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -172,23 +172,13 @@ windows_process_info::get_exec_module_filename (char *exe_name_ret,
DWORD cbNeeded;
cbNeeded = 0;
-#ifdef __x86_64__
- if (wow64_process)
- {
- if (!EnumProcessModulesEx (handle,
- &dh_buf, sizeof (HMODULE), &cbNeeded,
- LIST_MODULES_32BIT)
- || !cbNeeded)
- return 0;
- }
- else
-#endif
+ BOOL ret = with_context (nullptr, [&] (auto *context)
{
- if (!EnumProcessModules (handle,
- &dh_buf, sizeof (HMODULE), &cbNeeded)
- || !cbNeeded)
- return 0;
- }
+ return enum_process_modules (context, handle, &dh_buf,
+ sizeof (HMODULE), &cbNeeded);
+ });
+ if (!ret || !cbNeeded)
+ return 0;
/* We know the executable is always first in the list of modules,
which we just fetched. So no need to fetch more. */
@@ -523,41 +513,22 @@ windows_process_info::add_dll (LPVOID load_addr)
HMODULE *hmodules;
int i;
-#ifdef __x86_64__
- if (wow64_process)
+ BOOL ret = with_context (nullptr, [&] (auto *context)
{
- if (EnumProcessModulesEx (handle, &dummy_hmodule,
- sizeof (HMODULE), &cb_needed,
- LIST_MODULES_32BIT) == 0)
- return;
- }
- else
-#endif
- {
- if (EnumProcessModules (handle, &dummy_hmodule,
- sizeof (HMODULE), &cb_needed) == 0)
- return;
- }
-
- if (cb_needed < 1)
+ return enum_process_modules (context, handle, &dummy_hmodule,
+ sizeof (HMODULE), &cb_needed);
+ });
+ if (!ret || cb_needed < 1)
return;
hmodules = (HMODULE *) alloca (cb_needed);
-#ifdef __x86_64__
- if (wow64_process)
+ ret = with_context (nullptr, [&] (auto *context)
{
- if (EnumProcessModulesEx (handle, hmodules,
- cb_needed, &cb_needed,
- LIST_MODULES_32BIT) == 0)
- return;
- }
- else
-#endif
- {
- if (EnumProcessModules (handle, hmodules,
- cb_needed, &cb_needed) == 0)
- return;
- }
+ return enum_process_modules (context, handle, hmodules,
+ cb_needed, &cb_needed);
+ });
+ if (!ret)
+ return;
char system_dir[MAX_PATH];
char syswow_dir[MAX_PATH];