mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Implement IO_NO_PARAMETER_CHECKING flag
svn path=/trunk/; revision=13256
This commit is contained in:
parent
d7aea92eeb
commit
93551abbd2
3 changed files with 46 additions and 12 deletions
|
@ -160,6 +160,11 @@ enum
|
||||||
#define SL_INVOKE_ON_SUCCESS 0x40
|
#define SL_INVOKE_ON_SUCCESS 0x40
|
||||||
#define SL_INVOKE_ON_ERROR 0x80
|
#define SL_INVOKE_ON_ERROR 0x80
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IoCreateFile options
|
||||||
|
*/
|
||||||
|
#define IO_NO_PARAMETER_CHECKING 0x100
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Possible flags for the device object flags
|
* Possible flags for the device object flags
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -321,7 +321,7 @@ IoCreateStreamFileObject(PFILE_OBJECT FileObject,
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
IoCreateFile(OUT PHANDLE FileHandle,
|
IoCreateFile(OUT PHANDLE FileHandle,
|
||||||
IN ACCESS_MASK DesiredAccess,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
@ -341,7 +341,9 @@ IoCreateFile(OUT PHANDLE FileHandle,
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
PIO_STACK_LOCATION StackLoc;
|
PIO_STACK_LOCATION StackLoc;
|
||||||
IO_SECURITY_CONTEXT SecurityContext;
|
IO_SECURITY_CONTEXT SecurityContext;
|
||||||
KPROCESSOR_MODE PreviousMode;
|
KPROCESSOR_MODE PreviousMode;
|
||||||
|
HANDLE LocalFileHandle;
|
||||||
|
IO_STATUS_BLOCK LocalIoStatusBlock;
|
||||||
|
|
||||||
DPRINT("IoCreateFile(FileHandle %x, DesiredAccess %x, "
|
DPRINT("IoCreateFile(FileHandle %x, DesiredAccess %x, "
|
||||||
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n",
|
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n",
|
||||||
|
@ -350,14 +352,14 @@ IoCreateFile(OUT PHANDLE FileHandle,
|
||||||
|
|
||||||
ASSERT_IRQL(PASSIVE_LEVEL);
|
ASSERT_IRQL(PASSIVE_LEVEL);
|
||||||
|
|
||||||
if (IoStatusBlock == NULL)
|
if (IoStatusBlock == NULL || FileHandle == NULL)
|
||||||
return STATUS_ACCESS_VIOLATION;
|
return STATUS_ACCESS_VIOLATION;
|
||||||
|
|
||||||
*FileHandle = 0;
|
LocalFileHandle = 0;
|
||||||
|
|
||||||
PreviousMode = ExGetPreviousMode();
|
PreviousMode = ExGetPreviousMode();
|
||||||
|
|
||||||
Status = ObCreateObject(PreviousMode,
|
Status = ObCreateObject(0 == (Options & IO_NO_PARAMETER_CHECKING) ? PreviousMode : KernelMode,
|
||||||
IoFileObjectType,
|
IoFileObjectType,
|
||||||
ObjectAttributes,
|
ObjectAttributes,
|
||||||
PreviousMode,
|
PreviousMode,
|
||||||
|
@ -380,7 +382,7 @@ IoCreateFile(OUT PHANDLE FileHandle,
|
||||||
DesiredAccess,
|
DesiredAccess,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
FileHandle);
|
&LocalFileHandle);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("ObInsertObject() failed! (Status %lx)\n", Status);
|
DPRINT("ObInsertObject() failed! (Status %lx)\n", Status);
|
||||||
|
@ -418,14 +420,14 @@ IoCreateFile(OUT PHANDLE FileHandle,
|
||||||
Irp = IoAllocateIrp(FileObject->DeviceObject->StackSize, FALSE);
|
Irp = IoAllocateIrp(FileObject->DeviceObject->StackSize, FALSE);
|
||||||
if (Irp == NULL)
|
if (Irp == NULL)
|
||||||
{
|
{
|
||||||
ZwClose(*FileHandle);
|
ZwClose(LocalFileHandle);
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//trigger FileObject/Event dereferencing
|
//trigger FileObject/Event dereferencing
|
||||||
Irp->Tail.Overlay.OriginalFileObject = FileObject;
|
Irp->Tail.Overlay.OriginalFileObject = FileObject;
|
||||||
Irp->RequestorMode = PreviousMode;
|
Irp->RequestorMode = PreviousMode;
|
||||||
Irp->UserIosb = IoStatusBlock;
|
Irp->UserIosb = &LocalIoStatusBlock;
|
||||||
Irp->AssociatedIrp.SystemBuffer = EaBuffer;
|
Irp->AssociatedIrp.SystemBuffer = EaBuffer;
|
||||||
Irp->Tail.Overlay.AuxiliaryBuffer = NULL;
|
Irp->Tail.Overlay.AuxiliaryBuffer = NULL;
|
||||||
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
|
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
|
||||||
|
@ -493,7 +495,7 @@ IoCreateFile(OUT PHANDLE FileHandle,
|
||||||
PreviousMode,
|
PreviousMode,
|
||||||
FALSE,
|
FALSE,
|
||||||
NULL);
|
NULL);
|
||||||
Status = IoStatusBlock->Status;
|
Status = LocalIoStatusBlock.Status;
|
||||||
}
|
}
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -501,7 +503,34 @@ IoCreateFile(OUT PHANDLE FileHandle,
|
||||||
FileObject->DeviceObject = NULL;
|
FileObject->DeviceObject = NULL;
|
||||||
FileObject->Vpb = NULL;
|
FileObject->Vpb = NULL;
|
||||||
|
|
||||||
ZwClose(*FileHandle);
|
ZwClose(LocalFileHandle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (KernelMode == PreviousMode || 0 != (Options & IO_NO_PARAMETER_CHECKING))
|
||||||
|
{
|
||||||
|
*FileHandle = LocalFileHandle;
|
||||||
|
*IoStatusBlock = LocalIoStatusBlock;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_SEH_TRY
|
||||||
|
{
|
||||||
|
ProbeForWrite(FileHandle,
|
||||||
|
sizeof(HANDLE),
|
||||||
|
sizeof(ULONG));
|
||||||
|
*FileHandle = LocalFileHandle;
|
||||||
|
ProbeForWrite(IoStatusBlock,
|
||||||
|
sizeof(IO_STATUS_BLOCK),
|
||||||
|
sizeof(ULONG));
|
||||||
|
*IoStatusBlock = LocalIoStatusBlock;
|
||||||
|
}
|
||||||
|
_SEH_HANDLE
|
||||||
|
{
|
||||||
|
Status = _SEH_GetExceptionCode();
|
||||||
|
}
|
||||||
|
_SEH_END;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_IRQL(PASSIVE_LEVEL);
|
ASSERT_IRQL(PASSIVE_LEVEL);
|
||||||
|
|
|
@ -833,7 +833,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
||||||
0,
|
0,
|
||||||
CreateFileTypeNone,
|
CreateFileTypeNone,
|
||||||
NULL,
|
NULL,
|
||||||
SL_OPEN_PAGING_FILE);
|
SL_OPEN_PAGING_FILE | IO_NO_PARAMETER_CHECKING);
|
||||||
RtlReleaseCapturedUnicodeString(&CapturedFileName,
|
RtlReleaseCapturedUnicodeString(&CapturedFileName,
|
||||||
PreviousMode,
|
PreviousMode,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
Loading…
Reference in a new issue