views:

36

answers:

1

Hi.

I wish to call a x64 exe from x86 process/exe, for example:

  1. open x32 cmd : %windir%\SysWoW64\cmd.exe
  2. start notepad: notepad.exe <- it will be x32 notepad (according to taskmanager = *)

Is it possible to execute the x64 notepad from the x32 cmd ?

My problem is the process I'm executing must run as x64, I don't want it to work as x86 (WoW) since it acts differently... this is how it was programmed and I can't change it :-( and my exe is x86...

To simplify my question: can a WoW process create/fork/etc pure x64 process ?

many thanks

YB

+2  A: 

Yes, it can. Before you launch notepad you will need to turn off WOW64 redirection in order to get the correct executable to launch.

Edit: Now you've clarified it's not actually Notepad but your own 64 bit executable, this code should launch it as a true 64 bit process:

STARTUPINFO si;
PROCESS_INFORMATION pi;
bool_t bResult = FALSE;

ZeroMemory(&pi, sizeof(pi));
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOW;

bResult = CreateProcess(NULL, "foo.exe", NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);

if (bResult)
{
    WaitForSingleObject(pi.hThread, INFINITE);

    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
}
Vicky
I have the correct executable (there is only 1), I used notepad to illustrate the problem. Wouldn't turning off the WOW redirection effect only the Registry and certain (irrelevant) paths ?
Y.B
OK, notepad is a big red herring then because there are two notepad executables in different locations (one 32 bit and one 64 bit) in a 64 bit system, so you would need to turn off filesystem redirection to get the path to the 32 bit one. Given that you only have one executable and it is a 64 bit executable, you should be able to just launch it. I'll edit my answer to show an example.
Vicky