Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Combined .com executable/DOS driver, multi-header drivers (Announce)

posted by ecm Homepage E-mail, Düsseldorf, Germany, 10.08.2010, 18:49

Just in case someone still cares about that:

DOS only checks the offset part, and never will look at the "next device header" field's segment. The offset indeed needs to be -1 to denote the last device header in an actual device chain, or the last device header in a multi-header device driver file. The trick is that (compatible) DOS doesn't care about the values until after the init request is issued to the device. This means you can fill the whole dword with garbage in the assembler and then initialize the first word with -1 (or the (near) pointer to your next header) in your init handler of the strategy or interrupt callback.

The FreeDOS kernel sources that I have examined again just now (2036 or maybe 2038) do handle this correctly, as do my current sources. (Which I wrote after I had examined MS-DOS 6.x and 7.x behaviour.)

The only thing to note on multi-header device drivers additionally is that DOS doesn't care about the segment field for these either. So all headers are in the same segment. (I.e. the first 64 KiB of the executable's image, no matter whether the .COM or .EXE file format is used.)

As for UPX, of course you can't use it on .COM/device driver executables unless it fully supported them. (As it does support .EXE/device driver executables. If it detects them correctly. It requires the whole dword to be initialized with -1 or something.) Even if you were to trick UPX into compressing the executable, it would do so either as .COM or as device driver, making the executable crash if invoked as the other format. This would make patching of the UPX header/decompressor necessary. I solved the problem by including a fake UPX header that reliably makes UPX output an error, i.e. protects the kernel/debugger from well-intentioned users that think UPX can handle everything.

---
l

 

Complete thread:

Back to the forum
Board view  Mix view
22781 Postings in 2123 Threads, 402 registered users (0 online)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum