Implement IO_NO_PARAMETER_CHECKING flag
Modified: trunk/reactos/include/ddk/iodef.h
Modified: trunk/reactos/ntoskrnl/io/create.c
Modified: trunk/reactos/ntoskrnl/mm/pagefile.c

Modified: trunk/reactos/include/ddk/iodef.h
--- trunk/reactos/include/ddk/iodef.h	2005-01-24 21:25:27 UTC (rev 13255)
+++ trunk/reactos/include/ddk/iodef.h	2005-01-24 22:02:09 UTC (rev 13256)
@@ -161,6 +161,11 @@
 #define SL_INVOKE_ON_ERROR              0x80
 
 /*
+ * IoCreateFile options
+ */
+#define IO_NO_PARAMETER_CHECKING 0x100
+
+/*
  * Possible flags for the device object flags
  */
 #define DO_UNLOAD_PENDING           0x00000001

Modified: trunk/reactos/ntoskrnl/io/create.c
--- trunk/reactos/ntoskrnl/io/create.c	2005-01-24 21:25:27 UTC (rev 13255)
+++ trunk/reactos/ntoskrnl/io/create.c	2005-01-24 22:02:09 UTC (rev 13256)
@@ -321,7 +321,7 @@
  * @implemented
  */
 NTSTATUS STDCALL
-IoCreateFile(OUT	PHANDLE			FileHandle,
+IoCreateFile(OUT PHANDLE		FileHandle,
 	     IN	ACCESS_MASK		DesiredAccess,
 	     IN	POBJECT_ATTRIBUTES	ObjectAttributes,
 	     OUT PIO_STATUS_BLOCK	IoStatusBlock,
@@ -341,7 +341,9 @@
    PIRP			Irp;
    PIO_STACK_LOCATION	StackLoc;
    IO_SECURITY_CONTEXT  SecurityContext;
-   KPROCESSOR_MODE PreviousMode;
+   KPROCESSOR_MODE      PreviousMode;
+   HANDLE               LocalFileHandle;
+   IO_STATUS_BLOCK      LocalIoStatusBlock;
    
    DPRINT("IoCreateFile(FileHandle %x, DesiredAccess %x, "
 	  "ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n",
@@ -350,14 +352,14 @@
    
    ASSERT_IRQL(PASSIVE_LEVEL);
 
-  if (IoStatusBlock == NULL)
-    return STATUS_ACCESS_VIOLATION;
+   if (IoStatusBlock == NULL || FileHandle == NULL)
+     return STATUS_ACCESS_VIOLATION;
 
-   *FileHandle = 0;
+   LocalFileHandle = 0;
 
    PreviousMode = ExGetPreviousMode();
 
-   Status = ObCreateObject(PreviousMode,
+   Status = ObCreateObject(0 == (Options & IO_NO_PARAMETER_CHECKING) ? PreviousMode : KernelMode,
 			   IoFileObjectType,
 			   ObjectAttributes,
 			   PreviousMode,
@@ -380,7 +382,7 @@
 			    DesiredAccess,
 			    0,
 			    NULL,
-			    FileHandle);
+			    &LocalFileHandle);
    if (!NT_SUCCESS(Status))
      {
 	DPRINT("ObInsertObject() failed! (Status %lx)\n", Status);
@@ -418,14 +420,14 @@
    Irp = IoAllocateIrp(FileObject->DeviceObject->StackSize, FALSE);
    if (Irp == NULL)
      {
-	ZwClose(*FileHandle);
+	ZwClose(LocalFileHandle);
 	return STATUS_UNSUCCESSFUL;
      }
 
    //trigger FileObject/Event dereferencing
    Irp->Tail.Overlay.OriginalFileObject = FileObject;
    Irp->RequestorMode = PreviousMode;
-   Irp->UserIosb = IoStatusBlock;
+   Irp->UserIosb = &LocalIoStatusBlock;
    Irp->AssociatedIrp.SystemBuffer = EaBuffer;
    Irp->Tail.Overlay.AuxiliaryBuffer = NULL;
    Irp->Tail.Overlay.Thread = PsGetCurrentThread();
@@ -493,7 +495,7 @@
 			      PreviousMode,
 			      FALSE,
 			      NULL);
-	Status = IoStatusBlock->Status;
+	Status = LocalIoStatusBlock.Status;
      }
    if (!NT_SUCCESS(Status))
      {
@@ -501,8 +503,35 @@
         FileObject->DeviceObject = 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);
 

Modified: trunk/reactos/ntoskrnl/mm/pagefile.c
--- trunk/reactos/ntoskrnl/mm/pagefile.c	2005-01-24 21:25:27 UTC (rev 13255)
+++ trunk/reactos/ntoskrnl/mm/pagefile.c	2005-01-24 22:02:09 UTC (rev 13256)
@@ -833,7 +833,7 @@
                          0,
                          CreateFileTypeNone,
                          NULL,
-                         SL_OPEN_PAGING_FILE);
+                         SL_OPEN_PAGING_FILE | IO_NO_PARAMETER_CHECKING);
    RtlReleaseCapturedUnicodeString(&CapturedFileName,
                                    PreviousMode,
                                    FALSE);