private void Restorefilebtn_Click(object sender, EventArgs e) { try { File.WriteAllBytes(SaveasTxt.Text, backupROM); CorruptButton.BackColor = Color.Green; using (var soundPlayer = new SoundPlayer(Properties.Resources.success2)) { soundPlayer.Play(); } CorruptButtonColorChanger.Start(); } catch (ArgumentException) { MessageBox.Show("You don't have a file open!"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void Corruptusingstash_Click(object sender, EventArgs e) { { try { ROM = File.ReadAllBytes(MainOpenFileDialog.FileName); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } foreach (var line in File.ReadAllLines(Application.StartupPath + "\\CorruptionStashList\\" + StashList.GetItemText(StashList.SelectedItem))) { Object[] splitStrings; Object[] Instructions; try { splitStrings = line.Split(new string[] { "(", ")" }, StringSplitOptions.None); Instructions = line.Split(new string[] { ".", "(" }, StringSplitOptions.None); } catch (Exception ex) { MessageBox.Show("Error while splitting important variables: " + ex.Message); return; } Object i; Object result; try { i = splitStrings[1]; } catch (Exception ex) { MessageBox.Show("Invaild Corruption Location: " + ex.ToString()); return; } try { result = splitStrings[3]; } catch (Exception ex) { MessageBox.Show("Invaild Result Location: " + ex.ToString()); return; } //if (Char.IsDigit((char)i) == false | Char.IsDigit((char)result) == false) //{ // MessageBox.Show("IsNumeric Location/Result Check Failed, File is most likely corrupted or is blank."); // return; //} //MessageBox.Show(i.ToString()); //MessageBox.Show(result.ToString()); //ROM[(int)i] = (byte)result; ROM[int.Parse(i.ToString())] = (byte)int.Parse(result.ToString()); } File.WriteAllBytes(SaveasTxt.Text, ROM); CorruptButton.BackColor = Color.Green; using (var soundPlayer = new SoundPlayer(Properties.Resources.success2)) { soundPlayer.Play(); } CorruptButtonColorChanger.Start(); if (Runemulatorchbox.Checked && string.IsNullOrEmpty(EmulatorLocationtxt.Text)) { StartEmulator(); } } }
private void CorruptButtonColorChanger_Tick(object sender, EventArgs e) { CorruptButton.BackColor = Color.FromArgb(255, 32, 32, 32); CorruptButtonColorChanger.Stop(); }
private void CorruptButton_Click(object sender, EventArgs e) { StashItemList.Items.Clear(); StashItems.Clear(); StashItems.TrimExcess(); //This probably isn't required, it resizes the internal array to free up more memory. ROM = backupROM; //Here is where the multiple files check should occurr //Checks if the file is fit for corruption if (string.IsNullOrEmpty(FileSelectiontxt.Text)) { MessageBox.Show("File hasn't been selected.", "Error - LunarROMCorruptor", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (StartByteNumb.Value > EndByteNumb.Value) { MessageBox.Show("Start Byte cannot be greater than End Byte!", "Error - LunarROMCorruptor", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { File.WriteAllBytes(SaveasTxt.Text, backupROM); } catch (ArgumentNullException) { MessageBox.Show("You haven't got a file open! Error code: 3x013"); return; } catch (Exception ex) { MessageBox.Show(ex.ToString()); return; } if (StartByteNumb.Value > MaxByte) { StartByteNumb.Value = Int16.Parse(MaxByte.ToString("X")); } try { StartByte = (int)StartByteNumb.Value; } catch { MessageBox.Show("Start byte is incorrect or invaild.", "Error - LunarROMCorruptor ", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { EndByte = (int)EndByteNumb.Value; } catch { MessageBox.Show("End byte is incorrect or invaild.", "Error - LunarROMCorruptor ", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //The file will now be read. ROM = File.ReadAllBytes(MainOpenFileDialog.FileName); //Hell engine goes here. byte[] FinROM = null; if (CorruptionEngineComboBox.Text == "Hell Engine") { for (int i1 = 0; i1 <= Intensity.Value - 1; i1++) { int intes = (int)Intensity.Value; Intensity.Value = 1; int randomIndex = rnd.Next(1, CorruptionEngineComboBox.Items.Count - 1); CorruptionEngineComboBox.SelectedIndex = randomIndex; if (CorruptionEngineComboBox.Text == "Merge Engine" && string.IsNullOrEmpty(objForm2.TextBox5.Text)) { CorruptionEngineComboBox.Text = "Nightmare Engine"; } FinROM = StartCorruption(ROM); Intensity.Value = intes; } CorruptionEngineComboBox.Text = "Hell Engine"; } else { FinROM = StartCorruption(ROM); } if (FinROM == null) { MessageBox.Show("FinROM returned NULL! Corruption Failed!"); return; } File.WriteAllBytes(SaveasTxt.Text, FinROM); if (FilesaveEnableAutoSaves.Checked) { SaveCorruptedFile(); } CorruptButton.BackColor = Color.Green; using (var soundPlayer = new SoundPlayer(Properties.Resources.success2)) { soundPlayer.Play(); } CorruptButtonColorChanger.Start(); if (Runemulatorchbox.Checked && !string.IsNullOrEmpty(EmulatorLocationtxt.Text)) { StartEmulator(); } if (EnableStashSavesChkbox.Checked) { if (StashItems.Count > 50000) //This check is for preventing too many GUI rendering updates on the listbox. The items are contained in a variable but are not shown. { StashItemList.Items.Add("LargeStash"); } else { foreach (var item in StashItems) { StashItemList.Items.Add(item); } } } }