CreateProcess and WOW64
I did a simple test and just wanted to share the findings.
When you create a 32 bit application and run it on a 64 bit machine (i.e. you run the application under WOW64). If you create a process from inside it - the process that you create is a 32 bit process. If you compile the same application as 64 bit (either x64 or IA64) and do a create process for the same process - the child process will be created as 64 bit.
One more side note: if you create a 64 app in Visual Studio on a 64 bit machine -- you cannot run/debug the application from inside the IDE. This is because the Visual Studio is a 32 bit process (we do not have a 64 bit version of VS yet). You wil have to launch the application from the Windows Expolrer/Command Prompt. To debug it you may want to use the 64 bit version of WinDBG.
Comments
Anonymous
October 30, 2006
Um, that's not true. If you CreateProcess a 64-bit executable, you'll get a 64-bit process. Are you sure WOW64 wasn't choosing a different executable for you when you ran the 32-bit application (i.e. WOW64 looks in C:Program Files (x86) while native 64-bit looks in C:Program Files).Also, debugging a 64-bit app from Visual Studio works fine, though it's slightly more cumbersome than 32-bit debugging. See: http://msdn2.microsoft.com/en-us/library/ms184681.aspxAnonymous
November 12, 2006
Hi Dean,I will do some more testing and try to confirm. But as of now i tried with a simple 32 bit app - did a CreateProcess on notepad.exe by giving the full path (c:windowssystem32notepad.exe and c:windowssyswow64notepad.exe). In both the cases the process that was created was 32 bit. Atleast the task manager showed *32 for both the notepad.exe.The reverse however was not true - lanunching the notepad.exe from a 64 bit app by giving the full path launched the proper 32-bit or the 64-bit version that was referred from the 64 bit app.So either the task manager is showing something incorrectly or there is more to it.Anonymous
January 30, 2007
The createprocess will create a 32 bit process if the process is available, it converts system folder to syswow64 automatically I would like to know if you can disable this converstion paulgafa@gmail.comAnonymous
January 31, 2007
Hi Paul, I am not sure what you mean by "createprocess will create a 32 bit process if the process is available". Basically, when you call CreateProcess from another process - the bit-ness of child process created will depend on the bitness of the parent process. Are you seeing something different? Are you referring to the Wow64DisableWow64FsRedirection API that will disable file system redirection?