private void Form1_Load(object sender, EventArgs e) { try { richTextBox1.AppendText("Loading Wow.exe into memory...\n"); wowExe = ReadByteArrayFromFile(PatchInfo.fileWin); richTextBox1.AppendText("Success Windows 'wow.exe' loaded!\n"); patch = new PatchInfo(true); } catch { try { richTextBox1.AppendText("Loading Mac 'World of Warcraft' binary into memory...\n"); wowExe = ReadByteArrayFromFile(PatchInfo.fileMac); richTextBox1.AppendText("Success Mac 'World of Warcraft' loaded!\n"); patch = new PatchInfo(false); } catch { richTextBox1.AppendText("Could not load Win 'Wow.exe' or Mac 'World of Warcraft' into memory. Make sure this program is in your WoW directory and that WoW is closed.\n"); label2.Text = "Error"; label2.ForeColor = Color.Red; } //filenotfound or fileinuse } if (wowExe != null) { if (wowExe.Length != patch.exeLength) { richTextBox1.AppendText("Wrong version, this patch will only work for WoW 4.0.6a 13623. \n"); label2.Text = "Error"; label2.ForeColor = Color.Red; } else { byte[] testPatched = new byte[patch.unpatchedBytes.Length]; System.Buffer.BlockCopy(wowExe, patch.patchOffset, testPatched, 0, patch.unpatchedBytes.Length); if (testPatched.SequenceEqual(patch.unpatchedBytes)) { richTextBox1.AppendText("Ready to patch " + patch.fileName + ".\n"); label2.Text = "Ready!"; label2.ForeColor = Color.Orange; button1.Text = "Patch"; button1.Enabled = true; } if (testPatched.SequenceEqual(patch.patchedBytes)) { richTextBox1.AppendText("To restore " + patch.fileName + " click \"Unpatch\".\n"); label2.Text = "Ready!"; label2.ForeColor = Color.Orange; button1.Text = "Unpatch"; button1.Enabled = true; } } } }
private void Form1_Load(object sender, EventArgs e) { foreach (Type t in Assembly.GetExecutingAssembly().GetTypes()) { if (t.IsSubclassOf(typeof(PatchInfo))) { PatchInfo pInfo = (PatchInfo)t.GetConstructor(new Type[] { }).Invoke(new Object[] { }); Patches.Add(pInfo.ExeLength, pInfo.Patches); } } try { richTextBox1.AppendText("Loading Wow.exe into memory...\n"); wowExe = ReadByteArrayFromFile(FileWin); if (!Patches.ContainsKey(wowExe.Length)) { richTextBox1.AppendText("This Wow.exe version is not supported\n"); throw new Exception("Version not supported"); } patches = Patches[wowExe.Length]; richTextBox1.AppendText("Success Windows 'wow.exe' loaded!\n"); BackupFile = BackupWin; FileName = FileWin; } catch { try { richTextBox1.AppendText("Loading Mac 'World of Warcraft' binary into memory...\n"); wowExe = ReadByteArrayFromFile(FileMac); richTextBox1.AppendText("Success Mac 'World of Warcraft' loaded!\n"); BackupFile = BackupMac; FileName = FileMac; if (!Patches.ContainsKey(wowExe.Length)) { richTextBox1.AppendText("This Mac version is not supported\n"); throw new Exception("Version not supported"); } patches = patches = Patches[wowExe.Length]; } catch { richTextBox1.AppendText("Could not load Win 'Wow.exe' or Mac 'World of Warcraft' into memory. Make sure this program is in your WoW directory and that WoW is closed.\n"); label2.Text = "Error"; label2.ForeColor = Color.Red; wowExe = null; } //filenotfound or fileinuse } if (wowExe != null) { byte[] testPatched = new byte[patches[0].Unpatched.Length]; System.Buffer.BlockCopy(wowExe, patches[0].Offset, testPatched, 0, patches[0].Unpatched.Length); if (testPatched.SequenceEqual(patches[0].Unpatched)) { richTextBox1.AppendText("Ready to patch " + FileName + ".\n"); label2.Text = "Ready!"; label2.ForeColor = Color.Orange; button1.Text = "Patch"; button1.Enabled = true; } if (testPatched.SequenceEqual(patches[0].Patched)) { richTextBox1.AppendText("To restore " + FileName + " click \"Unpatch\".\n"); label2.Text = "Ready!"; label2.ForeColor = Color.Orange; button1.Text = "Unpatch"; button1.Enabled = true; } } }