public NandViewModel() { OpenCommand = new RelayCommand(Open); var query = new WqlObjectQuery("SELECT * FROM Win32_DiskDrive"); using (var searcher = new ManagementObjectSearcher(query)) { foreach (ManagementBaseObject drive in searcher.Get()) { if (drive.GetPropertyValue("Size") == null) { continue; } var info = new DiskInfo(); info.PhysicalName = (string)drive.GetPropertyValue("Name"); info.Name = (string)drive.GetPropertyValue("Caption"); info.Model = (string)drive.GetPropertyValue("Model"); //todo Why is Windows returning small sizes? https://stackoverflow.com/questions/15051660 info.Length = (long)((ulong)drive.GetPropertyValue("Size")); info.SectorSize = (int)((uint)drive.GetPropertyValue("BytesPerSector")); info.DisplaySize = Util.GetBytesReadable((long)((ulong)drive.GetPropertyValue("Size"))); Disks.Add(info); } } }
public void Open() { DiskInfo disk = SelectedDisk; var storage = new CachedStorage(new DeviceStream(disk.PhysicalName, disk.Length).AsStorage(), disk.SectorSize * 100, 4, true); storage.SetReadOnly(); Stream stream = storage.AsStream(); Keyset keyset = OpenKeyset(); var nand = new Nand(stream, keyset); Stream prodinfo = nand.OpenProdInfo(); var calibration = new Calibration(prodinfo); keyset.EticketExtKeyRsa = Crypto.DecryptRsaKey(calibration.EticketExtKeyRsa, keyset.EticketRsaKek); Ticket[] tickets = GetTickets(keyset, nand); using (var outStream = new StreamWriter("titlekeys.txt")) { foreach (Ticket ticket in tickets) { byte[] key = ticket.GetTitleKey(keyset); outStream.WriteLine($"{ticket.RightsId.ToHexString()},{key.ToHexString()}"); } } }