Sometimes, my windows XP x86 system crashes because my minifilter driver. I
simply called FltWrite in pre-create callback function as follow.
I noticed that the system crashed only when the disk is almost out of space
and there is a coming remote desktop connection. If there is enough disk
space (more than 10M) or there is no coming remote desktop connection, the
system won’t crash.
What do can do to prevent the crash? Is it possible to print some trace info
into a file.
MyPreCreate
{
TraceErrorOutput(SYBDBG_TRACE_ROUTINES);
// must set CompletionContext to NULL if return with
FLT_PREOP_SUCCESS_NO_CALLBACK
*CompletionContext = NULL;
}
VOID TraceErrorOutput()
{
FltWriteFile( gContext.Instance,
gContext.trcFileObject,
NULL,
100*sizeof(WCHAR),
gBuf,
0,
NULL,
NULL,
NULL);
return;
}
Where gBuf has already been allocated by
FltAllocatePoolAlignedWithTag(Instance, NonPagedPool, 100*sizeof(WCHAR),
‘abcd’).
Where the file is opened by calling
FltCreateFile( filterHandle,
Instance,
&trcFileHandle,
SYNCHRONIZE | FILE_APPEND_DATA,
&objectAttributes,
&ioStatusBlock,
(PLARGE_INTEGER) NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_SUPERSEDE,
FILE_NON_DIRECTORY_FILE |
FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0L,
0 );
STACK_TEXT:
b61862c4 ba6a16ad c000007f 89c7c270 8a498100 nt!ExRaiseStatus+0x82
b61862dc ba6fa3c6 89c7c270 c000007f 00000000 Ntfs!NtfsRaiseStatus+0xa0
b6186410 ba6caea4 89c7c270 8a498100 e2c130d0 Ntfs!NtfsAllocateClusters+0x85f
b61864e0 ba69fe5d 89c7c270 89d2f148 e2c130d0 Ntfs!NtfsAddAllocation+0x31e
b61866e0 ba69dc18 89c7c270 89c8c4d0 00000000 Ntfs!NtfsCommonWrite+0x12df
b6186744 804e37f7 8a498020 89c8c4d0 89c8c4d0 Ntfs!NtfsFsdWrite+0xf3
b6186754 ba743e9b 00000000 8a2abf5c 00000000 nt!IopfCallDriver+0x31
b6186778 ba7449e5 b6186798 89bd0188 00000000
fltmgr!FltpLegacyProcessingAfterPreCallbacksCompleted+0x20b
b61867b0 ba7450b2 89bb3a50 89c91fb4 89c91e70
fltmgr!FltPerformSynchronousIo+0xb9
b6186818 b641e72b 89bb3a50 89d2f148 00000000 fltmgr!FltWriteFile+0x286
b6186880 b641e2dc 00000001 00000001 00000000 myfilter!TraceErrorOutput+0xbb
b61876b0 ba741888 89d0b3fc b61876d0 b6187700 myfilter!MyPreCreate+0x1c
b6187710 ba7432a0 00187754 89d0b3a0 89bb44fc
fltmgr!FltpPerformPreCallbacks+0x2d4
b6187724 ba750217 b6187754 ba74e6aa 00000000
fltmgr!FltpPassThroughInternal+0x32
b618773c ba750742 b6187754 89d18f10 89bb43a0 fltmgr!FltpCreateInternal+0x63
b6187770 804e37f7 8a2b8020 89bb4390 89bb4390 fltmgr!FltpCreate+0x258
b6187780 8056c712 8a758c80 8a316304 b6187928 nt!IopfCallDriver+0x31
b6187860 80563fec 8a758c98 00000000 8a316260 nt!IopParseDevice+0xa12
b61878e8 805684da 00000000 b6187928 00000240 nt!ObpLookupObjectName+0x56a
b618793c 8056cbeb 00000000 00000000 d1f85800 nt!ObOpenObjectByName+0xeb
b61879b8 8056ccba b6187b80 00100001 b6187b58 nt!IopCreateFile+0x407
b6187a14 8056cdf0 b6187b80 00100001 b6187b58 nt!IoCreateFile+0x8e
b6187a54 804de7ec b6187b80 00100001 b6187b58 nt!NtCreateFile+0x30
b6187a54 804dc9b1 b6187b80 00100001 b6187b58 nt!KiFastCallEntry+0xf8
b6187af8 bf84fbcf b6187b80 00100001 b6187b58 nt!ZwCreateFile+0x11
b6187dc8 bf84f822 000004e4 b6187e48 000001c0
win32k!ConvertToAndFromWideChar+0x17f
b6187de8 bf84f9a3 000004e4 b6187e48 000001c0
win32k!EngMultiByteToWideChar+0x1b
b6187e18 bf891317 000004e4 20000020 000000e0
win32k!cUnicodeRangesSupported+0x106
b61883ec bf8919dc bf9a933c 00000020 000000ff win32k!pcpComputeGlyphset+0x89
b6188414 bf89191c 004b0000 00003260 b6188460 win32k!bConvertFontRes+0x68
b6188594 bf8914b9 e2bf65f0 004b0000 00003260 win32k!bBmfdLoadFont+0x2e1
b61885dc bf87fe68 00000001 e2bf65e8 e2f27e20 win32k!BmfdLoadFontFileTE+0x3c
b618860c bf880cc3 00000001 e2bf65e8 e2f27e20
win32k!PDEVOBJ::LoadFontFile+0x3a
b6188644 bf880159 b618870c 0000001e e2bf65e8 win32k!vLoadFontFileView+0x94
b61886c0 bf89b81b b618870c 0000001e 00000001
win32k!PUBLIC_PFTOBJ::bLoadFonts+0x1da
b618891c bf9aeb71 e2b34008 b6188944 00000002
win32k!PUBLIC_PFTOBJ::bLoadAFont+0x77
b6188af0 bf9aeb20 e2b34008 00000001 0000000d
win32k!bInitOneStockFontInternal+0x42
b6188b0c bf9ae916 bf9963e4 00000001 0000000d win32k!bInitOneStockFont+0x3f
b6188cf4 bf9ae833 bf996430 bf89c7cc 0015fd98
win32k!bInitStockFontsInternal+0x12a
b6188cfc bf89c7cc 0015fd98 bf9af0da 00000000 win32k!bInitStockFonts+0xa
b6188d48 bf89c65d b6188d64 804de7ec 00050000 win32k!InitializeGreCSRSS+0x144
b6188d50 804de7ec 00050000 00000058 0000005c win32k!NtUserInitialize+0x62
b6188d50 7c90e4f4 00050000 00000058 0000005c nt!KiFastCallEntry+0xf8
0015fd80 75b686df 75b68669 00050000 00000058 ntdll!KiFastSystemCallRet
0015fdb0 75b43472 00000000 00000000 0016273d winsrv!NtUserInitialize+0xc
0015fe20 75b4301b 0016271a 00162721 00000003 CSRSRV!CsrLoadServerDll+0x1a0
0015ff74 75b430f3 0000000a 00162438 7c90dc80
CSRSRV!CsrParseServerCommandLine+0x2d6
0015ff88 4a68115d 0000000a 00162438 00000005
CSRSRV!CsrServerInitialization+0x95
0015ffa8 4a6818d7 0000000a 00162438 00162464 csrss!main+0x4f
0015fff4 00000000 7ffdd000 000000c8 000001f1 csrss!NtProcessStartup+0x1d2