public uint Version; // 2.12 public void ReadFrom(byte[] buffer, int offset) { Signature = EndianUtilities.BytesToString(buffer, offset + 0x00, 8); Checksum = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x08); Version = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x0C); Timestamp = DateTime.FromFileTimeUtc(EndianUtilities.ToInt64BigEndian(buffer, offset + 0x10)); Unknown2 = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x18); Unknown3 = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x20); Unknown4 = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x28); DiskId = EndianUtilities.BytesToString(buffer, offset + 0x30, 0x40).Trim('\0'); HostId = EndianUtilities.BytesToString(buffer, offset + 0x70, 0x40).Trim('\0'); DiskGroupId = EndianUtilities.BytesToString(buffer, offset + 0xB0, 0x40).Trim('\0'); DiskGroupName = EndianUtilities.BytesToString(buffer, offset + 0xF0, 31).Trim('\0'); Unknown5 = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x10F); DataStartLba = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x11B); DataSizeLba = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x123); ConfigurationStartLba = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x12B); ConfigurationSizeLba = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x133); TocSizeLba = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x13B); NextTocLba = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x143); // These two may be reversed NumberOfConfigs = EndianUtilities.ToInt32BigEndian(buffer, offset + 0x14B); NumberOfLogs = EndianUtilities.ToInt32BigEndian(buffer, offset + 0x14F); ConfigSizeLba = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x153); LogSizeLba = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x15B); }
public int ReadFrom(byte[] buffer, int offset) { Count4Bytes = buffer[offset]; Count8Bytes = buffer[offset + 0x1]; byte count; _useShortInode = true; Parent = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x2); if (Count8Bytes != 0) { _useShortInode = false; count = Count8Bytes; } else if (Count4Bytes != 0) { count = Count4Bytes; } else { count = 0; } offset = offset + 10 - (_useShortInode?4:0);//sizeof(struct xfs_dir2_sf_hdr) - (i8count == 0) * (XFS_INO64_SIZE - XFS_INO32_SIZE); Entries = new ShortformDirectoryEntry[count]; for (int i = 0; i < count; i++) { var entry = new ShortformDirectoryEntry(_useShortInode, has_ftype); entry.ReadFrom(buffer, offset); offset += entry.Size; Entries[i] = entry; } return(Size); }
public int ReadFrom(byte[] buffer, int offset) { Count4Bytes = buffer[offset]; Count8Bytes = buffer[offset + 0x1]; byte count; _useShortInode = false; Parent = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x2); offset = offset + 0x6; if (Count4Bytes != 0) { _useShortInode = true; count = Count4Bytes; } else if (Count8Bytes != 0) { count = Count8Bytes; } else { count = 0; } Entries = new ShortformDirectoryEntry[count]; for (int i = 0; i < count; i++) { var entry = new ShortformDirectoryEntry(_useShortInode); entry.ReadFrom(buffer, offset); offset += entry.Size; Entries[i] = entry; } return(Size); }
public int ReadFrom(byte[] buffer, int offset) { Magic = EndianUtilities.ToUInt32BigEndian(buffer, offset); Version = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x4); SequenceNumber = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x8); Length = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xC); RootBlockNumbers = new uint[2]; RootBlockNumbers[0] = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x10); RootBlockNumbers[1] = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x14); Spare0 = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x18); Levels = new uint[2]; Levels[0] = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x1C); Levels[1] = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x20); Spare1 = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x24); FreeListFirst = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x28); FreeListLast = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x2C); FreeListCount = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x30); FreeBlocks = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x34); Longest = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x38); BTreeBlocks = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x3C); if (SbVersion >= 5) { UniqueId = EndianUtilities.ToGuidBigEndian(buffer, offset + 0x40); Lsn = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x50); Crc = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x58); } return(Size); }
public int ReadFrom(byte[] buffer, int offset) { Count4Bytes = buffer[offset]; Count8Bytes = buffer[offset + 0x1]; byte count = Count4Bytes; _useShortInode = Count8Bytes == 0; offset += 0x2; if (_useShortInode) { Parent = EndianUtilities.ToUInt32BigEndian(buffer, offset); offset += 0x4; } else { Parent = EndianUtilities.ToUInt64BigEndian(buffer, offset); offset += 0x8; } Entries = new ShortformDirectoryEntry[count]; for (int i = 0; i < count; i++) { var entry = new ShortformDirectoryEntry(_useShortInode, _context); entry.ReadFrom(buffer, offset); offset += entry.Size; Entries[i] = entry; } return(Size); }
private DateTime ReadTimestamp(byte[] buffer, int offset) { var seconds = EndianUtilities.ToUInt32BigEndian(buffer, offset); var nanoSeconds = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x4); return(((long)seconds).FromUnixTimeSeconds().AddTicks(nanoSeconds / 100).LocalDateTime); }
public void Parse(byte[] headerData, int headerOffset, byte[] bodyData) { BasicHeaderSegment _headerSegment = new BasicHeaderSegment(); _headerSegment.ReadFrom(headerData, headerOffset); if (_headerSegment.OpCode != OpCode.LoginResponse) { throw new InvalidProtocolException("Invalid opcode in response, expected " + OpCode.LoginResponse + " was " + _headerSegment.OpCode); } UnpackState(headerData[headerOffset + 1]); MaxVersion = headerData[headerOffset + 2]; ActiveVersion = headerData[headerOffset + 3]; TargetSessionId = EndianUtilities.ToUInt16BigEndian(headerData, headerOffset + 14); StatusPresent = true; StatusSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 24); ExpectedCommandSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 28); MaxCommandSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 32); StatusClass = headerData[headerOffset + 36]; StatusCode = (LoginStatusCode)EndianUtilities.ToUInt16BigEndian(headerData, headerOffset + 36); TextData = bodyData; }
public int ReadFrom(byte[] buffer, int offset) { StartInode = EndianUtilities.ToUInt32BigEndian(buffer, offset); FreeCount = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x4); Free = new BitArray(EndianUtilities.ToByteArray(buffer, offset + 0x8, 0x8)); return(Size); }
public ushort VersionNum; // 00 04 public void ReadFrom(byte[] buffer, int offset) { Signature = EndianUtilities.BytesToString(buffer, offset + 0x00, 4); NumVBlks = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x04); BlockSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x08); HeaderSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x0C); Unknown1 = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x10); VersionNum = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x12); VersionDenom = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x14); GroupName = EndianUtilities.BytesToString(buffer, offset + 0x16, 31).Trim('\0'); DiskGroupId = EndianUtilities.BytesToString(buffer, offset + 0x35, 0x40).Trim('\0'); // May be wrong way round... CommittedSequence = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x75); PendingSequence = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x7D); Unknown2 = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x85); Unknown3 = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x89); Unknown4 = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x8D); Unknown5 = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x91); Unknown6 = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x95); Unknown7 = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x9D); Unknown8 = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xA5); Unknown9 = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xA9); UnknownA = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xAD); UnknownB = EndianUtilities.ToInt64BigEndian(buffer, offset + 0xB1); UnknownC = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xB9); Timestamp = DateTime.FromFileTimeUtc(EndianUtilities.ToInt64BigEndian(buffer, offset + 0xBD)); }
public void Parse(byte[] headerData, int headerOffset, byte[] bodyData) { Header = new BasicHeaderSegment(); Header.ReadFrom(headerData, headerOffset); if (Header.OpCode != OpCode.ScsiDataIn) { throw new InvalidProtocolException("Invalid opcode in response, expected " + OpCode.ScsiDataIn + " was " + Header.OpCode); } UnpackFlags(headerData[headerOffset + 1]); if (StatusPresent) { Status = (ScsiStatus)headerData[headerOffset + 3]; } Lun = EndianUtilities.ToUInt64BigEndian(headerData, headerOffset + 8); TargetTransferTag = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 20); StatusSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 24); ExpectedCommandSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 28); MaxCommandSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 32); DataSequenceNumber = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 36); BufferOffset = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 40); ResidualCount = EndianUtilities.ToUInt32BigEndian(headerData, headerOffset + 44); ReadData = bodyData; }
public int ReadFrom(byte[] buffer, int offset) { this.Signature = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0); this.Version = EndianUtilities.ToUInt32BigEndian(buffer, offset + 4); this.HeaderSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 8); this.Flags = EndianUtilities.ToUInt32BigEndian(buffer, offset + 12); this.RunningDataForkOffset = EndianUtilities.ToUInt64BigEndian(buffer, offset + 16); this.DataForkOffset = EndianUtilities.ToUInt64BigEndian(buffer, offset + 24); this.DataForkLength = EndianUtilities.ToUInt64BigEndian(buffer, offset + 32); this.RsrcForkOffset = EndianUtilities.ToUInt64BigEndian(buffer, offset + 40); this.RsrcForkLength = EndianUtilities.ToUInt64BigEndian(buffer, offset + 48); this.SegmentNumber = EndianUtilities.ToUInt32BigEndian(buffer, offset + 56); this.SegmentCount = EndianUtilities.ToUInt32BigEndian(buffer, offset + 60); this.SegmentGuid = EndianUtilities.ToGuidBigEndian(buffer, offset + 64); this.DataForkChecksum = EndianUtilities.ToStruct <UdifChecksum>(buffer, offset + 80); this.XmlOffset = EndianUtilities.ToUInt64BigEndian(buffer, offset + 216); this.XmlLength = EndianUtilities.ToUInt64BigEndian(buffer, offset + 224); this.MasterChecksum = EndianUtilities.ToStruct <UdifChecksum>(buffer, offset + 352); this.ImageVariant = EndianUtilities.ToUInt32BigEndian(buffer, offset + 488); this.SectorCount = EndianUtilities.ToInt64BigEndian(buffer, offset + 492); return(this.Size); }
public int ReadFrom(byte[] buffer, int offset) { DataSize = EndianUtilities.ToUInt32BigEndian(buffer, offset); NumBlocks = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 4); return(Size); }
public int ReadFrom(byte[] buffer, int offset) { StartBlock = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0); BlockCount = EndianUtilities.ToUInt32BigEndian(buffer, offset + 4); return(8); }
public int ReadFrom(byte[] buffer, int offset) { Magic = EndianUtilities.ToUInt32BigEndian(buffer, offset); Version = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x4); SequenceNumber = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x8); Length = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0xc); Count = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x10); Root = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x14); Level = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x18); FreeCount = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x1c); NewInode = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x20); DirInode = EndianUtilities.ToInt32BigEndian(buffer, offset + 0x24); Unlinked = new int[64]; for (int i = 0; i < Unlinked.Length; i++) { Unlinked[i] = EndianUtilities.ToInt32BigEndian(buffer, offset + 0x28 + i * 0x4); } if (SbVersion >= 5) { UniqueId = EndianUtilities.ToGuidBigEndian(buffer, offset + 0x132); Lsn = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x142); Crc = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x14A); } return(Size); }
public int ReadFrom(byte[] buffer, int offset) { Magic = EndianUtilities.ToUInt32BigEndian(buffer, offset); BestFree = new BlockDirectoryDataFree[3]; offset += 0x4; for (int i = 0; i < BestFree.Length; i++) { var free = new BlockDirectoryDataFree(); offset += free.ReadFrom(buffer, offset); BestFree[i] = free; } var entries = new List <BlockDirectoryData>(); var eof = buffer.Length; while (offset < eof) { BlockDirectoryData entry; if (buffer[offset] == 0xff && buffer[offset + 0x1] == 0xff) { //unused entry = new BlockDirectoryDataUnused(); } else { entry = new BlockDirectoryDataEntry(); } offset += entry.ReadFrom(buffer, offset); entries.Add(entry); } Entries = entries.ToArray(); return(buffer.Length - offset); }
public static byte[] Receive(Stream stream) { MemoryStream ms = null; bool lastFragFound = false; while (!lastFragFound) { byte[] header = StreamUtilities.ReadExact(stream, 4); uint headerVal = EndianUtilities.ToUInt32BigEndian(header, 0); lastFragFound = (headerVal & 0x80000000) != 0; byte[] frag = StreamUtilities.ReadExact(stream, (int)(headerVal & 0x7FFFFFFF)); if (ms != null) { ms.Write(frag, 0, frag.Length); } else if (!lastFragFound) { ms = new MemoryStream(); ms.Write(frag, 0, frag.Length); } else { return(frag); } } return(ms.ToArray()); }
public int ReadFrom(byte[] buffer, int offset) { offset += ReadHeader(buffer, offset); BestFree = new BlockDirectoryDataFree[3]; for (int i = 0; i < BestFree.Length; i++) { var free = new BlockDirectoryDataFree(); offset += free.ReadFrom(buffer, offset); BestFree[i] = free; } offset += HeaderPadding; LeafStale = EndianUtilities.ToUInt32BigEndian(buffer, buffer.Length - 0x4); LeafCount = EndianUtilities.ToUInt32BigEndian(buffer, buffer.Length - 0x8); var entries = new List <BlockDirectoryData>(); var eof = buffer.Length - 0x8 - LeafCount * 0x8; while (offset < eof) { BlockDirectoryData entry; if (buffer[offset] == 0xff && buffer[offset + 0x1] == 0xff) { //unused entry = new BlockDirectoryDataUnused(); } else { entry = new BlockDirectoryDataEntry(_context); } offset += entry.ReadFrom(buffer, offset); entries.Add(entry); } Entries = entries.ToArray(); return(buffer.Length - offset); }
public int ReadFrom(byte[] buffer, int offset) { RecordType = (CatalogRecordType)EndianUtilities.ToInt16BigEndian(buffer, offset + 0); ParentId = EndianUtilities.ToUInt32BigEndian(buffer, offset + 4); Name = HfsPlusUtilities.ReadUniStr255(buffer, offset + 8); return(0); }
public override int ReadFrom(byte[] buffer, int offset) { _keyLength = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0); NodeId = new CatalogNodeId(EndianUtilities.ToUInt32BigEndian(buffer, offset + 2)); Name = HfsUtilities.ReadUniStr255(buffer, offset + 6); return(_keyLength + 2); }
public override int ReadFrom(byte[] buffer, int offset) { this.keyLength = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0); this.forkType = buffer[offset + 2]; this.NodeId = new CatalogNodeId(EndianUtilities.ToUInt32BigEndian(buffer, offset + 4)); this.startBlock = EndianUtilities.ToUInt32BigEndian(buffer, offset + 8); return this.keyLength + 2; }
public int ReadFrom(byte[] buffer, int offset) { this.Type = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0); this.ChecksumSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 4); this.Data = EndianUtilities.ToByteArray(buffer, offset + 8, 128); return(136); }
public static DateTime ReadHfsDate(DateTimeKind kind, byte[] buffer, int offset) { uint val = EndianUtilities.ToUInt32BigEndian(buffer, offset); DateTime epoch = new DateTime(1904, 1, 1, 0, 0, 0, 0, kind); DateTime result = epoch.AddSeconds(val); return(result); }
/// <inheritdoc/> public override int ReadFrom(byte[] buffer, int offset) { int read = base.ReadFrom(buffer, offset); this.Flags = EndianUtilities.ToUInt16BigEndian(buffer, offset + 2); this.Valence = EndianUtilities.ToUInt32BigEndian(buffer, offset + 4); return(read + 6); }
public override int ReadFrom(byte[] buffer, int offset) { base.ReadFrom(buffer, offset); Flags = EndianUtilities.ToUInt16BigEndian(buffer, offset + 2); Valence = EndianUtilities.ToUInt32BigEndian(buffer, offset + 4); return(0); }
public int ReadFrom(byte[] buffer, int offset) { FileType = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0); FileCreator = EndianUtilities.ToUInt32BigEndian(buffer, offset + 4); FinderFlags = (FinderFlags)EndianUtilities.ToUInt16BigEndian(buffer, offset + 8); Point = EndianUtilities.ToStruct <Point>(buffer, offset + 10); return(16); }
public virtual int ReadFrom(byte[] buffer, int offset) { Magic = EndianUtilities.ToUInt32BigEndian(buffer, offset); Level = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x4); NumberOfRecords = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0x6); LeftSibling = EndianUtilities.ToInt64BigEndian(buffer, offset + 0x8); RightSibling = EndianUtilities.ToInt64BigEndian(buffer, offset + 0xC); return(24); }
public int ReadFrom(byte[] buffer, int offset) { HeaderSize = EndianUtilities.ToUInt32BigEndian(buffer, offset); TotalSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 4); DataSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 8); Flags = EndianUtilities.ToUInt32BigEndian(buffer, offset + 12); return(Size); }
protected override int ReadHeader(byte[] buffer, int offset) { Magic = EndianUtilities.ToUInt32BigEndian(buffer, offset); Crc = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0x04); BlockNumber = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x08); LogSequenceNumber = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0x10); Uuid = EndianUtilities.ToGuidBigEndian(buffer, offset + 0x18); Owner = EndianUtilities.ToUInt64BigEndian(buffer, 0x28); return(0x30); }
public int ReadFrom(byte[] buffer, int offset) { Immediate = (buffer[offset] & 0x40) != 0; OpCode = (OpCode)(buffer[offset] & 0x3F); FinalPdu = (buffer[offset + 1] & 0x80) != 0; TotalAhsLength = buffer[offset + 4]; DataSegmentLength = EndianUtilities.ToInt32BigEndian(buffer, offset + 4) & 0x00FFFFFF; InitiatorTaskTag = EndianUtilities.ToUInt32BigEndian(buffer, offset + 16); return(48); }
public int ReadFrom(byte[] buffer, int offset) { Type = (RunType)EndianUtilities.ToUInt32BigEndian(buffer, offset + 0); SectorStart = EndianUtilities.ToInt64BigEndian(buffer, offset + 8); SectorCount = EndianUtilities.ToInt64BigEndian(buffer, offset + 16); CompOffset = EndianUtilities.ToInt64BigEndian(buffer, offset + 24); CompLength = EndianUtilities.ToInt64BigEndian(buffer, offset + 32); return(40); }