PE File MS-DOS Stub

The MS-DOS stub is a small section of code that, like the DOS Header, originates from the days of MS-DOS (Microsoft Disk Operating System). It serves as a relic of the past and is included for historical reasons and compatibility.

If you try to open a PE file (such as an executable or DLL) in MS-DOS, you will see an error message that is defined in the DOS Stub. The default value is “This program cannot be run in DOS mode.” However this can be changed.

The purpose of the MS-DOS stub is to provide helpful information and a recognizable message to users attempting to run the file in an DOS environment. MS-DOS is a text-based operating system that predates Windows and doesn’t support the Windows GUI or multitasking capabilities. When a user tries to run a Windows PE file in MS-DOS, the stub displays this message to inform them that the program isn’t compatible with MS-DOS.

Once Windows became the dominant operating system, the MS-DOS stub became less relevant. However it is still included in PE files for backward compatibility and as a placeholder. When you run a PE file in a modern Windows environment, the operating system ignores the MS-DOS stub and directly executes the Windows code contained within the PE file.

Scroll to Top