/// <summary> /// Overwrite a binary image of your FATX Drive /// </summary> /// <param name="xImageDrive"></param> /// <returns></returns> public bool RestoreImage(FATXDrive xImageDrive) { if (ActiveCheck()) { return(false); } return(restoreimg(xImageDrive) & ReloadDrive()); }
public FATXBrowser(FATXDrive xDriveIn, string file, MainForm parent) { InitializeComponent(); CheckForIllegalCrossThreadCalls = false; xDrive = xDriveIn; xthisfile = file; xparent = parent; setdrive(); }
public FATXViewer(FATXDrive drivein, string filein, MainForm par) { InitializeComponent(); node1.Text = drivein.DriveName; if (drivein.IsDriveIO) createDiskImageToolStripMenuItem.Enabled = restoreImageToolStripMenuItem.Enabled = false; xDrive = drivein; xthisfile = filein; xparent = par; set(); }
void rstthrd(object drv) { FATXDrive xImageDrive = (FATXDrive)drv; xImageDrive.GetIO(); GetIO(); xIO.Position = xImageDrive.xIO.Position = 0; for (long i = 0; i < xIO.Length && i < xImageDrive.xIO.Length; i += 0x1000) { xIO.unbufferedwrite(xImageDrive.xIO.ReadBytes(0x1000)); } }
internal FATXEntry(string xNameIn, uint xStart, int xSizeIn, long xPosition, bool xFolder, ref FATXDrive xdrive) { int DT = TimeStamps.FatTimeInt(DateTime.Now); xT1 = DT; xT2 = DT; xT3 = DT; Name = xNameIn; xStartBlock = xStart; xSize = (xIsFolder = xFolder) ? 0 : xSizeIn; xOffset = xPosition; xIsValid = true; xDrive = xdrive; }
bool restoreimg(FATXDrive xImageDrive) { if (xImageDrive == null || xImageDrive.IsDriveIO || !xImageDrive.Success || xImageDrive.Type != xType) { return(xactive = false); } System.Threading.Thread x = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(rstthrd)); x.Start(xImageDrive); while (x.IsAlive) { System.Windows.Forms.Application.DoEvents(); } return(!(xactive = false)); }
internal FATXEntry(ref FATXEntry xEntry, ref FATXDrive xdrive) { xOffset = xEntry.xOffset; xNLen = xEntry.xNLen; xName = xEntry.xName; xStartBlock = xEntry.xStartBlock; xSize = xEntry.xSize; xT1 = xEntry.xT1; xT2 = xEntry.xT2; xT3 = xEntry.xT3; xIsValid = xEntry.xIsValid; xIsFolder = xEntry.IsFolder; xPart = xEntry.xPart; xDrive = xEntry.xDrive; }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (listBox1.SelectedIndex >= 0) { string parse = ((string)listBox1.SelectedItem).Split(new char[] { ':' })[0]; if (!par.Files.Contains(parse)) { button1.Enabled = true; xChosenDrive = xDrives[listBox1.SelectedIndex]; return; } } button1.Enabled = false; xChosenDrive = null; }
/// <summary> /// Restores image via file location /// </summary> /// <param name="ImageLocation"></param> /// <returns></returns> public bool RestoreImage(string ImageLocation) { if (ActiveCheck()) { return(false); } FATXDrive ximg = new FATXDrive(ImageLocation); if (!ximg.Success) { return(xactive = false); } bool success = restoreimg(ximg); ximg.Close(); return(success & ReloadDrive()); }
internal FATXEntry(long Pos, byte[] xData, ref FATXDrive xdrive) { xDrive = xdrive; xOffset = Pos; try { DJsIO xIO = new DJsIO(xData, true); xNLen = xIO.ReadByte(); if (xNLen == 0xE5 || xNLen == 0xFF || xNLen == 0 || xNLen > 0x2A) { return; } byte xatt = (byte)((xIO.ReadByte() >> 4) & 1); byte xLen = (byte)(xNLen & 0x3F); xName = xIO.ReadString(StringForm.ASCII, xLen); xName.IsValidXboxName(); xIO.Position = 0x2C; xStartBlock = xIO.ReadUInt32(); if (xStartBlock == Constants.FATX32End) { return; } xSize = xIO.ReadInt32(); xT1 = xIO.ReadInt32(); xT2 = xIO.ReadInt32(); xT3 = xIO.ReadInt32(); if (xatt == 1) { xIsFolder = true; } else if (xSize == 0) { return; } xIsValid = true; } catch { xIsValid = false; } }
public FATXPartition(long xOffset, long xPartitionSize, FATXDrive xDrive, string xLocaleName) { xdrive = xDrive; xName = xLocaleName; xBase = xOffset; xDrive.GetIO(); xDrive.xIO.IsBigEndian = true; xDrive.xIO.Position = xOffset; string fatX = Encoding.ASCII.GetString(xdrive.xIO.ReadBytes(4).Reverse().ToArray()); if (fatX != "FATX") return; //if (xDrive.xIO.ReadUInt32() != 0x58544146) // return; var VolumeID = xDrive.xIO.ReadUInt32(); // Partition ID (884418784) SectorsPerBlock = xDrive.xIO.ReadUInt32();//Cluster size in (512 byte) sectors uint blockct = (uint)(xPartitionSize / xBlockSize); if (blockct < 0xFFF5 && xLocaleName != "Content") FatType = FATXType.FATX16; else FatType = FATXType.FATX32; uint dirblock = (uint)xdrive.xIO.ReadUInt32(); //Number of FAT copies xFATSize = (int)(blockct * (byte)FatType); xFATSize += (0x1000 - (xFATSize % 0x1000)); xTable = new AllocationTable(new DJsIO(true), (uint)((xPartitionSize - 0x1000 - xFATSize) / xBlockSize), FatType); xTable.xAllocTable.Position = 0; xDrive.xIO.Position = xFATLocale; for (int i = 0; i < xFATSize; i += 0x1000) { var blockBytes = xdrive.xIO.ReadBytes(0x1000); xTable.xAllocTable.Write(blockBytes); } xTable.xAllocTable.Flush(); long DirOffset = BlockToOffset(dirblock); xFolders = new List<FATXFolderEntry>(); xFiles = new List<FATXFileEntry>(); var xEntries = new List<FATXEntry>(); for (byte x = 0; x < xEntryCount; x++) { var offset = (DirOffset + (0x40 * x)); xDrive.xIO.Position = offset; var entry64 = xdrive.xIO.ReadBytes(0x40); FATXEntry z = new FATXEntry(FatType, offset, entry64, ref xdrive); z.SetAtts(this); if (z.xIsValid) { xEntries.Add(z); } else if (z.xNLen == 0xE5) { } else if (z.xNLen != 0xE5) { break; } } foreach (FATXEntry x in xEntries) { if (x.IsFolder) { xFolders.Add(new FATXFolderEntry(null, x, this.PartitionName + "/" + x.Name)); } else { xFiles.Add(new FATXFileEntry(null, x)); } } xExtParts = new List<FATXPartition>(); for (int i = 0; i < xFiles.Count; i++) { if (xFiles[i].Name.ToLower() != "extendedsystem.partition") continue; var x = new FATXPartition( BlockToOffset(xFiles[i].StartBlock), xFiles[i].Size, xdrive, xFiles[i].Name); if (!x.IsValid) continue; xExtParts.Add(x); xFiles.RemoveAt(i--); } }
public FATXEntry(FATXEntry parent, ref FATXEntry xEntry) { this.Parent = parent; //Debug.WriteLine("fatx entry ref"); xOffset = xEntry.xOffset; xNLen = xEntry.xNLen; xName = xEntry.xName; xStartBlock = xEntry.xStartBlock; xSize = xEntry.xSize; xT1 = xEntry.xT1; xT2 = xEntry.xT2; xT3 = xEntry.xT3; xIsValid = xEntry.xIsValid; xIsFolder = xEntry.IsFolder; xPart = xEntry.xPart; xDrive = xEntry.xDrive; fatType = xEntry.fatType; this.xPart = xEntry.xPart; this.FatEntry = xEntry.FatEntry; }
/// <summary> /// Restores image via file location /// </summary> /// <param name="ImageLocation"></param> /// <returns></returns> public bool RestoreImage(string ImageLocation) { if (ActiveCheck()) return false; FATXDrive ximg = new FATXDrive(ImageLocation); if (!ximg.Success) return xactive = false; bool success = restoreimg(ximg); ximg.Close(); return success & ReloadDrive(); }
bool restoreimg(FATXDrive xImageDrive) { if (xImageDrive == null || xImageDrive.IsDriveIO || !xImageDrive.Success || xImageDrive.Type != xType) return (xactive = false); rstthrd(xImageDrive); //System.Threading.Thread x = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(rstthrd)); //x.Start(xImageDrive); //while (x.IsAlive) // System.Windows.Forms.Application.DoEvents(); return !(xactive = false); }
private void openImageToolStripMenuItem_Click(object sender, EventArgs e) { string xfilez = X360.Other.VariousFunctions.GetUserFileLocale("Open a file", "Binary Image|*.bin|All Files|*.*", true); if (xfilez == null) return; if (par.Files.Contains(xfilez)) { MessageBox.Show("Error: Already opened"); return; } FATXDrive xBU = xChosenDrive; try { xChosenDrive = new FATXDrive(xfilez); } catch (Exception x) { xChosenDrive = xBU; MessageBox.Show(x.Message); return; } xfile = xfilez; DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// Overwrite a binary image of your FATX Drive /// </summary> /// <param name="xImageDrive"></param> /// <returns></returns> public bool RestoreImage(FATXDrive xImageDrive) { if (ActiveCheck()) return false; return restoreimg(xImageDrive) & ReloadDrive(); }
internal FATXFolderEntry(FATXEntry xEntry, ref FATXDrive xdrive) : base(ref xEntry, ref xdrive) { }
public FATXEntry(FATXType fatType, long Pos, byte[] xData, ref FATXDrive xdrive) { FatEntry = new FATXEntry64(xData); this.fatType = fatType; this.xDrive = xdrive; this.xIsFolder = FatEntry.Attribute != 0xFF && ((FatEntry.Attribute & 0x10) == 0x10); this.xName = FatEntry.FileNameStr; this.xNLen = FatEntry.FileNameSize; this.xStartBlock = FatEntry.FirstCluster; this.xSize = FatEntry.FileSize; this.xT1 = FatEntry.ModDate; this.xT2 = FatEntry.CreateDate; this.xT3 = FatEntry.AccessedDate; this.fatType = fatType; xDrive = xdrive; xOffset = Pos; xIsValid = this.FatEntry.IsValid; /* try { DJsIO xIO = new DJsIO(xData, true); xNLen = xIO.ReadByte(); if (xNLen == 0xE5 || xNLen == 0xFF || xNLen == 0 || xNLen > 0x2A) return; byte xatt = (byte)((xIO.ReadByte() >> 4) & 1); byte xLen = (byte)(xNLen & 0x3F); xName = xIO.ReadString(StringForm.ASCII, xLen); xName.IsValidXboxName(); xIO.Position = 0x2C; xStartBlock = xIO.ReadUInt32(); if (fatType == FATXType.FATX32) { if (xStartBlock == Constants.FATX32End) return; }else if (fatType == FATXType.FATX16) { if (xStartBlock == Constants.FATX16End) return; } xSize = xIO.ReadInt32(); xT1 = xIO.ReadInt32(); xT2 = xIO.ReadInt32(); xT3 = xIO.ReadInt32(); if (xatt == 1) xIsFolder = true; else if (xSize == 0) return; xIsValid = true; } catch { xIsValid = false; }*/ }
public void Close() { if (opened) { try { drive.Close(); drive = null; } catch { drive = null; } opened = false; } }
internal FATXPartition(long xOffset, long xPartitionSize, FATXDrive xDrive, string xLocaleName) { xdrive = xDrive; xName = xLocaleName; xBase = xOffset; xDrive.GetIO(); xDrive.xIO.IsBigEndian = true; xDrive.xIO.Position = xOffset; if (xDrive.xIO.ReadUInt32() != 0x58544146) { return; } xDrive.xIO.ReadBytes(4); // Partition ID SectorsPerBlock = xDrive.xIO.ReadUInt32(); uint blockct = (uint)(xPartitionSize / xBlockSize); if (blockct < 0xFFF5) { FatType = FATXType.FATX16; } else { FatType = FATXType.FATX32; } uint dirblock = xdrive.xIO.ReadUInt32(); xFATSize = (int)(blockct * (byte)FatType); xFATSize += (0x1000 - (xFATSize % 0x1000)); xTable = new AllocationTable(new DJsIO(true), (uint)((xPartitionSize - 0x1000 - xFATSize) / xBlockSize), FatType); xTable.xAllocTable.Position = 0; xDrive.xIO.Position = xFATLocale; for (int i = 0; i < xFATSize; i += 0x1000) { xTable.xAllocTable.Write(xdrive.xIO.ReadBytes(0x1000)); } xTable.xAllocTable.Flush(); long DirOffset = BlockToOffset(dirblock); xFolders = new List <FATXFolderEntry>(); xFiles = new List <FATXFileEntry>(); List <FATXEntry> xEntries = new List <FATXEntry>(); for (byte x = 0; x < xEntryCount; x++) { xDrive.xIO.Position = DirOffset + (0x40 * x); FATXEntry z = new FATXEntry((DirOffset + (0x40 * x)), xdrive.xIO.ReadBytes(0x40), ref xdrive); z.SetAtts(this); if (z.xIsValid) { xEntries.Add(z); } else if (z.xNLen != 0xE5) { break; } } foreach (FATXEntry x in xEntries) { if (x.IsFolder) { xFolders.Add(new FATXFolderEntry(x, ref xdrive)); } else { xFiles.Add(new FATXFileEntry(x, ref xdrive)); } } xExtParts = new List <FATXPartition>(); for (int i = 0; i < xFiles.Count; i++) { if (xFiles[i].Name.ToLower() != "extendedsystem.partition") { continue; } FATXPartition x = new FATXPartition(BlockToOffset(xFiles[i].StartBlock), xFiles[i].Size, xdrive, xFiles[i].Name); if (!x.IsValid) { continue; } xExtParts.Add(x); xFiles.RemoveAt(i--); } }
public FATXEntry(FATXEntry parent, string xNameIn, uint xStart, int xSizeIn, long xPosition, bool xFolder, ref FATXDrive xdrive) { Debug.WriteLine("fatx string " + xNameIn); int DT = TimeStamps.FatTimeInt(DateTime.Now); xT1 = DT; xT2 = DT; xT3 = DT; Name = xNameIn; xStartBlock = xStart; xSize = (xIsFolder = xFolder) ? 0 : xSizeIn; xOffset = xPosition; xIsValid = true; xDrive = xdrive; }
internal FATXPartition(long xOffset, long xPartitionSize, FATXDrive xDrive, string xLocaleName) { xdrive = xDrive; xName = xLocaleName; xBase = xOffset; xDrive.GetIO(); xDrive.xIO.IsBigEndian = true; xDrive.xIO.Position = xOffset; if (xDrive.xIO.ReadUInt32() != 0x58544146) return; xDrive.xIO.ReadBytes(4); // Partition ID SectorsPerBlock = xDrive.xIO.ReadUInt32(); uint blockct = (uint)(xPartitionSize / xBlockSize); if (blockct < 0xFFF5) FatType = FATXType.FATX16; else FatType = FATXType.FATX32; uint dirblock = xdrive.xIO.ReadUInt32(); xFATSize = (int)(blockct * (byte)FatType); xFATSize += (0x1000 - (xFATSize % 0x1000)); xTable = new AllocationTable(new DJsIO(true), (uint)((xPartitionSize - 0x1000 - xFATSize) / xBlockSize), FatType); xTable.xAllocTable.Position = 0; xDrive.xIO.Position = xFATLocale; for (int i = 0; i < xFATSize; i += 0x1000) xTable.xAllocTable.Write(xdrive.xIO.ReadBytes(0x1000)); xTable.xAllocTable.Flush(); long DirOffset = BlockToOffset(dirblock); xFolders = new List<FATXFolderEntry>(); xFiles = new List<FATXFileEntry>(); List<FATXEntry> xEntries = new List<FATXEntry>(); for (byte x = 0; x < xEntryCount; x++) { xDrive.xIO.Position = DirOffset + (0x40 * x); FATXEntry z = new FATXEntry((DirOffset + (0x40 * x)), xdrive.xIO.ReadBytes(0x40), ref xdrive); z.SetAtts(this); if (z.xIsValid) xEntries.Add(z); else if (z.xNLen != 0xE5) break; } foreach (FATXEntry x in xEntries) { if (x.IsFolder) xFolders.Add(new FATXFolderEntry(x, ref xdrive)); else xFiles.Add(new FATXFileEntry(x, ref xdrive)); } xExtParts = new List<FATXPartition>(); for (int i = 0; i < xFiles.Count; i++) { if (xFiles[i].Name.ToLower() != "extendedsystem.partition") continue; FATXPartition x = new FATXPartition(BlockToOffset(xFiles[i].StartBlock), xFiles[i].Size, xdrive, xFiles[i].Name); if (!x.IsValid) continue; xExtParts.Add(x); xFiles.RemoveAt(i--); } }
internal FATXFileEntry(FATXEntry x, ref FATXDrive xdrive) : base(ref x, ref xdrive) { }
public bool Open() { if (!opened) { try { drive = new FATXDrive(device); RefreshPartitions(); opened = true; return true; } catch { } } return false; }
void ReadFile(string file) { try { switch (VariousFunctions.ReadFileType(file)) { case XboxFileType.STFS: { LogRecord x = new LogRecord(); STFSPackage xPackage = new STFSPackage(file, x); if (!xPackage.ParseSuccess) return; PackageExplorer xExplorer = new PackageExplorer(this); xExplorer.listBox4.Items.AddRange(x.Log); x.WhenLogged += new LogRecord.OnLog(xExplorer.xAddLog); xExplorer.set(ref xPackage); xExplorer.Show(); } break; case XboxFileType.SVOD: { SVODPackage hd = new SVODPackage(file, null); if (!hd.IsValid) return; HDDGameForm frm = new HDDGameForm(hd, file, this); frm.MdiParent = this; frm.Show(); } break; case XboxFileType.Music: { MusicFile xfile = new MusicFile(file); MusicView xview = new MusicView(this, file, xfile); xview.MdiParent = this; xview.Show(); } break; case XboxFileType.GPD: { GameGPD y = new GameGPD(file, 0xFFFFFFFF); GPDViewer z = new GPDViewer(y, file, this); z.MdiParent = this; z.Show(); } break; case XboxFileType.FATX: { FATXDrive xdrive = new FATXDrive(file); Files.Add(file); FATXBrowser y = new FATXBrowser(xdrive, file, this); y.MdiParent = this; y.Show(); } break; case XboxFileType.GDF: { StatsForm x = new StatsForm(0); x.Text = "Select Deviation"; if (x.ShowDialog() != DialogResult.OK) return; GDFImage ximg = new GDFImage(file, x.ChosenID); if (!ximg.Valid) throw new Exception("Invalid package"); GDFViewer xViewer = new GDFViewer(ximg, this); xViewer.MdiParent = this; xViewer.Show(); } break; default: MessageBox.Show("Error: Unknown file"); return; } Files.Add(file); } catch (Exception x) { MessageBox.Show(x.Message); } }
internal FATXEntry(long Pos, byte[] xData, ref FATXDrive xdrive) { xDrive = xdrive; xOffset = Pos; try { DJsIO xIO = new DJsIO(xData, true); xNLen = xIO.ReadByte(); if (xNLen == 0xE5 || xNLen == 0xFF || xNLen == 0 || xNLen > 0x2A) return; byte xatt = (byte)((xIO.ReadByte() >> 4) & 1); byte xLen = (byte)(xNLen & 0x3F); xName = xIO.ReadString(StringForm.ASCII, xLen); xName.IsValidXboxName(); xIO.Position = 0x2C; xStartBlock = xIO.ReadUInt32(); if (xStartBlock == Constants.FATX32End) return; xSize = xIO.ReadInt32(); xT1 = xIO.ReadInt32(); xT2 = xIO.ReadInt32(); xT3 = xIO.ReadInt32(); if (xatt == 1) xIsFolder = true; else if (xSize == 0) return; xIsValid = true; } catch { xIsValid = false; } }