Skip to content

Commit 5e5a92f

Browse files
committed
[FREELDR] Add Windows 7 boot suport
Based on maharmstone work
1 parent d21b352 commit 5e5a92f

File tree

11 files changed

+508
-197
lines changed

11 files changed

+508
-197
lines changed

boot/freeldr/freeldr/arch/archwsup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ AddReactOSArcDiskInfo(
8787
reactos_arc_disk_info[reactos_disk_count].DiskSignature.Signature = Signature;
8888
reactos_arc_disk_info[reactos_disk_count].DiskSignature.CheckSum = Checksum;
8989
reactos_arc_disk_info[reactos_disk_count].DiskSignature.ValidPartitionTable = ValidPartitionTable;
90+
reactos_arc_disk_info[reactos_disk_count].DiskSignature.Unknown = (PVOID)0;
9091

9192
strcpy(reactos_arc_disk_info[reactos_disk_count].ArcName, ArcName);
9293
reactos_arc_disk_info[reactos_disk_count].DiskSignature.ArcName =

boot/freeldr/freeldr/bootmgr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ OSLoadingMethods[] =
6868
{"Windows" , EditCustomBootNTOS, LoadAndBootWindows},
6969
{"Windows2003" , EditCustomBootNTOS, LoadAndBootWindows},
7070
{"WindowsVista", EditCustomBootNTOS, LoadAndBootWindows},
71+
{"Windows7", EditCustomBootNTOS, LoadAndBootWindows},
7172
};
7273

7374
/* FUNCTIONS ******************************************************************/

boot/freeldr/freeldr/ntldr/arch/amd64/winldr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,14 @@ WinLdrSetProcessorContext(
371371
TRACE("leave WinLdrSetProcessorContext\n");
372372
}
373373

374-
void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
374+
void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK2 LoaderBlock2)
375375
{
376376
PVOID SharedUserDataAddress = NULL;
377377
ULONG_PTR Tss = 0;
378378
ULONG BlockSize, NumPages;
379379

380-
LoaderBlock->u.I386.CommonDataArea = (PVOID)DbgPrint; // HACK
381-
LoaderBlock->u.I386.MachineType = MACHINE_TYPE_ISA;
380+
LoaderBlock2->u.I386.CommonDataArea = (PVOID)DbgPrint; // HACK
381+
LoaderBlock2->u.I386.MachineType = MACHINE_TYPE_ISA;
382382

383383
/* Allocate 1 page for SharedUserData */
384384
SharedUserDataAddress = MmAllocateMemoryWithType(MM_PAGE_SIZE, LoaderStartupPcrPage);

boot/freeldr/freeldr/ntldr/arch/arm/winldr.c

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -164,33 +164,34 @@ WinLdrMapSpecialPages(ULONG PcrBasePage)
164164
}
165165

166166
VOID
167-
WinLdrSetupForNt(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
167+
WinLdrSetupForNt(IN PLOADER_PARAMETER_BLOCK1 LoaderBlock1,
168+
IN PLOADER_PARAMETER_BLOCK2 LoaderBlock2,
168169
IN PVOID *GdtIdt,
169170
IN PULONG PcrBasePage,
170171
IN PULONG TssBasePage)
171172
{
172173
PKPDR_PAGE PdrPage = (PVOID)0xFFD00000;
173174

174175
/* Load cache information */
175-
LoaderBlock->u.Arm.FirstLevelDcacheSize = FirstLevelDcacheSize;
176-
LoaderBlock->u.Arm.FirstLevelDcacheFillSize = FirstLevelDcacheFillSize;
177-
LoaderBlock->u.Arm.FirstLevelIcacheSize = FirstLevelIcacheSize;
178-
LoaderBlock->u.Arm.FirstLevelIcacheFillSize = FirstLevelIcacheFillSize;
179-
LoaderBlock->u.Arm.SecondLevelDcacheSize = SecondLevelDcacheSize;
180-
LoaderBlock->u.Arm.SecondLevelDcacheFillSize = SecondLevelDcacheFillSize;
181-
LoaderBlock->u.Arm.SecondLevelIcacheSize = SecondLevelIcacheSize;
182-
LoaderBlock->u.Arm.SecondLevelIcacheFillSize = SecondLevelIcacheSize;
176+
LoaderBlock2->u.Arm.FirstLevelDcacheSize = FirstLevelDcacheSize;
177+
LoaderBlock2->u.Arm.FirstLevelDcacheFillSize = FirstLevelDcacheFillSize;
178+
LoaderBlock2->u.Arm.FirstLevelIcacheSize = FirstLevelIcacheSize;
179+
LoaderBlock2->u.Arm.FirstLevelIcacheFillSize = FirstLevelIcacheFillSize;
180+
LoaderBlock2->u.Arm.SecondLevelDcacheSize = SecondLevelDcacheSize;
181+
LoaderBlock2->u.Arm.SecondLevelDcacheFillSize = SecondLevelDcacheFillSize;
182+
LoaderBlock2->u.Arm.SecondLevelIcacheSize = SecondLevelIcacheSize;
183+
LoaderBlock2->u.Arm.SecondLevelIcacheFillSize = SecondLevelIcacheSize;
183184

184185
/* Write initial context information */
185-
LoaderBlock->KernelStack = (ULONG_PTR)PdrPage->KernelStack;
186-
LoaderBlock->KernelStack += KERNEL_STACK_SIZE;
187-
LoaderBlock->u.Arm.PanicStack = (ULONG_PTR)PdrPage->PanicStack;
188-
LoaderBlock->u.Arm.PanicStack += KERNEL_STACK_SIZE;
189-
LoaderBlock->u.Arm.InterruptStack = (ULONG_PTR)PdrPage->InterruptStack;
190-
LoaderBlock->u.Arm.InterruptStack += KERNEL_STACK_SIZE;
191-
LoaderBlock->Prcb = (ULONG_PTR)PdrPage->Prcb;
192-
LoaderBlock->Process = (ULONG_PTR)PdrPage->InitialProcess;
193-
LoaderBlock->Thread = (ULONG_PTR)PdrPage->InitialThread;
186+
LoaderBlock1->KernelStack = (ULONG_PTR)PdrPage->KernelStack;
187+
LoaderBlock1->KernelStack += KERNEL_STACK_SIZE;
188+
LoaderBlock2->u.Arm.PanicStack = (ULONG_PTR)PdrPage->PanicStack;
189+
LoaderBlock2->u.Arm.PanicStack += KERNEL_STACK_SIZE;
190+
LoaderBlock2->u.Arm.InterruptStack = (ULONG_PTR)PdrPage->InterruptStack;
191+
LoaderBlock2->u.Arm.InterruptStack += KERNEL_STACK_SIZE;
192+
LoaderBlock1->Prcb = (ULONG_PTR)PdrPage->Prcb;
193+
LoaderBlock1->Process = (ULONG_PTR)PdrPage->InitialProcess;
194+
LoaderBlock1->Thread = (ULONG_PTR)PdrPage->InitialThread;
194195
}
195196

196197
static
@@ -278,6 +279,6 @@ WinLdrSetProcessorContext(
278279

279280
VOID
280281
WinLdrSetupMachineDependent(
281-
PLOADER_PARAMETER_BLOCK LoaderBlock)
282+
PLOADER_PARAMETER_BLOCK2 LoaderBlock2)
282283
{
283284
}

boot/freeldr/freeldr/ntldr/arch/i386/winldr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,16 +368,16 @@ void WinLdrSetupSpecialDataPointers(VOID)
368368
}
369369
}
370370

371-
void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
371+
void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK2 LoaderBlock2)
372372
{
373373
ULONG TssSize;
374374
//ULONG TssPages;
375375
ULONG_PTR Pcr = 0;
376376
ULONG_PTR Tss = 0;
377377
ULONG BlockSize, NumPages;
378378

379-
LoaderBlock->u.I386.CommonDataArea = NULL; // Force No ABIOS support
380-
LoaderBlock->u.I386.MachineType = MACHINE_TYPE_ISA;
379+
LoaderBlock2->u.I386.CommonDataArea = NULL; // Force No ABIOS support
380+
LoaderBlock2->u.I386.MachineType = MACHINE_TYPE_ISA;
381381

382382
/* Allocate 2 pages for PCR: one for the boot processor PCR and one for KI_USER_SHARED_DATA */
383383
Pcr = (ULONG_PTR)MmAllocateMemoryWithType(2 * MM_PAGE_SIZE, LoaderStartupPcrPage);

boot/freeldr/freeldr/ntldr/setupldr.c

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@ DBG_DEFAULT_CHANNEL(WINDOWS);
1919
VOID
2020
AllocateAndInitLPB(
2121
IN USHORT VersionToBoot,
22-
OUT PLOADER_PARAMETER_BLOCK* OutLoaderBlock);
22+
OUT PVOID* OutLoaderBlock,
23+
OUT PLOADER_PARAMETER_BLOCK1* OutLoaderBlock1,
24+
OUT PLOADER_PARAMETER_BLOCK2* OutLoaderBlock2,
25+
OUT PSETUP_LOADER_BLOCK** SetupBlockPtr,
26+
OUT PLOADER_PARAMETER_EXTENSION1* OutExtension1,
27+
OUT PLOADER_PARAMETER_EXTENSION2* OutExtension2);
2328

2429
static VOID
2530
SetupLdrLoadNlsData(
26-
_Inout_ PLOADER_PARAMETER_BLOCK LoaderBlock,
31+
_Inout_ PLOADER_PARAMETER_BLOCK1 LoaderBlock1,
2732
_In_ HINF InfHandle,
2833
_In_ PCSTR SearchPath)
2934
{
@@ -76,7 +81,7 @@ SetupLdrLoadNlsData(
7681
&AnsiFileName, &OemFileName, &LangFileName, &OemHalFileName);
7782

7883
/* Load NLS data */
79-
Success = WinLdrLoadNLSData(LoaderBlock,
84+
Success = WinLdrLoadNLSData(LoaderBlock1,
8085
SearchPath,
8186
&AnsiFileName,
8287
&OemFileName,
@@ -95,7 +100,7 @@ SetupLdrLoadNlsData(
95100
static
96101
BOOLEAN
97102
SetupLdrInitErrataInf(
98-
IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
103+
IN OUT PLOADER_PARAMETER_EXTENSION2 Extension2,
99104
IN HINF InfHandle,
100105
IN PCSTR SystemRoot)
101106
{
@@ -128,8 +133,8 @@ SetupLdrInitErrataInf(
128133
return FALSE;
129134
}
130135

131-
LoaderBlock->Extension->EmInfFileImage = PaToVa(PhysicalBase);
132-
LoaderBlock->Extension->EmInfFileSize = FileSize;
136+
Extension2->EmInfFileImage = PaToVa(PhysicalBase);
137+
Extension2->EmInfFileSize = FileSize;
133138

134139
return TRUE;
135140
}
@@ -488,8 +493,13 @@ LoadReactOSSetup(
488493
HINF InfHandle;
489494
INFCONTEXT InfContext;
490495
ULONG i, ErrorLine;
491-
PLOADER_PARAMETER_BLOCK LoaderBlock;
496+
PVOID LoaderBlock;
497+
PLOADER_PARAMETER_BLOCK1 LoaderBlock1;
498+
PLOADER_PARAMETER_BLOCK2 LoaderBlock2;
499+
PSETUP_LOADER_BLOCK* SetupBlockPtr;
492500
PSETUP_LOADER_BLOCK SetupBlock;
501+
PLOADER_PARAMETER_EXTENSION1 Extension1;
502+
PLOADER_PARAMETER_EXTENSION2 Extension2;
493503
CHAR BootPath[MAX_PATH];
494504
CHAR FilePath[MAX_PATH];
495505
CHAR UserBootOptions[256];
@@ -773,11 +783,13 @@ LoadReactOSSetup(
773783
UiResetForSOS();
774784

775785
/* Allocate and minimally-initialize the Loader Parameter Block */
776-
AllocateAndInitLPB(_WIN32_WINNT_WS03, &LoaderBlock);
786+
AllocateAndInitLPB(_WIN32_WINNT_WS03, &LoaderBlock, &LoaderBlock1,
787+
&LoaderBlock2, &SetupBlockPtr, &Extension1,
788+
&Extension2);
777789

778790
/* Allocate and initialize the setup loader block */
779791
SetupBlock = &WinLdrSystemBlock->SetupBlock;
780-
LoaderBlock->SetupLdrBlock = SetupBlock;
792+
*SetupBlockPtr = SetupBlock;
781793

782794
/* Set textmode setup flag */
783795
SetupBlock->Flags = SETUPLDR_TEXT_MODE;
@@ -793,17 +805,17 @@ LoadReactOSSetup(
793805
/* Load NLS data, they are in the System32 directory of the installation medium */
794806
RtlStringCbCopyA(FilePath, sizeof(FilePath), BootPath);
795807
RtlStringCbCatA(FilePath, sizeof(FilePath), "system32\\");
796-
SetupLdrLoadNlsData(LoaderBlock, InfHandle, FilePath);
808+
SetupLdrLoadNlsData(LoaderBlock1, InfHandle, FilePath);
797809

798810
/* Load the Firmware Errata file from the installation medium */
799-
Success = SetupLdrInitErrataInf(LoaderBlock, InfHandle, BootPath);
811+
Success = SetupLdrInitErrataInf(Extension2, InfHandle, BootPath);
800812
TRACE("Firmware Errata file %s\n", (Success ? "loaded" : "not loaded"));
801813
/* Not necessarily fatal if not found - carry on going */
802814

803815
// UiDrawStatusText("Press F6 if you need to install a 3rd-party SCSI or RAID driver...");
804816

805817
/* Get a list of boot drivers */
806-
SetupLdrScanBootDrivers(&LoaderBlock->BootDriverListHead, InfHandle, BootPath);
818+
SetupLdrScanBootDrivers(&LoaderBlock1->BootDriverListHead, InfHandle, BootPath);
807819

808820
/* Close the inf file */
809821
InfCloseFile(InfHandle);
@@ -813,6 +825,11 @@ LoadReactOSSetup(
813825
/* Finish loading */
814826
return LoadAndBootWindowsCommon(_WIN32_WINNT_WS03,
815827
LoaderBlock,
828+
LoaderBlock1,
829+
LoaderBlock2,
830+
SetupBlockPtr,
831+
Extension1,
832+
Extension2,
816833
BootOptions,
817834
BootPath);
818835
}

0 commit comments

Comments
 (0)