public Mart() { InitializeComponent(); if (Main.ExeFS == null) { Util.Alert("No exeFS code to load."); Close(); } string[] files = Directory.GetFiles(Main.ExeFS); if (!File.Exists(files[0]) || !Path.GetFileNameWithoutExtension(files[0]).Contains("code")) { Util.Alert("No .code.bin detected."); Close(); } data = File.ReadAllBytes(files[0]); if (data.Length % 0x200 != 0) { Util.Alert(".code.bin not decompressed. Aborting."); Close(); } offset = Util.IndexOfBytes(data, new byte[] { 0x00, 0x72, 0x6F, 0x6D, 0x3A, 0x2F, 0x44, 0x6C, 0x6C, 0x53, 0x74, 0x61, 0x72, 0x74, 0x4D, 0x65, 0x6E, 0x75, 0x2E, 0x63, 0x72, 0x6F, 0x00 }, 0x400000, 0) + 0x17; codebin = files[0]; itemlist[0] = ""; setupDGV(); foreach (string s in locations) { CB_Location.Items.Add(s); } CB_Location.SelectedIndex = 0; }
public TypeChart7() { if (Main.ExeFSPath == null) { WinFormsUtil.Alert("No exeFS code to load."); Close(); } string[] files = Directory.GetFiles(Main.ExeFSPath); if (!File.Exists(files[0]) || !Path.GetFileNameWithoutExtension(files[0]).Contains("code")) { WinFormsUtil.Alert("No .code.bin detected."); Close(); } InitializeComponent(); codebin = files[0]; exefs = File.ReadAllBytes(codebin); if (exefs.Length % 0x200 != 0) { WinFormsUtil.Alert(".code.bin not decompressed. Aborting."); Close(); } offset = Util.IndexOfBytes(exefs, Signature, 0x400000, 0) + Signature.Length; Array.Copy(exefs, offset, chart, 0, chart.Length); populateChart(); }
public TMEditor7() { InitializeComponent(); if (Main.ExeFSPath == null) { WinFormsUtil.Alert("No exeFS code to load."); Close(); } string[] files = Directory.GetFiles(Main.ExeFSPath); if (!File.Exists(files[0]) || !Path.GetFileNameWithoutExtension(files[0]).Contains("code")) { WinFormsUtil.Alert("No .code.bin detected."); Close(); } data = File.ReadAllBytes(files[0]); if (data.Length % 0x200 != 0) { WinFormsUtil.Alert(".code.bin not decompressed. Aborting."); Close(); } offset = Util.IndexOfBytes(data, Signature, 0x400000, 0) + Signature.Length; if (Main.Config.USUM) { offset += 0x22; } codebin = files[0]; movelist[0] = ""; setupDGV(); getList(); }
internal static void getTMHMList(ref ushort[] TMs) { if (Main.ExeFSPath == null) { return; } string[] files = Directory.GetFiles(Main.ExeFSPath); if (!File.Exists(files[0]) || !Path.GetFileNameWithoutExtension(files[0]).Contains("code")) { return; } byte[] data = File.ReadAllBytes(files[0]); int dataoffset = Util.IndexOfBytes(data, Signature, 0x400000, 0) + Signature.Length; if (data.Length % 0x200 != 0) { return; } if (Main.Config.USUM) { dataoffset += 0x22; } List <ushort> tms = new List <ushort>(); for (int i = 0; i < 100; i++) // TMs stored sequentially { tms.Add(BitConverter.ToUInt16(data, dataoffset + (2 * i))); } TMs = tms.ToArray(); }
public MartEditor7() { if (!File.Exists(CROPath)) { WinFormsUtil.Error("CRO does not exist! Closing.", CROPath); Close(); } InitializeComponent(); data = File.ReadAllBytes(CROPath); offset = Util.IndexOfBytes(data, Signature, 0x5000, 0) + Signature.Length; offsetBP = Util.IndexOfBytes(data, BPSignature, 0x5000, 0) + BPSignature.Length; itemlist[0] = ""; setupDGV(); foreach (string s in locations) { CB_Location.Items.Add(s); } foreach (string s in locationsBP) { CB_LocationBP.Items.Add(s); } CB_Location.SelectedIndex = 0; CB_LocationBP.SelectedIndex = 0; }
private static int GetDataOffset(byte[] data) { byte[] vanilla = { 0x00, 0x72, 0x6F, 0x6D, 0x3A, 0x2F, 0x44, 0x6C, 0x6C, 0x53, 0x74, 0x61, 0x72, 0x74, 0x4D, 0x65, 0x6E, 0x75, 0x2E, 0x63, 0x72, 0x6F, 0x00 }; int offset = Util.IndexOfBytes(data, vanilla, 0x400000, 0); if (offset >= 0) { return(offset + vanilla.Length); } byte[] patched = { 0x00, 0x72, 0x6F, 0x6D, 0x32, 0x3A, 0x2F, 0x44, 0x6C, 0x6C, 0x53, 0x74, 0x61, 0x72, 0x74, 0x4D, 0x65, 0x6E, 0x75, 0x2E, 0x63, 0x72, 0x6F, 0x00, 0xFF }; offset = Util.IndexOfBytes(data, patched, 0x400000, 0); if (offset >= 0) { return(offset + patched.Length); } return(-1); }
public ShinyRate() { InitializeComponent(); if (Main.ExeFSPath == null) { WinFormsUtil.Alert("No exeFS code to load."); Close(); } string[] files = Directory.GetFiles(Main.ExeFSPath); if (!File.Exists(files[0]) || !Path.GetFileNameWithoutExtension(files[0]).Contains("code")) { WinFormsUtil.Alert("No .code.bin detected."); Close(); } codebin = files[0]; exefsData = File.ReadAllBytes(codebin); if (exefsData.Length % 0x200 != 0) { WinFormsUtil.Alert(".code.bin not decompressed. Aborting."); Close(); } // Load instruction set byte[] raw = Core.Properties.Resources.asm_mov; for (int i = 0; i < raw.Length; i += 4) { byte[] data = new byte[2]; Array.Copy(raw, i + 2, data, 0, 2); InstructionList.Add(new Instruction(BitConverter.ToUInt16(raw, i), data)); } // Fetch Offset byte[] pattern = { 0x01, 0x50, 0x85, 0xE2, 0x05, 0x00, 0x50, 0xE1, 0xDE, 0xFF, 0xFF, 0xCA }; offset = Util.IndexOfBytes(exefsData, pattern, 0, 0) - 4; if (offset < 0) { WinFormsUtil.Alert("Unable to find PID Generation routine.", "Closing."); Close(); } if (exefsData[offset] != 0x23) // already patched { uint val = BitConverter.ToUInt16(exefsData, offset); var instruction = InstructionList.FirstOrDefault(z => z.ArgVal == val); if (instruction == null) { WinFormsUtil.Alert(".code.bin was modified externally.", "Existing value not loaded."); } else { WinFormsUtil.Alert(".code.bin was already patched for shiny rate.", "Loaded existing value."); NUD_Rerolls.Value = instruction.Value; } modified = true; } changeRerolls(null, null); CheckAlwaysShiny(); }
internal static void getTMHMList(bool oras, out ushort[] TMs, out ushort[] HMs) { TMs = new ushort[0]; HMs = new ushort[0]; if (Main.ExeFSPath == null) { return; } string[] files = Directory.GetFiles(Main.ExeFSPath); if (!File.Exists(files[0]) || !Path.GetFileNameWithoutExtension(files[0]).Contains("code")) { return; } byte[] data = File.ReadAllBytes(files[0]); int dataoffset = Util.IndexOfBytes(data, Signature, 0x400000, 0) + 8; if (data.Length % 0x200 != 0) { return; } List <ushort> tms = new List <ushort>(); List <ushort> hms = new List <ushort>(); for (int i = 0; i < 92; i++) // 1-92 TMs stored sequentially { tms.Add(BitConverter.ToUInt16(data, dataoffset + (2 * i))); } for (int i = 92; i < 92 + 5; i++) { hms.Add(BitConverter.ToUInt16(data, dataoffset + (2 * i))); } if (Main.Config.ORAS) { hms.Add(BitConverter.ToUInt16(data, dataoffset + (2 * 97))); for (int i = 98; i < 106; i++) { tms.Add(BitConverter.ToUInt16(data, dataoffset + (2 * i))); } hms.Add(BitConverter.ToUInt16(data, dataoffset + (2 * 106))); } else { for (int i = 97; i < 105; i++) { tms.Add(BitConverter.ToUInt16(data, dataoffset + (2 * i))); } } TMs = tms.ToArray(); HMs = hms.ToArray(); }
public static int GetItemMapOffset() { if (Main.ExeFSPath == null) { WinFormsUtil.Alert("No exeFS code to load."); return(-1); } string[] exefsFiles = Directory.GetFiles(Main.ExeFSPath); if (!File.Exists(exefsFiles[0]) || !Path.GetFileNameWithoutExtension(exefsFiles[0]).Contains("code")) { WinFormsUtil.Alert("No .code.bin detected."); return(-1); } byte[] data = File.ReadAllBytes(exefsFiles[0]); byte[] reference = ItemIconTableSignature; return(Util.IndexOfBytes(data, reference, 0x400000, 0) - 2 + reference.Length); }
public OPower() { InitializeComponent(); if (Main.ExeFSPath == null) { WinFormsUtil.Alert("No exeFS code to load."); Close(); } string[] files = Directory.GetFiles(Main.ExeFSPath); if (!File.Exists(files[0]) || !Path.GetFileNameWithoutExtension(files[0]).Contains("code")) { WinFormsUtil.Alert("No .code.bin detected."); Close(); } codebin = files[0]; exefsData = File.ReadAllBytes(codebin); if (exefsData.Length % 0x200 != 0) { WinFormsUtil.Alert(".code.bin not decompressed. Aborting."); Close(); } // Fetch Offset offset = Util.IndexOfBytes(exefsData, new byte[] { 0x34, 0x39, 0x34, 0x36, 0x31, 0x38, 0x34, 0x35, 0x00 }, 0x400000, 0) + 9; while (exefsData[offset] == 0xFF) { offset++; } // Gather Data for (int i = 0; i < powerData.Length; i++) { powerData[i] = exefsData.Skip(offset + 22 * i).Take(22).ToArray(); } // Prepare View for (int i = 0; i < 10; i++) { CB_SortOrder.Items.Add(i); } for (int i = 1; i < powerData.Length; i++) { CB_Item.Items.Add(i); } CB_Item.SelectedIndex = 0; WinFormsUtil.Alert("More research is required for giving S/MAX O-Powers ingame."); }
public static int GetItemMapOffset() { if (Main.ExeFSPath == null) { WinFormsUtil.Alert("No exeFS code to load."); return(-1); } string[] exefsFiles = Directory.GetFiles(Main.ExeFSPath); if (!File.Exists(exefsFiles[0]) || !Path.GetFileNameWithoutExtension(exefsFiles[0]).Contains("code")) { WinFormsUtil.Alert("No .code.bin detected."); return(-1); } byte[] data = File.ReadAllBytes(exefsFiles[0]); byte[] reference = Main.Config.ORAS ? new byte[] { 0x92, 0x0A, 0x06, 0x3F, 0x75, 0x02 } // ORAS (vanilla @ 47C640) : new byte[] { 0x92, 0x0A, 0x06, 0x3F, 0x41, 0x02 }; // XY (vanilla @ 43DB74) return(Util.IndexOfBytes(data, reference, 0x400000, 0) - 2 + reference.Length); }
private int getItemMapOffset() { if (Main.ExeFSPath == null) { Util.Alert("No exeFS code to load."); return(-1); } string[] files = Directory.GetFiles(Main.ExeFSPath); if (!File.Exists(files[0]) || !Path.GetFileNameWithoutExtension(files[0]).Contains("code")) { Util.Alert("No .code.bin detected."); return(-1); } byte[] data = File.ReadAllBytes(files[0]); byte[] reference = Main.oras ? new byte[] { 0x92, 0x0A, 0x06, 0x3F, 0x75, 0x02 } // ORAS (vanilla @ 47C640) : new byte[] { 0x92, 0x0A, 0x06, 0x3F, 0x41, 0x02 }; // XY (vanilla @ 43DB74) int ptr = Util.IndexOfBytes(data, reference, 0x400000, 0) - 2 + reference.Length; return(ptr); }
private void CheckAlwaysShiny() { byte[] pattern = { 0x00, 0x20, 0x22, 0xE0, 0x02, 0x30, 0x21, 0xE2, 0x03, 0x20, 0x92, 0xE1, 0x1C, 0x00, 0x00 }; int index = alwaysIndex = Util.IndexOfBytes(exefsData, pattern, 0, 0) + pattern.Length; if (index < 0) { CHK_EverythingShiny.Enabled = CHK_EverythingShiny.Visible = false; return; } bool original = exefsData[index] == 0x0A; bool always = exefsData[index] == 0xEA; if (!original && !always) // oh no { CHK_EverythingShiny.Enabled = CHK_EverythingShiny.Visible = false; return; } CHK_EverythingShiny.Checked = always; }
public PickupEditor6() { InitializeComponent(); if (Main.ExeFSPath == null) { WinFormsUtil.Alert("No exeFS code to load."); Close(); } string[] files = Directory.GetFiles(Main.ExeFSPath); if (!File.Exists(files[0]) || !Path.GetFileNameWithoutExtension(files[0]).Contains("code")) { WinFormsUtil.Alert("No .code.bin detected."); Close(); } data = File.ReadAllBytes(files[0]); if (data.Length % 0x200 != 0) { WinFormsUtil.Alert(".code.bin not decompressed. Aborting."); Close(); } offset = Util.IndexOfBytes(data, new byte[] { 0x1E, 0x28, 0x32, 0x3C, 0x46, 0x50, 0x5A, 0x5E, 0x62, 0x05, 0x0A, 0x0F, 0x14, 0x19, 0x1E, 0x23, 0x28, 0x2D, 0x32 }, 0x400000, 0) - 0x3A; codebin = files[0]; itemlist[0] = ""; SetupDGV(); GetList(); }
public TMHM() { InitializeComponent(); if (Main.ExeFSPath == null) { Util.Alert("No exeFS code to load."); Close(); } string[] files = Directory.GetFiles(Main.ExeFSPath); if (!File.Exists(files[0]) || !Path.GetFileNameWithoutExtension(files[0]).Contains("code")) { Util.Alert("No .code.bin detected."); Close(); } data = File.ReadAllBytes(files[0]); if (data.Length % 0x200 != 0) { Util.Alert(".code.bin not decompressed. Aborting."); Close(); } offset = Util.IndexOfBytes(data, new byte[] { 0xD4, 0x00, 0xAE, 0x02, 0xAF, 0x02, 0xB0, 0x02 }, 0x400000, 0) + 8; codebin = files[0]; movelist[0] = ""; setupDGV(); getList(); }
public TMHMEditor6() { InitializeComponent(); if (Main.ExeFSPath == null) { WinFormsUtil.Alert("No exeFS code to load."); Close(); } string[] files = Directory.GetFiles(Main.ExeFSPath); if (!File.Exists(files[0]) || !Path.GetFileNameWithoutExtension(files[0]).Contains("code")) { WinFormsUtil.Alert("No .code.bin detected."); Close(); } data = File.ReadAllBytes(files[0]); if (data.Length % 0x200 != 0) { WinFormsUtil.Alert(".code.bin not decompressed. Aborting."); Close(); } offset = Util.IndexOfBytes(data, Signature, 0x400000, 0) + 8; codebin = files[0]; movelist[0] = ""; SetupDGV(); GetList(); RandSettings.GetFormSettings(this, groupBox1.Controls); }