@@ -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 -> LoaderBlockWin7 .OsMajorVersion = (VersionToBoot & 0xFF00 ) >> 8 ;
@@ -121,7 +123,7 @@ AllocateAndInitLPB(
121123 RtlZeroMemory (WinLdrSystemBlock , sizeof (LOADER_SYSTEM_BLOCK ));
122124
123125 LoaderBlock = (PCHAR )& WinLdrSystemBlock -> LoaderBlockVista ;
124- * ( PULONG ) LoaderBlock = VersionToBoot ;
126+ WinLdrSystemBlock -> OsVersion = VersionToBoot ;
125127
126128 if (VersionToBoot >= _WIN32_WINNT_WIN7 )
127129 {
@@ -378,6 +380,8 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
378380 PLDR_DATA_TABLE_ENTRY * DriverDTE )
379381{
380382 CHAR FullPath [1024 ];
383+ CHAR FullFileName [1024 ];
384+ CHAR ArcPath [1024 ];
381385 CHAR DriverPath [1024 ];
382386 CHAR DllName [1024 ];
383387 PCHAR DriverNamePos ;
@@ -413,20 +417,21 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
413417 }
414418
415419 // It's not loaded, we have to load it
416- RtlStringCbPrintfA (FullPath , sizeof (FullPath ), "%s%wZ" , BootPath , FilePath );
420+ RtlStringCbPrintfA (ArcPath , sizeof (ArcPath ), "%s%wZ" , BootPath , FilePath );
417421
418- NtLdrOutputLoadMsg (FullPath , NULL );
419- Success = PeLdrLoadImage (FullPath , LoaderBootDriver , & DriverBase );
422+ NtLdrOutputLoadMsg (ArcPath , NULL );
423+ Success = PeLdrLoadImage (ArcPath , LoaderBootDriver , & DriverBase );
420424 if (!Success )
421425 {
422426 ERR ("PeLdrLoadImage('%s') failed\n" , DllName );
423427 return FALSE;
424428 }
425429
426430 // Allocate a DTE for it
431+ RtlStringCbPrintfA (FullFileName , sizeof (FullFileName ), "\\SystemRoot\\%s%s" , DriverPath , DllName );
427432 Success = PeLdrAllocateDataTableEntry (LoadOrderListHead ,
428433 DllName ,
429- DllName ,
434+ FullFileName ,
430435 PaToVa (DriverBase ),
431436 DriverDTE );
432437 if (!Success )
@@ -444,8 +449,9 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
444449 (* DriverDTE )-> Flags |= Flags ;
445450
446451 // Look for any dependencies it may have, and load them too
447- RtlStringCbPrintfA (FullPath , sizeof (FullPath ), "%s%s" , BootPath , DriverPath );
448- Success = PeLdrScanImportDescriptorTable (LoadOrderListHead , FullPath , * DriverDTE );
452+ RtlStringCbPrintfA (ArcPath , sizeof (ArcPath ), "%s%s" , BootPath , DriverPath );
453+ RtlStringCbPrintfA (FullPath , sizeof (FullPath ), "\\SystemRoot\\%s" , DriverPath );
454+ Success = PeLdrScanImportDescriptorTable (LoadOrderListHead , FullPath , ArcPath , * DriverDTE );
449455 if (!Success )
450456 {
451457 /* Cleanup and bail out */
@@ -599,6 +605,7 @@ PVOID
599605LoadModule (
600606 IN OUT PLOADER_PARAMETER_BLOCK1 LoaderBlock1 ,
601607 IN PCCH Path ,
608+ IN PCCH ArcPath ,
602609 IN PCCH File ,
603610 IN PCCH ImportName , // BaseDllName
604611 IN TYPE_OF_MEMORY MemoryType ,
@@ -607,6 +614,7 @@ LoadModule(
607614{
608615 BOOLEAN Success ;
609616 CHAR FullFileName [MAX_PATH ];
617+ CHAR ArcFileName [MAX_PATH ];
610618 CHAR ProgressString [256 ];
611619 PVOID BaseAddress ;
612620
@@ -616,8 +624,11 @@ LoadModule(
616624 RtlStringCbCopyA (FullFileName , sizeof (FullFileName ), Path );
617625 RtlStringCbCatA (FullFileName , sizeof (FullFileName ), File );
618626
619- NtLdrOutputLoadMsg (FullFileName , NULL );
620- Success = PeLdrLoadImage (FullFileName , MemoryType , & BaseAddress );
627+ RtlStringCbCopyA (ArcFileName , sizeof (ArcFileName ), ArcPath );
628+ RtlStringCbCatA (ArcFileName , sizeof (ArcFileName ), File );
629+
630+ NtLdrOutputLoadMsg (ArcFileName , NULL );
631+ Success = PeLdrLoadImage (ArcFileName , MemoryType , & BaseAddress );
621632 if (!Success )
622633 {
623634 ERR ("PeLdrLoadImage('%s') failed\n" , File );
@@ -633,7 +644,7 @@ LoadModule(
633644 if (!Success )
634645 {
635646 /* Cleanup and bail out */
636- ERR ("PeLdrAllocateDataTableEntry('%s') failed\n" , FullFileName );
647+ ERR ("PeLdrAllocateDataTableEntry('%s') failed\n" , ArcFileName );
637648 MmFreeMemory (BaseAddress );
638649 return NULL ;
639650 }
@@ -712,6 +723,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
712723 ULONG OptionLength ;
713724 PVOID KernelBase , HalBase , KdDllBase = NULL ;
714725 PLDR_DATA_TABLE_ENTRY HalDTE , KdDllDTE = NULL ;
726+ CHAR ArcPath [MAX_PATH ];
715727 CHAR DirPath [MAX_PATH ];
716728 CHAR HalFileName [MAX_PATH ];
717729 CHAR KernelFileName [MAX_PATH ];
@@ -720,8 +732,11 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
720732 if (!KernelDTE ) return FALSE;
721733
722734 /* Initialize SystemRoot\System32 path */
723- RtlStringCbCopyA (DirPath , sizeof (DirPath ), BootPath );
724- RtlStringCbCatA (DirPath , sizeof (DirPath ), "system32\\" );
735+ RtlStringCbCopyA (DirPath , sizeof (DirPath ), "\\SystemRoot\\system32\\" );
736+
737+ /* Initialize SystemRoot\System32 arc path */
738+ RtlStringCbCopyA (ArcPath , sizeof (ArcPath ), BootPath );
739+ RtlStringCbCatA (ArcPath , sizeof (ArcPath ), "system32\\" );
725740
726741 /* Parse the boot options */
727742 TRACE ("LoadWindowsCore: BootOptions '%s'\n" , BootOptions );
@@ -844,7 +859,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
844859 */
845860
846861 /* Load the Kernel */
847- KernelBase = LoadModule (LoaderBlock1 , DirPath , KernelFileName ,
862+ KernelBase = LoadModule (LoaderBlock1 , DirPath , ArcPath , KernelFileName ,
848863 "ntoskrnl.exe" , LoaderSystemCode , KernelDTE , 30 );
849864 if (!KernelBase )
850865 {
@@ -854,7 +869,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
854869 }
855870
856871 /* Load the HAL */
857- HalBase = LoadModule (LoaderBlock1 , DirPath , HalFileName ,
872+ HalBase = LoadModule (LoaderBlock1 , DirPath , ArcPath , HalFileName ,
858873 "hal.dll" , LoaderHalCode , & HalDTE , 35 );
859874 if (!HalBase )
860875 {
@@ -929,7 +944,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
929944 _strlwr (KdDllName );
930945
931946 /* Load the KD DLL. Override its base DLL name to the default "KDCOM.DLL". */
932- KdDllBase = LoadModule (LoaderBlock1 , DirPath , KdDllName ,
947+ KdDllBase = LoadModule (LoaderBlock1 , DirPath , ArcPath , KdDllName ,
933948 "kdcom.dll" , LoaderSystemCode , & KdDllDTE , 40 );
934949 if (!KdDllBase )
935950 {
@@ -942,7 +957,7 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
942957 IsCustomKdDll = FALSE;
943958 RtlStringCbCopyA (KdDllName , sizeof (KdDllName ), "kdcom.dll" );
944959
945- KdDllBase = LoadModule (LoaderBlock1 , DirPath , KdDllName ,
960+ KdDllBase = LoadModule (LoaderBlock1 , DirPath , ArcPath , KdDllName ,
946961 "kdcom.dll" , LoaderSystemCode , & KdDllDTE , 40 );
947962 }
948963
@@ -956,21 +971,21 @@ LoadWindowsCore(IN USHORT OperatingSystemVersion,
956971 }
957972
958973 /* Load all referenced DLLs for Kernel, HAL and Kernel Debugger Transport DLL */
959- Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , * KernelDTE );
974+ Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , ArcPath , * KernelDTE );
960975 if (!Success )
961976 {
962977 UiMessageBox ("Could not load %s" , KernelFileName );
963978 goto Quit ;
964979 }
965- Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , HalDTE );
980+ Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , ArcPath , HalDTE );
966981 if (!Success )
967982 {
968983 UiMessageBox ("Could not load %s" , HalFileName );
969984 goto Quit ;
970985 }
971986 if (KdDllDTE )
972987 {
973- Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , KdDllDTE );
988+ Success = PeLdrScanImportDescriptorTable (& LoaderBlock1 -> LoadOrderListHead , DirPath , ArcPath , KdDllDTE );
974989 if (!Success )
975990 {
976991 UiMessageBox ("Could not load %s" , KdDllName );
0 commit comments