@@ -75,6 +75,8 @@ NtLdrOutputLoadMsg(
7575VOID WinLdrSetOperatingSystemVersion (
7676 IN ULONG VersionToBoot )
7777{
78+ WinLdrSystemBlock -> OsVersion = VersionToBoot ;
79+
7880 if (VersionToBoot >= _WIN32_WINNT_WIN7 )
7981 {
8082 WinLdrSystemBlock -> u1 .LoaderBlockWin7 .OsMajorVersion = (VersionToBoot & 0xFF00 ) >> 8 ;
@@ -375,6 +377,8 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
375377 PLDR_DATA_TABLE_ENTRY * DriverDTE )
376378{
377379 CHAR FullPath [1024 ];
380+ CHAR FullFileName [1024 ];
381+ CHAR ArcPath [1024 ];
378382 CHAR DriverPath [1024 ];
379383 CHAR DllName [1024 ];
380384 PCHAR DriverNamePos ;
@@ -410,20 +414,21 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
410414 }
411415
412416 // It's not loaded, we have to load it
413- RtlStringCbPrintfA (FullPath , sizeof (FullPath ), "%s%wZ" , BootPath , FilePath );
417+ RtlStringCbPrintfA (ArcPath , sizeof (ArcPath ), "%s%wZ" , BootPath , FilePath );
414418
415- NtLdrOutputLoadMsg (FullPath , NULL );
416- Success = PeLdrLoadImage (FullPath , LoaderBootDriver , & DriverBase );
419+ NtLdrOutputLoadMsg (ArcPath , NULL );
420+ Success = PeLdrLoadImage (ArcPath , LoaderBootDriver , & DriverBase );
417421 if (!Success )
418422 {
419423 ERR ("PeLdrLoadImage('%s') failed\n" , DllName );
420424 return FALSE;
421425 }
422426
423427 // Allocate a DTE for it
428+ RtlStringCbPrintfA (FullFileName , sizeof (FullFileName ), "\\SystemRoot\\%s%s" , DriverPath , DllName );
424429 Success = PeLdrAllocateDataTableEntry (LoadOrderListHead ,
425430 DllName ,
426- DllName ,
431+ FullFileName ,
427432 PaToVa (DriverBase ),
428433 DriverDTE );
429434 if (!Success )
@@ -441,8 +446,9 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
441446 (* DriverDTE )-> Flags |= Flags ;
442447
443448 // Look for any dependencies it may have, and load them too
444- RtlStringCbPrintfA (FullPath , sizeof (FullPath ), "%s%s" , BootPath , DriverPath );
445- Success = PeLdrScanImportDescriptorTable (LoadOrderListHead , FullPath , * DriverDTE );
449+ RtlStringCbPrintfA (ArcPath , sizeof (ArcPath ), "%s%s" , BootPath , DriverPath );
450+ RtlStringCbPrintfA (FullPath , sizeof (FullPath ), "\\SystemRoot\\%s" , DriverPath );
451+ Success = PeLdrScanImportDescriptorTable (LoadOrderListHead , FullPath , ArcPath , * DriverDTE );
446452 if (!Success )
447453 {
448454 /* Cleanup and bail out */
@@ -596,6 +602,7 @@ PVOID
596602LoadModule (
597603 IN OUT PLOADER_PARAMETER_BLOCK1 LoaderBlock1 ,
598604 IN PCCH Path ,
605+ IN PCCH ArcPath ,
599606 IN PCCH File ,
600607 IN PCCH ImportName , // BaseDllName
601608 IN TYPE_OF_MEMORY MemoryType ,
@@ -604,6 +611,7 @@ LoadModule(
604611{
605612 BOOLEAN Success ;
606613 CHAR FullFileName [MAX_PATH ];
614+ CHAR ArcFileName [MAX_PATH ];
607615 CHAR ProgressString [256 ];
608616 PVOID BaseAddress ;
609617
@@ -613,8 +621,11 @@ LoadModule(
613621 RtlStringCbCopyA (FullFileName , sizeof (FullFileName ), Path );
614622 RtlStringCbCatA (FullFileName , sizeof (FullFileName ), File );
615623
616- NtLdrOutputLoadMsg (FullFileName , NULL );
617- Success = PeLdrLoadImage (FullFileName , MemoryType , & BaseAddress );
624+ RtlStringCbCopyA (ArcFileName , sizeof (ArcFileName ), ArcPath );
625+ RtlStringCbCatA (ArcFileName , sizeof (ArcFileName ), File );
626+
627+ NtLdrOutputLoadMsg (ArcFileName , NULL );
628+ Success = PeLdrLoadImage (ArcFileName , MemoryType , & BaseAddress );
618629 if (!Success )
619630 {
620631 ERR ("PeLdrLoadImage('%s') failed\n" , File );
@@ -630,7 +641,7 @@ LoadModule(
630641 if (!Success )
631642 {
632643 /* Cleanup and bail out */
633- ERR ("PeLdrAllocateDataTableEntry('%s') failed\n" , FullFileName );
644+ ERR ("PeLdrAllocateDataTableEntry('%s') failed\n" , ArcFileName );
634645 MmFreeMemory (BaseAddress );
635646 return NULL ;
636647 }
@@ -709,6 +720,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
709720 ULONG OptionLength ;
710721 PVOID KernelBase , HalBase , KdDllBase = NULL ;
711722 PLDR_DATA_TABLE_ENTRY HalDTE , KdDllDTE = NULL ;
723+ CHAR ArcPath [MAX_PATH ];
712724 CHAR DirPath [MAX_PATH ];
713725 CHAR HalFileName [MAX_PATH ];
714726 CHAR KernelFileName [MAX_PATH ];
@@ -717,8 +729,11 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
717729 if (!KernelDTE ) return FALSE;
718730
719731 /* Initialize SystemRoot\System32 path */
720- RtlStringCbCopyA (DirPath , sizeof (DirPath ), BootPath );
721- RtlStringCbCatA (DirPath , sizeof (DirPath ), "system32\\" );
732+ RtlStringCbCopyA (DirPath , sizeof (DirPath ), "\\SystemRoot\\system32\\" );
733+
734+ /* Initialize SystemRoot\System32 arc path */
735+ RtlStringCbCopyA (ArcPath , sizeof (ArcPath ), BootPath );
736+ RtlStringCbCatA (ArcPath , sizeof (ArcPath ), "system32\\" );
722737
723738 /* Parse the boot options */
724739 TRACE ("LoadWindowsCore: BootOptions '%s'\n" , BootOptions );
@@ -841,7 +856,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
841856 */
842857
843858 /* Load the Kernel */
844- KernelBase = LoadModule (LoaderBlock1 , DirPath , KernelFileName ,
859+ KernelBase = LoadModule (LoaderBlock1 , DirPath , ArcPath , KernelFileName ,
845860 "ntoskrnl.exe" , LoaderSystemCode , KernelDTE , 30 );
846861 if (!KernelBase )
847862 {
@@ -851,7 +866,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
851866 }
852867
853868 /* Load the HAL */
854- HalBase = LoadModule (LoaderBlock1 , DirPath , HalFileName ,
869+ HalBase = LoadModule (LoaderBlock1 , DirPath , ArcPath , HalFileName ,
855870 "hal.dll" , LoaderHalCode , & HalDTE , 35 );
856871 if (!HalBase )
857872 {
@@ -926,7 +941,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
926941 _strlwr (KdDllName );
927942
928943 /* Load the KD DLL. Override its base DLL name to the default "KDCOM.DLL". */
929- KdDllBase = LoadModule (LoaderBlock1 , DirPath , KdDllName ,
944+ KdDllBase = LoadModule (LoaderBlock1 , DirPath , ArcPath , KdDllName ,
930945 "kdcom.dll" , LoaderSystemCode , & KdDllDTE , 40 );
931946 if (!KdDllBase )
932947 {
@@ -939,7 +954,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
939954 IsCustomKdDll = FALSE;
940955 RtlStringCbCopyA (KdDllName , sizeof (KdDllName ), "kdcom.dll" );
941956
942- KdDllBase = LoadModule (LoaderBlock1 , DirPath , KdDllName ,
957+ KdDllBase = LoadModule (LoaderBlock1 , DirPath , ArcPath , KdDllName ,
943958 "kdcom.dll" , LoaderSystemCode , & KdDllDTE , 40 );
944959 }
945960
@@ -953,21 +968,21 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
953968 }
954969
955970 /* Load all referenced DLLs for Kernel, HAL and Kernel Debugger Transport DLL */
956- Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , * KernelDTE );
971+ Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , ArcPath , * KernelDTE );
957972 if (!Success )
958973 {
959974 UiMessageBox ("Could not load %s" , KernelFileName );
960975 goto Quit ;
961976 }
962- Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , HalDTE );
977+ Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , ArcPath , HalDTE );
963978 if (!Success )
964979 {
965980 UiMessageBox ("Could not load %s" , HalFileName );
966981 goto Quit ;
967982 }
968983 if (KdDllDTE )
969984 {
970- Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , KdDllDTE );
985+ Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , ArcPath , KdDllDTE );
971986 if (!Success )
972987 {
973988 UiMessageBox ("Could not load %s" , KdDllName );
0 commit comments