diff --git a/Driver Easy Loader/Driver Easy Loader.csproj b/Driver Easy Loader/Driver Easy Loader.csproj index 6ea5770..e47348f 100644 --- a/Driver Easy Loader/Driver Easy Loader.csproj +++ b/Driver Easy Loader/Driver Easy Loader.csproj @@ -35,9 +35,6 @@ DriverEasy.ico - - app.manifest - @@ -73,7 +70,6 @@ True - SettingsSingleFileGenerator Settings.Designer.cs diff --git a/Driver Easy Loader/Form1.Designer.cs b/Driver Easy Loader/Form1.Designer.cs index 0ecd966..fcdf417 100644 --- a/Driver Easy Loader/Form1.Designer.cs +++ b/Driver Easy Loader/Form1.Designer.cs @@ -30,61 +30,145 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.button1 = new System.Windows.Forms.Button(); this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.radioButton3 = new System.Windows.Forms.RadioButton(); + this.radioButton2 = new System.Windows.Forms.RadioButton(); + this.radioButton1 = new System.Windows.Forms.RadioButton(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // groupBox1 // + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Controls.Add(this.label4); + this.groupBox1.Controls.Add(this.label3); this.groupBox1.Controls.Add(this.label2); this.groupBox1.Location = new System.Drawing.Point(2, 1); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(249, 71); + this.groupBox1.Size = new System.Drawing.Size(285, 142); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "Status"; // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(10, 65); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(142, 19); + this.label4.TabIndex = 10; + this.label4.Text = "Loader installed: {null}"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(10, 42); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(144, 19); + this.label3.TabIndex = 9; + this.label3.Text = "License installed: {null}"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(10, 21); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(156, 19); + this.label2.TabIndex = 8; + this.label2.Text = "Running as admin: {null}"; + // // groupBox2 // + this.groupBox2.Controls.Add(this.button1); this.groupBox2.Controls.Add(this.checkBox1); - this.groupBox2.Location = new System.Drawing.Point(257, 1); + this.groupBox2.Controls.Add(this.radioButton3); + this.groupBox2.Controls.Add(this.radioButton2); + this.groupBox2.Controls.Add(this.radioButton1); + this.groupBox2.Location = new System.Drawing.Point(293, 1); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(201, 71); + this.groupBox2.Size = new System.Drawing.Size(285, 142); this.groupBox2.TabIndex = 1; this.groupBox2.TabStop = false; this.groupBox2.Text = "Settings"; // + // button1 + // + this.button1.Location = new System.Drawing.Point(122, 19); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(157, 46); + this.button1.TabIndex = 4; + this.button1.Text = "Why are some settings unavailable?"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // // checkBox1 // this.checkBox1.AutoSize = true; - this.checkBox1.Location = new System.Drawing.Point(6, 21); + this.checkBox1.Location = new System.Drawing.Point(6, 88); this.checkBox1.Name = "checkBox1"; - this.checkBox1.Size = new System.Drawing.Size(152, 17); + this.checkBox1.Size = new System.Drawing.Size(183, 23); this.checkBox1.TabIndex = 3; this.checkBox1.Text = "Kill Driver Easy processes"; this.checkBox1.UseVisualStyleBackColor = true; // + // radioButton3 + // + this.radioButton3.AutoSize = true; + this.radioButton3.Location = new System.Drawing.Point(6, 65); + this.radioButton3.Name = "radioButton3"; + this.radioButton3.Size = new System.Drawing.Size(174, 23); + this.radioButton3.TabIndex = 2; + this.radioButton3.TabStop = true; + this.radioButton3.Text = "Install License + Loader"; + this.radioButton3.UseVisualStyleBackColor = true; + // + // radioButton2 + // + this.radioButton2.AutoSize = true; + this.radioButton2.Location = new System.Drawing.Point(6, 42); + this.radioButton2.Name = "radioButton2"; + this.radioButton2.Size = new System.Drawing.Size(112, 23); + this.radioButton2.TabIndex = 1; + this.radioButton2.TabStop = true; + this.radioButton2.Text = "Install Loader"; + this.radioButton2.UseVisualStyleBackColor = true; + // + // radioButton1 + // + this.radioButton1.AutoSize = true; + this.radioButton1.Checked = true; + this.radioButton1.Location = new System.Drawing.Point(6, 19); + this.radioButton1.Name = "radioButton1"; + this.radioButton1.Size = new System.Drawing.Size(114, 23); + this.radioButton1.TabIndex = 0; + this.radioButton1.TabStop = true; + this.radioButton1.Text = "Install License"; + this.radioButton1.UseVisualStyleBackColor = true; + // // button2 // this.button2.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button2.Location = new System.Drawing.Point(12, 78); + this.button2.Location = new System.Drawing.Point(66, 149); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(174, 55); this.button2.TabIndex = 5; - this.button2.Text = "Install"; + this.button2.Text = "Install/Update"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // button3 // this.button3.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button3.Location = new System.Drawing.Point(204, 78); + this.button3.Location = new System.Drawing.Point(339, 149); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(174, 55); this.button3.TabIndex = 6; @@ -95,27 +179,17 @@ private void InitializeComponent() // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(384, 100); + this.label1.Location = new System.Drawing.Point(10, 88); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(77, 13); + this.label1.Size = new System.Drawing.Size(91, 19); this.label1.TabIndex = 7; this.label1.Text = "Version: {null}"; // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(10, 18); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(129, 13); - this.label2.TabIndex = 0; - this.label2.Text = "Driver Easy Status: {null}"; - // // Form1 // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 19F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(490, 142); - this.Controls.Add(this.label1); + this.ClientSize = new System.Drawing.Size(592, 208); this.Controls.Add(this.button3); this.Controls.Add(this.button2); this.Controls.Add(this.groupBox2); @@ -133,7 +207,6 @@ private void InitializeComponent() this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); this.ResumeLayout(false); - this.PerformLayout(); } @@ -141,10 +214,16 @@ private void InitializeComponent() private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.RadioButton radioButton1; + private System.Windows.Forms.Button button1; private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.RadioButton radioButton3; + private System.Windows.Forms.RadioButton radioButton2; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label2; } } diff --git a/Driver Easy Loader/Form1.cs b/Driver Easy Loader/Form1.cs index 92ff67c..c10f2e4 100644 --- a/Driver Easy Loader/Form1.cs +++ b/Driver Easy Loader/Form1.cs @@ -24,20 +24,57 @@ public Form1() private void Form1_Load(object sender, EventArgs e) { - if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Easeware\DriverEasy\License.dat")) + string LoaderPath = @"C:\Users\Default\AppData\Roaming\Easeware\DriverEasy\License.dat"; + if (File.Exists(LoaderPath)) { - label2.Text = "Driver Easy Status: Licensed"; + variables.isloaderinstalled = true; + } + string licensepath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Easeware\DriverEasy\License.dat"; + if (File.Exists(licensepath)) + { + variables.islicenseinstalled = true; + } + label1.Text = "Version: " + Application.ProductVersion.ToString(); + if (variables.isadmin) + { + label2.Text = "Running as admin: Yes"; + button1.Visible = false; + radioButton1.Checked = false; + radioButton2.Checked = false; + radioButton3.Checked = true; + } + else + { + label2.Text = "Running as admin: No"; + radioButton2.Enabled = false; + radioButton3.Enabled = false; + checkBox1.Enabled = false; + } + if (variables.islicenseinstalled) + { + label3.Text = "License installed: Yes"; } else { - label2.Text = "Driver Easy Status: Free Version"; + label3.Text = "License installed: No"; + } + if (variables.isloaderinstalled) + { + label4.Text = "Loader installed: Yes"; + } + else + { + label4.Text = "Loader installed: No"; + } + if (!variables.islicenseinstalled && !variables.isloaderinstalled) + { + button3.Enabled = false; } - label1.Text = "Version: " + Application.ProductVersion; } private void button1_Click(object sender, EventArgs e) - { - + { + MessageBox.Show("Some settings require admin privileges. To enable them, restart the program as administrator","Why are some settings unavailable?"); } private void button2_Click(object sender, EventArgs e) @@ -61,33 +98,69 @@ private void button2_Click(object sender, EventArgs e) { MessageBox.Show("Make sure to quit Driver Easy, then hit OK to start patching","Driver Easy Loader by Vichingo455",MessageBoxButtons.OK,MessageBoxIcon.Warning); } - try + checkBox1.Checked = false; //just to separate the if functions + if (radioButton1.Checked) + { + try + { + if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Easeware\DriverEasy\License.dat")) //delete existing license + { + File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Easeware\DriverEasy\License.dat"); + } + File.WriteAllBytes(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)+@"\Easeware\DriverEasy\License.dat",Resources.License); + } + catch (Exception ex) + { + MessageBox.Show("Can't patch Driver Easy. Make sure that Driver Easy is installed and closed. Details: " + ex.Message,"Driver Easy Loader",MessageBoxButtons.OK,MessageBoxIcon.Error); + return; + } + } + else if (radioButton2.Checked) { - string[] dirs = Directory.GetDirectories(@"C:\Users", "*", SearchOption.TopDirectoryOnly); - foreach (string dir in dirs) + try { - if (Directory.Exists(dir + @"\AppData\Roaming\Easeware\DriverEasy")) + if (!Directory.Exists(@"C:\Users\Default\AppData\Roaming\Easeware\DriverEasy")) { - if (File.Exists(dir + @"\AppData\Roaming\Easeware\DriverEasy\License.dat")) - { - File.Delete(dir + @"\AppData\Roaming\Easeware\DriverEasy\License.dat"); - } - File.WriteAllBytes(dir + @"\AppData\Roaming\Easeware\DriverEasy\License.dat", Resources.License); + Directory.CreateDirectory(@"C:\Users\Default\AppData\Roaming\Easeware\DriverEasy"); } + if (File.Exists(@"C:\Users\Default\AppData\Roaming\Easeware\DriverEasy\License.dat")) + { + File.Delete(@"C:\Users\Default\AppData\Roaming\Easeware\DriverEasy\License.dat"); + } + File.WriteAllBytes(@"C:\Users\Default\AppData\Roaming\Easeware\DriverEasy\License.dat", Resources.License); } - if (File.Exists(@"C:\Windows\System32\Drivers\etc\hosts.old")) + catch (Exception ex) { - File.Delete(@"C:\Windows\System32\Drivers\etc\hosts.old"); + MessageBox.Show("Can't patch Driver Easy. Make sure that Driver Easy is installed and closed. Details: " + ex.Message, "Driver Easy Loader", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; } - File.Copy("C:\\Windows\\System32\\Drivers\\etc\\Hosts", "C:\\Windows\\System32\\Drivers\\etc\\Hosts.backup",true); - File.AppendAllText("C:\\Windows\\System32\\Drivers\\etc\\Hosts", Environment.NewLine + "127.0.0.1 app.drivereasy.com"); - File.AppendAllText("C:\\Windows\\System32\\Drivers\\etc\\Hosts", Environment.NewLine + "127.0.0.1 cdn.drivereasy.com"); } - catch + else if (radioButton3.Checked) { - MessageBox.Show("An error occured, please report it as issue on GitHub.", "Driver Easy Loader by Useful Stuffs", MessageBoxButtons.OK, MessageBoxIcon.Error); + try + { + if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Easeware\DriverEasy\License.dat")) //delete existing license + { + File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Easeware\DriverEasy\License.dat"); + } + File.WriteAllBytes(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Easeware\DriverEasy\License.dat", Resources.License); + if (!Directory.Exists(@"C:\Users\Default\AppData\Roaming\Easeware\DriverEasy")) + { + Directory.CreateDirectory(@"C:\Users\Default\AppData\Roaming\Easeware\DriverEasy"); + } + if (File.Exists(@"C:\Users\Default\AppData\Roaming\Easeware\DriverEasy\License.dat")) + { + File.Delete(@"C:\Users\Default\AppData\Roaming\Easeware\DriverEasy\License.dat"); + } + File.WriteAllBytes(@"C:\Users\Default\AppData\Roaming\Easeware\DriverEasy\License.dat", Resources.License); + } + catch (Exception ex) + { + MessageBox.Show("Can't patch Driver Easy. Make sure that Driver Easy is installed and closed. Details: " + ex.Message, "Driver Easy Loader", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } } - MessageBox.Show("Patch successful!","Driver Easy Loader by Useful Stuffs",MessageBoxButtons.OK,MessageBoxIcon.Information); + MessageBox.Show("Patch successful!","Driver Easy Loader by Vichingo455",MessageBoxButtons.OK,MessageBoxIcon.Information); Environment.Exit(0); } @@ -114,26 +187,21 @@ private void button3_Click(object sender, EventArgs e) } try { - string[] dirs = Directory.GetDirectories(@"C:\Users", "*", SearchOption.TopDirectoryOnly); - foreach (string dir in dirs) + if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Easeware\DriverEasy\License.dat")) //delete existing license { - if (Directory.Exists(dir + @"\AppData\Roaming\Easeware\DriverEasy")) - { - if (File.Exists(dir + @"\AppData\Roaming\Easeware\DriverEasy\License.dat")) - { - File.Delete(dir + @"\AppData\Roaming\Easeware\DriverEasy\License.dat"); - } - } + File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Easeware\DriverEasy\License.dat"); + } + if (File.Exists(@"C:\Users\Default\AppData\Roaming\Easeware\DriverEasy\License.dat") && variables.isadmin) + { + File.Delete(@"C:\Users\Default\AppData\Roaming\Easeware\DriverEasy\License.dat"); } - File.Copy("C:\\Windows\\System32\\Drivers\\etc\\Hosts", "C:\\Windows\\System32\\Drivers\\etc\\Hosts.old"); - File.Copy("C:\\Windows\\System32\\Drivers\\etc\\Hosts.backup", "C:\\Windows\\System32\\Drivers\\etc\\Hosts", true); - File.Delete("C:\\Windows\\System32\\Drivers\\etc\\Hosts.backup"); } - catch + catch (Exception ex) { - MessageBox.Show("An error occured, please report it as issue on GitHub.", "Driver Easy Loader by Useful Stuffs", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Can't uninstall the loader. Was it installed in the past? Is Driver Easy Installed and Closed? Details: " + ex.Message,"Driver Easy Loader by Vichingo455",MessageBoxButtons.OK,MessageBoxIcon.Error); + return; } - MessageBox.Show("Loader uninstalled successfully","Driver Easy Loader by Useful Stuffs",MessageBoxButtons.OK,MessageBoxIcon.Information); + MessageBox.Show("Loader uninstalled successfully","Driver Easy Loader by Vichingo455",MessageBoxButtons.OK,MessageBoxIcon.Information); Environment.Exit(0); } } diff --git a/Driver Easy Loader/Program.cs b/Driver Easy Loader/Program.cs index fb09f33..320bae0 100644 --- a/Driver Easy Loader/Program.cs +++ b/Driver Easy Loader/Program.cs @@ -16,6 +16,12 @@ static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); + WindowsPrincipal pricipal = new WindowsPrincipal(WindowsIdentity.GetCurrent()); + bool hasAdministrativeRight = pricipal.IsInRole(WindowsBuiltInRole.Administrator); + if (hasAdministrativeRight) + { + variables.isadmin = true; + } Application.Run(new Form1()); } } diff --git a/Driver Easy Loader/Properties/AssemblyInfo.cs b/Driver Easy Loader/Properties/AssemblyInfo.cs index ea4f2f2..5693cd4 100644 --- a/Driver Easy Loader/Properties/AssemblyInfo.cs +++ b/Driver Easy Loader/Properties/AssemblyInfo.cs @@ -33,6 +33,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.0.0.0")] +[assembly: AssemblyVersion("1.3.0.0")] +[assembly: AssemblyFileVersion("1.3.0.0")] [assembly: NeutralResourcesLanguage("en")] diff --git a/Driver Easy Loader/Resources/License.dat b/Driver Easy Loader/Resources/License.dat index 07d39e3..c0ca34d 100644 --- a/Driver Easy Loader/Resources/License.dat +++ b/Driver Easy Loader/Resources/License.dat @@ -1,8 +1,8 @@ -WExaSUwtVTFaWVotRzJQVk4tSENKVDYtOUxWOEI= + true 99999999999999999999999999999999999999999999999999999999999999999999999 Activated with Driver Easy Loader by Useful Stuffs (http://github.com/usefulstuffs) -Volume +Normal diff --git a/Driver Easy Loader/app.manifest b/Driver Easy Loader/app.manifest deleted file mode 100644 index c903b54..0000000 --- a/Driver Easy Loader/app.manifest +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - true - true - - - - - - - - diff --git a/Driver Easy Loader/variables.cs b/Driver Easy Loader/variables.cs index b7f9a99..d1ae010 100644 --- a/Driver Easy Loader/variables.cs +++ b/Driver Easy Loader/variables.cs @@ -7,6 +7,8 @@ namespace Driver_Easy_Loader { internal class variables { - + public static bool islicenseinstalled = false; //false by fallback + public static bool isloaderinstalled = false; //false by fallback + public static bool isadmin = false; //false by fallback } }