This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 32 bits python ctypes creates 64 bits process from 32 bits executable
Type: Stage:
Components: ctypes Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Artur Korobeynyk
Priority: normal Keywords:

Created on 2016-01-04 12:06 by Artur Korobeynyk, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
testprog.exe Artur Korobeynyk, 2016-01-04 12:06
Messages (2)
msg257461 - (view) Author: Artur Korobeynyk (Artur Korobeynyk) Date: 2016-01-04 12:06
Hi,

I have a 32 bits python on 64 bits Windows and 32 bits executable (compiled from native C).
When I do kernel32.CreateProcessA(path_to_exe, ...) python creates a process which is 64 bit (ctypes IsWow64Process returns true).
I expect it to be 32 as well. Am I wrong or that is a bug?

I attached testprog.exe but it requires testdll.dll
The sources of testprog.c:

#include <stdio.h>
#include <windows.h>

int main()
{

        Sleep(15000);
        printf("%d", testSum(5,10));
        return 0;
}

testdll.c

#include <stdio.h>

__declspec(dllexport) int __cdecl testSum(int a, int b)
{
        return(a+b);
}

compiled as:
/usr/bin/i686-pc-mingw32-gcc.exe -c testdll.c
/usr/bin/i686-pc-mingw32-gcc.exe --shared -o testdll.dll testdll.o
/usr/bin/i686-pc-mingw32-gcc.exe -o testprog testprog.c -L. -ltestdll

Process creation:
if kernel32.CreateProcessA(path_to_exe,
                                   None,
                                   None,
                                   None,
                                   None,
                                   creation_flags,
                                   None,
                                   None,
                                   byref(startupinfo),
                                   byref(process_information))
msg257462 - (view) Author: Artur Korobeynyk (Artur Korobeynyk) Date: 2016-01-04 12:55
the Wow64Process output parameter is true for a 32-bit process. WOW64 is short for Win32 running on Win64 (i.e. the environment used to run 32-bit programs in 64-bit Windows). Even a 32-bit WOW64 process has some 64-bit modules, such as ntdll.dll, wow64.dll, wow64win.dll, and wow64cpu.dll
History
Date User Action Args
2022-04-11 14:58:25adminsetgithub: 70194
2016-01-04 12:55:29Artur Korobeynyksetstatus: open -> closed
resolution: not a bug
messages: + msg257462
2016-01-04 12:06:49Artur Korobeynykcreate