Esempio n. 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;
     }
 }
Esempio n. 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;
                }
            }
Esempio n. 3
0
        override protected void onFeature()
        {
            wmisession.Log("Received shutdown event");
            Win32Impl.AcquireSystemPrivilege(Win32Impl.SE_SHUTDOWN_NAME);


            if (controlKey.Exists())
            {
                string action = controlKey.value;
                wmisession.Log("Received shutdown event type " + controlKey.value);

                try
                {
                    switch (action)
                    {
                    case powerPowerOff:
                        doPowerOff();
                        break;

                    case powerHalt:
                        doPowerOff();
                        break;

                    case powerReboot:
                        doReboot();
                        break;

                    case powerHibernate:
                        controlHibernationState.value = statestarted;
                        controlKey.Remove();
                        if (!Application.SetSuspendState(PowerState.Hibernate, false, false))
                        {
                            controlHibernationState.value = statefailed;
                        }
                        break;

                    case powerS3:
                        controlS3State.value = statestarted;
                        controlKey.Remove();
                        if (!Application.SetSuspendState(PowerState.Suspend, false, false))
                        {
                            controlS3State.value = statefailed;
                        }
                        break;

                    default:
                        // This is a shutdown state we can't handle,
                        // so return without removing the control key
                        return;
                    }
                }
                catch (Exception e)
                {
                    wmisession.Log("Shutdown attempt" + action + " failed:\n" + e.ToString());
                }
                controlKey.Remove();
            }
        }