private void buttonApply_Click(object sender, EventArgs e) { using (OpenFileDialog OFD = new OpenFileDialog()) { OFD.Title = "Choose .exe files (32bit or 64bit)"; OFD.Filter = "Executable (*.exe)|*.exe"; OFD.FilterIndex = 0; OFD.RestoreDirectory = true; if (OFD.ShowDialog(this) == DialogResult.OK) { try { Plat platform = Plat.x32; bool supported = false; Reader reader = new Reader(OFD.FileName, Endian.Little); uint[] addr = new uint[] { ADDRESS_X64, ADDRESS_X32 }; foreach (uint address in addr) { reader.Position = address; if (reader.PeekString(4) == "2221") { if (address == ADDRESS_X64) platform = Plat.x64; supported = true; break; } } if (supported) { DialogResult result = MessageBox.Show("Backup ?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (result == DialogResult.Yes) File.Copy(OFD.FileName, OFD.FileName + ".bk", true); if (platform == Plat.x64) { Writer write = new Writer(OFD.FileName, Endian.Little); foreach (uint offset in Offset64) { write.Position = offset; write.Write(new byte[] { 0x32, 0x42 }); } write.Close(); MessageBox.Show("Successfully", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("can not apply a patch to this application"); } } else { MessageBox.Show("cannot apply this patch on this version of the application", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { OFD.Dispose(); } } } }