ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

iomgr.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:       See COPYING in the top level directory
00003  * PROJECT:         ReactOS Kernel
00004  * FILE:            ntoskrnl/io/iomgr.c
00005  * PURPOSE:         I/O Manager Initialization and Misc Utility Functions
00006  *
00007  * PROGRAMMERS:     David Welch (welch@mcmail.com)
00008  */
00009 
00010 /* INCLUDES ****************************************************************/
00011 
00012 #include <ntoskrnl.h>
00013 #define NDEBUG
00014 #include <debug.h>
00015 
00016 ULONG IopTraceLevel = 0;
00017 BOOLEAN PnpSystemInit = FALSE;
00018 
00019 VOID
00020 NTAPI
00021 IopTimerDispatch(
00022     IN PKDPC Dpc,
00023     IN PVOID DeferredContext,
00024     IN PVOID SystemArgument1,
00025     IN PVOID SystemArgument2
00026 );
00027 
00028 /* DATA ********************************************************************/
00029 
00030 POBJECT_TYPE IoDeviceObjectType = NULL;
00031 POBJECT_TYPE IoFileObjectType = NULL;
00032 extern POBJECT_TYPE IoControllerObjectType;
00033 extern UNICODE_STRING NtSystemRoot;
00034 BOOLEAN IoCountOperations = TRUE;
00035 ULONG IoReadOperationCount = 0;
00036 LARGE_INTEGER IoReadTransferCount = {{0, 0}};
00037 ULONG IoWriteOperationCount = 0;
00038 LARGE_INTEGER IoWriteTransferCount = {{0, 0}};
00039 ULONG IoOtherOperationCount = 0;
00040 LARGE_INTEGER IoOtherTransferCount = {{0, 0}};
00041 KSPIN_LOCK IoStatisticsLock = 0;
00042 ULONG IopNumTriageDumpDataBlocks;
00043 PVOID IopTriageDumpDataBlocks[64];
00044 
00045 GENERIC_MAPPING IopFileMapping = {
00046     FILE_GENERIC_READ,
00047     FILE_GENERIC_WRITE,
00048     FILE_GENERIC_EXECUTE,
00049     FILE_ALL_ACCESS};
00050 
00051 extern LIST_ENTRY ShutdownListHead;
00052 extern LIST_ENTRY LastChanceShutdownListHead;
00053 extern KSPIN_LOCK ShutdownListLock;
00054 extern POBJECT_TYPE IoAdapterObjectType;
00055 extern ERESOURCE IopDatabaseResource;
00056 ERESOURCE IopSecurityResource;
00057 extern KGUARDED_MUTEX PnpNotifyListLock;
00058 extern LIST_ENTRY IopDiskFileSystemQueueHead;
00059 extern LIST_ENTRY IopCdRomFileSystemQueueHead;
00060 extern LIST_ENTRY IopTapeFileSystemQueueHead;
00061 extern LIST_ENTRY IopNetworkFileSystemQueueHead;
00062 extern LIST_ENTRY DriverBootReinitListHead;
00063 extern LIST_ENTRY DriverReinitListHead;
00064 extern LIST_ENTRY PnpNotifyListHead;
00065 extern LIST_ENTRY IopFsNotifyChangeQueueHead;
00066 extern LIST_ENTRY IopErrorLogListHead;
00067 extern LIST_ENTRY IopTimerQueueHead;
00068 extern KDPC IopTimerDpc;
00069 extern KTIMER IopTimer;
00070 extern KSPIN_LOCK IoStatisticsLock;
00071 extern KSPIN_LOCK DriverReinitListLock;
00072 extern KSPIN_LOCK DriverBootReinitListLock;
00073 extern KSPIN_LOCK IopLogListLock;
00074 extern KSPIN_LOCK IopTimerLock;
00075 
00076 extern PDEVICE_OBJECT IopErrorLogObject;
00077 
00078 GENERAL_LOOKASIDE IoLargeIrpLookaside;
00079 GENERAL_LOOKASIDE IoSmallIrpLookaside;
00080 GENERAL_LOOKASIDE IopMdlLookasideList;
00081 extern GENERAL_LOOKASIDE IoCompletionPacketLookaside;
00082 
00083 PLOADER_PARAMETER_BLOCK IopLoaderBlock;
00084 
00085 #if defined (ALLOC_PRAGMA)
00086 #pragma alloc_text(INIT, IoInitSystem)
00087 #endif
00088 
00089 /* INIT FUNCTIONS ************************************************************/
00090 
00091 VOID
00092 INIT_FUNCTION
00093 NTAPI
00094 IopInitLookasideLists(VOID)
00095 {
00096     ULONG LargeIrpSize, SmallIrpSize, MdlSize;
00097     LONG i;
00098     PKPRCB Prcb;
00099     PGENERAL_LOOKASIDE CurrentList = NULL;
00100 
00101     /* Calculate the sizes */
00102     LargeIrpSize = sizeof(IRP) + (8 * sizeof(IO_STACK_LOCATION));
00103     SmallIrpSize = sizeof(IRP) + sizeof(IO_STACK_LOCATION);
00104     MdlSize = sizeof(MDL) + (23 * sizeof(PFN_NUMBER));
00105 
00106     /* Initialize the Lookaside List for I\O Completion */
00107     ExInitializeSystemLookasideList(&IoCompletionPacketLookaside,
00108                                     NonPagedPool,
00109                                     sizeof(IOP_MINI_COMPLETION_PACKET),
00110                                     IOC_TAG1,
00111                                     32,
00112                                     &ExSystemLookasideListHead);
00113     
00114     /* Initialize the Lookaside List for Large IRPs */
00115     ExInitializeSystemLookasideList(&IoLargeIrpLookaside,
00116                                     NonPagedPool,
00117                                     LargeIrpSize,
00118                                     IO_LARGEIRP,
00119                                     64,
00120                                     &ExSystemLookasideListHead);
00121 
00122 
00123     /* Initialize the Lookaside List for Small IRPs */
00124     ExInitializeSystemLookasideList(&IoSmallIrpLookaside,
00125                                     NonPagedPool,
00126                                     SmallIrpSize,
00127                                     IO_SMALLIRP,
00128                                     32,
00129                                     &ExSystemLookasideListHead);
00130 
00131     /* Initialize the Lookaside List for MDLs */
00132     ExInitializeSystemLookasideList(&IopMdlLookasideList,
00133                                     NonPagedPool,
00134                                     MdlSize,
00135                                     TAG_MDL,
00136                                     128,
00137                                     &ExSystemLookasideListHead);
00138 
00139     /* Allocate the global lookaside list buffer */
00140     CurrentList = ExAllocatePoolWithTag(NonPagedPool, 
00141                                         4 * KeNumberProcessors *
00142                                         sizeof(GENERAL_LOOKASIDE),
00143                                         TAG_IO);
00144     
00145     /* Loop all processors */
00146     for (i = 0; i < KeNumberProcessors; i++)
00147     {
00148         /* Get the PRCB for this CPU */
00149         Prcb = KiProcessorBlock[i];
00150         DPRINT("Setting up lookaside for CPU: %x, PRCB: %p\n", i, Prcb);
00151 
00152         /* Write IRP credit limit */
00153         Prcb->LookasideIrpFloat = 512 / KeNumberProcessors;
00154 
00155         /* Set the I/O Completion List */
00156         Prcb->PPLookasideList[LookasideCompletionList].L = &IoCompletionPacketLookaside;
00157         if (CurrentList)
00158         {
00159             /* Initialize the Lookaside List for mini-packets */
00160             ExInitializeSystemLookasideList(CurrentList,
00161                                             NonPagedPool,
00162                                             sizeof(IOP_MINI_COMPLETION_PACKET),
00163                                             IO_SMALLIRP_CPU,
00164                                             32,
00165                                             &ExSystemLookasideListHead);
00166             Prcb->PPLookasideList[LookasideCompletionList].P = CurrentList;
00167             CurrentList++;
00168             
00169         }
00170         else
00171         {
00172             Prcb->PPLookasideList[LookasideCompletionList].P = &IoCompletionPacketLookaside;
00173         }
00174         
00175         /* Set the Large IRP List */
00176         Prcb->PPLookasideList[LookasideLargeIrpList].L = &IoLargeIrpLookaside;
00177         if (CurrentList)
00178         {
00179             /* Initialize the Lookaside List for Large IRPs */
00180             ExInitializeSystemLookasideList(CurrentList,
00181                                             NonPagedPool,
00182                                             LargeIrpSize,
00183                                             IO_LARGEIRP_CPU,
00184                                             64,
00185                                             &ExSystemLookasideListHead);
00186             Prcb->PPLookasideList[LookasideLargeIrpList].P = CurrentList;
00187             CurrentList++;
00188             
00189         }
00190         else
00191         {
00192             Prcb->PPLookasideList[LookasideLargeIrpList].P = &IoLargeIrpLookaside;
00193         }
00194 
00195         /* Set the Small IRP List */
00196         Prcb->PPLookasideList[LookasideSmallIrpList].L = &IoSmallIrpLookaside;
00197         if (CurrentList)
00198         {
00199             /* Initialize the Lookaside List for Small IRPs */
00200             ExInitializeSystemLookasideList(CurrentList,
00201                                             NonPagedPool,
00202                                             SmallIrpSize,
00203                                             IO_SMALLIRP_CPU,
00204                                             32,
00205                                             &ExSystemLookasideListHead);
00206             Prcb->PPLookasideList[LookasideSmallIrpList].P = CurrentList;
00207             CurrentList++;
00208             
00209         }
00210         else
00211         {
00212             Prcb->PPLookasideList[LookasideSmallIrpList].P = &IoSmallIrpLookaside;
00213         }
00214 
00215         /* Set the MDL Completion List */
00216         Prcb->PPLookasideList[LookasideMdlList].L = &IopMdlLookasideList;
00217         if (CurrentList)
00218         {
00219             /* Initialize the Lookaside List for MDLs */
00220             ExInitializeSystemLookasideList(CurrentList,
00221                                             NonPagedPool,
00222                                             SmallIrpSize,
00223                                             TAG_MDL,
00224                                             128,
00225                                             &ExSystemLookasideListHead);
00226             
00227             Prcb->PPLookasideList[LookasideMdlList].P = CurrentList;
00228             CurrentList++;
00229             
00230         }
00231         else
00232         {
00233             Prcb->PPLookasideList[LookasideMdlList].P = &IopMdlLookasideList;
00234         }
00235     }
00236 }
00237 
00238 BOOLEAN
00239 INIT_FUNCTION
00240 NTAPI
00241 IopCreateObjectTypes(VOID)
00242 {
00243     OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
00244     UNICODE_STRING Name;
00245 
00246     /* Initialize default settings */
00247     RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
00248     ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
00249     ObjectTypeInitializer.PoolType = NonPagedPool;
00250     ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
00251     ObjectTypeInitializer.ValidAccessMask = FILE_ALL_ACCESS;
00252     ObjectTypeInitializer.UseDefaultObject = TRUE;
00253     ObjectTypeInitializer.GenericMapping = IopFileMapping;
00254 
00255     /* Do the Adapter Type */
00256     RtlInitUnicodeString(&Name, L"Adapter");
00257     if (!NT_SUCCESS(ObCreateObjectType(&Name,
00258                                        &ObjectTypeInitializer,
00259                                        NULL,
00260                                        &IoAdapterObjectType))) return FALSE;
00261 
00262     /* Do the Controller Type */
00263     RtlInitUnicodeString(&Name, L"Controller");
00264     ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(CONTROLLER_OBJECT);
00265     if (!NT_SUCCESS(ObCreateObjectType(&Name,
00266                                        &ObjectTypeInitializer,
00267                                        NULL,
00268                                        &IoControllerObjectType))) return FALSE;
00269 
00270     /* Do the Device Type */
00271     RtlInitUnicodeString(&Name, L"Device");
00272     ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(DEVICE_OBJECT);
00273     ObjectTypeInitializer.DeleteProcedure = IopDeleteDevice;
00274     ObjectTypeInitializer.ParseProcedure = IopParseDevice;
00275     ObjectTypeInitializer.SecurityProcedure = IopSecurityFile;
00276     if (!NT_SUCCESS(ObCreateObjectType(&Name,
00277                                        &ObjectTypeInitializer,
00278                                        NULL,
00279                                        &IoDeviceObjectType))) return FALSE;
00280 
00281     /* Initialize the Driver object type */
00282     RtlInitUnicodeString(&Name, L"Driver");
00283     ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(DRIVER_OBJECT);
00284     ObjectTypeInitializer.DeleteProcedure = IopDeleteDriver;
00285     ObjectTypeInitializer.ParseProcedure = NULL;
00286     ObjectTypeInitializer.SecurityProcedure = NULL;
00287     if (!NT_SUCCESS(ObCreateObjectType(&Name,
00288                                        &ObjectTypeInitializer,
00289                                        NULL,
00290                                        &IoDriverObjectType))) return FALSE;
00291 
00292     /* Initialize the I/O Completion object type */
00293     RtlInitUnicodeString(&Name, L"IoCompletion");
00294     ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KQUEUE);
00295     ObjectTypeInitializer.ValidAccessMask = IO_COMPLETION_ALL_ACCESS;
00296     ObjectTypeInitializer.InvalidAttributes |= OBJ_PERMANENT;
00297     ObjectTypeInitializer.GenericMapping = IopCompletionMapping;
00298     ObjectTypeInitializer.DeleteProcedure = IopDeleteIoCompletion;
00299     if (!NT_SUCCESS(ObCreateObjectType(&Name,
00300                                        &ObjectTypeInitializer,
00301                                        NULL,
00302                                        &IoCompletionType))) return FALSE;
00303 
00304     /* Initialize the File object type  */
00305     RtlInitUnicodeString(&Name, L"File");
00306     ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(FILE_OBJECT);
00307     ObjectTypeInitializer.InvalidAttributes |= OBJ_EXCLUSIVE;
00308     ObjectTypeInitializer.MaintainHandleCount = TRUE;
00309     ObjectTypeInitializer.ValidAccessMask = FILE_ALL_ACCESS;
00310     ObjectTypeInitializer.GenericMapping = IopFileMapping;
00311     ObjectTypeInitializer.CloseProcedure = IopCloseFile;
00312     ObjectTypeInitializer.DeleteProcedure = IopDeleteFile;
00313     ObjectTypeInitializer.SecurityProcedure = IopSecurityFile;
00314     ObjectTypeInitializer.QueryNameProcedure = IopQueryNameFile;
00315     ObjectTypeInitializer.ParseProcedure = IopParseFile;
00316     ObjectTypeInitializer.UseDefaultObject = FALSE;
00317     if (!NT_SUCCESS(ObCreateObjectType(&Name,
00318                                        &ObjectTypeInitializer,
00319                                        NULL,
00320                                        &IoFileObjectType))) return FALSE;
00321 
00322     /* Success */
00323     return TRUE;
00324 }
00325 
00326 BOOLEAN
00327 INIT_FUNCTION
00328 NTAPI
00329 IopCreateRootDirectories()
00330 {
00331     OBJECT_ATTRIBUTES ObjectAttributes;
00332     UNICODE_STRING DirName;
00333     HANDLE Handle;
00334 
00335     /* Create the '\Driver' object directory */
00336     RtlInitUnicodeString(&DirName, L"\\Driver");
00337     InitializeObjectAttributes(&ObjectAttributes,
00338                                &DirName,
00339                                OBJ_PERMANENT,
00340                                NULL,
00341                                NULL);
00342     if (!NT_SUCCESS(NtCreateDirectoryObject(&Handle,
00343                                             DIRECTORY_ALL_ACCESS,
00344                                             &ObjectAttributes))) return FALSE;
00345     NtClose(Handle);
00346 
00347     /* Create the '\FileSystem' object directory */
00348     RtlInitUnicodeString(&DirName, L"\\FileSystem");
00349     InitializeObjectAttributes(&ObjectAttributes,
00350                                &DirName,
00351                                OBJ_PERMANENT,
00352                                NULL,
00353                                NULL);
00354     if (!NT_SUCCESS(NtCreateDirectoryObject(&Handle,
00355                                             DIRECTORY_ALL_ACCESS,
00356                                             &ObjectAttributes))) return FALSE;
00357     NtClose(Handle);
00358 
00359     /* Return success */
00360     return TRUE;
00361 }
00362 
00363 BOOLEAN
00364 INIT_FUNCTION
00365 NTAPI
00366 IopMarkBootPartition(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
00367 {
00368     OBJECT_ATTRIBUTES ObjectAttributes;
00369     STRING DeviceString;
00370     CHAR Buffer[256];
00371     UNICODE_STRING DeviceName;
00372     NTSTATUS Status;
00373     HANDLE FileHandle;
00374     IO_STATUS_BLOCK IoStatusBlock;
00375     PFILE_OBJECT FileObject;
00376 
00377     /* Build the ARC device name */
00378     sprintf(Buffer, "\\ArcName\\%s", LoaderBlock->ArcBootDeviceName);
00379     RtlInitAnsiString(&DeviceString, Buffer);
00380     Status = RtlAnsiStringToUnicodeString(&DeviceName, &DeviceString, TRUE);
00381     if (!NT_SUCCESS(Status)) return FALSE;
00382 
00383     /* Open it */
00384     InitializeObjectAttributes(&ObjectAttributes,
00385                                &DeviceName,
00386                                OBJ_CASE_INSENSITIVE,
00387                                NULL,
00388                                NULL);
00389     Status = ZwOpenFile(&FileHandle,
00390                         FILE_READ_ATTRIBUTES,
00391                         &ObjectAttributes,
00392                         &IoStatusBlock,
00393                         0,
00394                         FILE_NON_DIRECTORY_FILE);
00395     if (!NT_SUCCESS(Status))
00396     {
00397         /* Fail */
00398         KeBugCheckEx(INACCESSIBLE_BOOT_DEVICE,
00399                      (ULONG_PTR)&DeviceName,
00400                      Status,
00401                      0,
00402                      0);
00403     }
00404 
00405     /* Get the DO */
00406     Status = ObReferenceObjectByHandle(FileHandle,
00407                                        0,
00408                                        IoFileObjectType,
00409                                        KernelMode,
00410                                        (PVOID *)&FileObject,
00411                                        NULL);
00412     if (!NT_SUCCESS(Status))
00413     {
00414         /* Fail */
00415         RtlFreeUnicodeString(&DeviceName);
00416         return FALSE;
00417     }
00418 
00419     /* Mark it as the boot partition */
00420     FileObject->DeviceObject->Flags |= DO_SYSTEM_BOOT_PARTITION;
00421 
00422     /* Save a copy of the DO for the I/O Error Logger */
00423     ObReferenceObject(FileObject->DeviceObject);
00424     IopErrorLogObject = FileObject->DeviceObject;
00425 
00426     /* Cleanup and return success */
00427     RtlFreeUnicodeString(&DeviceName);
00428     NtClose(FileHandle);
00429     ObDereferenceObject(FileObject);
00430     return TRUE;
00431 }
00432 
00433 BOOLEAN
00434 INIT_FUNCTION
00435 NTAPI
00436 IoInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
00437 {
00438     LARGE_INTEGER ExpireTime;
00439     NTSTATUS Status;
00440     CHAR Buffer[256];
00441     ANSI_STRING NtBootPath, RootString;
00442 
00443     /* Initialize empty NT Boot Path */
00444     RtlInitEmptyAnsiString(&NtBootPath, Buffer, sizeof(Buffer));
00445 
00446     /* Initialize the lookaside lists */
00447     IopInitLookasideLists();
00448 
00449     /* Initialize all locks and lists */
00450     ExInitializeResource(&IopDatabaseResource);
00451     ExInitializeResource(&IopSecurityResource);
00452     KeInitializeGuardedMutex(&PnpNotifyListLock);
00453     InitializeListHead(&IopDiskFileSystemQueueHead);
00454     InitializeListHead(&IopCdRomFileSystemQueueHead);
00455     InitializeListHead(&IopTapeFileSystemQueueHead);
00456     InitializeListHead(&IopNetworkFileSystemQueueHead);
00457     InitializeListHead(&DriverBootReinitListHead);
00458     InitializeListHead(&DriverReinitListHead);
00459     InitializeListHead(&PnpNotifyListHead);
00460     InitializeListHead(&ShutdownListHead);
00461     InitializeListHead(&LastChanceShutdownListHead);
00462     InitializeListHead(&IopFsNotifyChangeQueueHead);
00463     InitializeListHead(&IopErrorLogListHead);
00464     KeInitializeSpinLock(&IoStatisticsLock);
00465     KeInitializeSpinLock(&DriverReinitListLock);
00466     KeInitializeSpinLock(&DriverBootReinitListLock);
00467     KeInitializeSpinLock(&ShutdownListLock);
00468     KeInitializeSpinLock(&IopLogListLock);
00469 
00470     /* Initialize Timer List Lock */
00471     KeInitializeSpinLock(&IopTimerLock);
00472 
00473     /* Initialize Timer List */
00474     InitializeListHead(&IopTimerQueueHead);
00475 
00476     /* Initialize the DPC/Timer which will call the other Timer Routines */
00477     ExpireTime.QuadPart = -10000000;
00478     KeInitializeDpc(&IopTimerDpc, IopTimerDispatch, NULL);
00479     KeInitializeTimerEx(&IopTimer, SynchronizationTimer);
00480     KeSetTimerEx(&IopTimer, ExpireTime, 1000, &IopTimerDpc);
00481 
00482     /* Create Object Types */
00483     if (!IopCreateObjectTypes())
00484     {
00485         DPRINT1("IopCreateObjectTypes failed!\n");
00486         return FALSE;
00487     }
00488 
00489     /* Create Object Directories */
00490     if (!IopCreateRootDirectories())
00491     {
00492         DPRINT1("IopCreateRootDirectories failed!\n");
00493         return FALSE;
00494     }
00495 
00496     /* Initialize PnP manager */
00497     IopInitializePlugPlayServices();
00498 
00499     /* Initialize HAL Root Bus Driver */
00500     HalInitPnpDriver();
00501 
00502     /* Make loader block available for the whole kernel */
00503     IopLoaderBlock = LoaderBlock;
00504 
00505     /* Load boot start drivers */
00506     IopInitializeBootDrivers();
00507 
00508     /* Call back drivers that asked for */
00509     IopReinitializeBootDrivers();
00510 
00511     /* Check if this was a ramdisk boot */
00512     if (!_strnicmp(LoaderBlock->ArcBootDeviceName, "ramdisk(0)", 10))
00513     {
00514         /* Initialize the ramdisk driver */
00515         IopStartRamdisk(LoaderBlock);
00516     }
00517 
00518     /* No one should need loader block any longer */
00519     IopLoaderBlock = NULL;
00520 
00521     /* Create ARC names for boot devices */
00522     Status = IopCreateArcNames(LoaderBlock);
00523     if (!NT_SUCCESS(Status))
00524     {
00525         DPRINT1("IopCreateArcNames failed: %lx\n", Status);
00526         return FALSE;
00527     }
00528 
00529     /* Mark the system boot partition */
00530     if (!IopMarkBootPartition(LoaderBlock))
00531     {
00532         DPRINT1("IopMarkBootPartition failed!\n");
00533         return FALSE;
00534     }
00535 
00536     /* Initialize PnP root relations */
00537     IopEnumerateDevice(IopRootDeviceNode->PhysicalDeviceObject);
00538 
00539 #ifndef _WINKD_
00540     /* Read KDB Data */
00541     KdbInit();
00542 
00543     /* I/O is now setup for disk access, so phase 3 */
00544     KdInitSystem(3, LoaderBlock);
00545 #endif
00546 
00547     /* Load services for devices found by PnP manager */
00548     IopInitializePnpServices(IopRootDeviceNode);
00549 
00550     /* Load system start drivers */
00551     IopInitializeSystemDrivers();
00552     PnpSystemInit = TRUE;
00553 
00554     /* Reinitialize drivers that requested it */
00555     IopReinitializeDrivers();
00556 
00557     /* Convert SystemRoot from ARC to NT path */
00558     Status = IopReassignSystemRoot(LoaderBlock, &NtBootPath);
00559     if (!NT_SUCCESS(Status))
00560     {
00561         DPRINT1("IopReassignSystemRoot failed: %lx\n", Status);
00562         return FALSE;
00563     }
00564 
00565     /* Set the ANSI_STRING for the root path */
00566     RootString.MaximumLength = NtSystemRoot.MaximumLength / sizeof(WCHAR);
00567     RootString.Length = 0;
00568     RootString.Buffer = ExAllocatePoolWithTag(PagedPool,
00569                                               RootString.MaximumLength,
00570                                               TAG_IO);
00571 
00572     /* Convert the path into the ANSI_STRING */
00573     Status = RtlUnicodeStringToAnsiString(&RootString, &NtSystemRoot, FALSE);
00574     if (!NT_SUCCESS(Status))
00575     {
00576         DPRINT1("RtlUnicodeStringToAnsiString failed: %lx\n", Status);
00577         return FALSE;
00578     }
00579 
00580     /* Assign drive letters */
00581     IoAssignDriveLetters(LoaderBlock,
00582                          &NtBootPath,
00583                          (PUCHAR)RootString.Buffer,
00584                          &RootString);
00585 
00586     /* Update system root */
00587     Status = RtlAnsiStringToUnicodeString(&NtSystemRoot, &RootString, FALSE);
00588     if (!NT_SUCCESS(Status))
00589     {
00590         DPRINT1("RtlAnsiStringToUnicodeString failed: %lx\n", Status);
00591         return FALSE;
00592     }
00593 
00594     /* Load the System DLL and its Entrypoints */
00595     Status = PsLocateSystemDll();
00596     if (!NT_SUCCESS(Status))
00597     {
00598         DPRINT1("PsLocateSystemDll failed: %lx\n", Status);
00599         return FALSE;
00600     }
00601 
00602     /* Return success */
00603     return TRUE;
00604 }
00605 
00606 /* EOF */

Generated on Sun May 27 2012 04:37:16 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.