From - Fri Sep 12 10:09:55 1997 Path: news.mitre.org!blanket.mitre.org!nntprelay.mathworks.com!infeed1.internetmci.com!newsfeed.internetmci.com!199.60.229.5!feta.direct.ca!newsfeed.direct.ca!news.he.net!newshub.cts.com!relief.cts.com!not-for-mail From: jkirby@gloryroad.netX (Jamey Kirby) Newsgroups: comp.os.ms-windows.programmer.nt.kernel-mode,microsoft.public.win32.programmer.kernel Subject: Re: ZwXxx at IRQL > PASIVE_LEVEL ? Date: Mon, 01 Sep 1997 06:53:57 GMT Organization: Magnuson, Kirby & Associates, LLC. Lines: 46 Message-ID: <340a658a.42637669@nntp.cts.com> References: <5udb6m$pua@bmerhc5e.bnr.ca> Reply-To: jkirby@gloryroad.netX NNTP-Posting-Host: optional.cts.com X-Newsreader: Forte Free Agent 1.11/32.235 Cache-Post-Path: optional.cts.com!unknown@jkirby.cts.com Xref: news.mitre.org comp.os.ms-windows.programmer.nt.kernel-mode:3184 microsoft.public.win32.programmer.kernel:554 On Sun, 31 Aug 1997 23:03:20 -0400, "Eric Jobidon" wrote: >Hi all, > >I am writing a low-level device driver for NT 4.0 and am having problems >using the ZwXxx set of functions. The DDK tells me that the functions >should be running at IRQL PASIVE_LEVEL (if I understand correctly, this >means they shouldn`t be called at IRQL DISPATCH_LEVEL or DIRQL). My first >question is quite simple: Why? (I wish the answer could be >as simple!) > >My second question relates to the use of these functions in my driver`s >DispatchRoutine. I need to invoke ZwReadFile from within a dispatch routine >and I always get an error message stating that my HANDLE is invalid. On the >other hand, if I try to use the same piece of code in the DriverEntry or >DriverUnLoad functions, everything works perfectly... What is going on? I >tried the same code in a StartIo function but I still get the same >error... >What am I doing wrong? > >The sample source code in the DDK doesn`t seem to cover that situation. The >only hint I got was to start a separate thread to handle those requests in >PASSIVE_LEVEL. Would that solve my problem? if so, why? >Thank you sooooo much! > >Eric > The ZwXxx routines require that you be running in passive level. That is why you are getting the bug check. The second problem relating to the handles is because the process that opened the file isn't the one using the handle. The solution to both of these problems is to use a system thread to process IRPs. While in the system thread, the system process will be the active process. This will guarantee that you are running at passive level and that the file handles will be valid. You must make sure that the file is opened in the context of the system process. Hope this helps. Jamey Kirby Senior Partner Magnuson, Kirby & Associates, LLC. jkirby@gloryroad.netX