Dos Stub in PE

0x003D0000  4d 5a 90 00 03 00 00 00 04 00 00 00 ff ff 00  MZ…………. // MZ, Mark Zbikowski
0x003D000F  00 b8 00 00 00 00 00 00 00 40 00 00 00 00 00  ………@…..
0x003D001E  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ……………
0x003D002D  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ……………
0x003D003C  e0 00 00 00 0e 1f ba 0e 00 b4 09 cd 21 b8 01  …………!..
0x003D004B  4c cd 21 54 68 69 73 20 70 72 6f 67 72 61 6d  L.!This program
0x003D005A  20 63 61 6e 6e 6f 74 20 62 65 20 72 75 6e 20   cannot be run
0x003D0069  69 6e 20 44 4f 53 20 6d 6f 64 65 2e 0d 0d 0a  in DOS mode….
0x003D0078  24 00 00 00 00 00 00 00 ec 85 5b a1 a8 e4 35  $

The first 40h bytes of the PE Image contains IMAGE_DOS_HEADER, and then Dos Stub Program follows immediately. Try to launch whatever program with DEBUG in cmd. Step through with P command, "This program cannot be run in DOS mode" will be shown.

In Assembly, the accordant instrument is as below:

PUSH    CS              // Push Code Segment onto the stack
POP      DS              // Pop off the Code Segment and save it in DS
MOV     DX,000E       // DX, set the string that will be displayed with INT 21, with function 09
MOV     AH,09
INT      21
MOV    AX,4C01        // Exit the program
INT      21