Skip to content

Commit eb66956

Browse files
committed
header.asm: fix crash from DOS DS re-init after INSTALL= sharer (imported)
imported from: https://hg.pushbx.org/ecm/edrdos/rev/6c174e5361fb Reference: #139 === In EDR-DOS, the DOS DS is initialised at a high address [1] in the Low Memory Area and later relocated either to the start of available memory or to the UMA. This relocation happens after INSTALL= time but before INSTALLLAST= time. The dos_init pointer is advanced by 3 bytes [2] and then later it is called to re-init the DOS DS after the relocation [3]. In a retrocomputing stackexchange comment [4] I noticed that lDOS's DOSREINIT function [5] should take care to relocate SFT references. (In lDOS / MS-DOS / FreeDOS, the first 5 SFT entries live at DOSDATA:00CCh. In EDR-DOS due to the SFT layout extension, only 3 entries live there.) Specifically, if the sharer is installed using INSTALL= then in the sharer and within SFTs, pointers to the first 5 SFTs could exist at the time DOSREINIT is called to relocate the DOS DS. In EDR-DOS, the re-init seems to be done by jumping to the second DOS entrypoint [6] called "PCMODE Re Init Entry". This branches to the "pcmode_init2" function [7]. Much like current lDOS, this does not relocate references to the SFTs. Now here's the kicker: it re-initialises the sharer jump table [8] -- without regard to what it contains. So if you install a (compatible) sharer using INSTALL=, it seems like its entry pointers will be corrupted here because this code doesn't check that the pointers still point into the DOS DS. lDOS doesn't have this problem because its sharer jump table's [9] default entries point into the DOSENTRY segment where they relocate to the DOSCODE segment [10]. So DOSREINIT never has to relocate the sharer table contents, nor does anyone else have to. Homework: Does EDR-DOS indeed crash if the DR-DOS sharer is installed using INSTALL= ? === Installing https://pushbx.org/ecm/download/edrdos/share.zip (file from the defunct DR-DOS/OpenDOS Enhancement Project [11]) using INSTALL= does indeed crash current lDOS flavour EDR-DOS, whereas using INSTALLLAST= or running it from the command prompt don't crash. [1]: https://hg.pushbx.org/ecm/edrdos/file/a43d98646dad/drbio/biosinit.nas#l481 [2]: https://hg.pushbx.org/ecm/edrdos/file/a43d98646dad/drbio/biosinit.nas#l512 [3]: https://hg.pushbx.org/ecm/edrdos/file/a43d98646dad/drbio/biosinit.nas#l919 [4]: https://retrocomputing.stackexchange.com/questions/31384/whats-the-86-dos-system-with-the-smallest-low-memory-area-footprint#comment113902_31385 [5]: https://hg.pushbx.org/ecm/msdos4/file/108036fb9c72/src/DOS/msinit.nas#l272 [6]: https://hg.pushbx.org/ecm/edrdos/file/a43d98646dad/drdos/header.nas#l113 [7]: https://hg.pushbx.org/ecm/edrdos/file/a43d98646dad/drdos/header.nas#l1557 [8]: https://hg.pushbx.org/ecm/edrdos/file/a43d98646dad/drdos/header.nas#l1601 [9]: https://hg.pushbx.org/ecm/msdos4/file/108036fb9c72/src/DOS/msconst.nas#l169 [10]: https://hg.pushbx.org/ecm/msdos4/file/108036fb9c72/src/BIOS/entry.asm#l198 [11]: http://web.archive.org/web/20111218020655/http://drdosprojects.de/
1 parent aaf2359 commit eb66956

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

drdos/header.asm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,7 @@ pcmode_init2:
15581558

15591559
; add ds:vxdName,dl ; fixup drive letter
15601560
mov ds:word ptr buf_ptr+2,ds
1561+
mov dx,ds:word ptr file_ptr+2 ; get old DOS DS
15611562
mov ds:word ptr file_ptr+2,ds
15621563
mov ds:word ptr fcb_ptr+2,ds
15631564
mov ax,ds:word ptr fcb_ptr
@@ -1590,7 +1591,12 @@ stubs_loop2:
15901591
mov di,offset share_stub ; fixup the SHARE entries
15911592
mov cx,NUM_SHARE_STUB_ENTRIES
15921593
share_loop2:
1593-
add di,WORD ; skip the offset
1594+
scasw ; skip the offset (di += 2)
1595+
cmp dx, es:[di] ; still points into old DOS DS ?
1596+
je share_replace ; yes -->
1597+
scasw ; skip this segment entry (di += 2)
1598+
db 0A8h ; test al, imm8 (skip stosw)
1599+
share_replace:
15941600
stosw ; fixup segment
15951601
loop share_loop2
15961602
; mov cx,0

0 commit comments

Comments
 (0)