Is there any method of debugging the WINLOGON.EXE process on Windows 7
which successfully survives the user logoff action?
None of the documented or successful ways in which I did this under
Windows 5.x seem to be able to survive the user logoff. Or more
specifically, a WINLOGON.EXE process with the debugger attached to it
doesn’t survive the user logoff.
Instead of being returned to the logged-out state of the WINLOGON.EXE
in session ID 1, Windows appears to forcibly terminate the
WINLOGON.EXE from session ID 1, and the “logged out state” Windows
presents to me is actually a new instance of WINLOGON.EXE in session
ID 2.
The only method I’ve tried where the WINLOGON.EXE instance is allowed
to survive as expected is if I run DBGSRV as a remote process server
and connect with WinDBG from across the network. But in this process
server configuration apparently !htrace can’t be enabled (fails with
STATUS_OBJECT_TYPE_MISMATCH), and !htrace happens to be the entire
point of my exercise.
In the other configurations besides using a process server, !htrace
can be successfully enabled. But I’m not able to examine the
WINLOGON.EXE instance handle information post-logout because the
process being forcibly terminated for (currently) reasons unknown.
Since the point of my exercise is to capture a call stack for the
creator of a registry handle into HKEY_CURRENT_USER which has been
abandoned on the WINLOGON.EXE process (as declared by USERENV when
unloading the user profile), if someone knows of an even cleaner way
to capture that instead of !htrace, that would be useful towards a
solution too.
(UPClean 2.0.49’s stack trace does not engage or report this on
Windows 6.x.)
Methods which have been tried:
Controlling NTSD though kernel-mode debugger (the way WinDBG help file
recommends):
NTSD isn’t part of Windows itself any more, so I install Debugging
Tools for Windows 6.12.0002.633 and update the system environment PATH
variable such that NTSD.EXE can be located. Also add …\winext and
…\winxp subdirectories to the path as well, to NTSD in turn can
locate its extensions.
Setup Image File Execution Options to launch WINLOGON.EXE under “NTSD
-d -x”. Over a 1394 connection WinDBG 6.12.0002.633 is able to see
the initial breakpoint on WINLOGON.EXE that the successfully-attached
NTSD.EXE is presenting, and I can control the NTSD debugger
successfully.
But as soon as I initiate a user logout from Windows, a new instance
of NSTD presents a new initial breakpoint of the new WINLOGON.EXE
instance in session ID 2. Breaking into the kernel-mode debugger
confirms that the WINLOGON.EXE instance from session ID 1 is no longer
running.
Running an interactive instance of WinDBG as LocalSystem on the
Winlogon desktop of session ID 1:
“PsExec -d -x -s -i 1” is able to launch WinDBG successfully, and
using CTRL-ALT-DEL I am able to interact with that WinDBG on the
Winlogon desktop to successfully attach to the running WINLOGON.EXE
and enable !htrace.
But as soon as I initiate a user logout from Windows, I’m no longer in
the session where WinDBG was running and the WINLOGON.EXE with !htrace
enabled. Logging in again confirms that I’m now in session ID 2, and
none of the processes from session ID 1 are running any more.
Setup DBGSRV running as service to be process server controlled from
remote WinDBG over TCPIP:
Remote WinDBG is able to see and attach to WINLOGON.EXE instance in
session ID 1, but invoking “!htrace -enable” returns a failure citing
0xC0000024.
After user logout the instance of WINLOGON.EXE is still running and
the debugger is still attached.
The other thing I tried enabling was GFLAG’s “Silent Process Exit” to
try and write a dump of whatever is closing WINLOGON.EXE so
unexpectedly. But no dumps are generated from enabling that feature.
Alan Adams