private void MenuStrip_Reload_Click(object sender, EventArgs e) { try { Int32 selectedCellCount = ModuleList.GetCellCount(DataGridViewElementStates.Selected); if (selectedCellCount > 0) { int index = ModuleList.SelectedRows[0].Index; int ModuleHandle = Convert.ToInt32(ModuleList.Rows[index].Cells["mHandle"].Value); string ModuleName = Convert.ToString(ModuleList.Rows[index].Cells["ModuleName"].Value); SetStatus("Reloading Module " + ModuleName + "..."); Int32 Handle = PS4.SelectedTarget.Process.ReloadSPRX(ModuleHandle, 0); if (Handle == 0) { DarkMessageBox.ShowError("Handle returned 0.", "Module Failed to Reload."); } else { Thread.Sleep(100); } UpdateModuleList(); SetStatus("Ready"); } } catch { } }
private void MenuStrip_Dump_Click(object sender, EventArgs e) { try { Int32 selectedCellCount = ModuleList.GetCellCount(DataGridViewElementStates.Selected); if (selectedCellCount > 0) { int index = ModuleList.SelectedRows[0].Index; int ModuleHandle = Convert.ToInt32(ModuleList.Rows[index].Cells["mHandle"].Value); string ModuleName = Convert.ToString(ModuleList.Rows[index].Cells["ModuleName"].Value); SetStatus("Dumping Module " + ModuleName + "..."); ModuleInfo Info = PS4.SelectedTarget.Process.ModuleList.Find(x => x.Name == ModuleName); int Length = (int)(Info.TextSegmentLen + Info.DataSegmentLen); byte[] Buffer = new byte[Length]; string FilePath = string.Empty; //If its module 0 thats the process so we want to dump the process else we dump a module. if (ModuleHandle == 0) { API_ERRORS Result = PS4.SelectedTarget.Process.DumpModule(ModuleName, Length, Buffer); //API_ERRORS Result = PS4.SelectedTarget.DumpProcess(ModuleName, Length, Buffer); ModuleName = $"{PS4.SelectedTarget.Process.Current.TitleID}-{ModuleName}"; if (Result != API_ERRORS.API_OK) { DarkMessageBox.ShowError(string.Format("Failed to Dump Process \"{0}\".\n{1}", ModuleName, OrbisDef.API_ERROR_STR[(int)Result]), "Error dumping module."); return; } } else { API_ERRORS Result = PS4.SelectedTarget.Process.DumpModule(ModuleName, Length, Buffer); if (Result != API_ERRORS.API_OK) { DarkMessageBox.ShowError(string.Format("Failed to Dump Module \"{0}\".\n{1}", ModuleName, OrbisDef.API_ERROR_STR[(int)Result]), "Error dumping module."); return; } } //Create the Orbis Suite Directory in Documents. Directory.CreateDirectory($"{Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)}\\Orbis Suite\\"); //Write the file some where. FilePath = string.Format(@"{0}\Orbis Suite\{1}", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Utilities.IndexedFilename(Path.GetFileNameWithoutExtension(ModuleName) + "-Dump", Path.GetExtension(ModuleName))); using (FileStream fs = File.OpenWrite(FilePath)) fs.Write(Buffer, 0, (int)Length); SetStatus("Ready"); } } catch { } }