Why is "This program cannot be started in DOS mode" present in DLL files?

I recently opened a DLL file created by Visual Studio 9 when compiling my own C ++ DLL project, and was surprised to see the text "This program cannot be started in DOS mode" at the beginning.

Why is this text needed in DLL files?

+7
windows visual-c ++
source share
3 answers

A DLL is very similar to an executable with a different extension. The text you saw is part of the standard executable header in windows. It (was) used to gracefully stop trying to run an executable from DOS.

+7
source share

The Portable Executable format specification states the following:

The MS-DOS stub is a valid application that runs under MS-DOS. This is a front-facing EXE image. The compiler places a default stub here, which prints the message "This program cannot be started in DOS mode" when the image is launched in MS-DOS. The user can specify another stub using the / STUB linker option.

At 0x3c, the stub has a file offset to the PE signature. This information allows Windows to execute the image file correctly, although it has an MS-DOS stub. This file offset is placed at 0x3c during linking.

+3
source share

Win32 programs launched from DOS mode (i.e. one user, without graphics) print this text. DLLs also probably print this message if you try to use them without starting Windows.

+1
source share

All Articles