Shutdown system on driver

Hi,

I finished a virtual PCI bus driver and some other drivers to implement
windows paravirtual driver for xen. PCI bus driver can watch a key to
detect command which I send to it remote. Now I want to implement
shutdown/reboot system command. My virtual PCI bus driver can get this
command. So I need a approach to let system shutdown/reboot safely. In
current design, I create a windows service to response the
shutdown/reboot command from another system manager. In this windows
service, I share a system event with my pci driver. PCI driver will set
this event when it get a shutdown/reboot command from system manager.
Then windows service will call InitiateSystemShutdownEx API to
shutdown/reboot system. That looks like work well.

Now, I am thinking on that is there any way to shutdown/reboot system on
driver directly? Shall we call some kernel API in driver instead of
InitiateSystemShutdownEx in windows service?

Thanks
Wayne

There is no correct way to do it straight from kernel mode, at least, as best as I can remember without having access to checl the documentation from here.

InitiateSystemShutdown ultimately results in a process (typically winlogon) calling ExitWindowsEx. This talks to winlogon, win32k, and csrss to shut down user mode gracefully. Once this happens or the appropriate timeout is exceeded, NtShutdownSystem is invoked to perform the kernel mode portion of the shut down sequence (notifying drivers, registry/FS flushing, and halting or rebooting or powering off the system).

If you were to call NtShutdownSystem directly, then user mode would not be notified of the shutdown and would not get a chance to clean up, resulting in an unhappy user of the computer when data is lost.

  • S

-----Original Message-----
From: Wayne Gong
Sent: Thursday, November 13, 2008 20:22
To: Windows System Software Devs Interest List
Subject: [ntdev] Shutdown system on driver

Hi,

I finished a virtual PCI bus driver and some other drivers to implement
windows paravirtual driver for xen. PCI bus driver can watch a key to
detect command which I send to it remote. Now I want to implement
shutdown/reboot system command. My virtual PCI bus driver can get this
command. So I need a approach to let system shutdown/reboot safely. In
current design, I create a windows service to response the
shutdown/reboot command from another system manager. In this windows
service, I share a system event with my pci driver. PCI driver will set
this event when it get a shutdown/reboot command from system manager.
Then windows service will call InitiateSystemShutdownEx API to
shutdown/reboot system. That looks like work well.

Now, I am thinking on that is there any way to shutdown/reboot system on
driver directly? Shall we call some kernel API in driver instead of
InitiateSystemShutdownEx in windows service?

Thanks
Wayne


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer