Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO;
- namespace win10fix2
- {
- public partial class Form1 : Form
- {
- static bool ShouldDoBackups = true;
- static bool ShouldShowPrompts = true;
- public Form1()
- {
- InitializeComponent();
- }
- static void DirSearch(string sDir)
- {
- foreach (string f in Directory.GetFiles(sDir))
- {
- if (Path.GetExtension(f) == ".exe")
- {
- if (ShouldShowPrompts)
- {
- DialogResult dr = MessageBox.Show("Fix this file?\n" + f, "", MessageBoxButtons.YesNo);
- if (dr == DialogResult.Yes)
- {
- BackupAndFixFile(f);
- }
- }
- else
- {
- BackupAndFixFile(f);
- }
- }
- }
- foreach (string d in Directory.GetDirectories(sDir))
- {
- DirSearch(d);
- }
- }
- static void BackupAndFixFile(String fileName)
- {
- if (ShouldDoBackups)
- {
- BackupFile(fileName);
- }
- FixFile(fileName);
- }
- static void BackupFile(String fileName)
- {
- String newFileName = Path.GetFileNameWithoutExtension(fileName) + " backup before win10 fix" + Path.GetExtension(fileName);
- newFileName = Path.Combine(Path.GetDirectoryName(fileName), newFileName);
- try {
- File.Copy(fileName, newFileName);
- }
- catch
- {
- }
- }
- static void FixFile(String fileName)
- {
- try {
- using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite))
- {
- stream.Position = 0x116;
- stream.WriteByte(0xAE);
- }
- }
- catch
- {
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- ShouldDoBackups = checkBox1.Checked;
- ShouldShowPrompts = checkBox2.Checked;
- DirSearch(Directory.GetCurrentDirectory());
- this.Close();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "Executables (.txt)|*.exe|All Files (*.*)|*.*";
- DialogResult dr = ofd.ShowDialog();
- if (dr == DialogResult.OK)
- {
- BackupAndFixFile(ofd.FileName);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement