/// <summary> /// Initializes a new instance of the RegistryHive class. /// </summary> /// <param name="hive">The stream containing the registry hive</param> /// <param name="ownership">Whether the new object assumes object of the stream</param> public RegistryHive(Stream hive, Ownership ownership) { _fileStream = hive; _fileStream.Position = 0; _ownsStream = ownership; byte[] buffer = Utilities.ReadFully(_fileStream, HiveHeader.HeaderSize); _header = new HiveHeader(); _header.ReadFrom(buffer, 0); _bins = new List <BinHeader>(); int pos = 0; while (pos < _header.Length) { _fileStream.Position = BinStart + pos; byte[] headerBuffer = Utilities.ReadFully(_fileStream, BinHeader.HeaderSize); BinHeader header = new BinHeader(); header.ReadFrom(headerBuffer, 0); _bins.Add(header); pos += header.BinSize; } }
public Bin(RegistryHive hive, Stream stream) { _hive = hive; _fileStream = stream; _streamPos = stream.Position; stream.Position = _streamPos; byte[] buffer = Utilities.ReadFully(stream, 0x20); _header = new BinHeader(); _header.ReadFrom(buffer, 0); _fileStream.Position = _streamPos; _buffer = Utilities.ReadFully(_fileStream, _header.BinSize); // Gather list of all free cells. _freeCells = new List<Range<int, int>>(); int pos = 0x20; while (pos < _buffer.Length) { int size = Utilities.ToInt32LittleEndian(_buffer, pos); if (size > 0) { _freeCells.Add(new Range<int, int>(pos, size)); } pos += Math.Abs(size); } }
public Bin(RegistryHive hive, Stream stream) { _hive = hive; _fileStream = stream; _streamPos = stream.Position; stream.Position = _streamPos; byte[] buffer = Utilities.ReadFully(stream, 0x20); _header = new BinHeader(); _header.ReadFrom(buffer, 0); _fileStream.Position = _streamPos; _buffer = Utilities.ReadFully(_fileStream, _header.BinSize); // Gather list of all free cells. _freeCells = new List <Range <int, int> >(); int pos = 0x20; while (pos < _buffer.Length) { int size = Utilities.ToInt32LittleEndian(_buffer, pos); if (size > 0) { _freeCells.Add(new Range <int, int>(pos, size)); } pos += Math.Abs(size); } }