ASP.net through session 0 Isolation (i) _ Practical skills

Source: Internet
Author: User

Windows Services perform a variety of tasks in the background, supporting our day-to-day desktop operations. Sometimes it may be necessary for the service to interact with the user for information or interface, which is no problem in the XP era, but since Vista began you will find that this approach does not seem to work.

Session 0 Isolation Experiment
Here's a service called Alertservice, which is to send a prompt dialog to the user, and we'll see what happens to the service in Windows 7.

Copy Code code as follows:

Using System.ServiceProcess;
Using System.Windows.Forms;
Namespace Alertservice
{
public partial class Service1:servicebase
{
Public Service1 ()
{
InitializeComponent ();
}

protected override void OnStart (string[) args)
{
MessageBox.Show ("A message from Alertservice.");
}

protected override void OnStop ()
{
}
}
}


After the program is compiled, it is loaded into the system service by InstallUtil :

In the service properties, check "Allow service to interact with desktop", which enables Alertservice to interact with desktop users.

The Alertservice service is "started" in Service Manager, and an icon flashes in the taskbar:

Clicking the icon displays the following window, prompting a program (Alertservice) to display the information and whether it needs to be browsed:

Try clicking "View the Message", will display the following image interface (in fact, this interface I can not from the current desktop operation screenshot, is through virtual PC screenshot, the reason to continue reading). Note that the desktop background of the following figure is no longer the default desktop background for Windows 7, stating that Alertservice is not the same as the desktop system session, which is the result of Session 0 isolation.

Session 0 Isolation Principle

In the era of Windows XP, Windows Server 2003, or earlier Windows systems, when the first user logged on to the system, the service and application ran in the same session. This is session 0 as shown in the following figure:

This operation, however, raises the risk of system security because services are run by elevated user rights, and applications are often run by ordinary users who do not have administrator status, and the danger is obvious.

From Vista start session 0, which includes only system services, other applications run with separate sessions to increase the security of the system by isolating the service from the application. As shown in the following illustration:

This allows session 0 to interact with other sessions and not to pop-up information windows, UI windows, etc. from the service to the desktop user. That's why I just said that the diagram can't be shot through the current desktop.

Session Check

In the actual development process, you can use process Explorer to check which session the service or program is in, and will not encounter session 0 isolation problem. We found the Alertservice service that was previously loaded in services, and the right-key property looks at its session state.

You can see that Alertservice is in session 0:

Then look at the Outlook application:

It is clear that services and applications in Windows 7 are in different sessions and that a protective wall is added between them, and in the next article we'll explain how to get the service to interact with desktop users through this wall of protection.

Service Download

Author: Li Jinghan (Gnie)
Origin: (http://www.cnblogs.com/gnielee/)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.