Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Howto: Log off user after LogonUser()

157 views
Skip to first unread message

Daniel Lohmann

unread,
Nov 10, 1998, 3:00:00 AM11/10/98
to
Hi,

I need to end all processes from a specific logon session. I know that this
can be done with the ExitWindows() or ExitWindowsEx() API.

So I have created a logoff.exe, which calls one of the above functions and I
start this with CreateProcessAsUser (hToken,...) to end the session
represented by hToken. The token is from a LogonUser() call.

However, this does not work - it seems that there happens nothing. If I run
a console (cmd.exe) under hToken and start the logoff.exe from there, the
console hangs. The window remains on the desktop, but there is no "cmd.exe"
process. Any other process running under hToken still remains.

What I'am doing wrong? How is it possible to end a session created with
LogonUser() ?


Thanks in advance

Daniel


Felix Kasza [MVP]

unread,
Nov 16, 1998, 3:00:00 AM11/16/98
to
Daniel,

> What I'am doing wrong? How is it possible to end a session created with
> LogonUser() ?

Until you can move to NT5 (Job objects are neat!), I would probably
attach as a debugger to the first process I launch, and have myself
notified of child creation. This is not without risk (timing issues,
serialization point in the debug event loop), but it is guaranteed to
get you the handles of _all_ child processes.

Once you have the handles, it's just a matter of trying WM_CLOSE,
console control events, or TerminateProcess().

--

Cheers,

Felix.

If you post a reply, kindly refrain from emailing it, too.
Note to spammers: fel...@mvps.org is my real email address.
No anti-spam address here. Just one comment: IN YOUR FACE!

Anthony Roby

unread,
Nov 18, 1998, 3:00:00 AM11/18/98
to
I am doing pretty much the same thing. I basically have an application that allows multiple users to log on to the
same machine simultaneously. The main application does a LogonUser(), creates a new desktop for the user and
runs a Logoff.exe application under the user's token (it basically sits there waiting on an event). The application
then switches to the new desktop. The user can choose to logoff at this point, by selecting logoff from the Start
menu. This kills all of the processes running as that user (even Logoff.exe). Alernatively, the user can hit
CTRL-ALT-DEL and invoke my GINA stub, which switches the desktop back to the main desktop, where the logon
application is running. From this application, the user can choose to logoff, without accessing their desktop.
What happens in this case is that the event that Logoff.exe is waiting on is fired, causing Logoff.exe to call
ExitWindowsEx(). This logs the user off. The final piece in both cases is for the logon application to close the
handle to the user.

Anthony


In article <3648b...@news.ivm.net>, dan...@uni-koblenz.de (Daniel Lohmann) wrote:

> Hi,
>
> I need to end all processes from a specific logon session. I know that
> this
> can be done with the ExitWindows() or ExitWindowsEx() API.
>
> So I have created a logoff.exe, which calls one of the above functions
> and I
> start this with CreateProcessAsUser (hToken,...) to end the session
> represented by hToken. The token is from a LogonUser() call.
>
> However, this does not work - it seems that there happens nothing. If I
> run
> a console (cmd.exe) under hToken and start the logoff.exe from there,
> the
> console hangs. The window remains on the desktop, but there is no
> "cmd.exe"
> process. Any other process running under hToken still remains.
>

> What I'am doing wrong? How is it possible to end a session created with
> LogonUser() ?
>
>

> Thanks in advance
>
> Daniel


0 new messages