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!news-peer.sprintlink.net!news-pull.sprintlink.net!news-in-east.sprintlink.net!news.sprintlink.net!Sprint!192.35.44.7!news.crd.ge.com!not-for-mail From: Walt Dixon Newsgroups: comp.os.ms-windows.programmer.nt.kernel-mode Subject: re: disk driver/filter driver holding process resources, re: filter driver puzzle Date: Sat, 06 Dec 1997 18:10:02 -0800 Organization: GE Corporate Research and Development Lines: 100 Message-ID: <348A057A.6FDF@demeter.crd.ge.com> Reply-To: dixon-nospam@demeter.crd.ge.com NNTP-Posting-Host: demeter.crd.ge.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.04Gold (WinNT; I) On Thursday I wrote: (disk driver/filter driver holding process resources) I am developing a driver in which I want to hold on to a process specific resource. In my specific application I am moving data from a dedicated buffer to/from disk at very high data rates. Any application using this driver will always work with the same (big) buffer. I would like to probe and lock this buffer only once. Locking it is easy. How do I know when the application goes away? As a disk driver I do not see close requests. Is there any robust way to insure I find out when an application is going away? It is really bad for an application to exit with pages still locked. and I also wrote: (filter driver puzzle) I'm trying to write a scsi filter driver. Later I will turn this filter driver into a class driver. Each filter driver attaches to one or more physical devices. A request comming into my driver may or may not be modified before being passed down to its attached devices. Here are the questions (1) Does it make any sense for the filter driver to create a symbolic link? (2) Do I need to do anything special to create such a symbolic link? I naively tried to do this. The IoCreateSymbolicLink succeeded. I looked at both nt and win32 name and they were exactly as I had expected. When I use winobj to lookup the link, I find the link is not valid. (the mstools version does not allow me to double click. the version from ntinternals reports the link is invalid). (3) If my filter driver creates a device named Filter0 which is attached to PhysicalDrive1 and PhysicalDrive2, I know that I can open a handle to either of the two physical drives and pass Irps to my filter driver. I presume NT looks at the attached device field in the DeviceObject for PhysicalDrivex and reroutes the packet to my driver. Is there any way of telling which of the PhysicalDrives was opened? Do I need to pass the create request on to the underlying physical devices? There is no file system on these devices. Since these two questions are related and I now have an increased understanding of what is going on, I will attempt to answer my own questions. (1) If I declare my driver to be of type FILE_DEVICE_DISK, I will only see create requests when someone attaches and I won't see close requests. If I declare my driver to be of FILE_DEVICE_UNKNOWN I see open and close requests. I believe that a file opened by the user will always be closed -- if not explicitly then during IoRundown when the process exits. So long as I declare my device type appropriately, I can free any resources. I know there are people out here who know more than me. Please correct me if I am wrong. (2) When I think of a filter driver, I just assume that its device type must be the same as the driver it is attaching to. I now have a counter example of this theory. How much trouble am I getting into here? (3) As I thought about the problem I decided that I really did not want to write a filter driver, I needed an intermediate driver. When I grabbed what I thought was the scsi class driver with an IoGetDeviceObjectPointer, the request was apparently successful. When I tried to call the driver with an IRP_MJ_SCSI request, I got a STATUS_INVALID_DEVICE_REQUEST error. All the InternalDeviceIoControl routine was doing was setting an error in the Iosb and calling IoCompleteRequest. I do not know what driver I attached to. I used \Device\Harddisk[n]\Partition0 in the call to IoGetDeviceObjectByPointer. I know for a fact that the SCSI class driver supports IRP_MJ_SCSI. HOWEVER, if I change the IoGetDeviceObjectByPointer to IoAttachDevice (with appropriate argument changes), I do indeed grab the Scsi class driver. Can anyone explain what is going on? (4) There does not seem to be anything in NT that prevents one from assigning a name to a filter driver. In my case I am really the highest level driver that is going to access the device, but the IoAttachDevice seems to make it a filter driver. (5) The problem I was having with winobj was really dumb. The count for both the Nt and Win32 name included a NULL. Once I corrected the count problem, winobj was happy. Any comments, suggestions, corrections would be appreciated. -- Spam Protection: remove -nospam from "From:", "ReplyTo:", and "email:". Sorry. Walt Dixon email: dixon-nospam@demeter.crd.ge.com us mail: Walt Dixon GE Corp. R&D PO Box 8 Schenectady, NY 12301 voice: 518-387-5798 fax: 518-387-5164 And for you automated email spammers out there, here are the addresses of the current board of the Federal Communications Commission: Chairman Reed Hundt: rhundt@fcc.gov Commissioner James Quello: jquello@fcc.gov Commissioner Susan Ness: sness@fcc.gov Commissioner Rachelle Chong: rchong@fcc.gov