65.9K
CodeProject is changing. Read more.
Home

Vista_UAC

starIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIconemptyStarIcon

1.06/5 (15 votes)

Aug 21, 2007

viewsIcon

28380

downloadIcon

206

Interacting with the service

Introduction

This article describes about communicating with the service with elevating and without elevating on Vista.I have taken use of named events for creating the same.

Background

Showing the UI through service is really a big task as sending messages across the sessions have been banned on vista.

Using the Demo Project

1. Copy the MessageBox folder to the c:\ drive

2. Copy all the binaries in one folder .Install the service using Vista_UAC_Service.exe install

3. Use Vista_XP_Compatible.exe for testing the UI which is a created process through the service.

Blocks of code should be set as style "Formatted" like this:

//

// Any source code blocks look like this

//

// Giving permissions for all users for the objects has been given at msdn

    "http://msdn2.microsoft.com/en-us/library/ms717798.aspxTCHAR">http://msdn2.microsoft.com/en-us/library/ms717798.aspx

    TCHAR * szSD = TEXT("D:")       // Discretionary ACL

        TEXT("(A;OICI;GA;;;BG)")     // Allow access to 

                                     // built-in guests

        TEXT("(A;OICI;GA;;;AN)")     // Allow access to 

                                     // anonymous logon

        TEXT("(A;OICI;GRGWGX;;;AU)") // Allow 

                                     // read/write/execute 

                                     // to authenticated 

                                     // users

        TEXT("(A;OICI;GA;;;BA)");    // Allow full control 

                                     // to administrators

For getting the session ids in the session 0


WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,0,1,&wsi,&dwNos);

for(int i=0;i<dwNos;i++)

{

if(wsi[i].State == WTSActive)

{

dwSessionId= wsi[i].SessionId;

}

}
Use createprocessasuser for creating the process


bool bRet = ::CreateProcessAsUser( Token, L"c:\\Messagebox\\MessageBox.exe", NULL, NULL, NULL, FALSE,

CREATE_NEW_PROCESS_GROUP | CREATE_UNICODE_ENVIRONMENT|CREATE_NO_WINDOW , pEnv, NULL,

&startupInfo, &processInfo);