How to shutdown the computer in drivers?

Is there any code like this which can let me shutdown the computer(not reboot)?
__asm{
mov dx, 64h
mov al, 0xfe
out dx, al
}

There is no documented way to reboot or shutdown from a driver. What bigger problem are you trying to solve?

The Windows is installed in my box, I need to shutdown it. I have no files or hardware to protect, just need shutdown it at Ring0.

I replaced logonui.exe with my own program. After user logoning on my own program, my program connect to server and they can use the VMs in the server via my program. So Windows is not logoned. When they logoff, they may need to shutdown the system, but my program will not be able to do this, because Windows is not logoned, my program will fail to call exitwindowsex(or other functions).

Any help will be great helpfull, thanks!

The proper way to shutdown is to do it from an application. HAve a helper application.

> __asm{

mov dx, 64h
mov al, 0xfe
out dx, al

The wrapper around this low-level stuff is called HalReturnToFirmware.

What you need is Nt/ZwShutdownSystem, which is more high level, will flush the caches and send the power IRPs to the drivers.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Actually shutting down the computer without getting the user involved is
a really stupid idea. I’ve encountered this a couple of times with
software, and the damage it did was horrendous.

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

kuangnuzhiren@163.com” wrote in message
news:xxxxx@ntdev:

> Is there any code like this which can let me shutdown the computer(not reboot)?
> __asm{
> mov dx, 64h
> mov al, 0xfe
> out dx, al
> }

replacing logonui.exe is not supported nor documented. extend logon with the appropriate, documented ways and then you will have a supported system. why do you think replacing logonui is the solution?

This.

Listen to Messrs Burn, Grig, and Holan. Do it from user-mode.

The way the Windows shutdown process works, is a lot of stuff happens to shut down and wrap-up processing in user mode BEFORE anything takes place in kernel mode. You really DO want to do the user-mode stuff. Really. You do.

Write a simple help service and you’re all set. It’ll take you 20 minutes.

Peter
OSR

I put this in with ExitThread (under various disguises) and ExitProcess,
which includes the C function exit(). I claim that one way to see if the
programmer was totally clueless is to see how often these are used. Then
again, my threshold for declaring this is any value > 0. The use of any
premature exit construct is a worse sin than using strcpy or strcat
without bounds checks. Only the user has the right to request a program to
terminate, and the entire operating system is one such program.

Actually shutting down the computer without getting the user involved is
a really stupid idea. I’ve encountered this a couple of times with
software, and the damage it did was horrendous.

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

kuangnuzhiren@163.com” wrote in message
> news:xxxxx@ntdev:
>
>> Is there any code like this which can let me shutdown the computer(not
>> reboot)?
>> __asm{
>> mov dx, 64h
>> mov al, 0xfe
>> out dx, al
>> }
>
>
> —
> 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
>