public FileInfoDialog(Volume volume, DirectoryEntry dirent) { InitializeComponent(); listView1.Items.Add("Name").SubItems.Add(dirent.FileName); listView1.Items.Add("Size in bytes").SubItems.Add(dirent.FileSize.ToString()); listView1.Items.Add("First Cluster").SubItems.Add(dirent.FirstCluster.ToString()); listView1.Items.Add("First Cluster Offset").SubItems.Add("0x" + volume.ClusterToPhysicalOffset(dirent.FirstCluster).ToString("x")); listView1.Items.Add("Attributes").SubItems.Add(FormatAttributes(dirent.FileAttributes)); DateTime creationTime = new DateTime(dirent.CreationTime.Year, dirent.CreationTime.Month, dirent.CreationTime.Day, dirent.CreationTime.Hour, dirent.CreationTime.Minute, dirent.CreationTime.Second); DateTime lastWriteTime = new DateTime(dirent.LastWriteTime.Year, dirent.LastWriteTime.Month, dirent.LastWriteTime.Day, dirent.LastWriteTime.Hour, dirent.LastWriteTime.Minute, dirent.LastWriteTime.Second); DateTime lastAccessTime = new DateTime(dirent.LastAccessTime.Year, dirent.LastAccessTime.Month, dirent.LastAccessTime.Day, dirent.LastAccessTime.Hour, dirent.LastAccessTime.Minute, dirent.LastAccessTime.Second); listView1.Items.Add("Creation Time").SubItems.Add(creationTime.ToString()); listView1.Items.Add("Last Write Time").SubItems.Add(lastWriteTime.ToString()); listView1.Items.Add("Last Access Time").SubItems.Add(lastAccessTime.ToString()); }
private void AddCluster(uint cluster) { var address = volume.ClusterToPhysicalOffset(cluster); ListViewItem item = new ListViewItem(new string[] { $"0x{address.ToString("X")}", cluster.ToString() }); item.Tag = cluster; listView1.Items.Add(item); }
/// <summary> /// Searches for dirent's. /// </summary> /// <param name="worker"></param> private void RecoverMetadata(CancellationToken cancellationToken, IProgress <int> progress) { var maxClusters = _length / _interval; for (uint cluster = 1; cluster < maxClusters; cluster++) { var data = _volume.ReadCluster(cluster); var clusterOffset = (cluster - 1) * _interval; for (int i = 0; i < 256; i++) { var direntOffset = i * 0x40; try { DirectoryEntry dirent = new DirectoryEntry(_volume.Platform, data, direntOffset); if (IsValidDirent(dirent)) { Console.WriteLine(string.Format("0x{0:X8}: {1}", clusterOffset + direntOffset, dirent.FileName)); dirent.Cluster = cluster; dirent.Offset = _volume.ClusterToPhysicalOffset(cluster) + direntOffset; _dirents.Add(dirent); } } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } } if (cluster % 0x100 == 0) { progress?.Report((int)cluster); } if (cancellationToken.IsCancellationRequested) { // NOTE: even though this part of the analyzer returns, // it will continue on with the linking step to clean // up the results while keeping the progress bar // running to show that we are still working. break; } } progress?.Report((int)maxClusters); }
private void DataMap_CellHovered(object sender, EventArgs e) { var cellHoveredEventArgs = e as CellHoveredEventArgs; if (cellHoveredEventArgs != null) { var clusterIndex = CellToClusterIndex(cellHoveredEventArgs.Index); Debug.WriteLine($"Cluster Index: {clusterIndex}"); var occupants = integrityAnalyzer.GetClusterOccupants(clusterIndex); string toolTipMessage = "Cluster Index: " + clusterIndex.ToString() + Environment.NewLine; toolTipMessage += "Cluster Address: 0x" + volume.ClusterToPhysicalOffset(clusterIndex).ToString("X"); if (clusterIndex == volume.RootDirFirstCluster) { toolTipMessage += Environment.NewLine + Environment.NewLine; toolTipMessage += " Type: Root Directory"; } else if (occupants == null) { // TODO: something is off Debug.WriteLine("Something is wrong."); } else if (occupants.Count > 0) { toolTipMessage += Environment.NewLine; int index = 1; foreach (var occupant in occupants) { toolTipMessage += BuildToolTipMessage(index, occupant.GetDirent(), occupant.IsDeleted); index++; } } toolTip1.SetToolTip(this.dataMap, toolTipMessage); } else { toolTip1.SetToolTip(this.dataMap, ""); } }