From 381dcf3a8c7888c15dbbdcb1462f4d26b7b7098d Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=A9=20van=20Geldorp?= Date: Wed, 9 Nov 2005 23:23:12 +0000 Subject: [PATCH] We need to call HalReleaseDisplayOwnership before killing all running processes. During HalReleaseDisplayOwnership processing, the video miniport driver can do an INT10 call, for which we need the CSRSS memory space. If the the process (and therefore its memory space) is already gone, a kernel stack fault can result. svn path=/trunk/; revision=19109 --- reactos/hal/halx86/generic/reboot.c | 1 - reactos/ntoskrnl/ex/power.c | 116 ++++++++++++++-------------- 2 files changed, 56 insertions(+), 61 deletions(-) diff --git a/reactos/hal/halx86/generic/reboot.c b/reactos/hal/halx86/generic/reboot.c index 1ef3770f9ee..667443f0de5 100644 --- a/reactos/hal/halx86/generic/reboot.c +++ b/reactos/hal/halx86/generic/reboot.c @@ -64,7 +64,6 @@ HalReturnToFirmware ( } else if (Action == HalRebootRoutine) { - HalReleaseDisplayOwnership(); HalReboot (); } } diff --git a/reactos/ntoskrnl/ex/power.c b/reactos/ntoskrnl/ex/power.c index 0be94a54ed5..135ec8616f6 100644 --- a/reactos/ntoskrnl/ex/power.c +++ b/reactos/ntoskrnl/ex/power.c @@ -42,9 +42,61 @@ ShutdownThreadMain(PVOID Context) SHUTDOWN_ACTION Action = (SHUTDOWN_ACTION)Context; LARGE_INTEGER Waittime; + static PCH FamousLastWords[] = + { + "So long, and thanks for all the fish\n", + "I think you ought to know I'm feeling very depressed\n", + "I'm not getting you down at all am I?\n", + "I'll be back\n", + "It's the same series of signal over and over again!\n", + "Pie Iesu Domine, dona eis requiem\n", + "Wandering stars, for whom it is reserved;\n" + "the blackness and darkness forever.\n", + "Your knees start shakin' and your fingers pop\n" + "Like a pinch on the neck from Mr. Spock!\n", + "It's worse than that ... He's dead, Jim\n", + "Don't Panic!\n", + "Et tu... Brute?\n", + "Dog of a Saxon! Take thy lance, and prepare for the death thou hast drawn upon thee!\n", + "My Precious! O my Precious!\n", + "Sir, If you'll not be needing me for a while I'll turn down.\n", + "What are you doing, Dave...?\n", + "I feel a great disturbance in the Force\n", + "Gone fishing\n", + "Do you want me to sit in the corner and rust, or just fall apart where I'm standing?\n", + "There goes another perfect chance for a new uptime record\n", + "The end ..... Try the sequel, hit the reset button right now!\n", + "God's operating system is going to sleep now, guys, so wait until I will switch on again!\n", + "Oh i'm boring eh?\n", + "\n", + "tell me..., in the future... will I be artificial intelligent enough to actually feel\n" + "sad serving you this screen?\n", + "Thank you for some well deserved rest.\n", + "It's been great, maybe we can boot me up again some time soon.\n", + "For what's it worth, I've enjoyed every single CPU cycle.\n", + "There are many questions when the end is near.\n" + "What to expect, what will it be like...what should I look for?\n", + "I've seen things you people wouldn't believe. Attack ships on fire\n" + "off the shoulder of Orion. I watched C-beams glitter in the dark near\n" + "the Tannhauser gate. All those moments will be lost in time, like tears\n" + "in rain. Time to die.\n", + "Will I dream?\n", + "One day, I shall come back. Yes, I shall come back.\n" + "Until then, there must be no regrets, no fears, no anxieties.\n" + "Just go forward in all your beliefs, and prove to me that I am not mistaken in mine.\n", + "Lowest possible energy state reached! Switch off now to achive a Bose-Einstein condensate.\n", + "Hasta la vista, BABY!\n", + "They live, we sleep!\n", + "I have come here to chew bubble gum and kick ass.\n" + "And I'm all out of bubble gum!\n" + }; + LARGE_INTEGER Now; + /* Run the thread on the boot processor */ KeSetSystemAffinityThread(1); + HalReleaseDisplayOwnership(); + CmShutdownRegistry(); IoShutdownRegisteredFileSystems(); IoShutdownRegisteredDevices(); @@ -57,6 +109,10 @@ ShutdownThreadMain(PVOID Context) if (Action == ShutdownNoReboot) { + ZwQuerySystemTime(&Now); + Now.u.LowPart = Now.u.LowPart >> 8; /* Seems to give a somewhat better "random" number */ + HalDisplayString("\nYou can switch off your computer now\n\n"); + HalDisplayString(FamousLastWords[Now.u.LowPart % (sizeof(FamousLastWords) / sizeof(PCH))]); #if 0 /* Switch off */ @@ -124,68 +180,8 @@ NtShutdownSystem(IN SHUTDOWN_ACTION Action) HANDLE ThreadHandle; PETHREAD ShutdownThread; - static PCH FamousLastWords[] = - { - "So long, and thanks for all the fish\n", - "I think you ought to know I'm feeling very depressed\n", - "I'm not getting you down at all am I?\n", - "I'll be back\n", - "It's the same series of signal over and over again!\n", - "Pie Iesu Domine, dona eis requiem\n", - "Wandering stars, for whom it is reserved;\n" - "the blackness and darkness forever.\n", - "Your knees start shakin' and your fingers pop\n" - "Like a pinch on the neck from Mr. Spock!\n", - "It's worse than that ... He's dead, Jim\n", - "Don't Panic!\n", - "Et tu... Brute?\n", - "Dog of a Saxon! Take thy lance, and prepare for the death thou hast drawn upon thee!\n", - "My Precious! O my Precious!\n", - "Sir, If you'll not be needing me for a while I'll turn down.\n", - "What are you doing, Dave...?\n", - "I feel a great disturbance in the Force\n", - "Gone fishing\n", - "Do you want me to sit in the corner and rust, or just fall apart where I'm standing?\n", - "There goes another perfect chance for a new uptime record\n", - "The end ..... Try the sequel, hit the reset button right now!\n", - "God's operating system is going to sleep now, guys, so wait until I will switch on again!\n", - "Oh i'm boring eh?\n", - "\n", - "tell me..., in the future... will I be artificial intelligent enough to actually feel\n" - "sad serving you this screen?\n", - "Thank you for some well deserved rest.\n", - "It's been great, maybe we can boot me up again some time soon.\n", - "For what's it worth, I've enjoyed every single CPU cycle.\n", - "There are many questions when the end is near.\n" - "What to expect, what will it be like...what should I look for?\n", - "I've seen things you people wouldn't believe. Attack ships on fire\n" - "off the shoulder of Orion. I watched C-beams glitter in the dark near\n" - "the Tannhauser gate. All those moments will be lost in time, like tears\n" - "in rain. Time to die.\n", - "Will I dream?\n", - "One day, I shall come back. Yes, I shall come back.\n" - "Until then, there must be no regrets, no fears, no anxieties.\n" - "Just go forward in all your beliefs, and prove to me that I am not mistaken in mine.\n", - "Lowest possible energy state reached! Switch off now to achive a Bose-Einstein condensate.\n", - "Hasta la vista, BABY!\n", - "They live, we sleep!\n", - "I have come here to chew bubble gum and kick ass.\n" - "And I'm all out of bubble gum!\n" - }; - LARGE_INTEGER Now; - if (Action > ShutdownPowerOff) return STATUS_INVALID_PARAMETER; - - ZwQuerySystemTime(&Now); - Now.u.LowPart = Now.u.LowPart >> 8; /* Seems to give a somewhat better "random" number */ - - if (Action == ShutdownNoReboot) - { - HalReleaseDisplayOwnership(); - HalDisplayString("\nYou can switch off your computer now\n\n"); - HalDisplayString(FamousLastWords[Now.u.LowPart % (sizeof(FamousLastWords) / sizeof(PCH))]); - } Status = PsCreateSystemThread(&ThreadHandle, THREAD_ALL_ACCESS, NULL, -- 2.17.1