@@ -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 ;
@@ -377,6 +379,8 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
377379 PLDR_DATA_TABLE_ENTRY * DriverDTE )
378380{
379381 CHAR FullPath [1024 ];
382+ CHAR FullFileName [1024 ];
383+ CHAR ArcPath [1024 ];
380384 CHAR DriverPath [1024 ];
381385 CHAR DllName [1024 ];
382386 PCHAR DriverNamePos ;
@@ -412,20 +416,21 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
412416 }
413417
414418 // It's not loaded, we have to load it
415- RtlStringCbPrintfA (FullPath , sizeof (FullPath ), "%s%wZ" , BootPath , FilePath );
419+ RtlStringCbPrintfA (ArcPath , sizeof (ArcPath ), "%s%wZ" , BootPath , FilePath );
416420
417- NtLdrOutputLoadMsg (FullPath , NULL );
418- Success = PeLdrLoadImage (FullPath , LoaderBootDriver , & DriverBase );
421+ NtLdrOutputLoadMsg (ArcPath , NULL );
422+ Success = PeLdrLoadImage (ArcPath , LoaderBootDriver , & DriverBase );
419423 if (!Success )
420424 {
421425 ERR ("PeLdrLoadImage('%s') failed\n" , DllName );
422426 return FALSE;
423427 }
424428
425429 // Allocate a DTE for it
430+ RtlStringCbPrintfA (FullFileName , sizeof (FullFileName ), "\\SystemRoot\\%s%s" , DriverPath , DllName );
426431 Success = PeLdrAllocateDataTableEntry (LoadOrderListHead ,
427432 DllName ,
428- DllName ,
433+ FullFileName ,
429434 PaToVa (DriverBase ),
430435 DriverDTE );
431436 if (!Success )
@@ -443,8 +448,9 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
443448 (* DriverDTE )-> Flags |= Flags ;
444449
445450 // Look for any dependencies it may have, and load them too
446- RtlStringCbPrintfA (FullPath , sizeof (FullPath ), "%s%s" , BootPath , DriverPath );
447- Success = PeLdrScanImportDescriptorTable (LoadOrderListHead , FullPath , * DriverDTE );
451+ RtlStringCbPrintfA (ArcPath , sizeof (ArcPath ), "%s%s" , BootPath , DriverPath );
452+ RtlStringCbPrintfA (FullPath , sizeof (FullPath ), "\\SystemRoot\\%s" , DriverPath );
453+ Success = PeLdrScanImportDescriptorTable (LoadOrderListHead , FullPath , ArcPath , * DriverDTE );
448454 if (!Success )
449455 {
450456 /* Cleanup and bail out */
@@ -598,6 +604,7 @@ PVOID
598604LoadModule (
599605 IN OUT PLOADER_PARAMETER_BLOCK1 LoaderBlock1 ,
600606 IN PCCH Path ,
607+ IN PCCH ArcPath ,
601608 IN PCCH File ,
602609 IN PCCH ImportName , // BaseDllName
603610 IN TYPE_OF_MEMORY MemoryType ,
@@ -606,6 +613,7 @@ LoadModule(
606613{
607614 BOOLEAN Success ;
608615 CHAR FullFileName [MAX_PATH ];
616+ CHAR ArcFileName [MAX_PATH ];
609617 CHAR ProgressString [256 ];
610618 PVOID BaseAddress ;
611619
@@ -615,8 +623,11 @@ LoadModule(
615623 RtlStringCbCopyA (FullFileName , sizeof (FullFileName ), Path );
616624 RtlStringCbCatA (FullFileName , sizeof (FullFileName ), File );
617625
618- NtLdrOutputLoadMsg (FullFileName , NULL );
619- Success = PeLdrLoadImage (FullFileName , MemoryType , & BaseAddress );
626+ RtlStringCbCopyA (ArcFileName , sizeof (ArcFileName ), ArcPath );
627+ RtlStringCbCatA (ArcFileName , sizeof (ArcFileName ), File );
628+
629+ NtLdrOutputLoadMsg (ArcFileName , NULL );
630+ Success = PeLdrLoadImage (ArcFileName , MemoryType , & BaseAddress );
620631 if (!Success )
621632 {
622633 ERR ("PeLdrLoadImage('%s') failed\n" , File );
@@ -632,7 +643,7 @@ LoadModule(
632643 if (!Success )
633644 {
634645 /* Cleanup and bail out */
635- ERR ("PeLdrAllocateDataTableEntry('%s') failed\n" , FullFileName );
646+ ERR ("PeLdrAllocateDataTableEntry('%s') failed\n" , ArcFileName );
636647 MmFreeMemory (BaseAddress );
637648 return NULL ;
638649 }
@@ -711,6 +722,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
711722 ULONG OptionLength ;
712723 PVOID KernelBase , HalBase , KdDllBase = NULL ;
713724 PLDR_DATA_TABLE_ENTRY HalDTE , KdDllDTE = NULL ;
725+ CHAR ArcPath [MAX_PATH ];
714726 CHAR DirPath [MAX_PATH ];
715727 CHAR HalFileName [MAX_PATH ];
716728 CHAR KernelFileName [MAX_PATH ];
@@ -719,8 +731,11 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
719731 if (!KernelDTE ) return FALSE;
720732
721733 /* Initialize SystemRoot\System32 path */
722- RtlStringCbCopyA (DirPath , sizeof (DirPath ), BootPath );
723- RtlStringCbCatA (DirPath , sizeof (DirPath ), "system32\\" );
734+ RtlStringCbCopyA (DirPath , sizeof (DirPath ), "\\SystemRoot\\system32\\" );
735+
736+ /* Initialize SystemRoot\System32 arc path */
737+ RtlStringCbCopyA (ArcPath , sizeof (ArcPath ), BootPath );
738+ RtlStringCbCatA (ArcPath , sizeof (ArcPath ), "system32\\" );
724739
725740 /* Parse the boot options */
726741 TRACE ("LoadWindowsCore: BootOptions '%s'\n" , BootOptions );
@@ -843,7 +858,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
843858 */
844859
845860 /* Load the Kernel */
846- KernelBase = LoadModule (LoaderBlock1 , DirPath , KernelFileName ,
861+ KernelBase = LoadModule (LoaderBlock1 , DirPath , ArcPath , KernelFileName ,
847862 "ntoskrnl.exe" , LoaderSystemCode , KernelDTE , 30 );
848863 if (!KernelBase )
849864 {
@@ -853,7 +868,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
853868 }
854869
855870 /* Load the HAL */
856- HalBase = LoadModule (LoaderBlock1 , DirPath , HalFileName ,
871+ HalBase = LoadModule (LoaderBlock1 , DirPath , ArcPath , HalFileName ,
857872 "hal.dll" , LoaderHalCode , & HalDTE , 35 );
858873 if (!HalBase )
859874 {
@@ -928,7 +943,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
928943 _strlwr (KdDllName );
929944
930945 /* Load the KD DLL. Override its base DLL name to the default "KDCOM.DLL". */
931- KdDllBase = LoadModule (LoaderBlock1 , DirPath , KdDllName ,
946+ KdDllBase = LoadModule (LoaderBlock1 , DirPath , ArcPath , KdDllName ,
932947 "kdcom.dll" , LoaderSystemCode , & KdDllDTE , 40 );
933948 if (!KdDllBase )
934949 {
@@ -941,7 +956,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
941956 IsCustomKdDll = FALSE;
942957 RtlStringCbCopyA (KdDllName , sizeof (KdDllName ), "kdcom.dll" );
943958
944- KdDllBase = LoadModule (LoaderBlock1 , DirPath , KdDllName ,
959+ KdDllBase = LoadModule (LoaderBlock1 , DirPath , ArcPath , KdDllName ,
945960 "kdcom.dll" , LoaderSystemCode , & KdDllDTE , 40 );
946961 }
947962
@@ -955,21 +970,21 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
955970 }
956971
957972 /* Load all referenced DLLs for Kernel, HAL and Kernel Debugger Transport DLL */
958- Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , * KernelDTE );
973+ Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , ArcPath , * KernelDTE );
959974 if (!Success )
960975 {
961976 UiMessageBox ("Could not load %s" , KernelFileName );
962977 goto Quit ;
963978 }
964- Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , HalDTE );
979+ Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , ArcPath , HalDTE );
965980 if (!Success )
966981 {
967982 UiMessageBox ("Could not load %s" , HalFileName );
968983 goto Quit ;
969984 }
970985 if (KdDllDTE )
971986 {
972- Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , KdDllDTE );
987+ Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , ArcPath , KdDllDTE );
973988 if (!Success )
974989 {
975990 UiMessageBox ("Could not load %s" , KdDllName );
0 commit comments