Copyright 1984 by ABComputing ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º A Bug in the DOS 2.0 Program Loader º º º º by º º º º Richard Levaro º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Introduction ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ One of the most powerful features of DOS 2.0 is the ability to access the program loader via a DOS function call (4B). Using the DOS loader is relatively easy from Assembly Language, but is more difficult from high level languages like Pascal and C. Some of the newer versions of C contain function calls which make it easy to implement DOS function calls, and there are utility packages for Pascal and C on the market which can do this as well. Moreover, the "infamous" SHELL command from BASIC uses the DOS loader too. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Unmasking the Demon ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Unfortunately, the 2.0 version of the loader has a bug. Specifically, DOS assumes that the current value of the DS register points to the Program Segment Prefix. This assumption is correct for COM files, and for some EXE files, but is never true for Pascal or C EXE files. Because DOS uses the reserved area in the Program Segment Prefix for a scratch area, the net result is that part of the program data segment is overwritten. In a C program, this problem can be avoided by reserving low memory in the data segment (alter the initiator program whose source is provided in most C compilers), but it is not possible in Pascal because low memory is used by the heap. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Conclusion ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ DOS 2.0 can be patched so that DOS saves the data segment and sets the DS register to point to the correct area. To effect this correction, use the batch file patch2.bat (on this diskette ) to patch COMMAND.COM. With the patched version of COMMAND.COM, the BASICA SHELL command will perform correctly. This bug has been fixed in DOS 2.1. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ File Name: ÛÛ dos2.txt ÛÛ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ rticular, we learn how assembly la