public void Read(Stream stream) { var rw = new StreamRW(stream); HeaderSignature = rw.ReadBytes(8); CheckSignature(); CLSID = rw.ReadBytes(16); MinorVersion = rw.ReadUInt16(); MajorVersion = rw.ReadUInt16(); CheckVersion(); ByteOrder = rw.ReadUInt16(); SectorShift = rw.ReadUInt16(); MiniSectorShift = rw.ReadUInt16(); UnUsed = rw.ReadBytes(6); DirectorySectorsNumber = rw.ReadInt32(); FATSectorsNumber = rw.ReadInt32(); FirstDirectorySectorId = rw.ReadInt32(); UnUsed2 = rw.ReadUInt32(); MinSizeStandardStream = rw.ReadUInt32(); FirstMiniFATSectorId = rw.ReadInt32(); MiniFATSectorsNumber = rw.ReadUInt32(); FirstDIFATSectorId = rw.ReadInt32(); DIFATSectorsNumber = rw.ReadUInt32(); for (var i = 0; i < 109; i++) { DIFAT[i] = rw.ReadInt32(); } rw.Close(); }
public void Write(Stream stream) { StreamRW rw = new StreamRW(stream); rw.Write(headerSignature); rw.Write(clsid); rw.Write(minorVersion); rw.Write(majorVersion); rw.Write(byteOrder); rw.Write(sectorShift); rw.Write(miniSectorShift); rw.Write(unUsed); rw.Write(directorySectorsNumber); rw.Write(fatSectorsNumber); rw.Write(firstDirectorySectorID); rw.Write(unUsed2); rw.Write(minSizeStandardStream); rw.Write(firstMiniFATSectorID); rw.Write(miniFATSectorsNumber); rw.Write(firstDIFATSectorID); rw.Write(difatSectorsNumber); foreach (int i in difat) { rw.Write(i); } if (majorVersion == 4) { byte[] zeroHead = new byte[3584]; rw.Write(zeroHead); } rw.Close(); }
public void Write(Stream stream) { var rw = new StreamRW(stream); rw.Write(HeaderSignature); rw.Write(CLSID); rw.Write(MinorVersion); rw.Write(MajorVersion); rw.Write(ByteOrder); rw.Write(SectorShift); rw.Write(MiniSectorShift); rw.Write(UnUsed); rw.Write(DirectorySectorsNumber); rw.Write(FATSectorsNumber); rw.Write(FirstDirectorySectorId); rw.Write(UnUsed2); rw.Write(MinSizeStandardStream); rw.Write(FirstMiniFATSectorId); rw.Write(MiniFATSectorsNumber); rw.Write(FirstDIFATSectorId); rw.Write(DIFATSectorsNumber); foreach (var i in DIFAT) { rw.Write(i); } if (MajorVersion == 4) { var zeroHead = new byte[3584]; rw.Write(zeroHead); } rw.Close(); }
public void Read(Stream stream) { StreamRW rw = new StreamRW(stream); headerSignature = rw.ReadBytes(8); CheckSignature(); clsid = rw.ReadBytes(16); minorVersion = rw.ReadUInt16(); majorVersion = rw.ReadUInt16(); CheckVersion(); byteOrder = rw.ReadUInt16(); sectorShift = rw.ReadUInt16(); miniSectorShift = rw.ReadUInt16(); unUsed = rw.ReadBytes(6); directorySectorsNumber = rw.ReadInt32(); fatSectorsNumber = rw.ReadInt32(); firstDirectorySectorID = rw.ReadInt32(); unUsed2 = rw.ReadUInt32(); minSizeStandardStream = rw.ReadUInt32(); firstMiniFATSectorID = rw.ReadInt32(); miniFATSectorsNumber = rw.ReadUInt32(); firstDIFATSectorID = rw.ReadInt32(); difatSectorsNumber = rw.ReadUInt32(); for (int i = 0; i < 109; i++) { this.DIFAT[i] = rw.ReadInt32(); } rw.Close(); }
//public Byte[] ToByteArray() //{ // MemoryStream ms // = new MemoryStream(128); // BinaryWriter bw = new BinaryWriter(ms); // byte[] paddedName = new byte[64]; // Array.Copy(entryName, paddedName, entryName.Length); // bw.Write(paddedName); // bw.Write(nameLength); // bw.Write((byte)stgType); // bw.Write((byte)stgColor); // bw.Write(leftSibling); // bw.Write(rightSibling); // bw.Write(child); // bw.Write(storageCLSID.ToByteArray()); // bw.Write(stateBits); // bw.Write(creationDate); // bw.Write(modifyDate); // bw.Write(startSetc); // bw.Write(size); // return ms.ToArray(); //} public void Read(Stream stream) { StreamRW rw = new StreamRW(stream); entryName = rw.ReadBytes(64); nameLength = rw.ReadUInt16(); stgType = (StgType)rw.ReadByte(); //rw.ReadByte();//Ignore color, only black tree stgColor = (StgColor)rw.ReadByte(); leftSibling = rw.ReadInt32(); rightSibling = rw.ReadInt32(); child = rw.ReadInt32(); // Thanks to bugaccount (BugTrack id 3519554) if (stgType == StgType.StgInvalid) { leftSibling = NOSTREAM; rightSibling = NOSTREAM; child = NOSTREAM; } storageCLSID = new Guid(rw.ReadBytes(16)); stateBits = rw.ReadInt32(); creationDate = rw.ReadBytes(8); modifyDate = rw.ReadBytes(8); startSetc = rw.ReadInt32(); size = rw.ReadInt64(); }
public void Write(Stream stream) { StreamRW rw = new StreamRW(stream); rw.Write(EntryName); rw.Write(nameLength); rw.Write((byte)stgType); rw.Write((byte)stgColor); rw.Write(leftSibling); rw.Write(rightSibling); rw.Write(child); rw.Write(storageCLSID.ToByteArray()); rw.Write(stateBits); rw.Write(CreationDate); rw.Write(ModifyDate); rw.Write(startSetc); rw.Write(size); rw.Close(); }
//public Byte[] ToByteArray() //{ // MemoryStream ms // = new MemoryStream(128); // BinaryWriter bw = new BinaryWriter(ms); // byte[] paddedName = new byte[64]; // Array.Copy(entryName, paddedName, entryName.Length); // bw.Write(paddedName); // bw.Write(nameLength); // bw.Write((byte)stgType); // bw.Write((byte)stgColor); // bw.Write(leftSibling); // bw.Write(rightSibling); // bw.Write(child); // bw.Write(storageCLSID.ToByteArray()); // bw.Write(stateBits); // bw.Write(creationDate); // bw.Write(modifyDate); // bw.Write(startSetc); // bw.Write(size); // return ms.ToArray(); //} public void Read(Stream stream, CFSVersion ver = CFSVersion.Ver_3) { StreamRW rw = new StreamRW(stream); entryName = rw.ReadBytes(64); nameLength = rw.ReadUInt16(); stgType = (StgType)rw.ReadByte(); //rw.ReadByte();//Ignore color, only black tree stgColor = (StgColor)rw.ReadByte(); leftSibling = rw.ReadInt32(); rightSibling = rw.ReadInt32(); child = rw.ReadInt32(); // Thanks to bugaccount (BugTrack id 3519554) if (stgType == StgType.StgInvalid) { leftSibling = NOSTREAM; rightSibling = NOSTREAM; child = NOSTREAM; } storageCLSID = new Guid(rw.ReadBytes(16)); stateBits = rw.ReadInt32(); creationDate = rw.ReadBytes(8); modifyDate = rw.ReadBytes(8); startSetc = rw.ReadInt32(); if (ver == CFSVersion.Ver_3) { // avoid dirty read for version 3 files (max size: 32bit integer) // where most significant bits are not initialized to zero size = rw.ReadInt32(); rw.ReadBytes(4); //discard most significant 4 (possibly) dirty bytes } else { size = rw.ReadInt64(); } }
//public Byte[] ToByteArray() //{ // MemoryStream ms // = new MemoryStream(128); // BinaryWriter bw = new BinaryWriter(ms); // byte[] paddedName = new byte[64]; // Array.Copy(entryName, paddedName, entryName.Length); // bw.Write(paddedName); // bw.Write(nameLength); // bw.Write((byte)stgType); // bw.Write((byte)stgColor); // bw.Write(leftSibling); // bw.Write(rightSibling); // bw.Write(child); // bw.Write(storageCLSID.ToByteArray()); // bw.Write(stateBits); // bw.Write(creationDate); // bw.Write(modifyDate); // bw.Write(startSetc); // bw.Write(size); // return ms.ToArray(); //} public void Read(Stream stream, CFSVersion version) { StreamRW rw = new StreamRW(stream); entryName = rw.ReadBytes(64); nameLength = rw.ReadUInt16(); stgType = (StgType)rw.ReadByte(); rw.ReadByte();//Ignore color, only black tree //stgColor = (StgColor)br.ReadByte(); leftSibling = rw.ReadInt32(); rightSibling = rw.ReadInt32(); child = rw.ReadInt32(); // Thank you to bugaccount (BugTrack id 3519554) if (stgType == StgType.StgInvalid) { leftSibling = NOSTREAM; rightSibling = NOSTREAM; child = NOSTREAM; } storageCLSID = new Guid(rw.ReadBytes(16)); stateBits = rw.ReadInt32(); creationDate = rw.ReadBytes(8); modifyDate = rw.ReadBytes(8); startSetc = rw.ReadInt32(); if (version == CFSVersion.Ver_3) { size = rw.ReadInt32(); var rest = rw.ReadInt32(); } else { size = rw.ReadInt64(); } }
public void Write(Stream stream) { StreamRW rw = new StreamRW(stream); rw.Write(entryName); rw.Write(nameLength); rw.Write((byte)stgType); rw.Write((byte)stgColor); rw.Write(leftSibling); rw.Write(rightSibling); rw.Write(child); rw.Write(storageCLSID.ToByteArray()); rw.Write(stateBits); rw.Write(creationDate); rw.Write(modifyDate); rw.Write(startSetc); rw.Write(size); rw.Close(); }