VOGONS


Writing DOS device drivers in C

Topic actions

First post, by Oerg866

User metadata
Rank Newbie
Rank
Newbie

Hello,

I've been collecting some resources for a small project of mine, I wish to write an installable DOS device driver - i.e. something you load from within CONFIG.SYS. Coming from the ARM / m68k world I absolutely despise x86 assembly, moreso after all the reverse engineering projects I did, and I'd rather not deal with that.

I've found a few resources (that are ancient) to write installable device drivers in C, but most of these resources seem to be long gone. The most modern thing I could find were documents referencing Microsoft C 4.0 and Turbo C 1.5 (so late 80s stuff, very early 90s at best). I have no problem using either of them but I don't feel confident enough that they will work on, say, DOS 7.xx.

Any pointers would be appreciated

Best regards,
Eric

Reply 1 of 48, by maxtherabbit

User metadata
Rank l33t
Rank
l33t

Oh man this is a tough hill to climb these days, finding documentation is nearly impossible. I have some resources saved from my work on the dosfdrv that I'll try to dig up and post for you

Reply 2 of 48, by cyclone3d

User metadata
Rank l33t++
Rank
l33t++

One book you can get is:
Writing DOS Device Drivers in C
Phillip M. Adams / Clovis L. Tondo
ISBN 0-13-970864-2

As far as DOS versions, I don't see why older stuff wouldn't work on newer version of DOS. I've never seen an old DOS driver that wouldn't work on a much later version of DOS.

Edit:
What would be extremely nice to find would be the edition of that book which was released in 1999 and updated for DOS 6.x
ISBN-10: 0-13-108622-7 / 0131086227
ISBN-13: 978-0-13-108622-7 / 9780131086227

I have not been able to locate a copy anywhere.

Yamaha YMF modified setupds and drivers
Yamaha XG resource repository - updated November 27, 2018
Yamaha YMF7x4 Guide
AW744L II - YMF744 - AOpen Cobra Sound Card - Install SB-Link Header

Reply 3 of 48, by Oerg866

User metadata
Rank Newbie
Rank
Newbie

Thanks for the infos, I will try to find these books 😀

Looking forward to what you have @maxtherabbit!

EDIT: The German national library in my city (well, I live 20 miles north now) has an edition of this book, I will go there sometime next week and try to get it.

Best,
Eric

Reply 4 of 48, by BloodyCactus

User metadata
Rank Oldbie
Rank
Oldbie

I think the difficult part would be the two entry points, doing that in C. You'd probably have to shim that with assembler, and do it in small memory model so no relocations.

I've written some in a86 + ported them to Nasm later on, and its pretty simple stuff, but in C that might be difficult.

--/\-[ Stu : Bloody Cactus :: http://kråketær.com :: http://mega-tokyo.com ]-/\--

Reply 5 of 48, by AlexZ

User metadata
Rank Member
Rank
Member

16bit real mode x86 assembly wasn't difficult at all, it was taught at university and we did small projects using it. It gets translated into machine code so it's not like you're writing the machine code directly. It's more convenient than writing in something like hiew editor as you can organize code in asm files.

If that book is that rare and it's good it may make sense for you to have the whole book copied.

Pentium III 900E, ECS P6BXT-A+, 384MB RAM, NVIDIA GeForce FX 5600 128MB, Voodoo 2 12MB, 80GB HDD, Yamaha SM718 ISA, 19" AOC 9GlrA
Athlon 64 3400+, MSI K8T Neo V, 1GB RAM, NVIDIA GeForce 7600GT 256MB, 250GB HDD, Sound Blaster Audigy 2 ZS

Reply 6 of 48, by cyclone3d

User metadata
Rank l33t++
Rank
l33t++

The 1990 edition of the book is all over the place. I saw mention of a 1991 edition but didn't look into it.

If the library has the 1999 edition.. or any edition after the 1990 edition, copying / scanning it would be helpful.

Yamaha YMF modified setupds and drivers
Yamaha XG resource repository - updated November 27, 2018
Yamaha YMF7x4 Guide
AW744L II - YMF744 - AOpen Cobra Sound Card - Install SB-Link Header

Reply 9 of 48, by kjliew

User metadata
Rank Oldbie
Rank
Oldbie

That is perfectly possible with 16-bit MSVC 1.52 and MASM 6.11, but you still need basic x86 ASM knowledge to establish the ASM framework that interfaces with DOS while most of work will be done in C functions. You can also search in simtel/garbo ms-dos archives if libraries provide such framework already existed before writing your own. This is the nature of low-level programming in the early days, including Win9x VxD. The VtoolsD (a commercial MS DDK supplement) provides exactly the missing link from Win9x DDK, that is the x86 ASM framework that interfaces with Win9x kernel, for developers to focus on driver's functions in C.

Reply 10 of 48, by BitWrangler

User metadata
Rank l33t
Rank
l33t

Don't know if this gives you any clues in terms of what has to happen when http://archive.retro.co.za/archive/computers/ … NFO/DEVDRIV.ZIP

Dig up that tree though, other low level hardware stuff in that dir, then back to computers there's more tech ref directories.

On the uncreative labs site in the text directories, there's source code of a SCSI driver I think.

Unicorn herding operations are proceeding, but all the totes of hens teeth and barrels of rocking horse poop give them plenty of hiding spots.

Reply 11 of 48, by Caluser2000

User metadata
Rank l33t
Rank
l33t
BitWrangler wrote on 2021-08-16, 02:26:

On the uncreative labs site in the text directories, there's source code of a SCSI driver I think.

Crikey that's a name I haven't heard that name in a wee while. Was one of my favorite haunts.

There's a glitch in the matrix.
A founding member of the 286 appreciation society.
Apparently 32-bit is dead and nobody likes P4s.
Of course, as always, I'm open to correction...😉

Reply 12 of 48, by Predator99

User metadata
Rank Oldbie
Rank
Oldbie

If you are from germany I recommend "PC Intern 2.0" by Michael Tischer. Its very well explained there together with examples. Dont remember if its only assembly or also C.

It depends on what are you planning to to but in many cases a COM TSR can do the same as a SYS device driver. A COM is much easier to program and you can load it at any time.

Reply 14 of 48, by amadeus777999

User metadata
Rank Oldbie
Rank
Oldbie

Found a snippet I downloaded a while ago.

Attachments

Reply 15 of 48, by BloodyCactus

User metadata
Rank Oldbie
Rank
Oldbie
amadeus777999 wrote on 2021-08-16, 19:27:

Found a snippet I downloaded a while ago.

The second edition of that book is good, Advanced MSDOS Programming 2nd Edition. I remember using it.

--/\-[ Stu : Bloody Cactus :: http://kråketær.com :: http://mega-tokyo.com ]-/\--

Reply 16 of 48, by pan069

User metadata
Rank Oldbie
Rank
Oldbie
Oerg866 wrote on 2021-08-15, 19:32:
Thanks for the infos, I will try to find these books :) […]
Show full quote

Thanks for the infos, I will try to find these books 😀

Looking forward to what you have @maxtherabbit!

EDIT: The German national library in my city (well, I live 20 miles north now) has an edition of this book, I will go there sometime next week and try to get it.

Best,
Eric

In the 90's there was a very popular book going around in Europe called "PC Intern". It was originally by a German author called Michael Tischer and was translated into various languages (I still have a Dutch translation sitting here on my bookshelf). It might be worth hunting down a copy of this, it has an incredible amount of information in it, including DOS device drivers. Looking through the ToC, it doesn't seem to have a DOS driver in C examples (only assembler), which is probably more suitable for this kind of thing.

In any case, maybe something to look into.

Reply 17 of 48, by amadeus777999

User metadata
Rank Oldbie
Rank
Oldbie
BloodyCactus wrote on 2021-08-16, 21:27:
amadeus777999 wrote on 2021-08-16, 19:27:

Found a snippet I downloaded a while ago.

The second edition of that book is good, Advanced MSDOS Programming 2nd Edition. I remember using it.

Good to know, I'll see if I can find a used version online.

Reply 18 of 48, by the3dfxdude

User metadata
Rank Member
Rank
Member
amadeus777999 wrote on 2021-08-17, 06:17:
BloodyCactus wrote on 2021-08-16, 21:27:
amadeus777999 wrote on 2021-08-16, 19:27:

Found a snippet I downloaded a while ago.

The second edition of that book is good, Advanced MSDOS Programming 2nd Edition. I remember using it.

Good to know, I'll see if I can find a used version online.

I have the book. It's a deep reference so you can develop anything for DOS, and assumes you know C & ASM. But it doesn't really explain writing device drivers in C, only covers in ASM. It would be a good reference if you want to know how DOS works. I wouldn't fault it if that it isn't really what you are looking for, but I think that some stuff really can only get done in ASM anyway, so you might want to get a reference anyway, and be ready to learn some ASM.

Reply 19 of 48, by hyoenmadan

User metadata
Rank Member
Rank
Member

Really anyone did serious DOS drivers in C, besides some well know brand Antivirus TSRs? Even up to Win98 timeline there were still VxDs from some well known brands fully written in assembler, and these being Display Drivers on top of that. Is hard to imagine DOS device drivers written in anything high language, even if that language is C.

Just curious.