Windows: How to make programs think they're not running in a terminal server session?

I am using the program "SoftXPand 2011 Duo" by Miniframe on my Windows 7 PC. It makes two workstations out of one computer. It uses the terminal services built into Windows to create the additional session. I use two screens, two keyboards and two mice to create this "illusion" of two computers. It works quite well and I can even play two different 3D games on the two screens attached to this single machine (using a Radeon HD5770 and a Core i5 2500k with 8 Gbytes RAM).

There are a few downsides to this. I just found about one that is hidden on the first look. The sessions you are in (even on the first workstation) will identify as a terminal server session! Now some programs will run with limited effects (graphical), and some won't run at all.

This also resulted in some games not running at all. They just say "Cannot be run in a terminal server session" and exit. I have already proven that top modern games (DirectX 10, 11) run just as good as on the same machine without SoftXPand, so this is a pretty artificial limitation!

So, can I somehow hack my current session so it doesn't look like a terminal server session anymore? I. E.

#include <windows.h>
#pragma comment(lib, "user32.lib")

BOOL IsRemoteSession(void)
{
   return GetSystemMetrics( SM_REMOTESESSION );
}

Will return FALSE? (Not a programming question! Just an example how programs detect if they're in a terminal server session!)


There are several ways for an application to check whether it is running in a Terminal Server session. Some of them you might hack, as below :

  1. Registry : HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\TSAppCompat.
    This key is missing in a normal session on my desktop.
    You might try to delete it, if you can.
  2. SESSIONNAME environment variable values : Console / "RDP#" / (empty).
    You may try to run your game from the Command Prompt (cmd) after doing
    SET SESSIONNAME=Console (my desktop value) or SET SESSIONNAME= (empty).
    To find out its current value, enter SET SESSIONNAME before changing anything.
  3. The system calls GetSystemMetrics(SM_REMOTESESSION) and GetVersionEx (OSVERSIONINFOEX.wSuiteMask) return the execution context.
    Not much you can do against this one, except writing a system-hook for it.
    If interested see this codeproject.com article : API hooking revealed.