private void Button_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog { FileName = "rawnand.bin", DefaultExt = ".bin", Filter = "Raw NAND dump (.bin or .bin.*)|*.bin*", Multiselect = true }; if (dlg.ShowDialog() == true) { // it's nullable so i HAVE to compare it to true string[] files = dlg.FileNames; if (files != null && files.Length > 0) { IList <Stream> streams = new List <Stream>(); foreach (string file in files) { streams.Add(new FileInfo(file).OpenRead()); // Change to Open when write support is added } Stream NANDSource = new CombinationStream(streams); if (!NANDService.InsertNAND(NANDSource, false)) { MessageBox.Show("Invalid NAND dump!"); } } } }
private void ReadTable(string path) { psm = new PackStructureManager(Path.GetFileNameWithoutExtension(path)); streams = new List <Stream>(); if (File.Exists(path)) { streams.Add(new FileStream(path, FileMode.Open, FileAccess.Read)); } string pkx = path.Replace(".pck", ".pkx"); if (File.Exists(pkx)) { streams.Add(new FileStream(pkx, FileMode.Open, FileAccess.Read)); } stream = new CombinationStream(streams); BinaryReader br = new BinaryReader(stream); br.BaseStream.Seek(-8, SeekOrigin.End); int entryCount = br.ReadInt32(); br.BaseStream.Seek(-272, SeekOrigin.End); long fileTableOffset = (long)((ulong)((uint)(br.ReadUInt32() ^ (ulong)KEY_1))); br.BaseStream.Seek(fileTableOffset, SeekOrigin.Begin); PckEntry[] table = new PckEntry[entryCount]; for (int a = 0; a < entryCount; ++a) { int entrySize = br.ReadInt32() ^ KEY_1; entrySize = br.ReadInt32() ^ KEY_2; byte[] buffer = new byte[entrySize]; buffer = br.ReadBytes(entrySize); if (entrySize < 276) { table[a] = readTableEntry(buffer, true); } else { table[a] = readTableEntry(buffer, false); } string name = table[a].filePath.ToLower(); files[name] = table[a]; psm.addfille(files[name]); } initiated = true; }
internal static Stream OpenSplitNcaStream(IFileSystem fs, string path) { var files = new List <string>(); var streams = new List <Stream>(); if (fs.DirectoryExists(path)) { while (true) { string partName = Path.Combine(path, $"{files.Count:D2}"); if (!fs.FileExists(partName)) { break; } files.Add(partName); } } else if (fs.FileExists(path)) { if (Path.GetFileName(path) != "00") { return(fs.OpenFile(path, FileMode.Open, FileAccess.Read)); } files.Add(path); } else { throw new FileNotFoundException("Could not find the input file or directory"); } foreach (string file in files) { streams.Add(fs.OpenFile(file, FileMode.Open, FileAccess.Read)); } if (streams.Count == 0) { return(null); } var stream = new CombinationStream(streams); return(stream); }
private void MakeStreams() { if (disposed) { streams = new List <Stream>(); if (File.Exists(path)) { streams.Add(File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)); } string pkx = path.Replace(".pck", ".pkx"); if (File.Exists(pkx)) { streams.Add(File.Open(pkx, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)); } stream = new CombinationStream(streams); br = new BinaryReader(stream); disposed = false; } }