windows shutdown process

Vincent Povirk madewokherd+8cd9 at gmail.com
Fri Nov 27 13:02:13 CST 2009


In order to find the correct fix for bug 18753, I've been examining
the shutdown process on Windows. I have written a program that logs
the messages sent to it, and I've run it on Windows 7. What I found
was that a shutdown produces the following sequence of events:
* We get a 0x3b message. DefWindowProc sends a WM_QUERYENDSESSION
message. We return 1, allowing the session to end.
* We get another 0x3b message, which leads to a WM_ENDSESSION.
* Nothing else happens, but for some reason the program exits.

I added a trace after the message loop returns to see if the program
gets a WM_QUIT. It doesn't.

Apparently, my test program was killed.

I tried changing the window proc so that it loops infinitely when it
gets WM_ENDSESSION. Windows 7 sees this as "blocking shutdown".
(Naturally, it responds the same way if I return 0 from
WM_QUERYENDSESSION.)

This leads me to believe that Windows 7, when shutting down,
immediately kills any process that returns from a WM_ENDSESSION
message.

Does that seem sane?

I've posted my test program (source code and .exe file) at
http://madewokherd.nfshost.com/msgtest.zip, and I'd like to hear if
other Windows versions behave the same way Windows 7 does.

-- 
Vincent Povirk



More information about the wine-devel mailing list