Is dual mode possible?

A bit of history ... I have 3 systems that I spend time on, DOS 6.22 system, Windows 95 system and modern Windows 7 (64-bit) system. When I upgraded to Win7-64, some of my favorite command line utilities stopped working, so I decided to rewrite them myself. The only 2 compilers I have are Borland Turbo C ++ 3.0 and Visual Studio 2008, and they worked great for creating 2 versions, 16-bit DOS, and 32-bit Windows 7 (maybe I could build 64 too -bit version.) A problem occurred with my Win95 system. The DOS version works fine there, but since I spent time supporting LFN in the Win7 build, I wanted it with my Win95 system. So, after many studies, I found and purchased Visual Studio 6 (the latter with Win95 support, according towhat I investigated) copied the code (I had to rewrite the sections, of course), and it compiled just fine and works :)

The problem arose the next time I had to boot my Win95 system in DOS mode. The program stopped working (of course) because Win95 was not loaded. I really do not want to have 2 copies of the installed program (2 different file names are required), so I was hoping there was a way to link the 2 versions together into one file. If I executed it in DOS, instead of saying that it requires windows, it just goes to the DOS section of the program. Thus, it would be the only program with LFN support when loading Win95 and without loading Win95. Since the Win95 version also works fine in Win7-64, it will probably also create a single version that will work on all three systems (which will be an added bonus.)

I did a few searches on the Internet and did not find anything suitable for what I am looking for. So I have no idea if this is possible. I may have to get another compiler, but given how old it should be, I could probably afford it. My searches on the Internet have led to information that makes me believe that it should be possible. It just needs a different exe header than one of the Windows compilers. You may need to overwrite the DOS version for the 32-bit version and use the DOS extender (for protected mode, if I cannot find a way to include it in the file itself.) This would be acceptable (although not ideal). I would prefer to have 16-bit code in the DOS partition and 32-bit code in the Windows partition (for greater compatibility).

- - ? , .

+4
3

Visual Studio 6 /STUB , DOS .

VS6, , " ".

+2

, Windows 7, Win95 (EXE) - "", DOS , - Windows . DOS , " Windows" . , .

, , DOS 6.22 (, "sed" ), , , (, "sedx" )), "" .

+3

, - /stub Linker, Windows. , .... -, , , , .

, DOS 40 . , "DO" (Borland Turbo ++ ), , , /. BTW - Visual C 1.52c ( Visual C, DOS), , Open WatCom.

, , - , , , , . Open WatCom ( "Hello World" ) Windows, exe (Borland created,) . Open WatCom . Hex Editor , , , "stub.exe" ( Windows). Hex Editor, PE . DOS exe, . Windows . , :)

FYI - , Windows PE.

0 (, 1.) , Hex Editors ( ) .

2 3, DOS - . 2 , 3 - . , , 0 511 (0 - 1ff ). 0 , 512 (200 ) .

4 5 ( /), 512 (200 ) DOS. . , , 512 (200 hex), 2-3, DOS. 0, 1, , 0 - " " stub exe.

offset 60-61 (hex 3C-3D) PE ( Portable Executable) (, Windows). ( ,) DOS . , 0 ( PE .) , " DOS".

, : WatCom http://www.openwatcom.org/index.php/Main_Page    http://www.virtualobjectives.com.au/utilitiesprogs/partcopy.htm

I do not know where to find the Hex Editor that I used. I used CEdit, a DOS program that I really liked, but could not find on the network. You will have to use DOSBox with it, since Win7 will not start it. There are probably other compilers that do the same, and probably a bunch of partial file copiers. These are the tools that I used.

+1
source

Source: https://habr.com/ru/post/1535838/


All Articles