Rebooting from Kernel Mode
Alex Ionescu (AlexIonescu) <aionescugmailcom> Friday, February 16 2007 14:44.23 CST


I see this question posted on OSR Online a lot: “How do I force a reboot of the computer from kernel mode?”. The clean solution always being recommended is to have a user-mode service that talks to the driver and does the appropriate ExitWindowsEx API call. But what if you really want to do it from kernel-mode? Well, you could use HalReturnToFirmware or NtShutdownSystem, but those functions are undocumented, and you probably won’t get WHQLed if you try using them. So I’ll show you a sneaky way that does the same, but uses a fully documented kernel API. Don’t use it unless you really know what you’re doing; I personally recommend using a service as well.


Rebooting a machine from kernel mode:


KeBugCheck(POWER_FAILURE_SIMULATE);


Now, I know what you’re thinking, but you’re wrong. This will *not* bugcheck the machine. It will actually call HalReturnToFirmware(HalRebootMachine), right after processing bugcheck callbacks. No BSOD, no crash dump, just a clean, simple, immediate reboot.


Enjoy ;)



Comments
Posted: Wednesday, December 31 1969 18:00.00 CST