Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Power off PC function?

Sooncheol_WonSooncheol_Won Member Posts: 37
enum class ShutdownAction
{
    NoReboot,
    Reboot,
    PowerOff
};
typedef NTSTATUS(__stdcall *NtShutdownSystem)(ShutdownAction shutdownAction);

I'm using "NtShutdownSystem(ShutdownAction::PowerOff);" to power off but this requires 2~3 seconds (slow).
I know a fast function for reset.
KeBugCheck(POWER_FAILURE_SIMULATE);
Is there a fast power off function like KeBugCheck()?

Comments

  • ThatsBerkanThatsBerkan Member Posts: 44
  • MBond2MBond2 Member Posts: 277

    You do realize what the system is doing in those seconds it takes to shutdown right?

    it is not as though the guys at Microsoft said, someone wants to shutdown the system, but we want to make that deliberately slow by calculating the first million digits of pi before we get started. during this time, which can extend into minutes depending on your hardware and OS config, the OS is carefully stopping critical components. ensuring that they stop cleanly so that they can presumably start cleanly. This includes things like flushing the file system cache to ensure that data is not lost and while the structure of modern file systems makes them inherently resilient against corruption caused by 'pulling the power cord', it does not follow that they are resilient against data loss under that scenario nor that is a desirable way to reset a system.

    you should also note that depending on system config, rebooting via bug check can be significantly slower. Consider a system configured to write a full memory dump on failure with multiple TB of memory. Perhaps KeBugCheck(POWER_FAILURE_SIMULATE) bypasses this but I wouldn't rely on it.

  • Sooncheol_WonSooncheol_Won Member Posts: 37
    Actually we are developing diskless system and after the client reset or power off all data is cleared so data loss is not a problem.

    Yes I know what is done in 2~3 seconds including cache flushing but I think the clean-up or shutdown jobs are not needed and meaningless on diskless system.

    I just want to gain the faster power off speed..

    P.S: iSCSI diskless does not boot unless turn off kernel crash dump option so we turned off. KeBugCheck() will not create memory dump file. I still don't know why always "ndis_dump.sys" crashes while iSCSI booting..
  • Mark_RoddyMark_Roddy Member - All Emails Posts: 4,396

    Well then you already have the answer: KeBugCheck(POWER_FAILURE_SIMULATE), with don't generate dump file, shutdown rather than reboot.

  • Sooncheol_WonSooncheol_Won Member Posts: 37
    KeBugCheck(POWER_FAILURE_SIMULATE) does not shutdown but reboot..
  • MBond2MBond2 Member Posts: 277

    well, I have never known Windows to boot from ROM, so even if the disk is not installed in the chassis, iSCSI boot systems still have disks. The activities during shutdown are designed to make sure that that disk, along with any others that might exists, don't lose data or get corrupted as they might be during an abortive reset. iSCSI is no more immune to this kind of corruption than any other kind of drive except for a ROM - since by definition it is read only.

    if by diskless, you mean that it is a situation where after shutdown, your disk will be reverted to a previous known good state such as a VM snapshot, that is a different matter. But the result is still the same - if you want Windows to shutdown, it will do so cleanly. If you don't care about that, then you have to do it at a level below Windows. A hypervisor can kill a VM, a management module can kill a physical server and a smart PDU can reset just about anything.

  • Sooncheol_WonSooncheol_Won Member Posts: 37

    you have to do it at a level below Windows.

    Thank you!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Internals & Software Drivers 25 Jan 2021 LIVE ONLINE
Developing Minifilters 8 March 2021 LIVE ONLINE