DOS Plus v1.2 EXE loader

DOS Plus doesn't have a good record of running DOS programs. Anything compiled with Pacific C, for example, crashes when run under DOS Plus. So does PKZIP.

The reason for this is a defect in the EXE file loader. It assumes that the EXE header is always a multiple of 512 bytes. The programming tools available in 1985 may well have always generated EXEs with headers whose length is a multiple of 512 bytes (DRI's own LINKEXE does, for instance). But there's no rule that insists on it.

With this defect, EXE headers that are less than 512 bytes long are not removed from the EXE file when it was loaded. DOS Plus then jumps to the EXE header rather than the true entry point.

There are various solutions, with differing degrees of effectiveness:

1. A Quick Fix

At 026Ch in the DOS module of DOS Plus is the following code, which is supposed to convert the EXE header size from paragraphs to CP/M records:

026c	mov	dx,10h
026f	mul	dx	;AX = header size in bytes
0271	mov	cx,200h
0274	div	cx	;AX = header size in pages (512 bytes / page)
0276	mov	cx,4	
0279	mul	cx	;AX = header size in 128-byte records
This code can be simplified to:
026c	mov	dx,10h
026f	mul	dx	;AX = header size in bytes
0271	mov	cx,80h
0274	div	cx	;AX = header size in records
0276	nop
0277	nop
0278	nop
0279	nop
027a	nop
To make the change:

Alternatively, patch the bytes into a running system:

*** 8086 Symbolic Instruction Debugger *** Release 3.0
                 All Rights Reserved
Copyright (c) 1983, 84, 85, 88  Digital Research, Inc.

#sw0:80	             ; Look at the INT 20h vector
0000:0080 0703
0000:0082 09E4 .     ; Get the DOS module code segment
#l9e4:26c            ; Check that we found the code
  09E4:026C MOV    DX,0010
  09E4:026F MUL    DX
  09E4:0271 MOV    CX,0200
  09E4:0274 DIV    CX
  09E4:0276 MOV    CX,0004
  09E4:0279 MUL    CX
#a9e4:271            ; Apply our patch
09E4:0271 mov cx,80
09E4:0274 div cx
09E4:0276 nop
09E4:0277 nop
09E4:0278 nop
09E4:0279 nop
09E4:027A nop
09E4:027B .


This patch allows Pacific-compiled programs to run, and others whose headers are 128 or 256 bytes long. However, it isn't a universal fix. PKZIP, for instance, has a 96-byte EXE header.

2. Fixing the EXEs

If we just want one or two EXE files to run under DOS Plus, then it may be possible to produce modified versions with longer EXE headers. It is the only solution which allows an EXE to run on an unpatched installation of DOS Plus. It should be effective in most cases; but EXEs which contain overlays may not be so accommodating.

A program which does this (EXEBODGE) can be downloaded from this site.

3. A TSR or RSX

The fix outlined in (1) above only saves five bytes of code, which is not enough for a full solution to the problem. However a TSR or RSX can be written, which would replace bits of the existing loader with a far call into substitute code in the TSR/RSX. The substitute code will move the newly-loaded EXE to the right place in memory, overwriting any header fragments which were left by the original loader. The memory allocation code must also be altered to allow for the overhead of the header fragments during EXE loading.

A program which does this (EXEFIX) can be downloaded from this site.

4. An XIOS patch

A similar approach to the previous one, but instead of having the fix in a separate program, embed it in the XIOS, for which disassembled source exists. With this solution, we lose the ability to patch an install of the original DOS Plus, but the fix is now performed automatically rather than depending on the user to load a TSR. This has been done in DOSPLUS v1.2-je5.

5. Rewrite the DOS module

The ultimate fix: Disassemble the DOS emulator, make the fixes in its code, reassemble it, and use DPGEN to link it back into the .SYS file.

Return to archive listing