DOS Mode...

Published September 09, 2007
Advertisement
Everyone knows of the message This program cannot be run in MS-DOS mode.

This is a stub program that is embedded by the complier of 32 bit PE executables. It is inside the old MZ header section of the PE file, and is executed if you try to run the program under DOS.

It is possible to change the stub program. This is done using the /STUB option in MSVC++ 2005.

Under Project Properties=>Linker Options=>Command Line, type in:
   /STUB:myprog.exe


...Where myprog.exe is a valid 32 bit PE executable.

Now, MSVC++ will embed myprog.exe as the stub program, instead, so you can do whatever you want...Perhaps display another message like:
   DOS is dead! This game will not work for you, oldie.


This will probably be useless, but who knows.

Perhaps execute a different DOS version of the game, instead?
0 likes 2 comments

Comments

Ravuya
I think that was the genesis of the Portable Executable, actually.

I do remember seeing at least one Origin game use that trick to spell out to you why you had to switch up to a 386.

When they were still making the Alpha and PowerPC versions of NT, I think it was proposed that it could be used for alternate bytecode, but they ended up shipping separate binaries for each.

MacOS had a similar trick when they were moving from 68K to PPC; the "fat" binary wasn't quite the same, though. I think they use the same method for the OS X Universal binaries (i386/IA64/ppc64/ppc32).
September 09, 2007 01:11 PM
johnhattan
Way back in the Windows 3.x and earlier days when you launched Windows manually, you could make the DOS stub launch Windows with your app as the argument "win.exe myapp.exe"

IIRC, there were only a couple of apps that ran "dual mode" and appeared as a Windows and DOS-based app.
September 09, 2007 08:39 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement