MS-Dos LogoToday I troubleshooted an old DOS application that needed to run on a 32 bit Citrix XenApp Server. The last time I saw an actual DOS application in a production environment must be years ago.

When starting the application, the WOW subsystem (NTVDM) crashed with the message: “NTVM encountered a hard error.”:

NTVDM encoutered a hard error

After spending some time troubleshooting I remembered a similar issue from a few years ago where a DOS application worked fine from the Console but refused to work from an RDP or ICA session.

And indeed the application works perfectly when run from the Console but not from a Console session. I noticed that the application switched to full screen mode after it was launched (even when I set it to Windowed mode) and presumably this is why ntvdm errors: full-screen mode is disallowed for DOS apps in RDP (and ICA) sessions as documented in Q192190.

I looked for a way to force the application to run in windowed mode but I was unable to find such a solution. So I decided to test the application in DOSBox, an x86 PC emulator.

And that worked perfectly, no changes were needed at all to make the application run.

As an added bonus, DOSBox takes care of typical issues with DOS applications running on Citrix XenApp such as keyboard polling and 100% cpu usage.

I was even more impressed that the application runs fine with DOSBox on my Windows 7 64 bit machine!

There is one thing I didn’t like though, DOSBox always shows a Splashscreen that fades in and out:

image

This is typically something that is not desirable on a XenApp (or RDS) environment because it causes many unnecessary screen updates. This may be a non issue on a fast LAN but on a slower WAN or high latency connection it may matter. Do how do we get rid of it?

There is no commandline argument or config setting that disables the splash so I figured that my only option would be to compile the DOSBox source and leave out the splash screen.

So I downloaded the source files from the sourceforge project page and launched Visual Studio 2010.

The Splashscreen is in sdlmain.cpp but I noticed this comment:

This presented me with a dilemma: I really think the creators deserve their credit but at the same time I want to get rid of the splash.

So I decided to change the code in a way that the Splash screen is shown when run from the Console but not when run from an RDP or ICA session. This change was very easy, I surrounded the Splash screen code with a conditional statement:

In order to compile the code with Visual Studio I followed the Building DOSBox with Visual C 2008 Express article from the Wiki.

Below you will find two downloads:

  • A binary package, containing my compiled DOSBox.exe and it’s dependancies.
  • A source code package, containing the modified source and the SDL Development Libraries. The modified source is licensed under the GNU GPL license.

If you are going to use DOSBox I highly encourage you to make a donation to Support the DOSBox project.

 

A few other causes for the “NTVM encountered a hard error” message may be:

  • The %TEMP% or %TMP% variable point to a directory that is not in a short (8.3) format. See also CTX110996.
  • Error message when you run a 16-bit program in Windows Server 2003: "NTVDM has encountered a hard error” (Hotfix KB937932).
  • Check that HKLM\System\CurrentControlSet\Control\WOW\DisallowedPolicyDefault is set to 0
  • Check that HKLM\SYSTEM\CurrentControlSet\Control\VirtualDeviceDrivers\VDD doesn’t contain non existing files.