private void writeGDFsizes(CBinaryWriter bw) { long length = bw.BaseStream.Length; bw.Seek(8L, SeekOrigin.Begin); bw.Write(length - 0x400L); uint num2 = (uint)(length / 2048.0); bw.Seek(0x8050L, SeekOrigin.Begin); bw.Write(num2); bw.Endian = EndianType.BigEndian; bw.Seek(0x8054L, SeekOrigin.Begin); bw.Write(num2); bw.Endian = EndianType.LittleEndian; }
private void writeFiles(GDF src, CBinaryWriter bw, GDFDirTable table) { foreach (GDFDirEntry entry in table) { if (!entry.IsDirectory) { bw.Seek(entry.Sector * src.VolDesc.SectorSize, SeekOrigin.Begin); string path = ""; calcPath(table, entry, ref path); if (path.StartsWith(@"\")) { path = path.Remove(0, 1); } Console.WriteLine("+ Writing '" + path + "' at Sector 0x" + entry.Sector.ToString("X02") + "..."); src.WriteFileToStream(path, bw); } } foreach (GDFDirEntry entry2 in table) { if (entry2.IsDirectory && (entry2.SubDir != null)) { writeFiles(src, bw, entry2.SubDir); } } }
private void writeGDFheader(GDF src, CBinaryWriter bw) { bw.Seek(0L, SeekOrigin.Begin); bw.Write((uint)0x1a465358); bw.Write((uint)0x400); bw.Seek(0x8000L, SeekOrigin.Begin); bw.Write(gdf_sector); bw.Seek(0x10000L, SeekOrigin.Begin); bw.Write(src.VolDesc.Identifier); bw.Write(rootDir.Sector); bw.Write(sizeToSectors(src, rootDir.Size) * src.VolDesc.SectorSize); bw.Write(src.VolDesc.ImageCreationTime); bw.Write((byte)1); bw.Seek(0x107ecL, SeekOrigin.Begin); bw.Write(src.VolDesc.Identifier); }
private void writeFiles(GDF src, CBinaryWriter bw, GDFDirTable table) { uint fileCount = src.FileCount; foreach (GDFDirEntry entry in table) { if (!entry.IsDirectory) { bw.Seek((long)(entry.Sector * src.VolDesc.SectorSize), SeekOrigin.Begin); string path = ""; this.calcPath(table, entry, ref path); if (path.StartsWith(@"\")) { path = path.Remove(0, 1); } this.progress += ((1f / ((float)fileCount)) * 0.45f) * 100f; base.ReportProgress((int)this.progress, "Writing '" + path + "' at Sector 0x" + entry.Sector.ToString("X02") + "..."); src.WriteFileToStream(path, bw); } } foreach (GDFDirEntry entry2 in table) { if (entry2.IsDirectory && (entry2.SubDir != null)) { this.writeFiles(src, bw, entry2.SubDir); } } }
private void writeGDFheader(MemoryStream ms) { CBinaryWriter writer = new CBinaryWriter(EndianType.LittleEndian, ms); writer.Seek(0L, SeekOrigin.Begin); writer.Write((uint)0x1a465358); writer.Write((uint)0x400); writer.Seek(0x8000L, SeekOrigin.Begin); writer.Write(gdf_sector); writer.Seek(0x10000L, SeekOrigin.Begin); writer.Write(this.src.VolDesc.Identifier); writer.Write(this.tables[this.tables.Count - 1].Sector); writer.Write((uint)(this.sizeToSectors(this.tables[this.tables.Count - 1].Size) * this.src.VolDesc.SectorSize)); writer.Write(this.src.VolDesc.ImageCreationTime); writer.Write((byte)1); writer.Seek(0x107ecL, SeekOrigin.Begin); writer.Write(this.src.VolDesc.Identifier); writer.Close(); }
private void writeGDFtable(GDF src, CBinaryWriter bw, GDFDirTable table) { bw.Seek(table.Sector * src.VolDesc.SectorSize, SeekOrigin.Begin); byte[] buffer = table.ToByteArray(); bw.Write(buffer); foreach (GDFDirEntry entry in table) { if (entry.IsDirectory && (entry.SubDir != null)) { writeGDFtable(src, bw, entry.SubDir); } } }
public void WriteGDF(CBinaryWriter bw) { MemoryStream ms = new MemoryStream(); ms.Seek(0x12000L, SeekOrigin.Begin); for (int i = this.tables.Count - 1; i >= 0; i--) { if (this.tables[i].Size > 0) { byte[] buffer = this.tables[i].ToByteArray(); ms.Write(buffer, 0, buffer.Length); } } this.writeGDFheader(ms); bw.Seek(0L, SeekOrigin.Begin); bw.Write(ms.ToArray()); ms.Close(); }
public void WriteData(CBinaryWriter bw) { for (int i = this.tables.Count - 1; i >= 0; i--) { foreach (GDFDirEntry entry in this.tables[i]) { if (!entry.IsDirectory) { string path = ""; this.calcPath(this.tables[i], entry, ref path); if (path.StartsWith(@"\")) { path = path.Remove(0, 1); } bw.Seek((long)(entry.Sector * this.src.VolDesc.SectorSize), SeekOrigin.Begin); this.src.WriteFileToStream(path, bw); } } } this.writeGDFsizes(bw); }
public void Write(string FilePath) { bw.Seek(0x35bL, SeekOrigin.Begin); bw.Write((byte)0); bw.Seek(0x35fL, SeekOrigin.Begin); bw.Write((byte)0); bw.Seek(0x391L, SeekOrigin.Begin); bw.Write((byte)0); WriteHash(); FileStream stream = new FileStream(FilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.None); stream.Write(buffer, 0, buffer.Length); stream.Close(); }