I needed to connect remotely via Remote Desktop to a Windows Server 2012 machine.

I received an rdp file that was configured to use an RD Gateway server:

Remtoe Desktop Connection | RD Gateway Server Settings

However when trying to connect from my Windows 7 laptop (x64) machine, I got the following error message:

The two computers couldn't connect in the amount of time allocated. Try connecting again. If the problem continues, contact your network administrator or technical support.

 

Followed by this message when I tried to connect again:

Your computer can't connect to the remote computer because an error occurred on the remote computer that you want to connect to. Contact your network administrator for assistance.

After some troubleshooting I decided to test the connection from a virtual machine and to my surprise it worked fine there.

Knowing that I was able to connect to other machines with Remote Desktop from my laptop without problems there had to be a difference.

I compared the versions of mstsc.exe and mstscax.dll and noticed that the version of my laptop was newer:

file version 6.2.9200.163986.1.7600.16385

I copied mstsc.exe and mstscax.dll from the virtual machine to my laptop in a separate folder. When starting the copied mstsc.exe I got an error message about missing mui (multi language) files:

The system cannot find the file specified | <LANG_NAME>\mstsc.exe.MUI

To solve this I created a subfolder en-US and copied the files mstsc.exe.mui and mstscax.dll.mui from the virtual machine.

Mstsc now launched but a connection using the specified RDP file yielded yet another error:

You have specified to use a gateway server, however this feature is not supported by your system configuration.

I found the error message string in mstsc.exe.mui with a resource id of 13349:

SNAGHTML3866be

I opened mstsc.exe in Ida Pro and searched for 13349 but no hits. I then searched on 3425 which is the hex value of 13349 and then I got a hit in a function called CContainerWnd::StartConnection:

CContainerWnd::StartConnection

So if IsProxySupportEnabled returns FALSE, this message is displayed. The IsProxySupportEnabled function doesn’t do much, it just loads a DLL named AALibrary:

IsProxySupportEnabled

Clicking on in the code showed some traceoutput that identifies AALibrary  as aaclient.dll:

RegQueryExValue for aaclient.dll failed

I copied over aaclient.dll to the same folder as mstsc.exe and aaclient.dll.mui to the en-US subfolder and finally it worked!

For you convenience I have attached a zipped copy of the mstsc files.

mstsc.exe build 6.1.7600.16385 (46538 downloads )