Example #1
0
 void getConsoleAndSpawn()
 {
     if (running)
     {
         try {
             session = Win32Impl.WTSGetActiveConsoleSessionId();
             wmisession.Log("New session " + session.ToString());
             if (session != 0xFFFFFFFF)
             {
                 Win32Impl.AcquireSystemPrivilege(Win32Impl.SE_TCB_NAME);
                 consoletoken = Win32Impl.QueryUserToken(session);
                 wmisession.Log("Got new session token");
                 gotConsole = true;
                 spawnWorker();
             }
         }
         catch (Exception e) {
             gotConsole = false;
             WmiBase.Singleton.DebugMsg(e.ToString());
         }
     }
     else
     {
         gotConsole = false;
     }
 }
Example #2
0
            void getConsoleAndSpawn()
            {
                if (running)
                {
                    try {
                        session = Win32Impl.WTSGetActiveConsoleSessionId();
                        wmisession.Log("New session " + session.ToString());
                        if (session != 0xFFFFFFFF)
                        {
                            wmisession.Log("Checking to see if XenDesktop is active");
                            if (XenAppXenDesktop.ActiveConsoleSession(session))
                            {
                                wmisession.Log("Active XenDesktop session, not spawning worker");
                                gotConsole = false;
                                return;
                            }

                            Win32Impl.AcquireSystemPrivilege(Win32Impl.SE_TCB_NAME);
                            consoletoken = Win32Impl.QueryUserToken(session);
                            wmisession.Log("Got new session token");
                            gotConsole = true;
                            spawnWorker();
                        }
                    }
                    catch (Exception e) {
                        gotConsole = false;
                        WmiBase.Singleton.DebugMsg(e.ToString());
                    }
                }
                else
                {
                    wmisession.Log("Not got console");
                    gotConsole = false;
                }
            }
Example #3
0
 public void HandleSessionChange(System.ServiceProcess.SessionChangeReason changeargs, uint sessionId)
 {
     lock (statelock) {
         if (running &&
             (sessionId == Win32Impl.WTSGetActiveConsoleSessionId()))
         {
             state.HandleConsoleChanged(changeargs);
         }
     }
 }
Example #4
0
 void handleConsoleChanged()
 {
     if (running)
     {
         wmisession.Log("Console changed");
         if (gotConsole == false)
         {
             getConsoleAndSpawn();
         }
         else
         {
             uint newsession = Win32Impl.WTSGetActiveConsoleSessionId();
             wmisession.Log("changed to session " + newsession.ToString());
             if (newsession != session)
             {
                 restartWorker();
             }
         }
     }
 }