public void Int64ReadWrite() { Int64 value; Int64 result; value = 20; ResetPosition(); _writer.WriteInt64(value); ResetPosition(); result = _reader.ReadInt64(); Assert.AreEqual(value, result); //Multiple bytes value = 300000000; ResetPosition(); _writer.WriteInt64(value); ResetPosition(); result = _reader.ReadInt64(); Assert.AreEqual(value, result); //Negative Values value = -30; ResetPosition(); _writer.WriteInt64(value); ResetPosition(); result = _reader.ReadInt64(); Assert.AreEqual(value, result); //Int 32 Max Values + 1 value = 2147483648; ResetPosition(); _writer.WriteInt64(value); ResetPosition(); result = _reader.ReadInt64(); Assert.AreEqual(value, result); //Int 32 Min Values - 1 value = -2147483649; ResetPosition(); _writer.WriteInt64(value); ResetPosition(); result = _reader.ReadInt64(); Assert.AreEqual(value, result); }
/// <summary> /// VBLKs may reside in the same sector as the VMDB header. /// </summary> public byte[] GetBytes() { byte[] buffer = new byte[Length]; ByteWriter.WriteAnsiString(buffer, 0x00, Signature, 4); BigEndianWriter.WriteUInt32(buffer, 0x04, NumberOfVBlks); BigEndianWriter.WriteUInt32(buffer, 0x08, BlockSize); BigEndianWriter.WriteUInt32(buffer, 0x0C, HeaderSize); BigEndianWriter.WriteUInt16(buffer, 0x10, (ushort)UpdateStatus); BigEndianWriter.WriteUInt16(buffer, 0x12, MajorVersion); BigEndianWriter.WriteUInt16(buffer, 0x14, MinorVersion); ByteWriter.WriteAnsiString(buffer, 0x16, DiskGroupName, 31); ByteWriter.WriteAnsiString(buffer, 0x35, DiskGroupGuidString, 64); BigEndianWriter.WriteUInt64(buffer, 0x75, CommitTransactionID); BigEndianWriter.WriteUInt64(buffer, 0x7D, PendingTransactionID); BigEndianWriter.WriteUInt32(buffer, 0x85, CommittedTotalNumberOfVolumeRecords); BigEndianWriter.WriteUInt32(buffer, 0x89, CommittedTotalNumberOfComponentRecords); BigEndianWriter.WriteUInt32(buffer, 0x8D, CommittedTotalNumberOfExtentRecords); BigEndianWriter.WriteUInt32(buffer, 0x91, CommittedTotalNumberOfDiskRecords); BigEndianWriter.WriteUInt32(buffer, 0x95, CommittedTotalNumberOfDiskAccessRecords); BigEndianWriter.WriteUInt32(buffer, 0xA1, PendingTotalNumberOfVolumeRecords); BigEndianWriter.WriteUInt32(buffer, 0xA5, PendingTotalNumberOfComponentRecords); BigEndianWriter.WriteUInt32(buffer, 0xA9, PendingTotalNumberOfExtentRecords); BigEndianWriter.WriteUInt32(buffer, 0xAD, PendingTotalNumberOfDiskRecords); BigEndianWriter.WriteUInt32(buffer, 0xB1, PendingTotalNumberOfDiskAccessRecords); BigEndianWriter.WriteInt64(buffer, 0xBD, LastModificationDT.ToFileTimeUtc()); return(buffer); }
private static byte[] GetTestPattern(long sectorIndex, int bytesPerSector) { byte[] pattern = new byte[bytesPerSector]; for (int offset = 0; offset <= bytesPerSector - 8; offset += 8) { BigEndianWriter.WriteInt64(pattern, offset, sectorIndex); } return(pattern); }
private static byte[] GetTestPattern(long sectorIndex, int sectorCount, int bytesPerSector) { byte[] pattern = new byte[sectorCount * bytesPerSector]; for (int sectorOffset = 0; sectorOffset < sectorCount; sectorOffset++) { for (int offsetInSector = 0; offsetInSector <= bytesPerSector - 8; offsetInSector += 8) { BigEndianWriter.WriteInt64(pattern, sectorOffset * bytesPerSector + offsetInSector, sectorIndex + sectorOffset); } } return(pattern); }
public byte[] GetBytes() { byte[] buffer = new byte[Length]; ByteWriter.WriteAnsiString(buffer, 0x00, Signature, 8); // we'll write the checksum later BigEndianWriter.WriteUInt16(buffer, 0x0C, MajorVersion); BigEndianWriter.WriteUInt16(buffer, 0x0E, MinorVersion); BigEndianWriter.WriteInt64(buffer, 0x10, LastUpdateDT.ToFileTimeUtc()); BigEndianWriter.WriteUInt64(buffer, 0x18, UpdateSequenceNumber); BigEndianWriter.WriteUInt64(buffer, 0x20, PrimaryPrivateHeaderLBA); BigEndianWriter.WriteUInt64(buffer, 0x28, SecondaryPrivateHeaderLBA); ByteWriter.WriteAnsiString(buffer, 0x30, DiskGuidString, 0x40); ByteWriter.WriteAnsiString(buffer, 0x70, HostGuidString, 0x40); ByteWriter.WriteAnsiString(buffer, 0xB0, DiskGroupGuidString, 0x40); ByteWriter.WriteAnsiString(buffer, 0xF0, DiskGroupName, 31); BigEndianWriter.WriteUInt32(buffer, 0x10F, BytesPerSector); BigEndianWriter.WriteUInt32(buffer, 0x113, (uint)Flags); BigEndianWriter.WriteUInt16(buffer, 0x117, PublicRegionSliceNumber); BigEndianWriter.WriteUInt16(buffer, 0x119, PrivateRegionSliceNumber); BigEndianWriter.WriteUInt64(buffer, 0x11B, PublicRegionStartLBA); BigEndianWriter.WriteUInt64(buffer, 0x123, PublicRegionSizeLBA); BigEndianWriter.WriteUInt64(buffer, 0x12B, PrivateRegionStartLBA); BigEndianWriter.WriteUInt64(buffer, 0x133, PrivateRegionSizeLBA); BigEndianWriter.WriteUInt64(buffer, 0x13B, PrimaryTocLBA); BigEndianWriter.WriteUInt64(buffer, 0x143, SecondaryTocLBA); BigEndianWriter.WriteUInt32(buffer, 0x14B, NumberOfConfigs); BigEndianWriter.WriteUInt32(buffer, 0x14F, NumberOfLogs); BigEndianWriter.WriteUInt64(buffer, 0x153, ConfigSizeLBA); BigEndianWriter.WriteUInt64(buffer, 0x15B, LogSizeLBA); BigEndianWriter.WriteUInt32(buffer, 0x163, DiskSignature); BigEndianWriter.WriteGuidBytes(buffer, 0x167, DiskSetGuid); BigEndianWriter.WriteGuidBytes(buffer, 0x177, DiskSetGuidRepeat); uint checksum = CalculateChecksum(buffer); BigEndianWriter.WriteUInt32(buffer, 0x08, checksum); return(buffer); }