From - Wed Oct 15 07:39:03 1997 Path: news.mitre.org!blanket.mitre.org!philabs!newsjunkie.ans.net!newsfeeds.ans.net!news-was.dfn.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.internetmci.com!199.0.154.56!ais.net!news.idt.net!psinntp!pubxfer.news.psi.net!usenet From: "Dave Davis" Newsgroups: comp.os.ms-windows.programmer.networks,comp.os.ms-windows.programmer.nt.kernel-mode,microsoft.public.win32.programmer.kernel,microsoft.public.win32.programmer.networks Subject: Re: IOCTLs within NDIS miniport Date: 14 Oct 1997 17:35:31 GMT Organization: General Signal Networks Lines: 72 Message-ID: <01bcd8c8$4d90df10$d0b262c7@dcxsys02> References: <01bcd4f7$6b9b9420$0a00000a@peterg.sj.znet.com> <343E3C96.7BC95D4A@ftp.com> <01bcd7f7$bfde92a0$fbb262c7@dcxsys02> <34438782.9D46AAAF@ftp.com> NNTP-Posting-Host: 199.98.178.208 Mime-Version: 1.0 Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit X-Newsreader: Microsoft Internet News 4.70.1155 Xref: news.mitre.org comp.os.ms-windows.programmer.networks:11091 comp.os.ms-windows.programmer.nt.kernel-mode:4158 > Dave Davis wrote: > > > > > Don't forget that you must create a device of your own in order > > > to receive any IRP. I/O requests to the devices created by NDIS > > > (it does create a device for each miniport it loads) are handled > > > by NDIS itself. The app must open *your* device and then all IOCTL's > > > will eventually get into your IRP_MJ_DEVICE_CONTROL handler. > > > > Wait just a second. > > The MajorFunction [IRP_MJ_DEVICE_CONTROL] is a member driver > > object not device object. Replacing it will send all DeviceIoControl > > requests against a driver's devices to the to the new handler. (i.e. > > You cannot have a different IRP_MJ_DEVICE_CONTROL function for each > > device.) > > That's right. I have no problem with that. Your dispatch routine > gets the device object as a parameter which can be used to process > requests differently based on the device context. Which is pretty much > the same as having different dispatch routines for different devices. Pretty much, but with NDIS there is a critical difference. (see below.) > For example, you can keep the addresses of the actual handlers in > your device extension. > > > You don't have to create a new device in order to send io requests. > > I hook the IRP_MJ_DEVICE_CONTROL function and any io's that do not > > have my CTL_CODE I send to the old handler. (And there are some.) > > The device I open is the NDIS device. (e.x. "NE20003") > > What do you mean "hook the IRP_MJ_DEVICE_CONTROL function"? Modify > someone else's DRIVER_OBJECT? I wouldn't like this kind of solution... No, I don't modify someone else's DRIVER_OBJECT. > I mean, it's pretty good for debugging, testing or stuff like that, > when you know for sure that no one else in the system is using the > same trick. But I wouldn't recommend turning it into a product. > > Imagine this: two drivers X and Y "hook" the same DRIVER_OBJECT. > X loads first, Y loads after X. Then they unload in the same order, > and each of them attempts to restore the original DRIVER_OBJECT. > You get the idea. > > > > > Does anyone have a cleaner solution to this problem? > > > > I don't see any clean solution other than creating your own > device (or writing a protocol which translates IOCTLs into > ndis requests). If you find it let me know :) I still don't see why you feel a new device object is necessary. It may make things pretty, but, the real issue is replacing the IRP_MJ_DEVICE_CONTROL function. Consider the scenario: Lets say we have a NDIS driver NE2000, with a single device NE20003. Also lets create a new device object for the io control interface called NEIOCTL, and replace the IRP_MJ_DEVICE_CONTROL function with a new function, say NEDispatchIoControl. What happens to all the io ctrl requests made with device NEIOCTL? They end up in NEDispatchIoControl and are processed. Now where will requests for device NE20003 goto? (Previously handled by NDIS.) They end up in NEDispatchIoControl and are tossed into the bit bucket. Dave P.S. sorry for previous typos :)