protected override void OnCreateMainForm() { MainForm = SEBClientInfo.SebWindowsClientForm; string[] arguments = Environment.GetCommandLineArgs(); // Logger.AddInformation("KeyKitePassword: "******"REDACTED") { Logger.AddInformation("returning false, not correct config file."); // return; } if (arguments.Count() == 1) { var splashThread = new Thread(SebWindowsClientMain.StartSplash); splashThread.Start(); try { SebWindowsClientMain.InitSEBDesktop(); } catch (Exception ex) { Logger.AddError("Unable to InitSEBDesktop", null, ex); } if (!SEBClientInfo.SebWindowsClientForm.OpenSEBForm()) { Logger.AddError("Unable to OpenSEBForm", null, null); } SebWindowsClientMain.CloseSplash(); } }
public static void SetProcessLandscapePreference() { IntPtr hModule = SebWindowsClientMain.LoadLibrary("user32.dll"); if (hModule == IntPtr.Zero) { return; } try { IntPtr procAddress = SebWindowsClientMain.GetProcAddress(hModule, "SetDisplayAutoRotationPreferences"); if (procAddress == IntPtr.Zero) { Logger.AddInformation("SetProcessLandscapePreference - Unsupported OS detected.", (object)null, (Exception)null, (string)null); } else { Logger.AddInformation(string.Format("SetProcessLandscapePreference(Landscape) - {0}", (object)((SebWindowsClientMain.SetDisplayAutoRotationPreferences)Marshal.GetDelegateForFunctionPointer(procAddress, typeof(SebWindowsClientMain.SetDisplayAutoRotationPreferences)))(5)), (object)null, (Exception)null, (string)null); } } finally { SebWindowsClientMain.FreeLibrary(hModule); } }
protected override void OnCreateMainForm() { MainForm = SEBClientInfo.SebWindowsClientForm; string[] arguments = Environment.GetCommandLineArgs(); if (arguments.Count() == 1) { var splashThread = new Thread(SebWindowsClientMain.StartSplash); splashThread.Start(); try { SebWindowsClientMain.InitSEBDesktop(); } catch (Exception ex) { Logger.AddError("Unable to InitSEBDesktop", null, ex); } if (!SEBClientInfo.SebWindowsClientForm.OpenSEBForm()) { Logger.AddError("Unable to OpenSEBForm", null, null); } SebWindowsClientMain.CloseSplash(); } }
public static string ShowPasswordDialogForm(string title, string passwordRequestText) { if (SEBClientInfo.SebWindowsClientForm != null) { SebWindowsClientMain.SEBToForeground(); } if (SebWindowsClientMain.sessionCreateNewDesktop || SEBSettings.settingsCurrent.Count > 0 && (bool)SEBClientInfo.getSebSetting("touchOptimized")["touchOptimized"]) { return(SebPasswordDialogForm.ShowPasswordDialogForm(title, passwordRequestText)); } Worker worker = new Worker(); Thread thread = new Thread(new ThreadStart(worker.ShowPasswordDialogInThread)); worker.dialogTitle = title; worker.dialogText = passwordRequestText; thread.Start(); do { ; }while (!thread.IsAlive); thread.Join(); if (SebWindowsClientMain.sessionCreateNewDesktop) { SEBDesktopController.Show(SEBClientInfo.SEBNewlDesktop.DesktopName); } return(worker.dialogResultText); }
public static string ShowPasswordDialogForm(string title, string passwordRequestText) { // If we are running in SebWindowsClient we need to activate it before showing the password dialog if (SEBClientInfo.SebWindowsClientForm != null) { SebWindowsClientMain.SEBToForeground(); } //No longer necessary as you cannot switch from not-create-new-desktop to create-new-desktop and the other way around // Check if SEB is running on a separate desktop if (SebWindowsClientMain.sessionCreateNewDesktop) //Switch to default desktop: SEBDesktopController.Show(SEBClientInfo.OriginalDesktop.DesktopName); { // SEB is already running on a separate desktop: we can show the password entry dialog without a separate thread return(SebPasswordDialogForm.ShowPasswordDialogForm(title, passwordRequestText)); } //In Touch Mode, do not use the threaded Dialog because we know we can't use it else if (SEBSettings.settingsCurrent.Count > 0 && (Boolean)SEBClientInfo.getSebSetting(SEBSettings.KeyTouchOptimized)[SEBSettings.KeyTouchOptimized]) { return(SebPasswordDialogForm.ShowPasswordDialogForm(title, passwordRequestText)); } else { // SEB isn't running on a separate desktop (or not yet): // We need to show the password dialog in a separate thread to avoid hooks/references for the current main thread // (this makes switching desktops impossible in case it would be necessary later) // Create the thread object. This does not start the thread. Worker workerObject = new Worker(); Thread workerThread = new Thread(workerObject.ShowPasswordDialogInThread); workerThread.SetApartmentState(ApartmentState.STA); workerObject.dialogTitle = title; workerObject.dialogText = passwordRequestText; // Start the worker thread. workerThread.Start(); // Loop until worker thread activates. while (!workerThread.IsAlive) { ; } // Request that the worker thread stop itself: //workerObject.RequestStop(); // Use the Join method to block the current thread // until the object's thread terminates. workerThread.Join(); // Switch to new desktop if (SebWindowsClientMain.sessionCreateNewDesktop) { SEBDesktopController.Show(SEBClientInfo.SEBNewlDesktop.DesktopName); } return(workerObject.dialogResultText); } }
public static void CheckIfInsideVirtualMachine() { if (SebWindowsClientMain.IsInsideVM() && !(bool)SEBClientInfo.getSebSetting("allowVirtualMachine")["allowVirtualMachine"]) { int num = (int)SEBMessageBox.Show(SEBUIStrings.detectedVirtualMachine, SEBUIStrings.detectedVirtualMachineForbiddenMessage, MessageBoxIcon.Hand, MessageBoxButtons.OK, false); Logger.AddError("Forbidden to run SEB on a virtual machine!", (object)null, (Exception)null, (string)null); Logger.AddInformation("Safe Exam Browser is exiting", (object)null, (Exception)null, (string)null); throw new SEBNotAllowedToRunEception("Forbidden to run SEB on a virtual machine!"); } }
private static bool MyEnumThreadWindowsProc(IntPtr hWnd, IntPtr lParam) { StringBuilder text = new StringBuilder(256); if (SebWindowsClientMain.GetWindowText(hWnd, text, text.Capacity) > 0) { Console.WriteLine((object)text); if (text.ToString() == "Start") { SebWindowsClientMain.vistaStartMenuWnd = hWnd; return(false); } } return(true); }
private static IntPtr GetVistaStartMenuWnd(IntPtr taskBarWnd) { int lpdwProcessId; int windowThreadProcessId = (int)SebWindowsClientMain.GetWindowThreadProcessId(taskBarWnd, out lpdwProcessId); Process processById = Process.GetProcessById(lpdwProcessId); if (processById != null) { foreach (ProcessThread thread in (ReadOnlyCollectionBase)processById.Threads) { SebWindowsClientMain.EnumThreadWindows(thread.Id, new SebWindowsClientMain.EnumThreadProc(SebWindowsClientMain.MyEnumThreadWindowsProc), IntPtr.Zero); } } return(SebWindowsClientMain.vistaStartMenuWnd); }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); string[] commandLineArgs = Environment.GetCommandLineArgs(); Logger.AddInformation("---------- INITIALIZING SEB - STARTING SESSION -------------", (object)null, (Exception)null, (string)null); Logger.AddInformation(" Arguments: " + string.Join(", ", commandLineArgs), (object)null, (Exception)null, (string)null); try { if (!SebWindowsClientMain.InitSebSettings()) { return; } } catch (Exception ex) { Logger.AddError("Unable to InitSebSettings", (object)null, ex, (string)null); return; } /*try * { * SebWindowsClientMain.CheckDistributionIntegrity(); * } * catch (Exception ex) * { * int num = (int) SEBMessageBox.Show(SEBUIStrings.integrityCheckError, SEBUIStrings.integrityCheckErrorReason, MessageBoxIcon.Hand, MessageBoxButtons.OK, false); * Logger.AddError(SEBUIStrings.integrityCheckError, (object) null, ex, (string) null); * return; * } */ SebWindowsClientMain.singleInstanceController = new SingleInstanceController(); try { SEBClientInfo.SebWindowsClientForm = new SebWindowsClientForm(); SebWindowsClientMain.singleInstanceController.Run(commandLineArgs); } catch (Exception ex) { Logger.AddError(ex.Message, (object)null, ex, (string)null); } }
public static void SetVisibility(bool show) { IntPtr window = SebWindowsClientMain.FindWindow("Shell_TrayWnd", (string)null); IntPtr hwnd = SebWindowsClientMain.FindWindowEx(window, IntPtr.Zero, "Button", "Start"); if (hwnd == IntPtr.Zero) { hwnd = SebWindowsClientMain.FindWindowEx(IntPtr.Zero, IntPtr.Zero, (IntPtr)49175, "Start"); } if (hwnd == IntPtr.Zero) { hwnd = SebWindowsClientMain.FindWindow("Button", (string)null); if (hwnd == IntPtr.Zero) { hwnd = SebWindowsClientMain.GetVistaStartMenuWnd(window); } } SebWindowsClientMain.ShowWindow(window, show ? 5 : 0); SebWindowsClientMain.ShowWindow(hwnd, show ? 5 : 0); }