public static void SEBToForeground()
 {
     try
     {
         SebApplicationChooserForm.forceSetForegroundWindow(SEBClientInfo.SebWindowsClientForm.Handle);
         SEBClientInfo.SebWindowsClientForm.Activate();
     }
     catch (Exception ex)
     {
     }
 }
Пример #2
0
        /// ----------------------------------------------------------------------------------------
        /// <summary>
        /// Move SEB to the foreground.
        /// </summary>
        /// ----------------------------------------------------------------------------------------
        public static void SEBToForeground()
        {
            //if ((bool)SEBSettings.valueForDictionaryKey(SEBSettings.settingsCurrent, SEBSettings.KeyShowTaskBar))
            //{
            try
            {
                //SetForegroundWindow(SEBClientInfo.SebWindowsClientForm.Handle);
                SebApplicationChooserForm.forceSetForegroundWindow(SEBClientInfo.SebWindowsClientForm.Handle);
                SEBClientInfo.SebWindowsClientForm.Activate();
            }
            catch (Exception)
            {
            }

            //}
        }
Пример #3
0
        /// ----------------------------------------------------------------------------------------
        /// <summary>
        /// Move SEB to the foreground.
        /// </summary>
        /// ----------------------------------------------------------------------------------------
        public static void SEBToForeground()
        {
            //if ((bool)SEBSettings.valueForDictionaryKey(SEBSettings.settingsCurrent, SEBSettings.KeyShowTaskBar))
            //{
            try
            {
                if (SEBClientInfo.SebWindowsClientForm.InvokeRequired)
                {
                    SEBClientInfo.SebWindowsClientForm.Invoke((MethodInvoker) delegate { SEBToForeground(); });
                    return;
                }
                // this code will run on main (UI) thread

                //SetForegroundWindow(SEBClientInfo.SebWindowsClientForm.Handle);
                SebApplicationChooserForm.forceSetForegroundWindow(SEBClientInfo.SebWindowsClientForm.Handle);
                SEBClientInfo.SebWindowsClientForm.Activate();
            }
            catch (Exception)
            {
            }

            //}
        }
        /// ----------------------------------------------------------------------------------------
        /// <summary>
        /// Open SEB form.
        /// </summary>
        /// ----------------------------------------------------------------------------------------
        public bool OpenSEBForm()
        {
            Logger.AddInformation("entering Opensebform");
            if ((bool)SEBSettings.valueForDictionaryKey(SEBSettings.settingsCurrent, SEBSettings.KeyShowTaskBar))
            {
                //this.Show();
                Logger.AddInformation("attempting to position the taskbar");
                SetFormOnDesktop();
                Logger.AddInformation("finished taskbar positioning");
                //if (!this.Controls.Contains(this.taskbarToolStrip))
                //{
                //    this.Controls.Add(this.taskbarToolStrip);
                //    taskbarToolStrip.Show();
                //    Logger.AddInformation("Removed SEB taskbar re-added to form.", null, null);
                //}
            }
            else
            {
                Logger.AddInformation("hiding the taskbar");
                //this.Hide();
                this.Visible = false;
                this.Height = 1;
                this.Width = 1;
                //this.BackColor = Color.Transparent;
                this.Location = new System.Drawing.Point(-50000, -50000);

                taskbarHeight = 0;

                PlaceFormOnDesktop(false, true);
            }

            // Check if VM and SEB Windows Service are available and forbidden/required
            try
            {
                SebWindowsClientMain.CheckIfInsideVirtualMachine();
                SebWindowsClientMain.CheckServicePolicy(SebWindowsServiceHandler.IsServiceAvailable);

                Logger.AddInformation("attempting to start socket server");
                SEBXULRunnerWebSocketServer.StartServer();

                //Set Registry Values to lock down CTRL+ALT+DELETE Menu (with SEBWindowsServiceWCF)
                try
                {
                    Logger.AddInformation("setting registry values");
                    if (SebWindowsServiceHandler.IsServiceAvailable &&
                        !SebWindowsServiceHandler.SetRegistryAccordingToConfiguration())
                    {
                        Logger.AddError("Unable to set Registry values", this, null);
                        SebWindowsClientMain.CheckServicePolicy(false);
                    }
                }
                catch (SEBNotAllowedToRunEception ex)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    Logger.AddError("Unable to set Registry values", this, ex);
                    SebWindowsClientMain.CheckServicePolicy(false);
                }

                //Disable windows update service (with SEBWindowsServiceWCF)
                try
                {
                    Logger.AddInformation("Disabling Windows update");
                    if (SebWindowsServiceHandler.IsServiceAvailable && !SebWindowsServiceHandler.DisableWindowsUpdate())
                        Logger.AddWarning("Unable to disable Windows update service", this, null);
                }
                catch (Exception ex)
                {
                    Logger.AddError("Unable to disable Windows update service", this, ex);
                }

                try
                {
                    Logger.AddInformation("killing processes that are not allowed to run");
                    bool bClientRegistryAndProcesses = InitClientRegistryAndKillProcesses();
                }
                catch (Exception ex)
                {
                    Logger.AddError("Unable to kill processes that are running before start", this, ex);
                }

                // Disable unwanted keys.
                SebKeyCapture.FilterKeys = true;

                try
                {
                    Logger.AddInformation("adding allowed processes to taskbar");
                    addPermittedProcessesToTS();
                }
                catch (Exception ex)
                {
                    Logger.AddError("Unable to addPermittedProcessesToTS", this, ex);
                }

                if (sebCloseDialogForm == null)
                {
                    Logger.AddInformation("creating close dialog form");
                    sebCloseDialogForm = new SebCloseDialogForm();
                    sebCloseDialogForm.TopMost = true;
                }
                if (sebApplicationChooserForm == null)
                {
                    Logger.AddInformation("building application chooser form");
                    sebApplicationChooserForm = new SebApplicationChooserForm();
                    sebApplicationChooserForm.TopMost = true;
                    sebApplicationChooserForm.Show();
                    sebApplicationChooserForm.Visible = false;
                }

                return true;
            }
            catch (SEBNotAllowedToRunEception ex)
            {
                // VM or service not available and set to be required
                Logger.AddInformation(string.Format("exiting without starting up because {0}", ex.Message));
                ExitApplication(false);
                return false;
            }
        }
Пример #5
0
        /// ----------------------------------------------------------------------------------------
        /// <summary>
        /// Open SEB form.
        /// </summary>
        /// ----------------------------------------------------------------------------------------
        public bool OpenSEBForm()
        {
            Logger.AddInformation("entering Opensebform");
            if ((bool)SEBSettings.valueForDictionaryKey(SEBSettings.settingsCurrent, SEBSettings.KeyShowTaskBar))
            {
                //this.Show();
                Logger.AddInformation("attempting to position the taskbar");
                SetFormOnDesktop();
                Logger.AddInformation("finished taskbar positioning");
                //if (!this.Controls.Contains(this.taskbarToolStrip))
                //{
                //    this.Controls.Add(this.taskbarToolStrip);
                //    taskbarToolStrip.Show();
                //    Logger.AddInformation("Removed SEB taskbar re-added to form.", null, null);
                //}
            }
            else
            {
                Logger.AddInformation("hiding the taskbar");
                //this.Hide();
                this.Visible = false;
                this.Height = 1;
                this.Width = 1;
                //this.BackColor = Color.Transparent;
                this.Location = new System.Drawing.Point(-50000, -50000);

                taskbarHeight = 0;

                PlaceFormOnDesktop(false, true);
            }

            // Check if VM and SEB Windows Service available and required
            if (SebWindowsClientMain.CheckVMService()) {
                Logger.AddInformation("attempting to start socket server");
                SEBXULRunnerWebSocketServer.StartServer();

                //Set Registry Values to lock down CTRL+ALT+DELETE Menu (with SEBWindowsServiceWCF)
                try
                {
                    Logger.AddInformation("setting registry values");
                    if(SebWindowsServiceHandler.IsServiceAvailable && !SebWindowsServiceHandler.SetRegistryAccordingToConfiguration())
                        Logger.AddWarning("Unable to set registry values",this,null);
                }
                catch (Exception ex)
                {
                    Logger.AddError("Unable to set Registry values",this,ex);
                }

                //Disable windows update service (with SEBWindowsServiceWCF)
                try
                {
                    Logger.AddInformation("disabling windows update");
                    if (SebWindowsServiceHandler.IsServiceAvailable && !SebWindowsServiceHandler.DisableWindowsUpdate())
                        Logger.AddWarning("Unable to disable windows upate service", this, null);
                }
                catch (Exception ex)
                {
                    Logger.AddError("Unable to disable windows update service", this, ex);
                }

                try
                {
                    Logger.AddInformation("killing processes that are not allowed to run");
                    bool bClientRegistryAndProcesses = InitClientRegistryAndKillProcesses();
                }
                catch (Exception ex)
                {
                    Logger.AddError("Unable to kill processes that are running before start", this, ex);
                }

                // Disable unwanted keys.
                SebKeyCapture.FilterKeys = true;

                // Save the value of the environment variable determining if XULRunner (and Mozilla Firefox) start plugins in plugins-container.exe
                // If SEB runs on an own desktop (createNewDesktop = true), plugins like Flash won't work if they are started in plugin-container.exe
                //SEBClientInfo.XulRunnerFlashContainerState = System.Environment.GetEnvironmentVariable("MOZ_DISABLE_OOP_PLUGINS", EnvironmentVariableTarget.User);

                //// Disable plugins-container if enablePlugIns = true and createNewDesktop = true
                //if ((bool)SEBSettings.settingsCurrent[SEBSettings.KeyEnablePlugIns] && (bool)SEBSettings.settingsCurrent[SEBSettings.KeyCreateNewDesktop])
                //{
                //    System.Environment.SetEnvironmentVariable("MOZ_DISABLE_OOP_PLUGINS", "1", EnvironmentVariableTarget.User);
                //    string xulRunnerFlashContainer = System.Environment.GetEnvironmentVariable("MOZ_DISABLE_OOP_PLUGINS", EnvironmentVariableTarget.User);
                //    Logger.AddInformation("Environment Variable MOZ_DISABLE_OOP_PLUGINS had value: " +
                //        (SEBClientInfo.XulRunnerFlashContainerState == null ? "null" : SEBClientInfo.XulRunnerFlashContainerState), null, null);
                //    Logger.AddInformation("Environment Variable MOZ_DISABLE_OOP_PLUGINS was set to value: " + xulRunnerFlashContainer, null, null);
                //}
                try
                {
                    Logger.AddInformation("adding allowed processes to taskbar");
                    addPermittedProcessesToTS();
                }
                catch (Exception ex)
                {
                    Logger.AddError("Unable to addPermittedProcessesToTS",this,ex);
                }

                //SetFormOnDesktop();

                //System.Diagnostics.Process oskProcess = null;
                //oskProcess = Process.Start("OSK");
                //SEBDesktopController d = SEBDesktopController.OpenDesktop(SEBClientInfo.DesktopName);
                //oskProcess = d.CreateProcess("OSK");

                if (sebCloseDialogForm == null)
                {
                    Logger.AddInformation("creating close dialog form");
                    sebCloseDialogForm = new SebCloseDialogForm();
                    //SetForegroundWindow(sebCloseDialogForm.Handle);
                    sebCloseDialogForm.TopMost = true;
                    //sebCloseDialogForm.Show();
                    //sebCloseDialogForm.Visible = false;
                }
                if (sebApplicationChooserForm == null)
                {
                    Logger.AddInformation("building application chooser form");
                    sebApplicationChooserForm = new SebApplicationChooserForm();
                    sebApplicationChooserForm.TopMost = true;
                    sebApplicationChooserForm.Show();
                    sebApplicationChooserForm.Visible = false;
                }

                return true;
            }
            else
            {
                // VM or service not available and set to be required
                Logger.AddInformation("exiting without starting up because vm test failed");
                ExitApplication(false);
                return false;
            }
        }