mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Fix IopCloseFile: Use IRP_SYNC_API flag, use local stack event, get the right deviceobject if FO_DIRECT_DEVICE_OPEN is set, set IRP_CLOSE_OPERATION flag.
svn path=/trunk/; revision=14921
This commit is contained in:
parent
f7695b0f53
commit
aa1fd35178
1 changed files with 45 additions and 40 deletions
|
@ -183,7 +183,6 @@ IopDeleteFile(PVOID ObjectBody)
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
KEVENT Event;
|
KEVENT Event;
|
||||||
PDEVICE_OBJECT DeviceObject;
|
PDEVICE_OBJECT DeviceObject;
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
|
||||||
|
|
||||||
DPRINT("IopDeleteFile()\n");
|
DPRINT("IopDeleteFile()\n");
|
||||||
|
|
||||||
|
@ -208,9 +207,9 @@ IopDeleteFile(PVOID ObjectBody)
|
||||||
|
|
||||||
/* Set it up */
|
/* Set it up */
|
||||||
Irp->UserEvent = &Event;
|
Irp->UserEvent = &Event;
|
||||||
Irp->UserIosb = &IoStatusBlock;
|
Irp->UserIosb = &Irp->IoStatus;
|
||||||
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
|
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
|
||||||
Irp->Tail.Overlay.OriginalFileObject= FileObject;
|
Irp->Tail.Overlay.OriginalFileObject = FileObject;
|
||||||
Irp->Flags = IRP_CLOSE_OPERATION | IRP_SYNCHRONOUS_API;
|
Irp->Flags = IRP_CLOSE_OPERATION | IRP_SYNCHRONOUS_API;
|
||||||
|
|
||||||
/* Set up Stack Pointer Data */
|
/* Set up Stack Pointer Data */
|
||||||
|
@ -493,48 +492,54 @@ STDCALL
|
||||||
IopCloseFile(PVOID ObjectBody,
|
IopCloseFile(PVOID ObjectBody,
|
||||||
ULONG HandleCount)
|
ULONG HandleCount)
|
||||||
{
|
{
|
||||||
PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
|
PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
|
||||||
PIRP Irp;
|
KEVENT Event;
|
||||||
PIO_STACK_LOCATION StackPtr;
|
PIRP Irp;
|
||||||
NTSTATUS Status;
|
PIO_STACK_LOCATION StackPtr;
|
||||||
|
NTSTATUS Status;
|
||||||
|
PDEVICE_OBJECT DeviceObject;
|
||||||
|
|
||||||
DPRINT("IopCloseFile()\n");
|
DPRINT("IopCloseFile()\n");
|
||||||
|
|
||||||
if (HandleCount > 1 || FileObject->DeviceObject == NULL)
|
if (HandleCount > 1 || FileObject->DeviceObject == NULL) return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
/* Check if this is a direct open or not */
|
||||||
//NOTE: Allmost certain that the latest changes to I/O Mgr makes this redundant (OriginalFileObject case)
|
if (FileObject->Flags & FO_DIRECT_DEVICE_OPEN)
|
||||||
ObReferenceObjectByPointer(FileObject,
|
{
|
||||||
STANDARD_RIGHTS_REQUIRED,
|
DeviceObject = IoGetAttachedDevice(FileObject->DeviceObject);
|
||||||
IoFileObjectType,
|
}
|
||||||
UserMode);
|
else
|
||||||
#endif
|
{
|
||||||
|
DeviceObject = IoGetRelatedDeviceObject(FileObject);
|
||||||
KeResetEvent( &FileObject->Event );
|
}
|
||||||
|
|
||||||
|
/* Clear and set up Events */
|
||||||
|
KeClearEvent(&FileObject->Event);
|
||||||
|
KeInitializeEvent(&Event, SynchronizationEvent, FALSE);
|
||||||
|
|
||||||
IO_STATUS_BLOCK Dummy;
|
/* Allocate an IRP */
|
||||||
/* WRONG WRONG WRONG WRONG!!!!!! */
|
Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE);
|
||||||
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_CLEANUP,
|
|
||||||
FileObject->DeviceObject,
|
/* Set it up */
|
||||||
NULL,
|
Irp->UserEvent = &Event;
|
||||||
0,
|
Irp->UserIosb = &Irp->IoStatus;
|
||||||
NULL,
|
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
|
||||||
&FileObject->Event,
|
Irp->Tail.Overlay.OriginalFileObject = FileObject;
|
||||||
&Dummy);
|
Irp->Flags = IRP_CLOSE_OPERATION | IRP_SYNCHRONOUS_API;
|
||||||
/* Hack to fix the above WRONG WRONG WRONG WRONG CODE!!! */
|
|
||||||
Irp->UserIosb = &Irp->IoStatus;
|
/* Set up Stack Pointer Data */
|
||||||
|
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||||
|
StackPtr->MajorFunction = IRP_MJ_CLEANUP;
|
||||||
|
StackPtr->FileObject = FileObject;
|
||||||
|
|
||||||
StackPtr = IoGetNextIrpStackLocation(Irp);
|
/* Call the FS Driver */
|
||||||
StackPtr->FileObject = FileObject;
|
Status = IoCallDriver(DeviceObject, Irp);
|
||||||
|
|
||||||
Status = IoCallDriver(FileObject->DeviceObject, Irp);
|
/* Wait for completion */
|
||||||
if (Status == STATUS_PENDING)
|
if (Status == STATUS_PENDING)
|
||||||
{
|
{
|
||||||
KeWaitForSingleObject(&FileObject->Event, Executive, KernelMode, FALSE, NULL);
|
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
Loading…
Reference in a new issue