views:

1645

answers:

4

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.

+2  A: 

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.

Employed Russian
There are two versions of mstsc.exe installed. A 32-bit version in C:\Windows\SysWOW64\mstsc.exe and 64-bit in C:\Windows\System32\mstsc.exe.I tried copying the version from SysWOW64 to my development machine and did a dumpbin /headers and confirm that it is 32 bit.
John Sibly
You're wrong. The OP's report is correct. What happens is that SysWOW64 does contain the 32 bit version of mstsc, which is the one he's running. However, once run the 32 bit mstsc just launches the 64 bit mstsc (from System32) and shuts itself down. This can be easily observed using ProcMon or so. Why does it work that way I don't know, nor do I know how to prevent this weird behavior...
eran
("You're wrong" refers to Employed Russian, of course. I wrote the comment without noticing the OP has commented a few minutes earlier)
eran
No, I am not wrong: the original question *is* confused, and there isn't a single statement in my answer that is incorrect. However, as you correctly point out, my suggestion of installing 32-bit mstsc.exe *is* unhelpful and doesn't solve the problem. I'll update my answer shortly.
Employed Russian
Thanks for the answer Employed Russian (+1), you clearly understand the issue I'm having. I'll make the question community wiki-so feel free to clarify it.
John Sibly
A: 

Have you tried an old version (say, from Windows 2000) yet?

Joshua
Yes I've tried copying over the version from 32 bit XP.Running it starts the 32 bit version (*32 next to name in task monitor) but an error message pops up:The system cannot find the file specified.C:\WinXP32\<LANG_NAME>\mstsc.exe.MUIIf I copy over a version of this .MUI file and run again, it starts up but it leaves only the 64 bit version running
John Sibly
Which is why I referred you to Windows 2000, for which there is no 64 bit version and so won't have the elevate to 64 bit check.
Joshua
MSTSC version 5.1 (from XP pre SP3) and 5.2 (from server 2003) works fine. Version 6.0 (from XP SP3) starts 64-bit process.
Sergius
A: 

Come to think of it, hooking IsWow64Process() to return 0 might work.

Joshua