C++ – How to force the 32-bit version of the remote desktop client to run on 64 bit Vista

64-bitcremote desktopvista64

We need to run the 32-bit version of the remote desktop client on 64 bit Vista, because part of our product integrates with it, and communicates with the terminal server side app via the virtual channel. The integration loads some third party 32-bit drivers, and it is not possible to load a 32-bit dll in a 64-bit process.

Normally it is quite easy to run the 32 bit version of a windows application from the command line, e.g. run window:

C:\Windows\SysWOW64\Notepad.exe

You can tell that the process is 32-bit by checking in task monitor\processes as it will have a *32 next to the filename.

However, the remote desktop client (mstsc.exe) does not want to play ball. It always runs the 64-bit version from C:\Windows\System32\mstsc.exe regardless of how I start it (run window, 32-bit cmd windows etc). I've tried writing a 32-bit C++ program to create it (normally child processes are also 32-bit) but this did not work.

I also tried calling:

Wow64DisableWow64FsRedirection
Wow64RevertWow64FsRedirection

before and after starting mstsc.exe but this did not help either.

Anyone know a way around this?

[Edit]
I've done some further investigation with process monitor, and it seems that the 32-bit version of mstsc does start first, but then this creates a second 64 bit process and the 32 bit versions closes.

Best Answer

Your question is very confused (1). Every executable on the system is compiled either as a 32-bit, or as a 64-bit executable. If you have a 64-bit executable, then it doesn't matter how you invoke it: from a 32-bit command window, from "Run" menu, or from another 32-bit program; it will always run as a 64-bit process.

You can check whether the executable is 32 or 64-bit one by looking for x64 in the output of dumpbin /HEADERS mstsc.exe.

You need to download and install a 32-bit version of mstsc.exe. In fact, I believe mstsc.exe is largely independent of installation, so you might be able to simply copy it from a 32-bit system and just run it.

UPDATE:
eran points out that invoking 32-bit mstsc.exe directly does not solve the problem, because mstsc detects that it is running on a 64-bit system and reinvokes the 64-bit version of itself. I do not know why it does that, or how to stop it from doing that. If you do, please edit this answer.

(1) Microsoft greatly helps this confusion by shipping many executables as both 32 and 64-bit versions, and magically remapping PATHs so one or the other is found; often at apparently the same pathname. But this is just "smoke and mirrors", in reality the pathname is always different.

Related Topic