Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sessions, Window stations and Desktops

Tags:

windows

Sessions, Window Stations and Desktops.

A session consists of all process and other system objects that represent a single user's logon session. Sessions contain Window Stations and Window Stations contain desktops.

The above is from http://blogs.technet.com/b/askperf/archive/2007/07/24/sessions-desktops-and-windows-stations.aspx

(Similar articles say the same thing, e.g. blogs.technet.com/b/askperf/archive/2007/04/27/application-compatibility-session-0-isolation.aspx and blogs.msdn.com/b/ntdebugging/archive/2007/01/04/desktop-heap-overview.aspx)

I've always understood Sessions and logon sessions to be one and the same thing.

However, reading p. 474, Russinovich and Solomon, Windows Internals, 5th edition, it says (penultimate paragraph):

The CreateProcessWithLogon function also creates a token by creating a new logon session with an initial process, which is how the Runas command launches processes under alternative tokens.

So Runas creates a new logon session. If we use Runas to run Notepad under a different user's credentials we see it appear on the desktop. So Notepad is running on the same desktop as everything else. (This is, as far as I understand it, the default desktop in Window Station Winsta0; the interactive window station.) So what we have now are two logon sessions associated with the same Session (the thing that contains window stations). So Sessions and logon sessions would not appear to be one and the same.

Can anybody confirm this please?

Confused

like image 216
Confused Avatar asked Jan 14 '11 00:01

Confused


People also ask

What is session desktop?

A session-based desktop is a desktop environment instance that is hosted by a server operating system, such as Windows Server. In a session-based desktop, there is no dedicated virtual machine for each desktop session.

What is Window Station?

A window station is a securable object that is associated with a process, and contains a clipboard, an atom table, and one or more desktop objects. A desktop is a securable object contained within a window station.

What is the difference between the processes with a session ID of 0 and 1?

In Windows Vista, Session 0 is created for services and user-mode drivers. Session 1 is created for the first user who logs in. Applications for this user run in Session 1.


1 Answers

There are indeed two types of sessions here. Here's my understanding of how they work.

  1. A logon session[2] is managed by the Local Security Authority[2], and manages the scope of a user logon. These are created primarily by the winlogon process, but also secondarily by API functions such as LogonUser, CreateProcessAsUser, and CreateProcessWithLogonW, or by applications that use these functions, such as the runas command.

    A logon session isn't tied to any specific Object Manager[2] concepts as window stations and desktops. It's basically just a block of information containing the logon SID and some cached security information about the account. This block of information, this logon session, is what an access token points to.

  2. The other type of session is sometimes called a Terminal Services session, Terminal Server session, Remote Desktop session, logon session (as confusing as that is), user logon session, or user session. Usually, though, it's just called a "session", without further qualification.

    This is the type of session that you'll usually hear about, and is what window stations belong to. This type of session came about to support multiple interactive GUI logons, as provided by Terminal Services (now known as Remote Desktop), and is now also used to support Fast User Switching. Sessions provide the necessary isolation between the Object Manager objects associated with each user logon.

I don't spend much time messing with all this stuff, so I'm a little fuzzy on some of the details, but I think this is a pretty fair representation of the overall picture. I hope it clears things up a bit.

like image 85
P Daddy Avatar answered Sep 19 '22 23:09

P Daddy