@@ -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 ;
@@ -371,6 +373,8 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
371373 PLDR_DATA_TABLE_ENTRY * DriverDTE )
372374{
373375 CHAR FullPath [1024 ];
376+ CHAR FullFileName [1024 ];
377+ CHAR ArcPath [1024 ];
374378 CHAR DriverPath [1024 ];
375379 CHAR DllName [1024 ];
376380 PCHAR DriverNamePos ;
@@ -406,20 +410,21 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
406410 }
407411
408412 // It's not loaded, we have to load it
409- RtlStringCbPrintfA (FullPath , sizeof (FullPath ), "%s%wZ" , BootPath , FilePath );
413+ RtlStringCbPrintfA (ArcPath , sizeof (ArcPath ), "%s%wZ" , BootPath , FilePath );
410414
411- NtLdrOutputLoadMsg (FullPath , NULL );
412- Success = PeLdrLoadImage (FullPath , LoaderBootDriver , & DriverBase );
415+ NtLdrOutputLoadMsg (ArcPath , NULL );
416+ Success = PeLdrLoadImage (ArcPath , LoaderBootDriver , & DriverBase );
413417 if (!Success )
414418 {
415419 ERR ("PeLdrLoadImage('%s') failed\n" , DllName );
416420 return FALSE;
417421 }
418422
419423 // Allocate a DTE for it
424+ RtlStringCbPrintfA (FullFileName , sizeof (FullFileName ), "\\SystemRoot\\%s%s" , DriverPath , DllName );
420425 Success = PeLdrAllocateDataTableEntry (LoadOrderListHead ,
421426 DllName ,
422- DllName ,
427+ FullFileName ,
423428 PaToVa (DriverBase ),
424429 DriverDTE );
425430 if (!Success )
@@ -437,8 +442,9 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
437442 (* DriverDTE )-> Flags |= Flags ;
438443
439444 // Look for any dependencies it may have, and load them too
440- RtlStringCbPrintfA (FullPath , sizeof (FullPath ), "%s%s" , BootPath , DriverPath );
441- Success = PeLdrScanImportDescriptorTable (LoadOrderListHead , FullPath , * DriverDTE );
445+ RtlStringCbPrintfA (ArcPath , sizeof (ArcPath ), "%s%s" , BootPath , DriverPath );
446+ RtlStringCbPrintfA (FullPath , sizeof (FullPath ), "\\SystemRoot\\%s" , DriverPath );
447+ Success = PeLdrScanImportDescriptorTable (LoadOrderListHead , FullPath , ArcPath , * DriverDTE );
442448 if (!Success )
443449 {
444450 /* Cleanup and bail out */
@@ -592,6 +598,7 @@ PVOID
592598LoadModule (
593599 IN OUT PLOADER_PARAMETER_BLOCK1 LoaderBlock1 ,
594600 IN PCCH Path ,
601+ IN PCCH ArcPath ,
595602 IN PCCH File ,
596603 IN PCCH ImportName , // BaseDllName
597604 IN TYPE_OF_MEMORY MemoryType ,
@@ -600,6 +607,7 @@ LoadModule(
600607{
601608 BOOLEAN Success ;
602609 CHAR FullFileName [MAX_PATH ];
610+ CHAR ArcFileName [MAX_PATH ];
603611 CHAR ProgressString [256 ];
604612 PVOID BaseAddress ;
605613
@@ -609,8 +617,11 @@ LoadModule(
609617 RtlStringCbCopyA (FullFileName , sizeof (FullFileName ), Path );
610618 RtlStringCbCatA (FullFileName , sizeof (FullFileName ), File );
611619
612- NtLdrOutputLoadMsg (FullFileName , NULL );
613- Success = PeLdrLoadImage (FullFileName , MemoryType , & BaseAddress );
620+ RtlStringCbCopyA (ArcFileName , sizeof (ArcFileName ), ArcPath );
621+ RtlStringCbCatA (ArcFileName , sizeof (ArcFileName ), File );
622+
623+ NtLdrOutputLoadMsg (ArcFileName , NULL );
624+ Success = PeLdrLoadImage (ArcFileName , MemoryType , & BaseAddress );
614625 if (!Success )
615626 {
616627 ERR ("PeLdrLoadImage('%s') failed\n" , File );
@@ -626,7 +637,7 @@ LoadModule(
626637 if (!Success )
627638 {
628639 /* Cleanup and bail out */
629- ERR ("PeLdrAllocateDataTableEntry('%s') failed\n" , FullFileName );
640+ ERR ("PeLdrAllocateDataTableEntry('%s') failed\n" , ArcFileName );
630641 MmFreeMemory (BaseAddress );
631642 return NULL ;
632643 }
@@ -705,6 +716,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
705716 ULONG OptionLength ;
706717 PVOID KernelBase , HalBase , KdDllBase = NULL ;
707718 PLDR_DATA_TABLE_ENTRY HalDTE , KdDllDTE = NULL ;
719+ CHAR ArcPath [MAX_PATH ];
708720 CHAR DirPath [MAX_PATH ];
709721 CHAR HalFileName [MAX_PATH ];
710722 CHAR KernelFileName [MAX_PATH ];
@@ -713,8 +725,11 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
713725 if (!KernelDTE ) return FALSE;
714726
715727 /* Initialize SystemRoot\System32 path */
716- RtlStringCbCopyA (DirPath , sizeof (DirPath ), BootPath );
717- RtlStringCbCatA (DirPath , sizeof (DirPath ), "system32\\" );
728+ RtlStringCbCopyA (DirPath , sizeof (DirPath ), "\\SystemRoot\\system32\\" );
729+
730+ /* Initialize SystemRoot\System32 arc path */
731+ RtlStringCbCopyA (ArcPath , sizeof (ArcPath ), BootPath );
732+ RtlStringCbCatA (ArcPath , sizeof (ArcPath ), "system32\\" );
718733
719734 /* Parse the boot options */
720735 TRACE ("LoadWindowsCore: BootOptions '%s'\n" , BootOptions );
@@ -837,7 +852,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
837852 */
838853
839854 /* Load the Kernel */
840- KernelBase = LoadModule (LoaderBlock1 , DirPath , KernelFileName ,
855+ KernelBase = LoadModule (LoaderBlock1 , DirPath , ArcPath , KernelFileName ,
841856 "ntoskrnl.exe" , LoaderSystemCode , KernelDTE , 30 );
842857 if (!KernelBase )
843858 {
@@ -847,7 +862,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
847862 }
848863
849864 /* Load the HAL */
850- HalBase = LoadModule (LoaderBlock1 , DirPath , HalFileName ,
865+ HalBase = LoadModule (LoaderBlock1 , DirPath , ArcPath , HalFileName ,
851866 "hal.dll" , LoaderHalCode , & HalDTE , 35 );
852867 if (!HalBase )
853868 {
@@ -922,7 +937,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
922937 _strlwr (KdDllName );
923938
924939 /* Load the KD DLL. Override its base DLL name to the default "KDCOM.DLL". */
925- KdDllBase = LoadModule (LoaderBlock1 , DirPath , KdDllName ,
940+ KdDllBase = LoadModule (LoaderBlock1 , DirPath , ArcPath , KdDllName ,
926941 "kdcom.dll" , LoaderSystemCode , & KdDllDTE , 40 );
927942 if (!KdDllBase )
928943 {
@@ -935,7 +950,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
935950 IsCustomKdDll = FALSE;
936951 RtlStringCbCopyA (KdDllName , sizeof (KdDllName ), "kdcom.dll" );
937952
938- KdDllBase = LoadModule (LoaderBlock1 , DirPath , KdDllName ,
953+ KdDllBase = LoadModule (LoaderBlock1 , DirPath , ArcPath , KdDllName ,
939954 "kdcom.dll" , LoaderSystemCode , & KdDllDTE , 40 );
940955 }
941956
@@ -949,21 +964,21 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
949964 }
950965
951966 /* Load all referenced DLLs for Kernel, HAL and Kernel Debugger Transport DLL */
952- Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , * KernelDTE );
967+ Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , ArcPath , * KernelDTE );
953968 if (!Success )
954969 {
955970 UiMessageBox ("Could not load %s" , KernelFileName );
956971 goto Quit ;
957972 }
958- Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , HalDTE );
973+ Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , ArcPath , HalDTE );
959974 if (!Success )
960975 {
961976 UiMessageBox ("Could not load %s" , HalFileName );
962977 goto Quit ;
963978 }
964979 if (KdDllDTE )
965980 {
966- Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , KdDllDTE );
981+ Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , ArcPath , KdDllDTE );
967982 if (!Success )
968983 {
969984 UiMessageBox ("Could not load %s" , KdDllName );
0 commit comments