public void Activate(string filePath, int type, object[] values) { switch ((CCIActivation)type) { case CCIActivation.SaveNCCH: var cxiIndex = (int)values[0]; var saveFileDialog = new SaveFileDialog() { Filter = CXIContexts[cxiIndex].GetFileFilter(), FileName = CXIContexts[cxiIndex].TitleInfo.ProductCode }; if (saveFileDialog.ShowDialog() == DialogResult.OK) { var infs = File.OpenRead(filePath); infs.Seek(Header.CXIEntries[cxiIndex].Offset * 0x200, SeekOrigin.Begin); SaverProcess.Run("Saving NCCH", infs, saveFileDialog.FileName, Header.CXIEntries[cxiIndex].Length * 0x200); } break; } }
public void Activate(string filePath, int type, object[] values) { switch ((CCIActivation)type) { case CCIActivation.SaveNCCH: var cxiIndex = (int)values[0]; var saveFileDialog = new SaveFileDialog() { Filter = CXIContexts[cxiIndex].GetFileFilter(), FileName = CXIContexts[cxiIndex].TitleInfo.ProductCode }; if (saveFileDialog.ShowDialog() == DialogResult.OK) { var infs = File.OpenRead(filePath); infs.Seek(Header.CXIEntries[cxiIndex].Offset * NcsdInfo.media_unit, SeekOrigin.Begin); SaverProcess.Run("Saving " + CXIContexts[cxiIndex].NcchInfo.ncch_type, infs, saveFileDialog.FileName, Header.CXIEntries[cxiIndex].Length * NcsdInfo.media_unit); } break; case CCIActivation.SaveWritableRegion: saveFileDialog = new SaveFileDialog() { Filter = "Binary files (*.bin)|*.bin" }; if (saveFileDialog.ShowDialog() == DialogResult.OK) { var infs = File.OpenRead(filePath); infs.Seek((long)NcsdInfo.WritableRegionAddress, SeekOrigin.Begin); //right after the header var buffer = new byte[(long)NcsdInfo.WritableRegionSize]; infs.Read(buffer, 0, buffer.Length); var outpath = saveFileDialog.FileName; var outfs = File.OpenWrite(outpath); outfs.Write(buffer, 0, buffer.Length); outfs.Close(); } break; } }