Patch by Anton Yarotsky:
authorSir Richard <sir_richard@svn.reactos.org>
Wed, 15 Sep 2010 07:40:50 +0000 (07:40 +0000)
committerSir Richard <sir_richard@svn.reactos.org>
Wed, 15 Sep 2010 07:40:50 +0000 (07:40 +0000)
[FREELDR]: Fix Headless support.

svn path=/trunk/; revision=48772

reactos/boot/freeldr/freeldr/windows/headless.c
reactos/boot/freeldr/freeldr/windows/winldr.c

index 5e5d66d..bcc0f64 100644 (file)
@@ -237,11 +237,6 @@ WinLdrInitializeHeadlessPort(VOID)
                        StallExecutionProcessor(WinLdrTerminalDelay);
                }
        }
-       else
-       {
-               /* The port was bogus, so don't give any information to the kernel */
-               RtlZeroMemory(&LoaderRedirectionInformation, sizeof(HEADLESS_LOADER_BLOCK));
-       }
 }
 
 VOID
@@ -249,6 +244,9 @@ WinLdrSetupEms(IN PCHAR BootOptions)
 {
        PCHAR RedirectPort;
 
+    /* Start fresh */
+       RtlZeroMemory(&LoaderRedirectionInformation, sizeof(HEADLESS_LOADER_BLOCK));
+        
        /* Use a direction port if one was given, or use ACPI to detect one instead */
        RedirectPort = strstr(BootOptions, "/redirect=");
 
index bc13b86..3d53390 100644 (file)
@@ -203,6 +203,25 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
                /* See KiRosFrldrLpbToNtLpb for details */
                Extension->AcpiTable = (PVOID)1;
        }
+    
+    /* Set headless block pointer */
+    extern HEADLESS_LOADER_BLOCK LoaderRedirectionInformation;
+    extern BOOLEAN WinLdrTerminalConnected;
+    if (WinLdrTerminalConnected)
+    {
+        Extension->HeadlessLoaderBlock = MmHeapAlloc(sizeof(HEADLESS_LOADER_BLOCK));
+        if (Extension->HeadlessLoaderBlock == NULL)
+        {
+            UiMessageBox("Failed to allocate HLB Extension!");
+            while (TRUE);
+            return;
+        }
+        RtlCopyMemory(
+            Extension->HeadlessLoaderBlock,
+            &LoaderRedirectionInformation,
+            sizeof(HEADLESS_LOADER_BLOCK));
+        Extension->HeadlessLoaderBlock = PaToVa(Extension->HeadlessLoaderBlock);
+    }
 
        /* Load drivers database */
        strcpy(MiscFiles, BootPath);
@@ -215,6 +234,7 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
 
        if (LoaderBlock->SetupLdrBlock)
                LoaderBlock->SetupLdrBlock = PaToVa(LoaderBlock->SetupLdrBlock);
+
 }
 
 BOOLEAN
@@ -601,10 +621,6 @@ LoadAndBootWindows(PCSTR OperatingSystemName,
 
        /* Save final value of LoaderPagesSpanned */
        LoaderBlockVA->Extension->LoaderPagesSpanned = LoaderPagesSpanned;
-    
-    /* Set headless block pointer */
-    extern HEADLESS_LOADER_BLOCK LoaderRedirectionInformation;
-    LoaderBlockVA->Extension->HeadlessLoaderBlock = PaToVa(&LoaderRedirectionInformation);
 
        DPRINTM(DPRINT_WINDOWS, "Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n",
                KiSystemStartup, LoaderBlockVA);