diff --git a/src/Vinesauce ROM Corruptor/MainForm.Designer.cs b/src/Vinesauce ROM Corruptor/MainForm.Designer.cs index 3d6cb20..74ba706 100644 --- a/src/Vinesauce ROM Corruptor/MainForm.Designer.cs +++ b/src/Vinesauce ROM Corruptor/MainForm.Designer.cs @@ -1,4 +1,24 @@ -namespace Vinesauce_ROM_Corruptor +/* + * Copyright (C) 2013 Ryan Sammon. + * + * This file is part of the Vinesauce ROM Corruptor. + * + * The Vinesauce ROM Corruptor is free software: you can redistribute + * it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * The Vinesauce ROM Corruptor is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the Vinesauce ROM Corruptor. If not, see + * . + */ + +namespace Vinesauce_ROM_Corruptor { partial class MainForm { @@ -29,14 +49,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); - this.button_RomToCorruptBrowse = new System.Windows.Forms.Button(); - this.textBox_RomToCorrupt = new System.Windows.Forms.TextBox(); + this.button_RomDirectoryBrowse = new System.Windows.Forms.Button(); + this.textBox_RomDirectory = new System.Windows.Forms.TextBox(); this.labelRomToCorrupt = new System.Windows.Forms.Label(); this.labelSaveLocation = new System.Windows.Forms.Label(); this.textBox_SaveLocation = new System.Windows.Forms.TextBox(); this.button_SaveLocationBrowse = new System.Windows.Forms.Button(); this.checkBox_Overwrite = new System.Windows.Forms.CheckBox(); this.groupBox_FileSelection = new System.Windows.Forms.GroupBox(); + this.listView_Files = new System.Windows.Forms.ListView(); + this.listViewC_fileName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.groupBox_EmulatorSelection = new System.Windows.Forms.GroupBox(); this.button_EmulatorToRunBrowse = new System.Windows.Forms.Button(); this.textBox_EmulatorToRun = new System.Windows.Forms.TextBox(); @@ -124,40 +146,40 @@ ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // - // button_RomToCorruptBrowse + // button_RomDirectoryBrowse // - this.button_RomToCorruptBrowse.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button_RomToCorruptBrowse.Location = new System.Drawing.Point(327, 30); - this.button_RomToCorruptBrowse.Name = "button_RomToCorruptBrowse"; - this.button_RomToCorruptBrowse.Size = new System.Drawing.Size(26, 23); - this.button_RomToCorruptBrowse.TabIndex = 0; - this.button_RomToCorruptBrowse.Text = "..."; - this.button_RomToCorruptBrowse.UseVisualStyleBackColor = true; - this.button_RomToCorruptBrowse.Click += new System.EventHandler(this.button_RomToCorruptBrowse_Click); + this.button_RomDirectoryBrowse.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button_RomDirectoryBrowse.Location = new System.Drawing.Point(327, 30); + this.button_RomDirectoryBrowse.Name = "button_RomDirectoryBrowse"; + this.button_RomDirectoryBrowse.Size = new System.Drawing.Size(26, 23); + this.button_RomDirectoryBrowse.TabIndex = 0; + this.button_RomDirectoryBrowse.Text = "..."; + this.button_RomDirectoryBrowse.UseVisualStyleBackColor = true; + this.button_RomDirectoryBrowse.Click += new System.EventHandler(this.button_RomToCorruptBrowse_Click); // - // textBox_RomToCorrupt + // textBox_RomDirectory // - this.textBox_RomToCorrupt.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBox_RomToCorrupt.Location = new System.Drawing.Point(9, 32); - this.textBox_RomToCorrupt.Name = "textBox_RomToCorrupt"; - this.textBox_RomToCorrupt.Size = new System.Drawing.Size(312, 20); - this.textBox_RomToCorrupt.TabIndex = 1; + this.textBox_RomDirectory.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.textBox_RomDirectory.Location = new System.Drawing.Point(10, 32); + this.textBox_RomDirectory.Name = "textBox_RomDirectory"; + this.textBox_RomDirectory.Size = new System.Drawing.Size(312, 20); + this.textBox_RomDirectory.TabIndex = 1; // // labelRomToCorrupt // this.labelRomToCorrupt.AutoSize = true; this.labelRomToCorrupt.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelRomToCorrupt.Location = new System.Drawing.Point(6, 16); + this.labelRomToCorrupt.Location = new System.Drawing.Point(7, 16); this.labelRomToCorrupt.Name = "labelRomToCorrupt"; - this.labelRomToCorrupt.Size = new System.Drawing.Size(95, 13); + this.labelRomToCorrupt.Size = new System.Drawing.Size(90, 13); this.labelRomToCorrupt.TabIndex = 2; - this.labelRomToCorrupt.Text = "ROM to Corrupt"; + this.labelRomToCorrupt.Text = "ROM Directory"; // // labelSaveLocation // this.labelSaveLocation.AutoSize = true; this.labelSaveLocation.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelSaveLocation.Location = new System.Drawing.Point(6, 55); + this.labelSaveLocation.Location = new System.Drawing.Point(6, 245); this.labelSaveLocation.Name = "labelSaveLocation"; this.labelSaveLocation.Size = new System.Drawing.Size(146, 13); this.labelSaveLocation.TabIndex = 3; @@ -166,7 +188,7 @@ // textBox_SaveLocation // this.textBox_SaveLocation.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBox_SaveLocation.Location = new System.Drawing.Point(9, 71); + this.textBox_SaveLocation.Location = new System.Drawing.Point(9, 261); this.textBox_SaveLocation.Name = "textBox_SaveLocation"; this.textBox_SaveLocation.RightToLeft = System.Windows.Forms.RightToLeft.No; this.textBox_SaveLocation.Size = new System.Drawing.Size(312, 20); @@ -176,7 +198,7 @@ // button_SaveLocationBrowse // this.button_SaveLocationBrowse.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button_SaveLocationBrowse.Location = new System.Drawing.Point(327, 69); + this.button_SaveLocationBrowse.Location = new System.Drawing.Point(326, 261); this.button_SaveLocationBrowse.Name = "button_SaveLocationBrowse"; this.button_SaveLocationBrowse.Size = new System.Drawing.Size(26, 23); this.button_SaveLocationBrowse.TabIndex = 5; @@ -189,7 +211,7 @@ this.checkBox_Overwrite.AutoSize = true; this.checkBox_Overwrite.Checked = true; this.checkBox_Overwrite.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBox_Overwrite.Location = new System.Drawing.Point(9, 97); + this.checkBox_Overwrite.Location = new System.Drawing.Point(9, 287); this.checkBox_Overwrite.Name = "checkBox_Overwrite"; this.checkBox_Overwrite.Size = new System.Drawing.Size(104, 17); this.checkBox_Overwrite.TabIndex = 6; @@ -198,21 +220,44 @@ // // groupBox_FileSelection // + this.groupBox_FileSelection.Controls.Add(this.listView_Files); this.groupBox_FileSelection.Controls.Add(this.checkBox_Overwrite); this.groupBox_FileSelection.Controls.Add(this.labelRomToCorrupt); this.groupBox_FileSelection.Controls.Add(this.button_SaveLocationBrowse); - this.groupBox_FileSelection.Controls.Add(this.button_RomToCorruptBrowse); + this.groupBox_FileSelection.Controls.Add(this.button_RomDirectoryBrowse); this.groupBox_FileSelection.Controls.Add(this.textBox_SaveLocation); - this.groupBox_FileSelection.Controls.Add(this.textBox_RomToCorrupt); + this.groupBox_FileSelection.Controls.Add(this.textBox_RomDirectory); this.groupBox_FileSelection.Controls.Add(this.labelSaveLocation); this.groupBox_FileSelection.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.groupBox_FileSelection.Location = new System.Drawing.Point(12, 12); + this.groupBox_FileSelection.Location = new System.Drawing.Point(10, 5); this.groupBox_FileSelection.Name = "groupBox_FileSelection"; - this.groupBox_FileSelection.Size = new System.Drawing.Size(359, 117); + this.groupBox_FileSelection.Size = new System.Drawing.Size(359, 313); this.groupBox_FileSelection.TabIndex = 7; this.groupBox_FileSelection.TabStop = false; this.groupBox_FileSelection.Text = "File Selection"; // + // listView_Files + // + this.listView_Files.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.listViewC_fileName}); + this.listView_Files.FullRowSelect = true; + this.listView_Files.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.listView_Files.HideSelection = false; + this.listView_Files.Location = new System.Drawing.Point(10, 56); + this.listView_Files.Margin = new System.Windows.Forms.Padding(2); + this.listView_Files.MultiSelect = false; + this.listView_Files.Name = "listView_Files"; + this.listView_Files.Size = new System.Drawing.Size(344, 188); + this.listView_Files.TabIndex = 47; + this.listView_Files.UseCompatibleStateImageBehavior = false; + this.listView_Files.View = System.Windows.Forms.View.Details; + this.listView_Files.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.listView_Files_ItemSelectionChanged); + // + // listViewC_fileName + // + this.listViewC_fileName.Text = "File Name"; + this.listViewC_fileName.Width = 344; + // // groupBox_EmulatorSelection // this.groupBox_EmulatorSelection.Controls.Add(this.button_EmulatorToRunBrowse); @@ -220,7 +265,7 @@ this.groupBox_EmulatorSelection.Controls.Add(this.label_EmulatorToRun); this.groupBox_EmulatorSelection.Controls.Add(this.checkBox_RunEmulator); this.groupBox_EmulatorSelection.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.groupBox_EmulatorSelection.Location = new System.Drawing.Point(13, 135); + this.groupBox_EmulatorSelection.Location = new System.Drawing.Point(10, 323); this.groupBox_EmulatorSelection.Name = "groupBox_EmulatorSelection"; this.groupBox_EmulatorSelection.Size = new System.Drawing.Size(358, 83); this.groupBox_EmulatorSelection.TabIndex = 8; @@ -283,7 +328,7 @@ this.groupBox_TextReplace.Controls.Add(this.label_AnchorWords); this.groupBox_TextReplace.Controls.Add(this.checkBox_TextReplacementEnable); this.groupBox_TextReplace.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.groupBox_TextReplace.Location = new System.Drawing.Point(12, 224); + this.groupBox_TextReplace.Location = new System.Drawing.Point(10, 413); this.groupBox_TextReplace.Name = "groupBox_TextReplace"; this.groupBox_TextReplace.Size = new System.Drawing.Size(359, 162); this.groupBox_TextReplace.TabIndex = 9; @@ -417,7 +462,7 @@ // button_Run // this.button_Run.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button_Run.Location = new System.Drawing.Point(12, 569); + this.button_Run.Location = new System.Drawing.Point(10, 757); this.button_Run.Name = "button_Run"; this.button_Run.Size = new System.Drawing.Size(55, 28); this.button_Run.TabIndex = 10; @@ -464,7 +509,7 @@ this.groupBox_ByteCorruption.Controls.Add(this.label_StartByte); this.groupBox_ByteCorruption.Controls.Add(this.checkBox_ByteCorruptionEnable); this.groupBox_ByteCorruption.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.groupBox_ByteCorruption.Location = new System.Drawing.Point(378, 135); + this.groupBox_ByteCorruption.Location = new System.Drawing.Point(376, 323); this.groupBox_ByteCorruption.Name = "groupBox_ByteCorruption"; this.groupBox_ByteCorruption.Size = new System.Drawing.Size(358, 251); this.groupBox_ByteCorruption.TabIndex = 11; @@ -883,7 +928,7 @@ this.groupBox_ColorReplacement.Controls.Add(this.label_ColorsToReplace); this.groupBox_ColorReplacement.Controls.Add(this.checkBox_ColorReplacementEnable); this.groupBox_ColorReplacement.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.groupBox_ColorReplacement.Location = new System.Drawing.Point(12, 394); + this.groupBox_ColorReplacement.Location = new System.Drawing.Point(10, 583); this.groupBox_ColorReplacement.Name = "groupBox_ColorReplacement"; this.groupBox_ColorReplacement.Size = new System.Drawing.Size(359, 169); this.groupBox_ColorReplacement.TabIndex = 16; @@ -987,7 +1032,7 @@ // this.groupBox_NESPalette.Controls.Add(this.pictureBox_NESPalette); this.groupBox_NESPalette.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.groupBox_NESPalette.Location = new System.Drawing.Point(378, 392); + this.groupBox_NESPalette.Location = new System.Drawing.Point(376, 580); this.groupBox_NESPalette.Name = "groupBox_NESPalette"; this.groupBox_NESPalette.Size = new System.Drawing.Size(358, 171); this.groupBox_NESPalette.TabIndex = 35; @@ -1009,7 +1054,7 @@ // button_NESPaletteHelp // this.button_NESPaletteHelp.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button_NESPaletteHelp.Location = new System.Drawing.Point(704, 573); + this.button_NESPaletteHelp.Location = new System.Drawing.Point(702, 761); this.button_NESPaletteHelp.Name = "button_NESPaletteHelp"; this.button_NESPaletteHelp.Size = new System.Drawing.Size(26, 23); this.button_NESPaletteHelp.TabIndex = 16; @@ -1020,7 +1065,7 @@ // button_Save // this.button_Save.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button_Save.Location = new System.Drawing.Point(73, 569); + this.button_Save.Location = new System.Drawing.Point(70, 757); this.button_Save.Name = "button_Save"; this.button_Save.Size = new System.Drawing.Size(69, 28); this.button_Save.TabIndex = 37; @@ -1031,7 +1076,7 @@ // button_Load // this.button_Load.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button_Load.Location = new System.Drawing.Point(148, 569); + this.button_Load.Location = new System.Drawing.Point(146, 757); this.button_Load.Name = "button_Load"; this.button_Load.Size = new System.Drawing.Size(69, 28); this.button_Load.TabIndex = 38; @@ -1044,9 +1089,9 @@ this.pictureBox1.BackColor = System.Drawing.Color.White; this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.pictureBox1.Image = global::Vinesauce_ROM_Corruptor.Properties.Resources.Vinesauce_Mushroom; - this.pictureBox1.Location = new System.Drawing.Point(378, 12); + this.pictureBox1.Location = new System.Drawing.Point(376, 11); this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(358, 117); + this.pictureBox1.Size = new System.Drawing.Size(358, 307); this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; this.pictureBox1.TabIndex = 39; this.pictureBox1.TabStop = false; @@ -1055,7 +1100,7 @@ // this.checkBox_UseTinyURL.AutoSize = true; this.checkBox_UseTinyURL.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.checkBox_UseTinyURL.Location = new System.Drawing.Point(223, 577); + this.checkBox_UseTinyURL.Location = new System.Drawing.Point(220, 765); this.checkBox_UseTinyURL.Name = "checkBox_UseTinyURL"; this.checkBox_UseTinyURL.Size = new System.Drawing.Size(101, 17); this.checkBox_UseTinyURL.TabIndex = 41; @@ -1065,7 +1110,7 @@ // button_UseTinyURLHelp // this.button_UseTinyURLHelp.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button_UseTinyURLHelp.Location = new System.Drawing.Point(330, 573); + this.button_UseTinyURLHelp.Location = new System.Drawing.Point(328, 761); this.button_UseTinyURLHelp.Name = "button_UseTinyURLHelp"; this.button_UseTinyURLHelp.Size = new System.Drawing.Size(26, 23); this.button_UseTinyURLHelp.TabIndex = 42; @@ -1077,7 +1122,7 @@ // this.checkBox_HotkeyEnable.AutoSize = true; this.checkBox_HotkeyEnable.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.checkBox_HotkeyEnable.Location = new System.Drawing.Point(363, 577); + this.checkBox_HotkeyEnable.Location = new System.Drawing.Point(361, 765); this.checkBox_HotkeyEnable.Name = "checkBox_HotkeyEnable"; this.checkBox_HotkeyEnable.Size = new System.Drawing.Size(109, 17); this.checkBox_HotkeyEnable.TabIndex = 43; @@ -1089,7 +1134,7 @@ // this.button_HotkeySet.Enabled = false; this.button_HotkeySet.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button_HotkeySet.Location = new System.Drawing.Point(473, 574); + this.button_HotkeySet.Location = new System.Drawing.Point(471, 762); this.button_HotkeySet.Name = "button_HotkeySet"; this.button_HotkeySet.Size = new System.Drawing.Size(26, 23); this.button_HotkeySet.TabIndex = 44; @@ -1100,7 +1145,7 @@ // button_HotkeyHelp // this.button_HotkeyHelp.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button_HotkeyHelp.Location = new System.Drawing.Point(505, 574); + this.button_HotkeyHelp.Location = new System.Drawing.Point(502, 762); this.button_HotkeyHelp.Name = "button_HotkeyHelp"; this.button_HotkeyHelp.Size = new System.Drawing.Size(26, 23); this.button_HotkeyHelp.TabIndex = 45; @@ -1113,7 +1158,7 @@ this.AcceptButton = this.button_Run; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(742, 599); + this.ClientSize = new System.Drawing.Size(742, 791); this.Controls.Add(this.button_HotkeyHelp); this.Controls.Add(this.button_HotkeySet); this.Controls.Add(this.checkBox_HotkeyEnable); @@ -1155,8 +1200,8 @@ #endregion - private System.Windows.Forms.Button button_RomToCorruptBrowse; - private System.Windows.Forms.TextBox textBox_RomToCorrupt; + private System.Windows.Forms.Button button_RomDirectoryBrowse; + private System.Windows.Forms.TextBox textBox_RomDirectory; private System.Windows.Forms.Label labelRomToCorrupt; private System.Windows.Forms.Label labelSaveLocation; private System.Windows.Forms.TextBox textBox_SaveLocation; @@ -1240,6 +1285,8 @@ private System.Windows.Forms.CheckBox checkBox_HotkeyEnable; private System.Windows.Forms.Button button_HotkeySet; private System.Windows.Forms.Button button_HotkeyHelp; + private System.Windows.Forms.ListView listView_Files; + private System.Windows.Forms.ColumnHeader listViewC_fileName; } } diff --git a/src/Vinesauce ROM Corruptor/MainForm.cs b/src/Vinesauce ROM Corruptor/MainForm.cs index 416699b..d97129a 100644 --- a/src/Vinesauce ROM Corruptor/MainForm.cs +++ b/src/Vinesauce ROM Corruptor/MainForm.cs @@ -66,15 +66,19 @@ namespace Vinesauce_ROM_Corruptor static private Process Emulator = null; - private List NESCPUJamProtection_Avoid = new List() { 0x48, 0x08, 0x68, 0x28, 0x78, 0x00, 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72, 0x92, 0xB2, 0xD2, 0xF2 }; - private List NESCPUJamProtection_Protect_1 = new List() { 0x48, 0x08, 0x68, 0x28, 0x78, 0x40, 0x60, 0x00, 0x90, 0xB0, 0xF0, 0x30, 0xD0, 0x10, 0x50, 0x70, 0x4C, 0x6C, 0x20 }; - private List NESCPUJamProtection_Protect_2 = new List() { 0x90, 0xB0, 0xF0, 0x30, 0xD0, 0x10, 0x50, 0x70, 0x4C, 0x6C, 0x20 }; - private List NESCPUJamProtection_Protect_3 = new List() { 0x4C, 0x6C, 0x20 }; + static private List NESCPUJamProtection_Avoid = new List() { 0x48, 0x08, 0x68, 0x28, 0x78, 0x00, 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72, 0x92, 0xB2, 0xD2, 0xF2 }; + static private List NESCPUJamProtection_Protect_1 = new List() { 0x48, 0x08, 0x68, 0x28, 0x78, 0x40, 0x60, 0x00, 0x90, 0xB0, 0xF0, 0x30, 0xD0, 0x10, 0x50, 0x70, 0x4C, 0x6C, 0x20 }; + static private List NESCPUJamProtection_Protect_2 = new List() { 0x90, 0xB0, 0xF0, 0x30, 0xD0, 0x10, 0x50, 0x70, 0x4C, 0x6C, 0x20 }; + static private List NESCPUJamProtection_Protect_3 = new List() { 0x4C, 0x6C, 0x20 }; static public Keys Hotkey = Keys.Space; static public HotkeyActions HotkeyAction = HotkeyActions.AddStart; static public bool HotkeyEnabled = false; + static private RomId SelectedROM = null; + + static private string SettingSaveDirectory = ""; + public MainForm() { InitializeComponent(); @@ -83,7 +87,12 @@ namespace Vinesauce_ROM_Corruptor try { string text = File.ReadAllText("VinesauceROMCorruptor.txt"); - Match m = Regex.Match(text, "(?<=textBox_SaveLocation\\.Text=).*?(?=\r)"); + Match m = Regex.Match(text, "(?<=textBox_RomDirectory\\.Text=).*?(?=\r)"); + if (m.Success) + { + textBox_RomDirectory.Text = m.Groups[0].Value; + } + m = Regex.Match(text, "(?<=textBox_SaveLocation\\.Text=).*?(?=\r)"); if (m.Success) { textBox_SaveLocation.Text = m.Groups[0].Value; @@ -93,6 +102,11 @@ namespace Vinesauce_ROM_Corruptor { textBox_EmulatorToRun.Text = m.Groups[0].Value; } + m = Regex.Match(text, "(?<=SettingSaveDirectory=).*?(?=\r)"); + if (m.Success) + { + SettingSaveDirectory = m.Groups[0].Value; + } m = Regex.Match(text, "(?<=HotkeyEnabled=).*?(?=\r)"); if (m.Success) { @@ -101,13 +115,14 @@ namespace Vinesauce_ROM_Corruptor m = Regex.Match(text, "(?<=Hotkey=).*?(?=\r)"); if (m.Success) { - Hotkey = (Keys)Enum.Parse(typeof(Keys),m.Groups[0].Value,false); + Hotkey = (Keys)Enum.Parse(typeof(Keys), m.Groups[0].Value, false); } m = Regex.Match(text, "(?<=HotkeyAction=).*?(?=\r)"); if (m.Success) { HotkeyAction = (HotkeyActions)Enum.Parse(typeof(HotkeyActions), m.Groups[0].Value, false); } + PopulateFileList(); } catch { @@ -117,23 +132,14 @@ namespace Vinesauce_ROM_Corruptor private void button_RomToCorruptBrowse_Click(object sender, EventArgs e) { - button_Run.Focus(); - OpenFileDialog fDialog = new OpenFileDialog(); - fDialog.Title = "Select ROM to Corrupt"; - fDialog.CheckFileExists = true; - fDialog.CheckPathExists = true; - fDialog.Filter = "All files (*.*)|*.*"; + listView_Files.Focus(); + FolderBrowserDialog fDialog = new FolderBrowserDialog(); + fDialog.Description = "Select ROM Directory"; + fDialog.SelectedPath = textBox_RomDirectory.Text; if (fDialog.ShowDialog() == DialogResult.OK) { - textBox_RomToCorrupt.Text = fDialog.FileName.ToString(); - } - textBox_RomToCorrupt.SelectionStart = textBox_RomToCorrupt.Text.Length; - textBox_RomToCorrupt.ScrollToCaret(); - - // Set to end of new ROM if desired. - if (checkBox_AutoEnd.Checked) - { - FindEndOfROM(); + textBox_RomDirectory.Text = fDialog.SelectedPath; + PopulateFileList(); } } @@ -148,10 +154,19 @@ namespace Vinesauce_ROM_Corruptor fDialog.OverwritePrompt = false; fDialog.Title = "Select Save Location for Corrupted ROM"; fDialog.Filter = "All files (*.*)|*.*"; + try + { + fDialog.InitialDirectory = Path.GetDirectoryName(textBox_SaveLocation.Text); + } + catch + { + fDialog.InitialDirectory = ""; + } if (fDialog.ShowDialog() == DialogResult.OK) { textBox_SaveLocation.Text = fDialog.FileName; + PopulateFileList(); } textBox_SaveLocation.SelectionStart = textBox_SaveLocation.Text.Length; textBox_SaveLocation.ScrollToCaret(); @@ -172,6 +187,15 @@ namespace Vinesauce_ROM_Corruptor fDialog.Filter = "Executable Files|*.exe"; fDialog.CheckFileExists = true; fDialog.CheckPathExists = true; + try + { + fDialog.InitialDirectory = Path.GetDirectoryName(textBox_EmulatorToRun.Text); + } + catch + { + fDialog.InitialDirectory = ""; + } + if (fDialog.ShowDialog() == DialogResult.OK) { textBox_EmulatorToRun.Text = fDialog.FileName.ToString(); @@ -225,13 +249,16 @@ namespace Vinesauce_ROM_Corruptor } } - // Read the ROM in. - byte[] ROM = null; - try + // Check that a ROM is selected. + if (SelectedROM == null) { - ROM = File.ReadAllBytes(textBox_RomToCorrupt.Text); + MessageBox.Show("No ROM is selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; } - catch + + // Read the ROM in. + byte[] ROM = SelectedROM.Load(); + if (ROM == null) { MessageBox.Show("Error reading ROM.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -738,8 +765,8 @@ namespace Vinesauce_ROM_Corruptor { if (NESCPUJamProtection_Avoid.Contains((byte)((ROM[i] + AddXtoByte) % (Byte.MaxValue + 1))) || NESCPUJamProtection_Protect_1.Contains(ROM[i]) - || NESCPUJamProtection_Protect_2.Contains(ROM[i-1]) - || NESCPUJamProtection_Protect_3.Contains(ROM[i-2])) + || NESCPUJamProtection_Protect_2.Contains(ROM[i - 1]) + || NESCPUJamProtection_Protect_3.Contains(ROM[i - 2])) { Protected = true; } @@ -783,8 +810,8 @@ namespace Vinesauce_ROM_Corruptor { if (NESCPUJamProtection_Avoid.Contains(ROM[i]) || NESCPUJamProtection_Protect_1.Contains(ROM[j]) - || NESCPUJamProtection_Protect_2.Contains(ROM[j-1]) - || NESCPUJamProtection_Protect_3.Contains(ROM[j-2])) + || NESCPUJamProtection_Protect_2.Contains(ROM[j - 1]) + || NESCPUJamProtection_Protect_3.Contains(ROM[j - 2])) { Protected = true; } @@ -843,6 +870,12 @@ namespace Vinesauce_ROM_Corruptor // Start the emulator if desired. if (checkBox_RunEmulator.Checked) { + if (textBox_EmulatorToRun.Text == "") + { + MessageBox.Show("No emulator path given.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + try { // See if the emulator is already running. @@ -946,50 +979,36 @@ namespace Vinesauce_ROM_Corruptor "Auto End Help"); } - private void FindEndOfROM() + private void EnforceAutoEnd() { - byte[] ROM = null; - try + if (SelectedROM != null && checkBox_AutoEnd.Checked) { - ROM = File.ReadAllBytes(textBox_RomToCorrupt.Text); - } - catch - { - MessageBox.Show("Error reading ROM.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - checkBox_AutoEnd.Checked = false; - return; - } + long StartByte; + try + { + StartByte = Convert.ToInt64(textBox_StartByte.Text, 16); + } + catch + { + MessageBox.Show("Invalid start byte.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + checkBox_AutoEnd.Checked = false; + return; + } - long StartByte; - try - { - StartByte = Convert.ToInt64(textBox_StartByte.Text, 16); + long MaxByte = SelectedROM.FileLength - 1; + if (StartByte > MaxByte) + { + StartByte = MaxByte; + textBox_StartByte.Text = MaxByte.ToString("X"); + } + textBox_EndByte.Text = MaxByte.ToString("X"); } - catch - { - MessageBox.Show("Invalid start byte.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - checkBox_AutoEnd.Checked = false; - return; - } - - long MaxByte = ROM.LongLength - 1; - if (StartByte > MaxByte) - { - StartByte = MaxByte; - textBox_StartByte.Text = MaxByte.ToString("X"); - } - textBox_EndByte.Text = MaxByte.ToString("X"); } private void checkBox_AutoEnd_CheckedChanged(object sender, EventArgs e) { if (checkBox_ByteCorruptionEnable.Checked) { - if (checkBox_AutoEnd.Checked) - { - FindEndOfROM(); - } - label_EndByte.Enabled = !checkBox_AutoEnd.Checked; textBox_EndByte.Enabled = !checkBox_AutoEnd.Checked; button_EndByteUp.Enabled = !checkBox_AutoEnd.Checked; @@ -997,6 +1016,8 @@ namespace Vinesauce_ROM_Corruptor button_RangeUp.Enabled = !checkBox_AutoEnd.Checked; button_RangeDown.Enabled = !checkBox_AutoEnd.Checked; } + + EnforceAutoEnd(); } private void button_StartByteUp_Click(object sender, EventArgs e) @@ -1393,6 +1414,7 @@ namespace Vinesauce_ROM_Corruptor fDialog.OverwritePrompt = true; fDialog.Title = "Select Save Location for Corruption Settings"; fDialog.Filter = "Text Documents (*.txt)|*.txt"; + fDialog.InitialDirectory = SettingSaveDirectory; if (fDialog.ShowDialog() == DialogResult.OK) { @@ -1412,6 +1434,15 @@ namespace Vinesauce_ROM_Corruptor MessageBox.Show("Error saving corruption settings.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } + + try + { + SettingSaveDirectory = Path.GetDirectoryName(fDialog.FileName); + } + catch + { + SettingSaveDirectory = ""; + } } } } @@ -1446,6 +1477,7 @@ namespace Vinesauce_ROM_Corruptor // Load the settings. StringToSettings(text); + EnforceAutoEnd(); } catch { @@ -1460,6 +1492,7 @@ namespace Vinesauce_ROM_Corruptor fDialog.Filter = "Text Documents (*.txt)|*.txt"; fDialog.CheckFileExists = true; fDialog.CheckPathExists = true; + fDialog.InitialDirectory = SettingSaveDirectory; if (fDialog.ShowDialog() == DialogResult.OK) { @@ -1467,12 +1500,22 @@ namespace Vinesauce_ROM_Corruptor { // Load the settings from the file. StringToSettings(File.ReadAllText(fDialog.FileName)); + EnforceAutoEnd(); } catch { MessageBox.Show("Error loading corruption settings.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } + + try + { + SettingSaveDirectory = Path.GetDirectoryName(fDialog.FileName); + } + catch + { + SettingSaveDirectory = ""; + } } } } @@ -1496,7 +1539,10 @@ namespace Vinesauce_ROM_Corruptor StringBuilder sb = new StringBuilder(); // ROM to corrupt. - sb.AppendLine("textBox_RomToCorrupt.Text=" + textBox_RomToCorrupt.Text); + SelectedROM.ComputeHash(); + sb.AppendLine("ROM.FileName=" + SelectedROM.FileName); + sb.AppendLine("ROM.FileLength=" + String.Format("{0:X}", SelectedROM.FileLength)); + sb.AppendLine("ROM.Hash=" + SelectedROM.HashStringBase64); // General settings. sb.AppendLine("checkBox_EnableNESCPUJamProtection.Checked=" + checkBox_EnableNESCPUJamProtection.Checked.ToString()); @@ -1534,11 +1580,56 @@ namespace Vinesauce_ROM_Corruptor private void StringToSettings(string text) { + // ROM to corrupt. - Match m = Regex.Match(text, "(?<=textBox_RomToCorrupt\\.Text=).*?(?=\r)"); + string TargetROMFileName = ""; + long TargetROMFileLength = 0; + byte[] TargetROMHash = null; + Match m = Regex.Match(text, "(?<=ROM\\.FileName=).*?(?=\r)"); if (m.Success) { - textBox_RomToCorrupt.Text = m.Groups[0].Value; + TargetROMFileName = Path.GetFileName(m.Groups[0].Value); + } + m = Regex.Match(text, "(?<=ROM\\.FileLength=).*?(?=\r)"); + if (m.Success) + { + TargetROMFileLength = Convert.ToInt64(m.Groups[0].Value, 16); + } + m = Regex.Match(text, "(?<=ROM\\.Hash=).*?(?=\r)"); + if (m.Success) + { + TargetROMHash = Convert.FromBase64String(m.Groups[0].Value); + } + + // Backwards compatibility. + if (TargetROMFileName == "") + { + m = Regex.Match(text, "(?<=textBox_RomToCorrupt\\.Text=).*?(?=\r)"); + if (m.Success) + { + TargetROMFileName = Path.GetFileName(m.Groups[0].Value); + } + } + + // Select the ROM. + bool success = false; + if (TargetROMHash != null) + { + success = SelectROMWithFileLengthAndHash(TargetROMFileLength, TargetROMHash); + } + if (!success && TargetROMFileName != "") + { + success = SelectROMWithFileName(TargetROMFileName); + if (success) + { + MessageBox.Show("The ROM selected was matched on the name of the file, not its hash. This file may be different than the intended corruption target file.", + "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + else + { + MessageBox.Show("No ROM matching the target hash or name could be found in the selected directory. Please select the correct directory and load the corruption settings again.", + "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } } // Enable checkboxes. @@ -1781,7 +1872,7 @@ namespace Vinesauce_ROM_Corruptor { button_Run.Focus(); MessageBox.Show("When this box is checked, a hotkey is enabled that will change the byte corruption range, corrupt the ROM, close the emulator, and re-run the ROM. This is useful for quickly attempting many corruptions. The default hotkey is the spacebar, but can be set to any key via the \"...\" button." - +" The default change to the byte corruption range is to add the increment to the start byte, but can be set to one of six actions via the \"...\" button", + + " The default change to the byte corruption range is to add the increment to the start byte, but can be set to one of six actions via the \"...\" button", "Hotkey Help"); } @@ -1791,7 +1882,7 @@ namespace Vinesauce_ROM_Corruptor form.StartPosition = FormStartPosition.CenterParent; form.ShowDialog(); while (form.Visible == true) - this.Enabled = false; + this.Enabled = false; } private void checkBox_HotkeyEnable_CheckedChanged(object sender, EventArgs e) @@ -1809,8 +1900,10 @@ namespace Vinesauce_ROM_Corruptor StreamWriter sw = new StreamWriter("VinesauceROMCorruptor.txt", false); // Write the save location and emulator to run. + sw.WriteLine("textBox_RomDirectory.Text=" + textBox_RomDirectory.Text); sw.WriteLine("textBox_SaveLocation.Text=" + textBox_SaveLocation.Text); sw.WriteLine("textBox_EmulatorToRun.Text=" + textBox_EmulatorToRun.Text); + sw.WriteLine("SettingSaveDirectory=" + SettingSaveDirectory); sw.WriteLine("HotkeyEnabled=" + checkBox_HotkeyEnable.Checked); sw.WriteLine("Hotkey=" + Hotkey); sw.WriteLine("HotkeyAction=" + HotkeyAction); @@ -1823,5 +1916,95 @@ namespace Vinesauce_ROM_Corruptor // Do nothing, stop exception. } } + + private void PopulateFileList() + { + string[] FilePaths; + try + { + FilePaths = Directory.GetFiles(textBox_RomDirectory.Text); + } + catch + { + return; + } + + listView_Files.Items.Clear(); + listView_Files.Focus(); + if (FilePaths.Length > 0) + { + foreach (string FilePath in FilePaths) + { + if (FilePath != textBox_SaveLocation.Text) + { + RomId id = new RomId(FilePath); + if (id.FileLength > 0) + { + listView_Files.Items.Add(id.GetListViewItem()); + } + } + } + listView_Files.Items[0].Selected = true; + } + else + { + SelectedROM = null; + } + } + + private bool SelectROMWithFileLengthAndHash(long FileLength, byte[] Hash) + { + bool success = false; + foreach (ListViewItem item in listView_Files.Items) + { + RomId id = (RomId)item.Tag; + if (id.MatchesFileLength(FileLength)) + { + id.ComputeHash(); + if (id.MatchesHash(Hash)) + { + success = true; + listView_Files.Focus(); + if (item.Index >= 4) + { + listView_Files.TopItem = listView_Files.Items[item.Index-4]; + } + item.Selected = true; + break; + } + } + } + return success; + } + + private bool SelectROMWithFileName(string FileName) + { + bool success = false; + foreach (ListViewItem item in listView_Files.Items) + { + RomId id = (RomId)item.Tag; + if (id.MatchesFileName(FileName)) + { + success = true; + listView_Files.Focus(); + if (item.Index >= 4) + { + listView_Files.TopItem = listView_Files.Items[item.Index - 4]; + } + item.Selected = true; + break; + } + } + return success; + } + + private void listView_Files_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) + { + if (e.IsSelected) + { + SelectedROM = (RomId)e.Item.Tag; + EnforceAutoEnd(); + } + } } } diff --git a/src/Vinesauce ROM Corruptor/RomId.cs b/src/Vinesauce ROM Corruptor/RomId.cs new file mode 100644 index 0000000..a2575e9 --- /dev/null +++ b/src/Vinesauce ROM Corruptor/RomId.cs @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2013 Ryan Sammon. + * + * This file is part of the Vinesauce ROM Corruptor. + * + * The Vinesauce ROM Corruptor is free software: you can redistribute + * it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * The Vinesauce ROM Corruptor is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the Vinesauce ROM Corruptor. If not, see + * . + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Windows.Forms; + +namespace Vinesauce_ROM_Corruptor +{ + class RomId + { + static SHA256 SHA = SHA256Managed.Create(); + + public string FilePath = ""; + public string FileName = ""; + public long FileLength = 0; + public byte[] Hash = null; + public string HashStringBase64 = ""; + + public RomId(string FilePath) + { + this.FilePath = FilePath; + this.FileName = Path.GetFileName(FilePath); + + try + { + FileInfo fi = new FileInfo(FilePath); + this.FileLength = fi.Length; + } + catch + { + // Do nothing. + } + } + + public ListViewItem GetListViewItem() + { + ListViewItem item = new ListViewItem(new string[] { FileName }); + item.Tag = this; + return item; + } + + public byte[] Load() + { + try + { + return File.ReadAllBytes(FilePath); + } + catch + { + return null; + } + } + + public bool MatchesHash(byte[] OtherHash) + { + if (OtherHash == null) + { + return false; + } + return OtherHash.SequenceEqual(Hash); + } + + public bool MatchesFileName(string OtherFileName) + { + if (OtherFileName == "") + { + return false; + } + return OtherFileName == FileName; + } + + public bool MatchesFileLength(long OtherFileLength) + { + if (OtherFileLength < 1) + { + return false; + } + return OtherFileLength == FileLength; + } + + public void ComputeHash() + { + if (Hash == null) + { + FileInfo fi = new FileInfo(FilePath); + FileStream fs = fi.OpenRead(); + Hash = SHA.ComputeHash(fs); + fs.Close(); + HashStringBase64 = Convert.ToBase64String(Hash); + } + } + + } +} \ No newline at end of file diff --git a/src/Vinesauce ROM Corruptor/Vinesauce ROM Corruptor.csproj b/src/Vinesauce ROM Corruptor/Vinesauce ROM Corruptor.csproj index 8cfbe92..11c1930 100644 --- a/src/Vinesauce ROM Corruptor/Vinesauce ROM Corruptor.csproj +++ b/src/Vinesauce ROM Corruptor/Vinesauce ROM Corruptor.csproj @@ -64,6 +64,7 @@ + HotkeyForm.cs