Skip to content

Commit ed2f325

Browse files
committed
Revert "Prevent attaching to a process with a different architecture"
This reverts commit 746ecfc. That commit isn't correct. It conflates the return from `IsWow64Process` (whether the process is running under 32-bit emulation on a 64-bit process) with whether the process is 64-bit. A 32-bit process on 32-bit Windows would have `IsWow64Process` set our `isWow64` flag to `FALSE`, and we'd then incorrectly return `TRUE` from `is_process64Bit`.
1 parent 45e73c5 commit ed2f325

File tree

1 file changed

+0
-32
lines changed

1 file changed

+0
-32
lines changed

Python/remote_debugging.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -422,28 +422,6 @@ search_map_for_section(proc_handle_t *handle, const char* secname, const char* m
422422

423423
#ifdef MS_WINDOWS
424424

425-
static BOOL is_process64Bit(HANDLE hProcess) {
426-
BOOL isWow64 = FALSE;
427-
if (IsWow64Process(hProcess, &isWow64)) {
428-
return !isWow64;
429-
}
430-
else {
431-
PyErr_SetString(PyExc_RuntimeError, "Failed to determine the architecture of the process.");
432-
return FALSE;
433-
}
434-
}
435-
436-
static
437-
BOOL is_current_process64Bit() {
438-
#if defined(_WIN64)
439-
return TRUE;
440-
#elif defined(_WIN32)
441-
return is_process64Bit(GetCurrentProcess());
442-
#else
443-
return FALSE;
444-
#endif
445-
}
446-
447425
static void* analyze_pe(const wchar_t* mod_path, BYTE* remote_base, const char* secname) {
448426
HANDLE hFile = CreateFileW(mod_path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
449427
if (hFile == INVALID_HANDLE_VALUE) {
@@ -504,16 +482,6 @@ static void* analyze_pe(const wchar_t* mod_path, BYTE* remote_base, const char*
504482

505483
static uintptr_t
506484
search_windows_map_for_section(proc_handle_t* handle, const char* secname, const wchar_t* substr) {
507-
// Check if the architecture of the current process matches the target process
508-
BOOL currentProcess64Bit = is_current_process64Bit();
509-
BOOL targetProcess64Bit = is_process64Bit(handle->hProcess);
510-
511-
// If the architectures of the current and target processes differ, abort
512-
if (currentProcess64Bit != targetProcess64Bit) {
513-
PyErr_SetString(PyExc_RuntimeError, "Bitness mismatch between current process and target process.");
514-
return 0;
515-
}
516-
517485
HANDLE hProcSnap;
518486
do {
519487
hProcSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, handle->pid);

0 commit comments

Comments
 (0)