Beispiel #1
0
 public File(FATXDrive DRIVE, PartitionInfo partition)
 {
     PartInfo = partition;
     e = new Entries(this);
     Drive = DRIVE;
     Misc = new Misc();
 }
Beispiel #2
0
 public Folder(FATXDrive DRIVE, PartitionInfo partition)
 {
     PartInfo = partition;
     e = new Entries(this);
     Drive = DRIVE;
     Misc = new Misc();
     isfolder = true;
 }
Beispiel #3
0
 public Write(FATXDrive drive)
 {
     ourDrive = drive;
     m = new Misc();
 }
Beispiel #4
0
 /// <summary>
 /// Returns an array of valid FATXDrives
 /// </summary>
 public FATX.FATXDrive[] GetFATXDrives(int range)
 {
     List<FATX.FATXDrive> driveList = new List<FATX.FATXDrive>();
     ///Gets physical disks
     for (int i = 0; i < range; i++)
     {
         try
         {
             //Start reading the physical drive
             fs = fs_diskStream(i);
             br = br_diskReader(i);
             //Seek to the FATX partition
             //try
             //{
                 br.BaseStream.Position = (long)FATX.Info.HDDFATX.Partitions.Data;
                 //Read the header
                 byte[] header = br.ReadBytes(0x4);
                 //Convert the header to a string, check if it's fatx
                 if (Encoding.ASCII.GetString(header) == "XTAF")
                 {
                     FATX.FATXDrive drive = new FATXDrive(i, FATX.Info.DriveType.HDD);
                     driveList.Add(drive);
                 }
             //}
             //catch{ }
             br.Close();
             fs.Close();
             diskDrive.Close();
             bool closed = diskDrive.IsClosed;
         }
         catch { fs.Close(); br.Close(); diskDrive.Close(); }
     }
     ///Gets usb drives
     List<string> driveLetters = new List<string>();
     char[] DriveLetters = new char[26] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
     //Loop for each possible drive letter
     for (int i = 0; i < DriveLetters.Length; i++)
     {
         //Create a new drive info
         DriveInfo di = new DriveInfo(DriveLetters[i].ToString());
         //If the drive doesn't exist, it will return false, so if it's true, it exists
         if (di.IsReady)
         {
             //Add it to the drive letters
             driveLetters.Add(DriveLetters[i].ToString());
         }
     }
     ///Check to see if the drive has a subdirectory of "Xbox360"
     List<string> indexesToRemove = new List<string>();
     for (int i = 0; i < driveLetters.Count; i++)
     {
         //If the directory does not exist
         DirectoryInfo di = new DirectoryInfo(driveLetters[i] + ":\\Xbox360");
         if (!di.Exists)
         {
             //Remove the drive from the list
             indexesToRemove.Add(driveLetters[i]);
         }
         else
         {
             //Check to make sure that there's actually files in that directory..
             FileInfo[] fi = di.GetFiles();
             if (fi[0].Name != "Data0000")
             {
                 indexesToRemove.Add(driveLetters[i]);
             }
         }
     }
     for (int i = 0; i < indexesToRemove.Count; i++)
     {
         driveLetters.Remove(indexesToRemove[i]);
     }
     ///Finally create our new FATXDrive...
     for (int i = 0; i < driveLetters.Count; i++)
     {
         driveList.Add(new FATXDrive(driveLetters[i] + ":\\Xbox360", Info.DriveType.USB));
     }
     return driveList.ToArray();
 }
Beispiel #5
0
 /// <summary>
 /// Provides partition/FAT information
 /// </summary>
 public FATStuff(Entry entry)
 {
     ourDrive = (FATXDrive)entry.Drive;
     Partition = entry.PartInfo;
 }
Beispiel #6
0
 public FATStuff(FATXDrive Drive, Info.HDDFATX.Partitions p)
 {
     ourDrive = Drive;
     Partition.Name = p.ToString();
     Partition.Offset = (long)p;
 }
Beispiel #7
0
 public FATStuff(FATXDrive Drive, long partitionOffset)
 {
     ourDrive = Drive;
     Partition.Name = "Root";
     Partition.Offset = partitionOffset;
 }
Beispiel #8
0
 /// <summary>
 /// Provides partition/FAT information
 /// </summary>
 public FATStuff(FATXDrive Drive, Folder partition)
 {
     ourDrive = Drive;
     Partition = partition.PartInfo;
 }
Beispiel #9
0
        /// <summary>
        /// Returns the readable partitions as folders on the drive
        /// </summary>
        public Folder[] Get(FATXDrive xDrive)
        {
            List<Folder> PIList = new List<Folder>();
            if (xDrive.DriveType == Info.DriveType.HDD | xDrive.DriveType == Info.DriveType.Backup)
            {
                foreach (Info.HDDFATX.Partitions e in Enum.GetValues(typeof(Info.HDDFATX.Partitions)))
                {
                    if (e == Info.HDDFATX.Partitions.Data | e == Info.HDDFATX.Partitions.Compatibility)
                    {
                        FATStuff FS = new FATStuff(xDrive, e);
                        if (FS.Magic() == "XTAF")
                        {
                            PartitionInfo PI = new PartitionInfo();
                            PI.ClusterSize = FS.ClusterSize();
                            PI.DataOffset = FS.DataOffset();
                            PI.FATCopies = FS.FATCopies();
                            PI.FATOffset = FS.FATOffset;
                            PI.FATSize = FS.FATSize();
                            PI.ID = FS.PartitionID();
                            PI.Magic = FS.Magic();
                            PI.Name = e.ToString();
                            PI.Offset = (long)e;
                            PI.SectorsPerCluster = FS.SectorsPerCluster();
                            PI.EntrySize = FS.bit;
                            PI.Size = FS.PartitionSize();
                            Folder f = new Folder(xDrive, PI);
                            f.EData.StartingCluster = 0;
                            PIList.Add(f);
                        }
                    }
                }

                if (PIList.Count == 0)
                {
                    FATStuff FS = new FATStuff(xDrive, (long)0);
                    if (FS.Magic() == "XTAF")
                    {
                        PartitionInfo PI = new PartitionInfo();
                        PI.ClusterSize = FS.ClusterSize();
                        PI.DataOffset = FS.DataOffset();
                        PI.FATCopies = FS.FATCopies();
                        PI.FATOffset = FS.FATOffset;
                        PI.FATSize = FS.FATSize();
                        PI.ID = FS.PartitionID();
                        PI.Magic = FS.Magic();
                        PI.Name = "Root";
                        PI.Offset = 0x0;
                        PI.SectorsPerCluster = FS.SectorsPerCluster();
                        PI.EntrySize = FS.bit;
                        PI.Size = xDrive.DriveSize;
                        Folder f = new Folder(xDrive, PI);
                        PIList.Add(f);
                    }
                }
            }
            else if (xDrive.DriveType == Info.DriveType.USB)
            {
                foreach (Info.USBOffsets e in Enum.GetValues(typeof(Info.USBOffsets)))
                {
                    FATStuff FS = new FATStuff(xDrive, (long)e);
                    if (FS.Magic() == "XTAF")
                    {
                        PartitionInfo PI = new PartitionInfo();
                        PI.ClusterSize = FS.ClusterSize();
                        PI.DataOffset = FS.DataOffset();
                        PI.FATCopies = FS.FATCopies();
                        PI.FATOffset = FS.FATOffset;
                        PI.FATSize = FS.FATSize();
                        PI.ID = FS.PartitionID();
                        PI.Magic = FS.Magic();
                        PI.Name = e.ToString();
                        PI.Offset = (long)e;
                        PI.SectorsPerCluster = FS.SectorsPerCluster();
                        PI.EntrySize = FS.bit;
                        PI.Size = FS.PartitionSize();
                        Folder f = new Folder(xDrive, PI);
                        f.EData.StartingCluster = 0;
                        PIList.Add(f);
                    }
                }
            }
            else if (PIList.Count == 0)
            {
                if (System.Windows.Forms.MessageBox.Show("No partitions were found.  Would you like to use the Manual Partition tool to set the offset yourself?", "No Partitions Found", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    PartitionInfo PI = new PartitionInfo();
                    Manual_Partition mp = new Manual_Partition(ref PI);
                    if (mp.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        PI = mp.ReturnInfo;
                        FATStuff FS = new FATStuff(xDrive, PI.Offset);
                        if (FS.Magic() == "XTAF")
                        {
                            PI.ClusterSize = FS.ClusterSize();
                            PI.DataOffset = FS.DataOffset();
                            PI.FATCopies = FS.FATCopies();
                            PI.FATOffset = FS.FATOffset;
                            PI.FATSize = FS.FATSize();
                            PI.ID = FS.PartitionID();
                            PI.Magic = FS.Magic();
                            PI.Name = "Root";
                            PI.SectorsPerCluster = FS.SectorsPerCluster();
                            PI.EntrySize = FS.bit;
                            PI.Size = FS.PartitionSize();
                            Folder f = new Folder(xDrive, PI);
                            f.EData.StartingCluster = 0;
                            PIList.Add(f);
                        }
                    }
                }
            }
            return PIList.ToArray();
        }