From b71e8bd82f810161b301eec37ba4c3e12c5fbdda Mon Sep 17 00:00:00 2001 From: Vichingo455 Date: Mon, 23 Jun 2025 17:07:12 +0200 Subject: [PATCH] v1.6 --- patch-seb/Form1.cs | 12 ++- patch-seb/OfflinePatcher.Designer.cs | 152 ++++++++++++++------------- patch-seb/OfflinePatcher.cs | 55 ++++++++-- patch-seb/Program.cs | 2 +- patch-seb/Properties/AssemblyInfo.cs | 4 +- patch-seb/patch-seb.csproj | 1 + 6 files changed, 136 insertions(+), 90 deletions(-) diff --git a/patch-seb/Form1.cs b/patch-seb/Form1.cs index 0ae751f..faf9f5a 100644 --- a/patch-seb/Form1.cs +++ b/patch-seb/Form1.cs @@ -174,16 +174,16 @@ namespace patch_seb } if (checkBox2.Checked) { - File.WriteAllText(Path.GetTempPath() + @"\SEB.reg", Resources.cert); + File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\Temp\SEB.reg", Resources.cert); ProcessStartInfo info = new ProcessStartInfo { FileName = Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\regedit.exe", - Arguments = $@"/s \""{Path.GetTempPath() + @"\SEB.reg"}\""", + Arguments = $@"/s {Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\Temp\SEB.reg"}", CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden }; Process.Start(info).WaitForExit(); - File.Delete(Path.GetTempPath() + @"\SEB.reg"); + File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\Temp\SEB.reg"); } AddLog("PATCHING DONE"); button1.Text = "PATCH DONE"; @@ -199,7 +199,11 @@ namespace patch_seb if (something == 4) { something = 0; - MessageBox.Show("Safe Exam Browser Patch v" + Application.ProductVersion + "\nFor Safe Exam Browser version " + Variables.SupportedSEB + "\nCreated with love by Vichingo455\n\nBecause Freedom is a right, respect it.", "Safe Exam Browser Patch", MessageBoxButtons.OK, MessageBoxIcon.Information); + #if DEBUG + MessageBox.Show("Safe Exam Browser Patch (Debug/Beta) v" + Application.ProductVersion + "\nFor Safe Exam Browser version " + Variables.SupportedSEB + "\nCreated with love by Vichingo455\n\nBecause Freedom is a right, respect it.", "Safe Exam Browser Patch", MessageBoxButtons.OK, MessageBoxIcon.Information); + #else + MessageBox.Show("Safe Exam Browser Patch v" + Application.ProductVersion + "\nFor Safe Exam Browser version " + Variables.SupportedSEB + "\nCreated with love by Vichingo455\n\nBecause Freedom is a right, respect it.", "Safe Exam Browser Patch", MessageBoxButtons.OK, MessageBoxIcon.Information); + #endif } else { diff --git a/patch-seb/OfflinePatcher.Designer.cs b/patch-seb/OfflinePatcher.Designer.cs index e5a619c..d86c0b0 100644 --- a/patch-seb/OfflinePatcher.Designer.cs +++ b/patch-seb/OfflinePatcher.Designer.cs @@ -31,17 +31,17 @@ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OfflinePatcher)); this.label1 = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.partitionComboBox = new System.Windows.Forms.ComboBox(); - this.label2 = new System.Windows.Forms.Label(); this.button1 = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.partitionComboBox = new System.Windows.Forms.ComboBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.label3 = new System.Windows.Forms.Label(); - this.selectedinstallation = new System.Windows.Forms.Label(); - this.autodetect = new System.Windows.Forms.RadioButton(); - this.x64 = new System.Windows.Forms.RadioButton(); - this.x86 = new System.Windows.Forms.RadioButton(); - this.checkBox1 = new System.Windows.Forms.CheckBox(); this.checkBox2 = new System.Windows.Forms.CheckBox(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.x86 = new System.Windows.Forms.RadioButton(); + this.x64 = new System.Windows.Forms.RadioButton(); + this.autodetect = new System.Windows.Forms.RadioButton(); + this.selectedinstallation = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); this.button2 = new System.Windows.Forms.Button(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.textBox1 = new System.Windows.Forms.TextBox(); @@ -61,6 +61,7 @@ this.label1.Size = new System.Drawing.Size(324, 28); this.label1.TabIndex = 0; this.label1.Text = "Safe Exam Browser Offline Patch"; + this.label1.Click += new System.EventHandler(this.label1_Click); // // groupBox1 // @@ -74,14 +75,15 @@ this.groupBox1.TabStop = false; this.groupBox1.Text = "Safe Exam Browser installations"; // - // partitionComboBox + // button1 // - this.partitionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.partitionComboBox.FormattingEnabled = true; - this.partitionComboBox.Location = new System.Drawing.Point(178, 44); - this.partitionComboBox.Name = "partitionComboBox"; - this.partitionComboBox.Size = new System.Drawing.Size(381, 29); - this.partitionComboBox.TabIndex = 0; + this.button1.Location = new System.Drawing.Point(583, 44); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(116, 29); + this.button1.TabIndex = 2; + this.button1.Text = "USE"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); // // label2 // @@ -92,15 +94,14 @@ this.label2.TabIndex = 1; this.label2.Text = "Installation to patch:"; // - // button1 + // partitionComboBox // - this.button1.Location = new System.Drawing.Point(583, 44); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(116, 29); - this.button1.TabIndex = 2; - this.button1.Text = "USE"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); + this.partitionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.partitionComboBox.FormattingEnabled = true; + this.partitionComboBox.Location = new System.Drawing.Point(178, 44); + this.partitionComboBox.Name = "partitionComboBox"; + this.partitionComboBox.Size = new System.Drawing.Size(381, 29); + this.partitionComboBox.TabIndex = 0; // // groupBox2 // @@ -119,23 +120,47 @@ this.groupBox2.TabStop = false; this.groupBox2.Text = "Patch settings"; // - // label3 + // checkBox2 // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(21, 73); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(233, 21); - this.label3.TabIndex = 0; - this.label3.Text = "Safe Exam Browser Architecture:"; + this.checkBox2.AutoSize = true; + this.checkBox2.Checked = true; + this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBox2.Location = new System.Drawing.Point(25, 152); + this.checkBox2.Name = "checkBox2"; + this.checkBox2.Size = new System.Drawing.Size(467, 25); + this.checkBox2.TabIndex = 6; + this.checkBox2.Text = "Install custom certificate on the offline system (recommended)"; + this.checkBox2.UseVisualStyleBackColor = true; // - // selectedinstallation + // checkBox1 // - this.selectedinstallation.AutoSize = true; - this.selectedinstallation.Location = new System.Drawing.Point(21, 38); - this.selectedinstallation.Name = "selectedinstallation"; - this.selectedinstallation.Size = new System.Drawing.Size(190, 21); - this.selectedinstallation.TabIndex = 1; - this.selectedinstallation.Text = "Selected Installation: none"; + this.checkBox1.AutoSize = true; + this.checkBox1.Location = new System.Drawing.Point(25, 110); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(86, 25); + this.checkBox1.TabIndex = 5; + this.checkBox1.Text = "Backup"; + this.checkBox1.UseVisualStyleBackColor = true; + // + // x86 + // + this.x86.AutoSize = true; + this.x86.Location = new System.Drawing.Point(605, 73); + this.x86.Name = "x86"; + this.x86.Size = new System.Drawing.Size(60, 25); + this.x86.TabIndex = 4; + this.x86.Text = "x86"; + this.x86.UseVisualStyleBackColor = true; + // + // x64 + // + this.x64.AutoSize = true; + this.x64.Location = new System.Drawing.Point(525, 73); + this.x64.Name = "x64"; + this.x64.Size = new System.Drawing.Size(60, 25); + this.x64.TabIndex = 3; + this.x64.Text = "x64"; + this.x64.UseVisualStyleBackColor = true; // // autodetect // @@ -149,47 +174,23 @@ this.autodetect.Text = "Auto-Detect (recommended)"; this.autodetect.UseVisualStyleBackColor = true; // - // x64 + // selectedinstallation // - this.x64.AutoSize = true; - this.x64.Location = new System.Drawing.Point(525, 73); - this.x64.Name = "x64"; - this.x64.Size = new System.Drawing.Size(60, 25); - this.x64.TabIndex = 3; - this.x64.Text = "x64"; - this.x64.UseVisualStyleBackColor = true; + this.selectedinstallation.AutoSize = true; + this.selectedinstallation.Location = new System.Drawing.Point(21, 38); + this.selectedinstallation.Name = "selectedinstallation"; + this.selectedinstallation.Size = new System.Drawing.Size(190, 21); + this.selectedinstallation.TabIndex = 1; + this.selectedinstallation.Text = "Selected Installation: none"; // - // x86 + // label3 // - this.x86.AutoSize = true; - this.x86.Location = new System.Drawing.Point(605, 73); - this.x86.Name = "x86"; - this.x86.Size = new System.Drawing.Size(60, 25); - this.x86.TabIndex = 4; - this.x86.Text = "x86"; - this.x86.UseVisualStyleBackColor = true; - // - // checkBox1 - // - this.checkBox1.AutoSize = true; - this.checkBox1.Location = new System.Drawing.Point(25, 110); - this.checkBox1.Name = "checkBox1"; - this.checkBox1.Size = new System.Drawing.Size(86, 25); - this.checkBox1.TabIndex = 5; - this.checkBox1.Text = "Backup"; - this.checkBox1.UseVisualStyleBackColor = true; - // - // checkBox2 - // - this.checkBox2.AutoSize = true; - this.checkBox2.Checked = true; - this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBox2.Location = new System.Drawing.Point(25, 152); - this.checkBox2.Name = "checkBox2"; - this.checkBox2.Size = new System.Drawing.Size(467, 25); - this.checkBox2.TabIndex = 6; - this.checkBox2.Text = "Install custom certificate on the offline system (recommended)"; - this.checkBox2.UseVisualStyleBackColor = true; + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(21, 73); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(233, 21); + this.label3.TabIndex = 0; + this.label3.Text = "Safe Exam Browser Architecture:"; // // button2 // @@ -218,6 +219,7 @@ this.textBox1.Multiline = true; this.textBox1.Name = "textBox1"; this.textBox1.ReadOnly = true; + this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both; this.textBox1.Size = new System.Drawing.Size(707, 204); this.textBox1.TabIndex = 0; // diff --git a/patch-seb/OfflinePatcher.cs b/patch-seb/OfflinePatcher.cs index 3590baf..b040d2c 100644 --- a/patch-seb/OfflinePatcher.cs +++ b/patch-seb/OfflinePatcher.cs @@ -22,6 +22,7 @@ namespace patch_seb public static bool alreadyPatched = false; public static bool is64bits = false; public static string SEBPath = ""; + public static int something = 0; public OfflinePatcher() { InitializeComponent(); @@ -118,7 +119,7 @@ namespace patch_seb private void button2_Click(object sender, EventArgs e) { - SEBPath = installation + @"Program Files\SafeExamBrowser\Application"; + SEBPath = installation + @"Program Files\SafeExamBrowser\Application\"; if (alreadyPatched) { var dialog = MessageBox.Show("An already patched Safe Exam Browser has been found. Are you sure to continue?", "Safe Exam Browser Offline Patch", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); @@ -185,7 +186,28 @@ namespace patch_seb File.Delete(SEBPath + @"SafeExamBrowser.Monitoring.dll"); File.Delete(SEBPath + @"SafeExamBrowser.UserInterface.Desktop.dll"); File.Delete(SEBPath + @"SafeExamBrowser.UserInterface.Mobile.dll"); - if (is64bits) // 64 bits patch + if (autodetect.Checked) // Autodetect + { + if (is64bits) // 64 bits patch + { + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.exe", Resources.SafeExamBrowser); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.Client.exe", Resources.SafeExamBrowser_Client); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.Configuration.dll", Resources.SafeExamBrowser_Configuration); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.Monitoring.dll", Resources.SafeExamBrowser_Monitoring); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.UserInterface.Desktop.dll", Resources.SafeExamBrowser_UserInterface_Desktop); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.UserInterface.Mobile.dll", Resources.SafeExamBrowser_UserInterface_Mobile); + } + else // 32 bits patch + { + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.exe", Resources.SafeExamBrowser1); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.Client.exe", Resources.SafeExamBrowser_Client1); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.Configuration.dll", Resources.SafeExamBrowser_Configuration1); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.Monitoring.dll", Resources.SafeExamBrowser_Monitoring1); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.UserInterface.Desktop.dll", Resources.SafeExamBrowser_UserInterface_Desktop1); + File.WriteAllBytes(SEBPath + @"SafeExamBrowser.UserInterface.Mobile.dll", Resources.SafeExamBrowser_UserInterface_Mobile1); + } + } + else if (x64.Checked) // 64 bits patch { File.WriteAllBytes(SEBPath + @"SafeExamBrowser.exe", Resources.SafeExamBrowser); File.WriteAllBytes(SEBPath + @"SafeExamBrowser.Client.exe", Resources.SafeExamBrowser_Client); @@ -208,27 +230,27 @@ namespace patch_seb // Load offline registry ProcessStartInfo load = new ProcessStartInfo { - FileName = Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"System32\reg.exe", + FileName = Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\System32\reg.exe", Arguments = $@"load HKLM\OFFSOFTWARE {installation}Windows\System32\config\software", CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden }; Process.Start(load).WaitForExit(); // Add certificate to offline registry - File.WriteAllText(Path.GetTempPath() + @"\SEB.reg", Resources.cert_offline); + File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\Temp\SEB.reg", Resources.cert_offline); ProcessStartInfo info = new ProcessStartInfo { FileName = Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\regedit.exe", - Arguments = $@"/s \""{Path.GetTempPath() + @"\SEB.reg"}\""", + Arguments = $@"/s {Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\Temp\SEB.reg"}", CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden }; Process.Start(info).WaitForExit(); - File.Delete(Path.GetTempPath() + @"\SEB.reg"); + File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\Temp\SEB.reg"); // Unload offline registry ProcessStartInfo unload = new ProcessStartInfo { - FileName = Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"System32\reg.exe", + FileName = Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\System32\reg.exe", Arguments = $@"unload HKLM\OFFSOFTWARE", CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden @@ -243,5 +265,22 @@ namespace patch_seb AddLog("[ERROR] " + ex.Message); } } - } + + private void label1_Click(object sender, EventArgs e) + { + if (something == 4) + { + something = 0; + #if DEBUG + MessageBox.Show("Safe Exam Browser Offline Patch (Debug/Beta) v" + Application.ProductVersion + "\nFor Safe Exam Browser version " + Variables.SupportedSEB + "\nCreated with love by Vichingo455\n\nBecause Freedom is a right, respect it.", "Safe Exam Browser Patch", MessageBoxButtons.OK, MessageBoxIcon.Information); + #else + MessageBox.Show("Safe Exam Browser Offline Patch v" + Application.ProductVersion + "\nFor Safe Exam Browser version " + Variables.SupportedSEB + "\nCreated with love by Vichingo455\n\nBecause Freedom is a right, respect it.", "Safe Exam Browser Patch", MessageBoxButtons.OK, MessageBoxIcon.Information); + #endif + } + else + { + something++; + } + } + } } diff --git a/patch-seb/Program.cs b/patch-seb/Program.cs index c9230de..57f4760 100644 --- a/patch-seb/Program.cs +++ b/patch-seb/Program.cs @@ -28,7 +28,7 @@ namespace patch_seb // Check if the user wants the offline patcher if (args.Length == 1) { - if (args[1] == "/offline" || args[1] == "/Offline") + if (args[0] == "/offline" || args[0] == "/Offline") { Application.Run(new OfflinePatcher()); } diff --git a/patch-seb/Properties/AssemblyInfo.cs b/patch-seb/Properties/AssemblyInfo.cs index 49bcf25..4933d8a 100644 --- a/patch-seb/Properties/AssemblyInfo.cs +++ b/patch-seb/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Numero di build // Revisione // -[assembly: AssemblyVersion("1.5.2.0")] -[assembly: AssemblyFileVersion("1.5.2.0")] +[assembly: AssemblyVersion("1.6.0.0")] +[assembly: AssemblyFileVersion("1.6.0.0")] diff --git a/patch-seb/patch-seb.csproj b/patch-seb/patch-seb.csproj index f13cc71..b0d04ec 100644 --- a/patch-seb/patch-seb.csproj +++ b/patch-seb/patch-seb.csproj @@ -23,6 +23,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU