1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Utilities;
- namespace DiskAccessLibrary.VMDK
- {
- public class SparseExtentHeader
- {
- private const string ValidSignature = "KDMV";
- public string Signature;
- public uint Version;
- public uint Flags;
- public ulong Capacity;
- public ulong GrainSize;
- public ulong DescriptorOffset;
- public ulong DescriptorSize;
- public uint NumGTEsPerGT;
- public ulong RGDOffset;
- public ulong GDOffset;
- public ulong OverHead;
- public bool UncleanShutdown;
- public char SingleEndLineChar;
- public char NonEndLineChar;
- public char DoubleEndLineChar1;
- public char DoubleEndLineChar2;
- public ushort CompressionAlgirithm;
- public SparseExtentHeader()
- {
- }
- public SparseExtentHeader(byte[] buffer)
- {
- Signature = ByteReader.ReadAnsiString(buffer, 0x00, 4);
- Version = LittleEndianConverter.ToUInt32(buffer, 0x04);
- Flags = LittleEndianConverter.ToUInt32(buffer, 0x08);
- Capacity = LittleEndianConverter.ToUInt64(buffer, 0x0C);
- GrainSize = LittleEndianConverter.ToUInt64(buffer, 0x14);
- DescriptorOffset = LittleEndianConverter.ToUInt64(buffer, 0x1C);
- DescriptorSize = LittleEndianConverter.ToUInt64(buffer, 0x24);
- NumGTEsPerGT = LittleEndianConverter.ToUInt32(buffer, 0x2C);
- RGDOffset = LittleEndianConverter.ToUInt64(buffer, 0x30);
- GDOffset = LittleEndianConverter.ToUInt64(buffer, 0x38);
- OverHead = LittleEndianConverter.ToUInt64(buffer, 0x40);
- UncleanShutdown = ByteReader.ReadByte(buffer, 0x48) == 1;
- SingleEndLineChar = (char)ByteReader.ReadByte(buffer, 0x49);
- NonEndLineChar = (char)ByteReader.ReadByte(buffer, 0x4A);
- DoubleEndLineChar1 = (char)ByteReader.ReadByte(buffer, 0x4B);
- DoubleEndLineChar2 = (char)ByteReader.ReadByte(buffer, 0x4C);
- CompressionAlgirithm = (char)LittleEndianConverter.ToUInt16(buffer, 0x4D);
- }
- public bool IsValid
- {
- get
- {
- return String.Equals(Signature, ValidSignature);
- }
- }
- public bool IsValidAndSupported
- {
- get
- {
- return this.IsValid && (Version == 1) && (CompressionAlgirithm == 0);
- }
- }
- }
- }
|