Re: Interactive Services related to desktop

From: Samuel Lee (samthebigbear_at_gmail.com)
Date: 11/17/04

  • Next message: Mark Stanley: "Re: Incorrect message box from non-interactive service"
    Date: 16 Nov 2004 17:51:42 -0800
    
    

    We have a dll which exports function(ShowDialog). We call the function
    from the service present in the dll; and the ShowDialog function
    creates a Thread and then the thread displays the dialog. Is it
    recommended way?

    We are not sure how to change the Thread Session ID to current Sesson
    ID --(Is it not allowed because threads can not cross session
    boundares?) If we can not change Thread Session ID, how should we
    resolve this matter? We need to have the Thread to draw the dialog
    across the multiple session. Does anyone know how to draw the dialog
    on the Login Window for multiple users?

    Thank you

    "Eric Perlin [MS]" <ericperl@online.microsoft.com> wrote in message news:<eIn#rs5wEHA.1564@TK2MSFTNGP09.phx.gbl>...
    > I recommend you stay away from interactive services. Not only do they have
    > serious security implications, but they can not be used in FUS and TS
    > (Terminal Services) environments, as you found out. FUS leverages TS
    > (multiple TS sessions, with only one bound to the physical console) and
    > processes can not cross session boundaries. Your service is hosted in a
    > process that exists in session 0. It will never be able to display UI in
    > other sessions.
    > --
    > Eric Perlin [MS]
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    > ---
    >
    > "Samuel Lee" <samthebigbear@gmail.com> wrote in message
    > news:c94893b3.0411012243.5fb71ac0@posting.google.com...
    > > Hi,
    > > I am writing a Service that will authenticate the users during the
    > > Login.
    > > The way I implement this scheme is that I start separate thread that
    > > draws dialog whenever the service get Event Notification (Lock,
    > > Logoff, Startup) from winlogon.
    > >
    > > Since it is a interactive service, Windows Station that the thread
    > > gets assigned is WinSta0. What I am trying to do is whenever I get
    > > either Lock, Logoff, and Startup Message, I start a thread to draw
    > > dialog on the "Winlogon" Desktop.
    > >
    > > The problem from this is that if there are multiple users, dialog does
    > > not always appear on the LogIn window even I know that the thread has
    > > drawn the dialog especially during the Fast User Switching. More
    > > specifically, whenever I fast user switch out of the first user that I
    > > log onto to any other users, Dialog appears. However, whenever I fast
    > > user switch out of second or third user that I log onto to any other
    > > user doesn't work.
    > >
    > > Did anyone have similar problem with this? Could Someone PLEASE help
    > > me...
    > > Thank you,
    > >
    > > Here is a piece of code that the thread is executing:
    > >
    > > DWORD dwThreadId;
    > > HWINSTA hwinstaSave;
    > > HDESK hdeskSave;
    > > HWINSTA hwinstaUser;
    > > HDESK hdeskUser;
    > > HWND hParent = NULL;
    > >
    > > // Ensure connection to service window station and desktop, and
    > > // save their handles.
    > >
    > > hParent = GetDesktopWindow();
    > > hwinstaSave = GetProcessWindowStation();
    > > hdeskSave = GetThreadDesktop(dwThreadId);
    > >
    > > hwinstaUser = OpenWindowStation(TEXT("Winsta0"), FALSE,
    > > MAXIMUM_ALLOWED);
    > >
    > > if (hwinstaUser == NULL)
    > > {
    > > DEBUG_MSG("return in windowstation here....\n");
    > > return 0;
    > > }
    > >
    > > //SETTING THE WINDOW STATION TO Winsta0 and DESKTOP to Winlogon
    > > SetProcessWindowStation(hwinstaUser);
    > > hdeskUser= OpenDesktop(TEXT("Winlogon"), NULL, FALSE,
    > > MAXIMUM_ALLOWED);
    > > if (hdeskUser== NULL)
    > > {
    > > DEBUG_MSG("return in windowstation here....\n");
    > > return 0;
    > > }
    > > SetThreadDesktop(hdeskUser);
    > >
    > > hParent = GetDesktopWindow();
    > >
    > >
    > > g_hWnd =
    > CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_FINGER_PRINT),NULL,Welcome
    > DlgProc,0);
    > > SetWindowPos(g_hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_SHOWWINDOW);
    > > UpdateWindow(g_hWnd);
    > >
    > > // Restore window station and desktop.
    > > SetThreadDesktop(hdeskSave);
    > > SetProcessWindowStation(hwinstaSave);
    > > CloseDesktop(hdeskUser);
    > > CloseWindowStation(hwinstaUser);
    > >
    > >
    > > int status;
    > > MSG msg;
    > > while ( ( status = GetMessage( &msg, NULL, 0, 0 ) ) != 0 )
    > > {
    > > if ( status == -1 )
    > > return -1;
    > >
    > > if ( !IsDialogMessage( g_hWnd, &msg ) )
    > > {
    > > TranslateMessage( &msg );
    > > DispatchMessage( &msg );
    > > }
    > > }
    > > return 1;


  • Next message: Mark Stanley: "Re: Incorrect message box from non-interactive service"

    Relevant Pages

    • Re: Question about retained values
      ... custom created database property). ... on if your database is single or multiple users. ... is the databse split into a front end mdb ... must be retained from one session to the next. ...
      (microsoft.public.access.reports)
    • Re: Interactive user name?
      ... Your second suggestion, using a Winlogon Notification Package, will not work ... user's session will work for us. ... I'm surprized that Microsoft has added the ability to have multiple users ... stale or orphaned interactive logon sessions of already logged ...
      (microsoft.public.win32.programmer.networks)
    • USB mount with multiple users broken (hal and consolekit)
      ... I'm having trouble with automounting of removable devices, ... when I do this repeatedly with multiple users ... Sometimes it's the UID ... know about the active session, but apparently it still does not work. ...
      (Debian-User)
    • Re: End a disconnected session in less than 1 minute
      ... multiple users. ... > printing and limit access to the TS, I have created general TS logins ... When a user closes the TS session without logging out of the ... > Active session limit - Never ...
      (microsoft.public.windows.terminal_services)
    • Re: Run code part (like threadproc) in separate process
      ... some process level session objects. ... If one dll fails, it fails the process. ... wcoloader /dll:wcothread1.dll ...
      (microsoft.public.vc.language)