From aebf8308218102fa2bf1decac36d948ee8c10ba4 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Sun, 1 Oct 2006 06:43:26 +0000 Subject: [PATCH] - Add two more lines in boot.S which detect boot-by-NTLDR and jump into KiSystemService (I thought FreeLdr didn't use the entrypoint, but it looks like it does, so this hack is needed). Detection is done by checking for the high bit in the PLOADER_PARAMETER_BLOCK pointer, which will be set on NT. - Fix a double bug in KiSystemStartup. First, we were setting KPCR->Number instead of KPRCB->Number. Second, we were using KeGetPcr instead of __writefsdword. It worked on ROS because KeGetPcr is hard-coded to ROS's KPCR buffer. svn path=/trunk/; revision=24334 --- reactos/ntoskrnl/ke/i386/boot.S | 7 ++++++- reactos/ntoskrnl/ke/i386/kiinit.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/ke/i386/boot.S b/reactos/ntoskrnl/ke/i386/boot.S index c0a68014fc4..7c94f74e162 100644 --- a/reactos/ntoskrnl/ke/i386/boot.S +++ b/reactos/ntoskrnl/ke/i386/boot.S @@ -30,6 +30,11 @@ _KiDoubleFaultStack: .text .func NtProcessStartup _NtProcessStartup: - /* Call the main kernel initialization */ + + /* NTLDR Boot: Call the main kernel initialization */ + test dword ptr [esp+4], 0x80000000 + jnz _KiSystemStartup@4 + + /* FREELDR Boot: Cal the FreeLDR wrapper */ jmp @KiRosPrepareForSystemStartup@8 .endfunc diff --git a/reactos/ntoskrnl/ke/i386/kiinit.c b/reactos/ntoskrnl/ke/i386/kiinit.c index 154be617d13..3bd35b1271d 100644 --- a/reactos/ntoskrnl/ke/i386/kiinit.c +++ b/reactos/ntoskrnl/ke/i386/kiinit.c @@ -294,7 +294,7 @@ KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock) { /* If this is the boot CPU, set FS and the CPU Number*/ Ke386SetFs(KGDT_R0_PCR); - KeGetPcr()->Number = Cpu; + __writefsdword(0x130, Cpu); /* Set the initial stack and idle thread as well */ LoaderBlock->KernelStack = (ULONG_PTR)P0BootStack;