Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is "This program cannot be run in DOS mode" text present in .dll files?

Recently I opened a .dll file produced by Visual Studio 9 while compiling a native C++ DLL project and was surprised to see the "This program cannot be run in DOS mode" text near the beginning.

Why have this text in .dll files?

like image 357
sharptooth Avatar asked Apr 05 '10 08:04

sharptooth


People also ask

What does it mean when program cant run in DOS mode?

It's purpose is to display the message "This program cannot be run in DOS mode" on 16-bit real mode operating systems, such as MS-DOS, as to inform the user that the program is not compatible with the oldish system. This means that you're running a Windows nasm on a MS-DOS (virtual) platform.

How do I open a DLL file in CMD?

Once you find the folder, hold the Shift key and right-click the folder to open the command prompt directly in that folder. Type "regsvr32 [DLL name]. dll" and press Enter. This function can add the DLL file to your Windows Registry, helping you access your DLL file.

What is DOS mode on Windows 10?

On a Microsoft Windows computer, DOS mode is a true MS-DOS environment. For example, early versions of Windows, such as Windows 95 allowed the user to exit from Windows and run the computer from MS-DOS. Doing this allowed older programs written before Windows or computers with limited resources to run a program.


2 Answers

A dll is very much like an executable with a different extension. The text you saw is part of the 'standard' executable header on windows. It is (was) used to gracefully abort the attempt to run a windows executable from DOS.

like image 141
lexu Avatar answered Sep 19 '22 20:09

lexu


The Portable Executable format specification states the following:

The MS-DOS stub is a valid application that runs under MS-DOS. It is placed at the front of the EXE image. The linker places a default stub here, which prints out the message “This program cannot be run in DOS mode.” when the image is run in MS-DOS. The user can specify a different stub by using the /STUB linker option.

At location 0x3c, the stub has the file offset to the PE signature. This information enables Windows to properly execute the image file, even though it has an MS-DOS stub. This file offset is placed at location 0x3c during linking.

like image 26
Petr Hudeček Avatar answered Sep 17 '22 20:09

Petr Hudeček