started moving tags to a private internal header
[reactos.git] / reactos / ntoskrnl / io / iomgr.c
index 4a09a3e..dd2d0b4 100644 (file)
@@ -1,37 +1,23 @@
-/* $Id: iomgr.c,v 1.47 2004/05/02 19:33:50 ekohl Exp $
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS Kernel
+ * FILE:            ntoskrnl/io/iomgr.c
+ * PURPOSE:         I/O Manager Initialization and Misc Utility Functions
  *
- * COPYRIGHT:            See COPYING in the top level directory
- * PROJECT:              ReactOS kernel
- * FILE:                 ntoskrnl/io/iomgr.c
- * PURPOSE:              Initializes the io manager
- * PROGRAMMER:           David Welch (welch@mcmail.com)
- * REVISION HISTORY:
- *             29/07/98: Created
+ * PROGRAMMERS:     David Welch (welch@mcmail.com)
  */
 
 /* INCLUDES ****************************************************************/
 
-#include <limits.h>
-#include <ddk/ntddk.h>
-#include <internal/ob.h>
-#include <internal/io.h>
-#include <internal/pool.h>
-#include <internal/module.h>
-#include <rosrtl/string.h>
-
+#include <ntoskrnl.h>
 #define NDEBUG
 #include <internal/debug.h>
 
-/* GLOBALS *******************************************************************/
-
-#define TAG_DEVICE_TYPE     TAG('D', 'E', 'V', 'T')
-#define TAG_FILE_TYPE       TAG('F', 'I', 'L', 'E')
-
 /* DATA ********************************************************************/
 
-
 POBJECT_TYPE EXPORTED IoDeviceObjectType = NULL;
 POBJECT_TYPE EXPORTED IoFileObjectType = NULL;
+extern POBJECT_TYPE IoControllerObjectType;
 ULONG        EXPORTED IoReadOperationCount = 0;
 ULONGLONG    EXPORTED IoReadTransferCount = 0;
 ULONG        EXPORTED IoWriteOperationCount = 0;
@@ -40,236 +26,197 @@ ULONG                 IoOtherOperationCount = 0;
 ULONGLONG             IoOtherTransferCount = 0;
 KSPIN_LOCK   EXPORTED IoStatisticsLock = 0;
 
-static GENERIC_MAPPING IopFileMapping = {FILE_GENERIC_READ,
-                                        FILE_GENERIC_WRITE,
-                                        FILE_GENERIC_EXECUTE,
-                                        FILE_ALL_ACCESS};
-
-/* FUNCTIONS ****************************************************************/
-
-VOID STDCALL
-IopCloseFile(PVOID ObjectBody,
-            ULONG HandleCount)
+GENERIC_MAPPING IopFileMapping = {
+    FILE_GENERIC_READ,
+    FILE_GENERIC_WRITE,
+    FILE_GENERIC_EXECUTE,
+    FILE_ALL_ACCESS};
+
+static KSPIN_LOCK CancelSpinLock;
+extern LIST_ENTRY ShutdownListHead;
+extern KSPIN_LOCK ShutdownListLock;
+extern NPAGED_LOOKASIDE_LIST IoCompletionPacketLookaside;
+NPAGED_LOOKASIDE_LIST IoLargeIrpLookaside;
+NPAGED_LOOKASIDE_LIST IoSmallIrpLookaside;
+
+/* INIT FUNCTIONS ************************************************************/
+                                
+VOID
+INIT_FUNCTION
+IoInitCancelHandling(VOID)
 {
-   PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
-   PIRP Irp;
-   PIO_STACK_LOCATION StackPtr;
-   NTSTATUS Status;
-   
-   DPRINT("IopCloseFile()\n");
-   
-   if (HandleCount > 0 || FileObject->DeviceObject == NULL)
-     {
-       return;
-     }
-
-#if 0
-//NOTE: Allmost certain that the latest changes to I/O Mgr makes this redundant (OriginalFileObject case)
-   ObReferenceObjectByPointer(FileObject,
-                             STANDARD_RIGHTS_REQUIRED,
-                             IoFileObjectType,
-                             UserMode);
-#endif
-
-   KeResetEvent( &FileObject->Event );
-  
-   Irp = IoBuildSynchronousFsdRequest(IRP_MJ_CLEANUP,
-                                     FileObject->DeviceObject,
-                                     NULL,
-                                     0,
-                                     NULL,
-                                     NULL,
-                                     NULL);
-   StackPtr = IoGetNextIrpStackLocation(Irp);
-   StackPtr->FileObject = FileObject;
-   
-   Status = IoCallDriver(FileObject->DeviceObject, Irp);
-   if (Status == STATUS_PENDING)
-   {
-      KeWaitForSingleObject(&FileObject->Event, Executive, KernelMode, FALSE, NULL);
-   }
+    KeInitializeSpinLock(&CancelSpinLock);
 }
 
-
-VOID STDCALL
-IopDeleteFile(PVOID ObjectBody)
+VOID
+INIT_FUNCTION
+IoInitShutdownNotification (VOID)
 {
-   PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
-   PIRP Irp;
-   PIO_STACK_LOCATION StackPtr;
-   NTSTATUS Status;
-   
-   DPRINT("IopDeleteFile()\n");
-
-   if (FileObject->DeviceObject)
-   {
-#if 0
-//NOTE: Allmost certain that the latest changes to I/O Mgr makes this redundant (OriginalFileObject case)
-     
-     ObReferenceObjectByPointer(ObjectBody,
-                               STANDARD_RIGHTS_REQUIRED,
-                               IoFileObjectType,
-                               UserMode);
-#endif   
-     KeResetEvent( &FileObject->Event );
-     Irp = IoBuildSynchronousFsdRequest(IRP_MJ_CLOSE,
-                                       FileObject->DeviceObject,
-                                       NULL,
-                                       0,
-                                       NULL,
-                                       NULL,
-                                       NULL);
-     Irp->Flags |= IRP_CLOSE_OPERATION;
-     StackPtr = IoGetNextIrpStackLocation(Irp);
-     StackPtr->FileObject = FileObject;
-   
-     Status = IoCallDriver(FileObject->DeviceObject, Irp);
-     if (Status == STATUS_PENDING)
-     {
-        KeWaitForSingleObject(&FileObject->Event, Executive, KernelMode, FALSE, NULL);
-     }
-   }
-   
-   if (FileObject->FileName.Buffer != NULL)
-     {
-       ExFreePool(FileObject->FileName.Buffer);
-       FileObject->FileName.Buffer = 0;
-     }
+   InitializeListHead(&ShutdownListHead);
+   KeInitializeSpinLock(&ShutdownListLock);
 }
 
-
-NTSTATUS STDCALL
-IopQueryNameFile(PVOID ObjectBody,
-                POBJECT_NAME_INFORMATION ObjectNameInfo,
-                ULONG Length,
-                PULONG ReturnLength)
+VOID
+INIT_FUNCTION
+IopInitLookasideLists(VOID)
 {
-  POBJECT_NAME_INFORMATION LocalInfo;
-  PFILE_NAME_INFORMATION FileNameInfo;
-  PFILE_OBJECT FileObject;
-  ULONG LocalReturnLength;
-  NTSTATUS Status;
-
-  DPRINT ("IopQueryNameFile() called\n");
-
-  FileObject = (PFILE_OBJECT)ObjectBody;
-
-  LocalInfo = ExAllocatePool (NonPagedPool,
-                             sizeof(OBJECT_NAME_INFORMATION) +
-                               MAX_PATH * sizeof(WCHAR));
-  if (LocalInfo == NULL)
-    return STATUS_INSUFFICIENT_RESOURCES;
-
-  Status = ObQueryNameString (FileObject->DeviceObject->Vpb->RealDevice,
-                             LocalInfo,
-                             MAX_PATH * sizeof(WCHAR),
-                             &LocalReturnLength);
-  if (!NT_SUCCESS (Status))
-    {
-      ExFreePool (LocalInfo);
-      return Status;
-    }
-  DPRINT ("Device path: %wZ\n", &LocalInfo->Name);
-
-  Status = RtlAppendUnicodeStringToString (&ObjectNameInfo->Name,
-                                          &LocalInfo->Name);
-
-  ExFreePool (LocalInfo);
-
-  FileNameInfo = ExAllocatePool (NonPagedPool,
-                                MAX_PATH * sizeof(WCHAR) + sizeof(ULONG));
-  if (FileNameInfo == NULL)
-    return STATUS_INSUFFICIENT_RESOURCES;
-
-  Status = IoQueryFileInformation (FileObject,
-                                  FileNameInformation,
-                                  MAX_PATH * sizeof(WCHAR) + sizeof(ULONG),
-                                  FileNameInfo,
-                                  NULL);
-  if (Status != STATUS_SUCCESS)
+    ULONG LargeIrpSize, SmallIrpSize;
+    ULONG i;
+    PKPRCB Prcb;
+    PNPAGED_LOOKASIDE_LIST CurrentList = NULL;
+    
+    /* Calculate the sizes */
+    LargeIrpSize = sizeof(IRP) + (8 * sizeof(IO_STACK_LOCATION));
+    SmallIrpSize = sizeof(IRP) + sizeof(IO_STACK_LOCATION);
+    
+    /* Initialize the Lookaside List for Large IRPs */
+    ExInitializeNPagedLookasideList(&IoLargeIrpLookaside,
+                                    NULL,
+                                    NULL,
+                                    0,
+                                    LargeIrpSize,
+                                    IO_LARGEIRP,
+                                    0);
+                                    
+    /* Initialize the Lookaside List for Small IRPs */
+    ExInitializeNPagedLookasideList(&IoSmallIrpLookaside,
+                                    NULL,
+                                    NULL,
+                                    0,
+                                    SmallIrpSize,
+                                    IO_SMALLIRP,
+                                    0);
+
+    /* Initialize the Lookaside List for I\O Completion */
+    ExInitializeNPagedLookasideList(&IoCompletionPacketLookaside,
+                                    NULL,
+                                    NULL,
+                                    0,
+                                    sizeof(IO_COMPLETION_PACKET),
+                                    IOC_TAG1,
+                                    0);
+                                    
+    /* Now allocate the per-processor lists */
+    for (i = 0; i < KeNumberProcessors; i++)
     {
-      ExFreePool (FileNameInfo);
-      return Status;
+        /* Get the PRCB for this CPU */
+        Prcb = ((PKPCR)(KPCR_BASE + i * PAGE_SIZE))->Prcb;
+        DPRINT("Setting up lookaside for CPU: %x, PRCB: %p\n", i, Prcb);
+        
+        /* Set the Large IRP List */
+        Prcb->PPLookasideList[LookasideLargeIrpList].L = &IoLargeIrpLookaside.L;
+        CurrentList = ExAllocatePoolWithTag(NonPagedPool,
+                                            sizeof(NPAGED_LOOKASIDE_LIST),
+                                            IO_LARGEIRP_CPU);
+        if (CurrentList)
+        {
+            /* Initialize the Lookaside List for Large IRPs */
+            ExInitializeNPagedLookasideList(CurrentList,
+                                            NULL,
+                                            NULL,
+                                            0,
+                                            LargeIrpSize,
+                                            IO_LARGEIRP_CPU,
+                                            0);
+        }
+        else
+        {
+            CurrentList = &IoLargeIrpLookaside;
+        }
+        Prcb->PPLookasideList[LookasideLargeIrpList].P = &CurrentList->L;
+        
+        /* Set the Small IRP List */
+        Prcb->PPLookasideList[LookasideSmallIrpList].L = &IoSmallIrpLookaside.L;
+        CurrentList = ExAllocatePoolWithTag(NonPagedPool,
+                                            sizeof(NPAGED_LOOKASIDE_LIST),
+                                            IO_SMALLIRP_CPU);
+        if (CurrentList)
+        {
+            /* Initialize the Lookaside List for Large IRPs */
+            ExInitializeNPagedLookasideList(CurrentList,
+                                            NULL,
+                                            NULL,
+                                            0,
+                                            SmallIrpSize,
+                                            IO_SMALLIRP_CPU,
+                                            0);
+        }
+        else
+        {
+            CurrentList = &IoSmallIrpLookaside;
+        }
+        Prcb->PPLookasideList[LookasideSmallIrpList].P = &CurrentList->L;
+        
+        /* Set the I/O Completion List */
+        Prcb->PPLookasideList[LookasideCompletionList].L = &IoCompletionPacketLookaside.L;
+        CurrentList = ExAllocatePoolWithTag(NonPagedPool,
+                                            sizeof(NPAGED_LOOKASIDE_LIST),
+                                            IO_SMALLIRP_CPU);
+        if (CurrentList)
+        {
+            /* Initialize the Lookaside List for Large IRPs */
+            ExInitializeNPagedLookasideList(CurrentList,
+                                            NULL,
+                                            NULL,
+                                            0,
+                                            SmallIrpSize,
+                                            IOC_CPU,
+                                            0);
+        }
+        else
+        {
+            CurrentList = &IoCompletionPacketLookaside;
+        }
+        Prcb->PPLookasideList[LookasideCompletionList].P = &CurrentList->L;
     }
-
-  Status = RtlAppendUnicodeToString (&ObjectNameInfo->Name,
-                                    FileNameInfo->FileName);
-
-  DPRINT ("Total path: %wZ\n", &ObjectNameInfo->Name);
-
-  ExFreePool (FileNameInfo);
-
-  return Status;
+    
+    DPRINT("Done allocation\n");
 }
 
-
-VOID INIT_FUNCTION
+VOID
+INIT_FUNCTION
 IoInit (VOID)
 {
-  OBJECT_ATTRIBUTES ObjectAttributes;
-  UNICODE_STRING DirName;
-  UNICODE_STRING LinkName;
-  HANDLE Handle;
-
-  IopInitDriverImplementation();
-  
-  /*
-   * Register iomgr types: DeviceObjectType
-   */
-  IoDeviceObjectType = ExAllocatePool (NonPagedPool,
-                                      sizeof (OBJECT_TYPE));
-  
-  IoDeviceObjectType->Tag = TAG_DEVICE_TYPE;
-  IoDeviceObjectType->TotalObjects = 0;
-  IoDeviceObjectType->TotalHandles = 0;
-  IoDeviceObjectType->MaxObjects = ULONG_MAX;
-  IoDeviceObjectType->MaxHandles = ULONG_MAX;
-  IoDeviceObjectType->PagedPoolCharge = 0;
-  IoDeviceObjectType->NonpagedPoolCharge = sizeof (DEVICE_OBJECT);
-  IoDeviceObjectType->Mapping = &IopFileMapping;
-  IoDeviceObjectType->Dump = NULL;
-  IoDeviceObjectType->Open = NULL;
-  IoDeviceObjectType->Close = NULL;
-  IoDeviceObjectType->Delete = NULL;
-  IoDeviceObjectType->Parse = NULL;
-  IoDeviceObjectType->Security = NULL;
-  IoDeviceObjectType->QueryName = NULL;
-  IoDeviceObjectType->OkayToClose = NULL;
-  IoDeviceObjectType->Create = IopCreateDevice;
-  IoDeviceObjectType->DuplicationNotify = NULL;
-  
-  RtlRosInitUnicodeStringFromLiteral(&IoDeviceObjectType->TypeName, L"Device");
+    OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
+    UNICODE_STRING Name;
+    OBJECT_ATTRIBUTES ObjectAttributes;
+    UNICODE_STRING DirName;
+    UNICODE_STRING LinkName;
+    HANDLE Handle;
 
-  ObpCreateTypeObject(IoDeviceObjectType);
+    IopInitDriverImplementation();
 
-  /*
-   * Register iomgr types: FileObjectType
-   * (alias DriverObjectType)
-   */
-  IoFileObjectType = ExAllocatePool (NonPagedPool, sizeof (OBJECT_TYPE));
-  
-  IoFileObjectType->Tag = TAG_FILE_TYPE;
-  IoFileObjectType->TotalObjects = 0;
-  IoFileObjectType->TotalHandles = 0;
-  IoFileObjectType->MaxObjects = ULONG_MAX;
-  IoFileObjectType->MaxHandles = ULONG_MAX;
-  IoFileObjectType->PagedPoolCharge = 0;
-  IoFileObjectType->NonpagedPoolCharge = sizeof(FILE_OBJECT);
-  IoFileObjectType->Mapping = &IopFileMapping;
-  IoFileObjectType->Dump = NULL;
-  IoFileObjectType->Open = NULL;
-  IoFileObjectType->Close = IopCloseFile;
-  IoFileObjectType->Delete = IopDeleteFile;
-  IoFileObjectType->Parse = NULL;
-  IoFileObjectType->Security = NULL;
-  IoFileObjectType->QueryName = IopQueryNameFile;
-  IoFileObjectType->OkayToClose = NULL;
-  IoFileObjectType->Create = IopCreateFile;
-  IoFileObjectType->DuplicationNotify = NULL;
+    DPRINT1("Creating Device Object Type\n");
   
-  RtlRosInitUnicodeStringFromLiteral(&IoFileObjectType->TypeName, L"File");
-
-  ObpCreateTypeObject(IoFileObjectType);
+    /* Initialize the Driver object type  */
+    RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
+    RtlInitUnicodeString(&Name, L"Device");
+    ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
+    ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(DEVICE_OBJECT);
+    ObjectTypeInitializer.PoolType = NonPagedPool;
+    ObjectTypeInitializer.ValidAccessMask = FILE_ALL_ACCESS;
+    ObjectTypeInitializer.UseDefaultObject = TRUE;
+    ObjectTypeInitializer.GenericMapping = IopFileMapping;
+    ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &IoDeviceObjectType);
+    
+    /* Do the Adapter Type */
+    RtlInitUnicodeString(&Name, L"Adapter");
+    ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &IoAdapterObjectType);
+    
+    /* Do the Controller Type */
+    RtlInitUnicodeString(&Name, L"Controller");
+    ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(CONTROLLER_OBJECT);
+    ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &IoControllerObjectType);    
+    
+    /* Initialize the File object type  */
+    RtlInitUnicodeString(&Name, L"File");
+    ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
+    ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(FILE_OBJECT);
+    ObjectTypeInitializer.CloseProcedure = IopCloseFile;
+    ObjectTypeInitializer.DeleteProcedure = IopDeleteFile;
+    ObjectTypeInitializer.SecurityProcedure = IopSecurityFile;
+    ObjectTypeInitializer.QueryNameProcedure = IopQueryNameFile;
+    ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &IoFileObjectType);
 
   /*
    * Create the '\Driver' object directory
@@ -280,7 +227,7 @@ IoInit (VOID)
                             0,
                             NULL,
                             NULL);
-  NtCreateDirectoryObject(&Handle,
+  ZwCreateDirectoryObject(&Handle,
                          0,
                          &ObjectAttributes);
 
@@ -294,7 +241,7 @@ IoInit (VOID)
                             0,
                             NULL,
                             NULL);
-  NtCreateDirectoryObject(&Handle,
+  ZwCreateDirectoryObject(&Handle,
                          0,
                          &ObjectAttributes);
 
@@ -347,7 +294,11 @@ IoInit (VOID)
   IoInitFileSystemImplementation();
   IoInitVpbImplementation();
   IoInitShutdownNotification();
+  IopInitPnpNotificationImplementation();
   IopInitErrorLog();
+  IopInitTimerImplementation();
+  IopInitIoCompletionImplementation();
+  IopInitLookasideLists();
 
   /*
    * Create link from '\DosDevices' to '\??' directory
@@ -364,16 +315,18 @@ IoInit (VOID)
    */
   PnpInit();
 }
-
-
-VOID INIT_FUNCTION
-IoInit2(VOID)
+                                   
+VOID
+INIT_FUNCTION
+IoInit2(BOOLEAN BootLog)
 {
   PDEVICE_NODE DeviceNode;
   PDRIVER_OBJECT DriverObject;
   MODULE_OBJECT ModuleObject;
   NTSTATUS Status;
 
+  IoCreateDriverList();
+
   KeInitializeSpinLock (&IoStatisticsLock);
 
   /* Initialize raw filesystem driver */
@@ -395,6 +348,7 @@ IoInit2(VOID)
   Status = IopInitializeDriverModule(
     DeviceNode,
     &ModuleObject,
+    &DeviceNode->ServiceName,
     TRUE,
     &DriverObject);
   if (!NT_SUCCESS(Status))
@@ -412,21 +366,144 @@ IoInit2(VOID)
       return;
     }
 
+  Status = IopStartDevice(DeviceNode);
+  if (!NT_SUCCESS(Status))
+    {
+      IopFreeDeviceNode(DeviceNode);
+      CPRINT("IopInitializeDevice() failed with status (%x)\n", Status);
+      return;
+    }
+
   /*
    * Initialize PnP root releations
    */
   IopInvalidateDeviceRelations(
     IopRootDeviceNode,
     BusRelations);
+
+     /* Start boot logging */
+    IopInitBootLog(BootLog);
+
+    /* Load boot start drivers */
+    IopInitializeBootDrivers();
+}
+
+VOID
+STDCALL
+INIT_FUNCTION
+IoInit3(VOID)
+{
+    NTSTATUS Status;
+
+    /* Create ARC names for boot devices */
+    IoCreateArcNames();
+
+    /* Create the SystemRoot symbolic link */
+    DPRINT("CommandLine: %s\n", (PCHAR)KeLoaderBlock.CommandLine);
+    Status = IoCreateSystemRootLink((PCHAR)KeLoaderBlock.CommandLine);
+    if (!NT_SUCCESS(Status)) {
+        CPRINT("IoCreateSystemRootLink FAILED: (0x%x) - ", Status);
+        KEBUGCHECK(INACCESSIBLE_BOOT_DEVICE);
+    }
+
+    /* Read KDB Data */
+    KdbInit();
+
+    /* I/O is now setup for disk access, so phase 3 */
+    KdInitSystem(3, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
+
+    /* Load services for devices found by PnP manager */
+    IopInitializePnpServices(IopRootDeviceNode, FALSE);
+
+    /* Load system start drivers */
+    IopInitializeSystemDrivers();
+    IoDestroyDriverList();
+
+    /* Stop boot logging */
+    IopStopBootLog();
+
+    /* Assign drive letters */
+    IoAssignDriveLetters((PLOADER_PARAMETER_BLOCK)&KeLoaderBlock,
+                         NULL,
+                         NULL,
+                         NULL);
+}
+
+/* FUNCTIONS *****************************************************************/
+
+/*
+ * @implemented
+ */
+VOID
+STDCALL
+IoAcquireCancelSpinLock(PKIRQL Irql)
+{
+   KeAcquireSpinLock(&CancelSpinLock,Irql);
+}
+
+/*
+ * @implemented
+ */
+PVOID
+STDCALL
+IoGetInitialStack(VOID)
+{
+    return(PsGetCurrentThread()->Tcb.InitialStack);
+}
+
+/*
+ * @implemented
+ */
+VOID
+STDCALL
+IoGetStackLimits(OUT PULONG LowLimit,
+                 OUT PULONG HighLimit)
+{
+    *LowLimit = (ULONG)NtCurrentTeb()->Tib.StackLimit;
+    *HighLimit = (ULONG)NtCurrentTeb()->Tib.StackBase;
+}
+
+/*
+ * @implemented
+ */
+BOOLEAN
+STDCALL
+IoIsSystemThread(IN PETHREAD Thread)
+{
+    /* Call the Ps Function */
+    return PsIsSystemThread(Thread);
+}
+
+/*
+ * @implemented
+ */
+BOOLEAN STDCALL
+IoIsWdmVersionAvailable(IN UCHAR MajorVersion,
+                        IN UCHAR MinorVersion)
+{
+   if (MajorVersion <= 1 && MinorVersion <= 10)
+      return TRUE;
+   return FALSE;
+}
+
+/*
+ * @implemented
+ */
+VOID
+STDCALL
+IoReleaseCancelSpinLock(KIRQL Irql)
+{
+   KeReleaseSpinLock(&CancelSpinLock,Irql);
 }
 
 /*
  * @implemented
  */
-PGENERIC_MAPPING STDCALL
-IoGetFileObjectGenericMapping(VOID)
+PEPROCESS
+STDCALL
+IoThreadToProcess(IN PETHREAD Thread)
 {
-  return(&IopFileMapping);
+    return(Thread->ThreadsProcess);
 }
 
 /* EOF */