The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Magnum on November 07, 2011, 12:47:57 AM

Title: Inform running processes about pending shutdown action
Post by: Magnum on November 07, 2011, 12:47:57 AM
I don't understand what the 2nd sentence means.

Function NtShutdownSystem closes system. Caller should manually inform running processes about pending shutdown action.
Title: Re: Inform running processes about pending shutdown action
Post by: qWord on November 07, 2011, 09:04:24 AM
Probably you must send WM_QUERYENDSESSION and WM_ENDSESSION to all processes/GUI threads (BroadcastSystemMessage).
You may stay a way from the undocumented function and use one of the System Shutdown Functions (http://msdn.microsoft.com/en-us/library/windows/desktop/aa376883(v=VS.85).aspx) instead...
Title: Re: Inform running processes about pending shutdown action
Post by: Vortex on November 07, 2011, 09:39:15 AM
Quote from: qWord on November 07, 2011, 09:04:24 AM
You may stay a way from the undocumented function.

I am sorry but that's not true. What are your options to shutdown a Windows PE system running only a console window?

http://www.masm32.com/board/index.php?topic=17417.0
Title: Re: Inform running processes about pending shutdown action
Post by: qWord on November 07, 2011, 10:11:23 AM
Quote from: Vortex on November 07, 2011, 09:39:15 AMI am sorry but that's not true.
true/false?
Quote from: Vortex on November 07, 2011, 09:39:15 AMWhat are your options to shutdown a Windows PE system running only a console window?
Undocumented functions may be necessary in such exotic environments,  but for all normal windows version there is mostly no need to use them.
Title: Re: Inform running processes about pending shutdown action
Post by: sinsi on November 07, 2011, 10:24:10 AM
Quote from: Vortex on November 07, 2011, 09:39:15 AMWhat are your options to shutdown a Windows PE system running only a console window?
Power button? That usually forces a shutdown.
Title: Re: Inform running processes about pending shutdown action
Post by: Vortex on November 07, 2011, 10:32:44 AM
Quote from: qWord on November 07, 2011, 10:11:23 AM
Undocumented functions may be necessary in such exotic environments,  but for all normal windows version there is mostly no need to use them.

A Windows PE environment is not an exotic one. They are the main components of Windows Automated Installation Kits to deploy Windows. Just visit the http://reboot.pro forum. You will see there a lot of Win PE projects.
Title: Re: Inform running processes about pending shutdown action
Post by: Vortex on November 07, 2011, 10:33:48 AM
Quote from: sinsi on November 07, 2011, 10:24:10 AM
Power button? That usually forces a shutdown.

The power button is the last solution when you can shutdown the system programmatically.
Title: Re: Inform running processes about pending shutdown action
Post by: sinsi on November 07, 2011, 10:49:12 AM
Vortex, thanks for that link (and for the next few hours/days of my idle time) :U
Title: Re: Inform running processes about pending shutdown action
Post by: Vortex on November 07, 2011, 10:58:35 AM
Hi sinsi,

I am sure you will enjoy the reboot forum. The MultiPE project is an interesting one as you can build a mini version of Windows PE 1.X having a size of 72 Mb which is ideal for old computers with few RAM. Booting into Windows PE is a very good option to fix crashed Windows installations and recover data.
Title: Re: Inform running processes about pending shutdown action
Post by: Magnum on November 07, 2011, 01:16:53 PM
Qword,

The system shutdown functions are significantly slower.

Title: Re: Inform running processes about pending shutdown action
Post by: ToutEnMasm on November 07, 2011, 02:10:44 PM

The actions depends of the system to shutdown
http://kinglix.wordpress.com/2011/08/29/hello-world/
Title: Re: Inform running processes about pending shutdown action
Post by: Magnum on November 07, 2011, 03:50:44 PM
ToutEnMasm,

I am using it to shutdown XP.

On my system, NTShutDownSystem is about 3 times faster than ExitWindowsEx.
I make sure everything is closed before using. :-)
Title: Re: Inform running processes about pending shutdown action
Post by: qWord on November 07, 2011, 06:24:39 PM
Quote from: Magnum on November 07, 2011, 01:16:53 PM
Qword,

The system shutdown functions are significantly slower.


:dazzled:
This has a good reason!
Title: Re: Inform running processes about pending shutdown action
Post by: Vortex on November 07, 2011, 07:11:45 PM
Hi ToutEnMasm,

Thanks for the article you mentioned but I guess there is a serious mistake. The author tells that :

QuoteIn WINPE, ExitWindowsEx may do nothing, because SMSS.EXE and Winlogon.EXE isn't running.

In my Win PE, both of those executables are running but yet you need the NTShutDownSystem function to stop the system :

(http://www.masm32.com/board/index.php?action=dlattach;topic=17686.0;id=9919)