Subject: What's the status of cygwin on NT device drivers
From: David Welch <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Wed, 16 Aug 2000 22:46:57 +0100

On Wed, Aug 16, 2000 at 11:00:40AM -0000, Marc Esipovich wrote:
> 
>  Hi,
> 
> 	I would like very much to avoid using MSVC or similar packages
> to make an NT device driver. paying cygnus is way better than paying MS :)
> 
> 	I've  skimmed through the lists, and found some old (1999) notes
> about cygwin already supporting native PE's, but not __fastcall, what
> has changed since then?
> 
> 	So, who has some updated info for me on building them pesky drivers
> w/ the help of that butt-ugly NT DDK?
> 
> 	It needn't be a comlex driver,  basically hooking some syscalls and
> talking to a userland app. maybe even write a device which emulates /dev
> so no changes will be needed in my Unixified userland code. ;)
> 
> 	I'd also be glad to land a hand to those with things in progress
> concerning this issue.
> 
There are several problems. Firstly gcc probably can't compile the ntddk
headers, you could try pulling an alternative set from the reactos source
but I don't think these are compatible with nt except at the source level
e.g. some constants maybe wrong. If you only need a small set of functions
then you could probably build up your own set of headers from the ddk
ones.

The fastcall problem can be easily worked around by providing assembly
language wrappers for functions which don't have stdcall equivalents.

Drivers need to be built as relocatable dlls. A big problem is that the nt
kernel requires a checksum in the PE header. The algorithm for calculating
this checksum is proprietary, but the implementation in the kernel source
isn't obfuscated (LdrVerifyMappedImageMatchesChecksum in a debugger). Here
some more information http://www.instinct.org/fravia/wi_igno.htm. It such
be relatively easy to reverse-engineer the alogrithm and write a program
to set the checksum, or you can get the correct value by setting a
breakpoint on the routine in the kernel that calculates it.

I've not produced any significant drivers using mingw/cygwin but a 'hello
world' one worked using the above techniques.

--
Want to unsubscribe from this list?
Send a message to [email-masked]