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?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With