diff --git a/Win_1337_Patch/1337.Designer.cs b/Win_1337_Patch/1337.Designer.cs index 8a981b3..f94f24b 100644 --- a/Win_1337_Patch/1337.Designer.cs +++ b/Win_1337_Patch/1337.Designer.cs @@ -30,7 +30,6 @@ { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); - this.btnSelectExe = new System.Windows.Forms.Button(); this.label7 = new System.Windows.Forms.Label(); this.t1337 = new System.Windows.Forms.TextBox(); this.label6 = new System.Windows.Forms.Label(); @@ -44,26 +43,12 @@ this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.SuspendLayout(); // - // btnSelectExe - // - this.btnSelectExe.CausesValidation = false; - this.btnSelectExe.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); - this.btnSelectExe.ForeColor = System.Drawing.Color.DarkRed; - this.btnSelectExe.Location = new System.Drawing.Point(397, 4); - this.btnSelectExe.Margin = new System.Windows.Forms.Padding(0); - this.btnSelectExe.Name = "btnSelectExe"; - this.btnSelectExe.Size = new System.Drawing.Size(24, 23); - this.btnSelectExe.TabIndex = 18; - this.btnSelectExe.Text = "..."; - this.btnSelectExe.UseVisualStyleBackColor = true; - this.btnSelectExe.Click += new System.EventHandler(this.btnSelectExe_Click); - // // label7 // this.label7.AutoSize = true; this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label7.ForeColor = System.Drawing.Color.DarkGreen; - this.label7.Location = new System.Drawing.Point(2, 35); + this.label7.Location = new System.Drawing.Point(7, 8); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(67, 13); this.label7.TabIndex = 17; @@ -74,22 +59,24 @@ this.t1337.AllowDrop = true; this.t1337.BackColor = System.Drawing.SystemColors.Info; this.t1337.ForeColor = System.Drawing.Color.DarkRed; - this.t1337.Location = new System.Drawing.Point(85, 32); + this.t1337.Location = new System.Drawing.Point(90, 5); this.t1337.Name = "t1337"; this.t1337.ReadOnly = true; this.t1337.Size = new System.Drawing.Size(309, 20); this.t1337.TabIndex = 16; + this.t1337.TabStop = false; this.t1337.Text = "Select .1337 File..."; this.t1337.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this.t1337.DragDrop += new System.Windows.Forms.DragEventHandler(this.t1337_DragDrop); this.t1337.DragEnter += new System.Windows.Forms.DragEventHandler(this.t1337_DragEnter); + this.t1337.DoubleClick += new System.EventHandler(this.t1337_DoubleClick); // // label6 // this.label6.AutoSize = true; this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label6.ForeColor = System.Drawing.Color.DarkGreen; - this.label6.Location = new System.Drawing.Point(2, 9); + this.label6.Location = new System.Drawing.Point(7, 34); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(81, 13); this.label6.TabIndex = 15; @@ -97,25 +84,23 @@ // // texe // - this.texe.AllowDrop = true; this.texe.BackColor = System.Drawing.SystemColors.Info; this.texe.ForeColor = System.Drawing.Color.DarkRed; - this.texe.Location = new System.Drawing.Point(85, 6); + this.texe.Location = new System.Drawing.Point(90, 31); this.texe.Name = "texe"; this.texe.ReadOnly = true; - this.texe.Size = new System.Drawing.Size(309, 20); + this.texe.Size = new System.Drawing.Size(336, 20); this.texe.TabIndex = 14; - this.texe.Text = "Select Exe/Dll to Patch..."; + this.texe.TabStop = false; + this.texe.Text = "Name of Exe/Dll to Patch..."; this.texe.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - this.texe.DragDrop += new System.Windows.Forms.DragEventHandler(this.texe_DragDrop); - this.texe.DragEnter += new System.Windows.Forms.DragEventHandler(this.texe_DragEnter); // // btnSelect1337 // this.btnSelect1337.CausesValidation = false; this.btnSelect1337.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); this.btnSelect1337.ForeColor = System.Drawing.Color.DarkRed; - this.btnSelect1337.Location = new System.Drawing.Point(397, 30); + this.btnSelect1337.Location = new System.Drawing.Point(402, 3); this.btnSelect1337.Margin = new System.Windows.Forms.Padding(0); this.btnSelect1337.Name = "btnSelect1337"; this.btnSelect1337.Size = new System.Drawing.Size(24, 23); @@ -130,7 +115,7 @@ this.linkdfox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.linkdfox.ForeColor = System.Drawing.Color.BlueViolet; this.linkdfox.LinkColor = System.Drawing.Color.Indigo; - this.linkdfox.Location = new System.Drawing.Point(250, 62); + this.linkdfox.Location = new System.Drawing.Point(255, 62); this.linkdfox.Name = "linkdfox"; this.linkdfox.Size = new System.Drawing.Size(77, 13); this.linkdfox.TabIndex = 73; @@ -142,7 +127,7 @@ // this.Patch.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Patch.ForeColor = System.Drawing.Color.DarkBlue; - this.Patch.Location = new System.Drawing.Point(333, 57); + this.Patch.Location = new System.Drawing.Point(338, 57); this.Patch.Name = "Patch"; this.Patch.Size = new System.Drawing.Size(88, 23); this.Patch.TabIndex = 74; @@ -205,7 +190,6 @@ this.Controls.Add(this.Patch); this.Controls.Add(this.linkdfox); this.Controls.Add(this.btnSelect1337); - this.Controls.Add(this.btnSelectExe); this.Controls.Add(this.label7); this.Controls.Add(this.t1337); this.Controls.Add(this.label6); @@ -216,7 +200,7 @@ this.MinimumSize = new System.Drawing.Size(448, 122); this.Name = "Form1"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "Win 1337 Apply Patch File v1.5..."; + this.Text = "Win 1337 Apply Patch File v1.6..."; this.Load += new System.EventHandler(this.DFoX_Load); this.ResumeLayout(false); this.PerformLayout(); @@ -224,8 +208,6 @@ } #endregion - - private System.Windows.Forms.Button btnSelectExe; private System.Windows.Forms.Label label7; private System.Windows.Forms.TextBox t1337; private System.Windows.Forms.Label label6; diff --git a/Win_1337_Patch/1337.cs b/Win_1337_Patch/1337.cs index 351e4cc..697220a 100644 --- a/Win_1337_Patch/1337.cs +++ b/Win_1337_Patch/1337.cs @@ -8,8 +8,8 @@ namespace Win_1337_Patch { public partial class Form1 : Form { - public string exe = String.Empty; - public string f1337 = String.Empty; + private string exe = String.Empty; + private string f1337 = String.Empty; [System.Runtime.InteropServices.DllImport("Imagehlp.dll")] private static extern bool ImageRemoveCertificate(IntPtr handle, int index); @@ -19,56 +19,51 @@ namespace Win_1337_Patch InitializeComponent(); } - private void btnSelectExe_Click(object sender, EventArgs e) - { - string urlexe = Properties.Settings.Default["urlexe"].ToString(); - OpenFileDialog apriDialogoFile1 = new OpenFileDialog(); - apriDialogoFile1.Filter = "File Exe|*.exe|File Dll|*.dll|All File|*.*"; - apriDialogoFile1.FilterIndex = 0; - apriDialogoFile1.Title = "Select the file Exe/Dll File..."; - apriDialogoFile1.InitialDirectory = urlexe != "" ? urlexe : Directory.GetCurrentDirectory() + "\\"; - apriDialogoFile1.RestoreDirectory = true; - if (apriDialogoFile1.ShowDialog() == DialogResult.OK) - { - exe = apriDialogoFile1.FileName; - texe.Text = Ellipsis.Compact(exe, texe, EllipsisFormat.Path); - toolTip1.SetToolTip(texe, exe); - Properties.Settings.Default["urlexe"] = exe; - Properties.Settings.Default.Save(); - } - } - private void btnSelect1337_Click(object sender, EventArgs e) { - string url1337 = Properties.Settings.Default["url1337"].ToString(); - OpenFileDialog apriDialogoFile1 = new OpenFileDialog(); - apriDialogoFile1.Filter = "File 1337|*.*"; - apriDialogoFile1.FilterIndex = 0; - apriDialogoFile1.Title = "Select the file 1337 File..."; - apriDialogoFile1.InitialDirectory = url1337 != "" ? url1337 : Directory.GetCurrentDirectory() + "\\"; - apriDialogoFile1.RestoreDirectory = true; - if (apriDialogoFile1.ShowDialog() == DialogResult.OK) + try { - f1337 = apriDialogoFile1.FileName; - t1337.Text = Ellipsis.Compact(f1337, t1337, EllipsisFormat.Path); - toolTip1.SetToolTip(t1337, f1337); - Properties.Settings.Default["url1337"] = f1337; - Properties.Settings.Default.Save(); + string url1337 = Properties.Settings.Default["url1337"].ToString(); + OpenFileDialog apriDialogoFile1 = new OpenFileDialog(); + apriDialogoFile1.Filter = "File 1337|*.*"; + apriDialogoFile1.FilterIndex = 0; + apriDialogoFile1.Title = "Select the file 1337 File..."; + apriDialogoFile1.InitialDirectory = url1337 != "" ? url1337 : Directory.GetCurrentDirectory() + "\\"; + apriDialogoFile1.RestoreDirectory = true; + if (apriDialogoFile1.ShowDialog() == DialogResult.OK) + { + f1337 = apriDialogoFile1.FileName; + t1337.Text = Ellipsis.Compact(f1337, t1337, EllipsisFormat.Path); + toolTip1.SetToolTip(t1337, f1337); + Properties.Settings.Default["url1337"] = f1337; + Properties.Settings.Default.Save(); + string[] lines = File.ReadAllLines(f1337); + if (lines[0].Substring(0, 1) != ">") + { + MessageBox.Show("File 1337 is not valid...", "Info...", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + string unf = lines[0].Substring(1).ToLower().Trim(); + string nf = Path.GetFileName(unf); + string ext = Path.GetExtension(unf); + apriDialogoFile1.FileName = nf; + apriDialogoFile1.Filter = "File " + ext + "|" + nf; + apriDialogoFile1.FilterIndex = 0; + apriDialogoFile1.Title = "Select the file \"" + nf + "\" File..."; + if (apriDialogoFile1.ShowDialog() == DialogResult.OK) + { + exe = apriDialogoFile1.FileName; + texe.Text = Ellipsis.Compact(Path.GetFileName(exe), texe, EllipsisFormat.Path); + toolTip1.SetToolTip(texe, exe); + Properties.Settings.Default["urlexe"] = exe; + Properties.Settings.Default.Save(); + } + } + } + catch + { + return; } - } - private void texe_DragEnter(object sender, DragEventArgs e) - { - e.Effect = DragDropEffects.All; - } - - private void texe_DragDrop(object sender, DragEventArgs e) - { - exe = ((string[])e.Data.GetData(DataFormats.FileDrop, false))[0]; - texe.Text = Ellipsis.Compact(exe, texe, EllipsisFormat.Path); - toolTip1.SetToolTip(texe, exe); - Properties.Settings.Default["urlexe"] = exe; - Properties.Settings.Default.Save(); - } private void t1337_DragEnter(object sender, DragEventArgs e) @@ -78,11 +73,40 @@ namespace Win_1337_Patch private void t1337_DragDrop(object sender, DragEventArgs e) { - f1337 = ((string[])e.Data.GetData(DataFormats.FileDrop, false))[0]; - t1337.Text = Ellipsis.Compact(f1337, t1337, EllipsisFormat.Path); - toolTip1.SetToolTip(t1337, f1337); - Properties.Settings.Default["url1337"] = f1337; - Properties.Settings.Default.Save(); + try + { + f1337 = ((string[])e.Data.GetData(DataFormats.FileDrop, false))[0]; + t1337.Text = Ellipsis.Compact(f1337, t1337, EllipsisFormat.Path); + toolTip1.SetToolTip(t1337, f1337); + Properties.Settings.Default["url1337"] = f1337; + Properties.Settings.Default.Save(); + string[] lines = File.ReadAllLines(f1337); + if (lines[0].Substring(0, 1) != ">") + { + MessageBox.Show("File 1337 is not valid...", "Info...", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + string unf = lines[0].Substring(1).ToLower().Trim(); + string nf = Path.GetFileName(unf); + string ext = Path.GetExtension(unf); + OpenFileDialog apriDialogoFile1 = new OpenFileDialog(); + apriDialogoFile1.FileName = nf; + apriDialogoFile1.Filter = "File " + ext + "|" + nf; + apriDialogoFile1.FilterIndex = 0; + apriDialogoFile1.Title = "Select the file \"" + nf + "\" File..."; + if (apriDialogoFile1.ShowDialog() == DialogResult.OK) + { + exe = apriDialogoFile1.FileName; + texe.Text = Ellipsis.Compact(Path.GetFileName(exe), texe, EllipsisFormat.Path); + toolTip1.SetToolTip(texe, exe); + Properties.Settings.Default["urlexe"] = exe; + Properties.Settings.Default.Save(); + } + } + catch + { + return; + } } private void Esci_Click(object sender, EventArgs e) { @@ -91,9 +115,9 @@ namespace Win_1337_Patch private void Patch_Click(object sender, EventArgs e) { - if (exe == String.Empty || f1337 == String.Empty) + if (f1337 == String.Empty) { - MessageBox.Show("Select a " + ((exe == String.Empty) ? "Exe" : "1337") + " File...", "Info...", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Select a 1337 File...", "Info...", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try @@ -123,7 +147,7 @@ namespace Win_1337_Patch MessageBox.Show("File 1337 is not valid...", "Info...", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (lines[0].Substring(1).ToLower() != Path.GetFileName(exe).ToLower()) + if (lines[0].Substring(1).ToLower().Trim() != Path.GetFileName(exe).ToLower().Trim()) { MessageBox.Show("File 1337 is not valid for selected exe/dll...\n\n(\"" + lines[0].Substring(1).ToLower() + "\" but you have selected \"" + Path.GetFileName(exe).ToLower() + "\")", "Info...", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -191,13 +215,13 @@ namespace Win_1337_Patch controlloBackup.Checked = (bool)Properties.Settings.Default["backup"]; if (urlexe != "") { - texe.Text = Ellipsis.Compact(urlexe, texe, EllipsisFormat.Path); + texe.Text = Ellipsis.Compact(Path.GetFileName(urlexe), texe, EllipsisFormat.Path); toolTip1.SetToolTip(texe, urlexe); exe = urlexe; } else - texe.Text = "Select Exe/Dll to Patch..."; - if (url1337 != "") + texe.Text = "Name of Exe/Dll to Patch..."; + if (url1337 != "" && urlexe != "") { t1337.Text = Ellipsis.Compact(url1337, t1337, EllipsisFormat.Path); toolTip1.SetToolTip(t1337, url1337); @@ -267,5 +291,10 @@ namespace Win_1337_Patch } return name; } + + private void t1337_DoubleClick(object sender, EventArgs e) + { + btnSelect1337.PerformClick(); + } } } diff --git a/Win_1337_Patch/Properties/AssemblyInfo.cs b/Win_1337_Patch/Properties/AssemblyInfo.cs index d6a7818..7afd961 100644 --- a/Win_1337_Patch/Properties/AssemblyInfo.cs +++ b/Win_1337_Patch/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build // usando l'asterisco '*' come illustrato di seguito: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.5.0.0")] -[assembly: AssemblyFileVersion("1.5.0.0")] +[assembly: AssemblyVersion("1.6.0.0")] +[assembly: AssemblyFileVersion("1.6.0.0")]