status = IoCallDriver(((PDEVICE_EXTENSION) DeviceObject->DeviceExtension)->FileSystemDeviceObject, Irp);
if(STATUS_PENDING == status)
{
NTSTATUS localStatus = KeWaitForSingleObject(&waitEvent, Executive, KernelMode, FALSE, NULL);
ASSERT(STATUS_SUCCESS == localStatus);
} if (NT_SUCCESS(Irp->IoStatus.Status)&& IrpSp->FileObject !=NULL)
{
FILE_STANDARD_INFORMATION StdInfo;
if(QueryStdInfo(IrpSp->FileObject, ((PDEVICE_EXTENSION) DeviceObject->DeviceExtension)->FileSystemDeviceObject, &StdInfo))
bIsDir = StdInfo.Directory;
else
{
if(FilePath != NULL)
ExFreePool(FilePath);
IoCancelFileOpen(((PDEVICE_EXTENSION) DeviceObject->DeviceExtension)->FileSystemDeviceObject,IrpSp->FileObject);
goto EXIT_BLOCK_RES_IRP;
}
if ((FilePath!=NULL)&&(IrpSp->FileObject->FsContext!=NULL))
{
if (!AddHashEntry(FilePath,IrpSp->FileObject, bIsDir,ucObjAttr,ObjectType))
{
if(FilePath != NULL)
ExFreePool(FilePath);
IoCancelFileOpen(((PDEVICE_EXTENSION) DeviceObject->DeviceExtension)->FileSystemDeviceObject,IrpSp->FileObject);
goto EXIT_BLOCK_RES_IRP;
}
}
}
以上是create例程的代码,其中QueryStdInfo函数如下
BOOLEAN QueryStdInfo(PFILE_OBJECT FileObject, PDEVICE_OBJECT DeviceObject,
PFILE_STANDARD_INFORMATION FileStdInfo)
{
IO_STATUS_BLOCK IoStatusBlock;
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
KEVENT Event;
NTSTATUS Status;
KeInitializeEvent(&Event,SynchronizationEvent,FALSE);
if (FileStdInfo == NULL)
return FALSE;
Irp = IoAllocateIrp(DeviceObject->StackSize,
FALSE);
if (Irp == NULL)
{
return FALSE;
}
Irp->AssociatedIrp.SystemBuffer = FileStdInfo;
Irp->UserIosb = &IoStatusBlock;
Irp->UserEvent = &Event;
Irp->RequestorMode = KernelMode;
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
Irp->Tail.Overlay.OriginalFileObject = FileObject;
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = IRP_MJ_QUERY_INFORMATION;
StackPtr->MinorFunction = 0;
StackPtr->Flags = 0;
StackPtr->Control = 0;
StackPtr->DeviceObject = DeviceObject;
StackPtr->FileObject = FileObject;
StackPtr->Parameters.QueryFile.FileInformationClass =
FileStandardInformation;
StackPtr->Parameters.QueryFile.Length = sizeof(FILE_STANDARD_INFORMATION);
IoSetCompletionRoutine(Irp, QueryStdInfoComplete, 0, TRUE, TRUE, TRUE);
Status = IoCallDriver(DeviceObject,Irp);
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
return (NT_SUCCESS(IoStatusBlock.Status));
}NTSTATUS
QueryStdInfoComplete(PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context)
//
// FilemonQueryFileNameComplete
//
// This routine is used to handle I/O completion for our self-generated
// IRP that is used to query a file's name.
//
{
//
// Copy the status information back into the "user" IOSB.
//
*Irp->UserIosb = Irp->IoStatus;
// Set the user event - wakes up the mainline code doing this.
//
KeSetEvent(Irp->UserEvent, 0, FALSE);
//
// Free the IRP now that we are done with it. //
IoFreeIrp(Irp);
//
// We return STATUS_MORE_PROCESSING_REQUIRED because this "magic" return value
// tells the I/O Manager that additional processing will be done by this driver
// to the IRP - in fact, it might (as it is in this case) already BE done - and
// the IRP cannot be completed.
//
return STATUS_MORE_PROCESSING_REQUIRED;
}但是这样在访问网上共享文件时出现死锁,于是将代码该为
if(STATUS_PENDING == Status && FileObject->Flags & FO_SYNCHRONOUS_IO)
{
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
}
结果和clearcase冲突,已运行就蓝屏,搞不明白为什么,望高手指教。
if(STATUS_PENDING == status)
{
NTSTATUS localStatus = KeWaitForSingleObject(&waitEvent, Executive, KernelMode, FALSE, NULL);
ASSERT(STATUS_SUCCESS == localStatus);
} if (NT_SUCCESS(Irp->IoStatus.Status)&& IrpSp->FileObject !=NULL)
{
FILE_STANDARD_INFORMATION StdInfo;
if(QueryStdInfo(IrpSp->FileObject, ((PDEVICE_EXTENSION) DeviceObject->DeviceExtension)->FileSystemDeviceObject, &StdInfo))
bIsDir = StdInfo.Directory;
else
{
if(FilePath != NULL)
ExFreePool(FilePath);
IoCancelFileOpen(((PDEVICE_EXTENSION) DeviceObject->DeviceExtension)->FileSystemDeviceObject,IrpSp->FileObject);
goto EXIT_BLOCK_RES_IRP;
}
if ((FilePath!=NULL)&&(IrpSp->FileObject->FsContext!=NULL))
{
if (!AddHashEntry(FilePath,IrpSp->FileObject, bIsDir,ucObjAttr,ObjectType))
{
if(FilePath != NULL)
ExFreePool(FilePath);
IoCancelFileOpen(((PDEVICE_EXTENSION) DeviceObject->DeviceExtension)->FileSystemDeviceObject,IrpSp->FileObject);
goto EXIT_BLOCK_RES_IRP;
}
}
}
以上是create例程的代码,其中QueryStdInfo函数如下
BOOLEAN QueryStdInfo(PFILE_OBJECT FileObject, PDEVICE_OBJECT DeviceObject,
PFILE_STANDARD_INFORMATION FileStdInfo)
{
IO_STATUS_BLOCK IoStatusBlock;
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
KEVENT Event;
NTSTATUS Status;
KeInitializeEvent(&Event,SynchronizationEvent,FALSE);
if (FileStdInfo == NULL)
return FALSE;
Irp = IoAllocateIrp(DeviceObject->StackSize,
FALSE);
if (Irp == NULL)
{
return FALSE;
}
Irp->AssociatedIrp.SystemBuffer = FileStdInfo;
Irp->UserIosb = &IoStatusBlock;
Irp->UserEvent = &Event;
Irp->RequestorMode = KernelMode;
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
Irp->Tail.Overlay.OriginalFileObject = FileObject;
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = IRP_MJ_QUERY_INFORMATION;
StackPtr->MinorFunction = 0;
StackPtr->Flags = 0;
StackPtr->Control = 0;
StackPtr->DeviceObject = DeviceObject;
StackPtr->FileObject = FileObject;
StackPtr->Parameters.QueryFile.FileInformationClass =
FileStandardInformation;
StackPtr->Parameters.QueryFile.Length = sizeof(FILE_STANDARD_INFORMATION);
IoSetCompletionRoutine(Irp, QueryStdInfoComplete, 0, TRUE, TRUE, TRUE);
Status = IoCallDriver(DeviceObject,Irp);
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
return (NT_SUCCESS(IoStatusBlock.Status));
}NTSTATUS
QueryStdInfoComplete(PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context)
//
// FilemonQueryFileNameComplete
//
// This routine is used to handle I/O completion for our self-generated
// IRP that is used to query a file's name.
//
{
//
// Copy the status information back into the "user" IOSB.
//
*Irp->UserIosb = Irp->IoStatus;
// Set the user event - wakes up the mainline code doing this.
//
KeSetEvent(Irp->UserEvent, 0, FALSE);
//
// Free the IRP now that we are done with it. //
IoFreeIrp(Irp);
//
// We return STATUS_MORE_PROCESSING_REQUIRED because this "magic" return value
// tells the I/O Manager that additional processing will be done by this driver
// to the IRP - in fact, it might (as it is in this case) already BE done - and
// the IRP cannot be completed.
//
return STATUS_MORE_PROCESSING_REQUIRED;
}但是这样在访问网上共享文件时出现死锁,于是将代码该为
if(STATUS_PENDING == Status && FileObject->Flags & FO_SYNCHRONOUS_IO)
{
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
}
结果和clearcase冲突,已运行就蓝屏,搞不明白为什么,望高手指教。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货