This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: File operations on a Windows Driver (character device)


Alessio Faina writes:
> I've got the kernelspace part on github (
> https://github.com/PicMelter/uniioShd.git ).
> It consists of sys (the kernel module), testExe (loads/unloads on the
> fly the module
> in the kernel) and secondExe that just interact with the first
> executable and the kernel
> module if it is loaded. With the buildAll.bat if the WDK7.1 is
> present, all the applications
> are builded automatically.
> There is a Cyg.c that represent my effort to connect to the module,
> sending an ioctl and doing
> an mmap.
> 
> I think that, even if it's a semplification of the program I'm
> porting, this little project
> is very close to what I'm trying to do with the main project.
> 
> As I read somewhere else, cygwin doesn't support custom ioctl on
> custom modules, have I
> understood well? This may explain why I'm never able to send any ioctl
> to my module.
> 
> For the mmap part, well, I've tried to follow with gdb what Cygwin is
> doing but II must admit
> that at some point I just lose track of what it's doing.
> 
> If it's too messy, I can polish the code a little bit; consider that
> it's the environment where I'm
> always doing tests so rarely I have the time to clean the code...

First, a belated welcome to the Cygwin mailing list.  Second, may I ask that
you please follow the list's posting conventions?  That means...

No <https://cygwin.com/acronyms/#TOFU>.
And also <https://cygwin.com/acronyms/#PCYMTNQREAIYR>.
Thanks!

I looked at your GitHub code.  I'm not at all experienced with Windows
kernel interfacing though.  Are you saying that that Windows native code
works properly for you?  If it doesn't, we're not likely able to help (and
it's off-topic for this list).

If it works, then you have two options.  You are trying the first option,
which is to recode your test program for Cygwin line-by-line.  You're using
Cygwin ioctl() and mmap().  I looked at the Cygwin source for its ioctl()
and found that it's not likely to work for you.  If I'm reading it
correctly, it only supports some of the TCxxx terminal control ioctls. 
That's a show-stopper, so I didn't even check whether your use of mmap()
could work.

The second option you could try, is this:  Compile your existing Windows
native test program with gcc, thus making it a Cygwin program that calls
Windows syscalls.  Cygwin doesn't prevent use of Windows syscalls.  You
don't want to overdo it and collide with Cygwin's own internals, but
localized Windows syscalls can be OK.  There's a <windows.h> in the Cygwin
distribution; it's in /usr/include/w32api.  You may have minor issues
compiling and linking but those can be asked about here and more folks will
have insight on them.
HTH,

..mark


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]