Hello,
I’ve been working on a file system filter. The filter has been
running fairly well under NT4. However, the other day, I decided to
*finally* run it on Win2k, and immediately I started having problems. The
most persistent problem is an intermittent ASSERT from the io manager which
quickly resolved into a system bugcheck. It looks (to my inexperienced
eyes) that FASTFAT is completing an IRP with STATUS_PENDING and then
competing the IRP again from a system worker thread. I suspect my filter
driver is the cause of this errant behavior, but I don’t know what I am
doing wrong.
First, let me explain an assumption I made long ago: I assumed that
in the dispatch handler for an IRP_MJ_CREATE request, it would be ok for me
to try to open the target of the create in the dispatch handler:
CreateDispatchHandler(dev, irp)
{
-if certain access rights have been requested:
-figure out the targe file name
–ZwCreate(TargetFileName) (recurses back through
me, but, because of access requested, I just pass it through)
-if the file already exists (open succeeded)
-reference the handle
-query the fsd for information on this file
-derefererence file
-close handle
-pass IRP through to file system
}
It seems to be this recursive create behavior which is freaking out
Win2K (note is seemed to work fine on NT4). Am I doing something completely
stupid here?
Anyways, *most* of the time, everything works fine in Win2K.
However, *sometimes* I get an assertion, and then a crash. Most of the
time, the assertion happends right after logon, if the system sits idle for
a few seconds. It seems to occur most often as the system is unloading some
other drivers. Here is the ASSERTION followed by a stack dump ( I’ve
annotated the stack dump with **jts comments:
440.600p> Cairole: Unbalanced call to CoInitialize for thread 600
'swmidi: Entering PnpDriverUnload
****** Unloaded driver (swmidi)
Module Unload: SWMIDI.SYS
****** Unloaded driver (DMusic)
Module Unload: DMUSIC.SYS
Module Load: C:\WINNT\system32\NTMSDBA.DLL (symbol loading deferred)
*** Assertion failed: Irp->IoStatus.Status != STATUS_PENDING
*** Source File: D:\nt\private\ntos\io\iosubs.c, line 3297
Break, Ignore, Terminate Process or Terminate Thread (bipt)? b
Execute ‘!cxr BC098390’ to dump context
Hard coded breakpoint hit
kv
ffffffffbc098384 ffffffff804a35df NT!DbgBreakPoint (FPO: [0,0,0])
ffffffffbc098660 ffffffff804249cb NT!RtlAssert+0x9a (EBP)
ffffffffbc098694 ffffffffbfe731f0 NT!@IopfCompleteRequest@8+0x85 (EBP)
ffffffffbc0986a0 ffffffffbfe78b4c FASTFAT!FatCompleteRequest_Real+0x64
(EBP)
ffffffffbc09870c ffffffffbfe787c2 FASTFAT!FatCommonQueryInformation+0x2a0
(EBP)
ffffffffbc098750 ffffffff80424606 FASTFAT!FatFsdQueryInformation+0x5a
(EBP)
ffffffffbc098768 ffffffffed28a1bf NT!@IopfCallDriver@8+0x4f (FPO: [0,0,3])
ffffffffbc0987c0 ffffffffed289020
QMFILTER!QmGetOpenFileInformation+0x163(0x81437748, 0x818546A0, 0x00000005,
0xBC0987EC, 0x00000018) (EBP)
**jts - QmGetOpenFileInformation sends an IRP_MJ_QUERY_INFORMATION to the
file system driver. Here I query for FileStandardInformation.
ffffffffbc09886c ffffffffed288872
QMFILTER!NcAddFileToCacheInCreateDispatch+0x246(0x81853C00, 0x81402548,
0xBC098894) (EBP)
**jts - here, I call a function which adds a record to a RtlGenericTable for
the file (the record includes the file’s full name, its size, possibly its
owner (if the file already exists). I’ve acquired a kernel mutext in the
dispatch routine to synchronize access to the table. Also in this function,
I call ZwCreateFile to attempt to open the target of the original open.
ffffffffbc0988f4 ffffffff80424606 QMFILTER!QmCreate+0x145(0x81853C00,
0x81402548) (EBP)
**jts - QmCreate is my create dispatch routine. If certain conditions are
met (certain access rights are requested) I try to ascertain some
information about the file. I do this by acquiring a kernel mutex and then
calling a function (NcAddFileToCacheInCreateDispatch - see above).
ffffffffbc09890c ffffffff8054106f NT!@IopfCallDriver@8+0x4f (FPO: [0,0,3])
ffffffffbc098a8c ffffffff804967fe NT!IopParseDevice+0xa52 (EBP)
ffffffffbc098afc ffffffff8056ceb1 NT!ObpLookupObjectName+0x5f8 (EBP)
ffffffffbc098c0c ffffffff80510351 NT!ObOpenObjectByName+0x119 (EBP)
ffffffffbc098ce0 ffffffff8051c4b3 NT!IoCreateFile+0x425 (EBP)
ffffffffbc098d24 ffffffff804b19ba NT!NtCreateFile+0x61 (EBP)
ffffffffbc098d24 0000000077f7851b NT!KiSystemService+0x10a (FPO: [0,3]
TrapFrame @ bc098d64)
000000000573f578 0000000077e6ec35 NTDLL!ZwCreateFile+0xb (FPO: [11,0,0])
000000000573f614 0000000075bfff2c KERNEL32!CreateFileW+0x343 (EBP)
000000000573f640 0000000075c00050
NTMSDBA!?xxxxx@NtmsDbFile@@UAEKK@Z+0x2a (EBP)
000000000573f650 0000000075c068eb
NTMSDBA!?xxxxx@NtmsDbFile@@UAEKK@Z+0x14 (EBP)
000000000573f6a4 0000000075c009f2
NTMSDBA!?xxxxx@NtmsDbRegistration@@QAEKAAVNtmsDbRecordType@@PBD@Z+0x31
(EBP)
000000000573f6bc 0000000075bfe06f
NTMSDBA!?xxxxx@NtmsDatabase@@QAEKPBDAAVNtmsDbRecordType@@@Z+0x2
2 (EBP)
000000000573f904 0000000075bfdf77
NTMSDBA!?xxxxx@NtmsDbObjTypeDef@@QAEXXZ+0x2d (EBP)
000000000573f90c 0000000075bfa23d
NTMSDBA!?xxxxx@NtmsDbDataCtxt@@IAEXXZ+0x19 (FPO: [0,0,1])
000000000573f91c 0000000075bb0856
NTMSDBA!??0NtmsDbDataCtxt@@xxxxx@PBD0H@Z+0x2d (EBP)
000000000573f9e0 0000000075b7db04
NTMSSVC!?LmConfigure@@YGKPAGAAJPAVDeviceInfo@@@Z+0x22 (EBP)
000000000573ff84 0000000075b743ed NTMSSVC!?LmInitialize@@YGKXZ+0x11c (EBP)
000000000573ffb4 0000000077e5d4a3 NTMSSVC!?LmInitStart@@YGKPAX@Z+0x4f
(EBP)
000000000573ffec 0000000000000000 KERNEL32!BaseThreadStart+0x52 (EBP)
If I ignore this assertion, I get a second assertion:
*** Assertion failed: IrpContext->NodeTypeCode == FAT_NTC_IRP_CONTEXT
*** Source File: D:\nt\private\ntos\fastfat\strucsup.c, line 1986
Break, Ignore, Terminate Process or Terminate Thread (bipt)? b
Execute ‘!cxr ED43F974’ to dump context
Hard coded breakpoint hit
kv
ffffffffed43f968 ffffffff804a35df NT!DbgBreakPoint (FPO: [0,0,0])
ffffffffed43fc44 ffffffffbfe71f9c NT!RtlAssert+0x9a (EBP)
ffffffffed43fc64 ffffffffbfe731c4 FASTFAT!FatDeleteIrpContext_Real+0x28
(EBP)
ffffffffed43fc74 ffffffffbfe78b4c FASTFAT!FatCompleteRequest_Real+0x38
(EBP)
ffffffffed43fce0 ffffffffbfe966a6 FASTFAT!FatCommonQueryInformation+0x2a0
(EBP)
ffffffffed43fd40 ffffffff8041beae FASTFAT!FatFspDispatch+0x10b (EBP)
ffffffffed43fda8 ffffffff8049d5a2 NT!ExpWorkerThread+0x106 (EBP)
ffffffffed43fddc ffffffff804b70aa NT!PspSystemThreadStartup+0x54 (EBP)
0000000000000000 0000000000000000 NT!KiThreadStartup+0x16 (No FPO)
If I ignore this assertion, I get a bugcheck:
*** Fatal System Error: 0x00000044
(0x81402288,0x00000CCA,0x00000000,0x00000000)
Hard coded breakpoint hit
kv
ffffffffed43f878 ffffffff80438523 NT!RtlpBreakWithStatusInstruction (FPO:
[1,0,0])
ffffffffed43f8a8 ffffffff80438b01 NT!KiBugCheckDebugBreak+0x31 (EBP)
ffffffffed43fc30 ffffffff80424978 NT!KeBugCheckEx+0x37b (EBP)
ffffffffed43fc68 ffffffffbfe731f0 NT!@IopfCompleteRequest@8+0x32 (EBP)
ffffffffed43fc74 ffffffffbfe78b4c FASTFAT!FatCompleteRequest_Real+0x64
(EBP)
ffffffffed43fce0 ffffffffbfe966a6 FASTFAT!FatCommonQueryInformation+0x2a0
(EBP)
ffffffffed43fd40 ffffffff8041beae FASTFAT!FatFspDispatch+0x10b (EBP)
ffffffffed43fda8 ffffffff8049d5a2 NT!ExpWorkerThread+0x106 (EBP)
ffffffffed43fddc ffffffff804b70aa NT!PspSystemThreadStartup+0x54 (EBP)
0000000000000000 0000000000000000 NT!KiThreadStartup+0x16 (No FPO)
I figure somehow I’ve bolloxed up the file system driver.
Unfortuneately, I haven’t the skill and knowledge to see what I’ve done
wrong. I’m hoping its glaringly obvious to one of you, and you can save me
a lot of time by telling me just what I’ve done wrong!
Thanks,
Joel