I need help!

In my Minifilter PreCreate, I use FltCreateFile to open the file first. General it work right!
When the process system.exe open a file, than FltCreateFile like Lock for ever!
What Can I do? I need help!

you should probably post a stack trace…

just guessing, but kind of sounds like a logic error where you end up with a
cross-lock.

  1. system.exe opens file with exclusive access
  2. filter suspends the operation
  3. FltCreateFile reissues the request (IRP) to the top of the stack
  4. Pre-Create receives new IRP and blocks while waiting for original
    exclusive lock to be released
  5. OS is hung (cross-lock)

I’d start by looking at the sharing flags…

Just a thought…

Good Luck

-----Original Message-----
From: xxxxx@sina.com
Sent: Tuesday, June 21, 2011 4:10 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] I need help!

In my Minifilter PreCreate, I use FltCreateFile to open the file first.
General it work right!
When the process system.exe open a file, than FltCreateFile like Lock for
ever!
What Can I do? I need help!


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Thank you!
I don’t know many WinDBG command, I cann’t get the stack trace.
I will post the related code later on!
Best Regards!

Check one thing in FltCreateFile… The second parameter is ‘Instance’…

The docs state:

Instance [in, optional]

An opaque instance pointer for the minifilter driver instance that the
create request is to be sent to. The instance must be attached to the volume
where the file or directory resides. This parameter is optional and can be
NULL. If this parameter is NULL, the request is sent to the device object at
the top of the file system driver stack for the volume. If it is non-NULL,
the request is sent only to minifilter driver instances that are attached
below the specified instance.

This Parameter isn’t NULL is it?

-----Original Message-----
From: Matt
Sent: Tuesday, June 21, 2011 4:19 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] I need help!

you should probably post a stack trace…

just guessing, but kind of sounds like a logic error where you end up with a
cross-lock.

  1. system.exe opens file with exclusive access
  2. filter suspends the operation
  3. FltCreateFile reissues the request (IRP) to the top of the stack
  4. Pre-Create receives new IRP and blocks while waiting for original
    exclusive lock to be released
  5. OS is hung (cross-lock)

I’d start by looking at the sharing flags…

Just a thought…

Good Luck

-----Original Message-----
From: xxxxx@sina.com
Sent: Tuesday, June 21, 2011 4:10 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] I need help!

In my Minifilter PreCreate, I use FltCreateFile to open the file first.
General it work right!
When the process system.exe open a file, than FltCreateFile like Lock for
ever!
What Can I do? I need help!


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

This Parameter isn’t NULL, I use FltObjects->Instance

Posting the code won’t necessarily help, what people need to see if the call
stack of the hanging thread. I can guarantee you that this will not be the
first hang that you have to debug, so if you’re going to learn to write file
system filters you are going to have to learn how to debug these issues.

You can try:

!stacks 2

To look for threads that might be interesting. Alternatively, if you the
problem open is coming from the System process you can dump the threads in
the system process:

!process 0 7 System

-scott


Scott Noone
Consulting Associate and Chief System Problem Analyst
OSR Open Systems Resources, Inc.
http://www.osronline.com

wrote in message news:xxxxx@ntfsd…

Thank you!
I don’t know many WinDBG command, I cann’t get the stack trace.
I will post the related code later on!
Best Regards!

Matt and Scott Noone:
Thank you!
Here are my code:

FLT_PREOP_CALLBACK_STATUS PreCreate (
__inout PFLT_CALLBACK_DATA Data,
__in PCFLT_RELATED_OBJECTS FltObjects,
__deref_out_opt PVOID *CompletionContext
)
{
PFLT_FILE_NAME_INFORMATION pfNameInfo = NULL ;
NTSTATUS status = STATUS_SUCCESS;
OBJECT_ATTRIBUTES ob ;
IO_STATUS_BLOCK IoStatus;
HANDLE hFile = NULL ;

//PFLT_FILE_NAME_INFORMATION pfNameInfo = NULL ;
try
{
//
// system.exe processID == 4
//
if((!Data)
|| (!FltObjects->FileObject)
|| (0 == Data->Iopb->TargetFileObject->FileName.Length))
leave;
if ((HANDLE)4 == PsGetCurrentProcessId())
{
KdPrint((“0: System.exe createfile!\n”));
status = FltGetFileNameInformation(Data,
FLT_FILE_NAME_OPENED|FLT_FILE_NAME_QUERY_ALWAYS_ALLOW_CACHE_LOOKUP,
&pfNameInfo) ;
if (!NT_SUCCESS(status))
{
//pfNameInfo = NULL;
leave ;
}

status = FltParseFileNameInformation(pfNameInfo);
if (!NT_SUCCESS(status))
leave ;

if (0 == pfNameInfo->Name.Length)
leave ;

KdPrint((“1: System.exe createfile = %wZ !\n”, &pfNameInfo->Name));

InitializeObjectAttributes(&ob,
&pfNameInfo->Name,
OBJ_KERNEL_HANDLE|OBJ_CASE_INSENSITIVE,
NULL,
NULL) ;

status = FltCreateFile(FltObjects->Filter,
FltObjects->Instance,
&hFile,
FILE_READ_DATA,
&ob,
&IoStatus,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE | FILE_NO_INTERMEDIATE_BUFFERING,
NULL,
0,
IO_IGNORE_SHARE_ACCESS_CHECK
) ;

if (!NT_SUCCESS(status))
{
KdPrint((“Create file failed, ExitCode = %x\n”, status));
leave;
}
KdPrint((“2: System.exe createfile success!\n”));
}
}
finally{
if (NULL != pfNameInfo)
FltReleaseFileNameInformation(pfNameInfo);
if (NULL != hFile)
FltClose(hFile);
return FLT_PREOP_SUCCESS_NO_CALLBACK;
}
return FLT_PREOP_SUCCESS_NO_CALLBACK;
}

For Scott Noone’s advise I am looking for the handing thread and stack.
Maybe can find the reason with the code,Divine Favor!
Best Regards!