:py:mod:`dissect.hypervisor.disk.vdi` ===================================== .. py:module:: dissect.hypervisor.disk.vdi Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: dissect.hypervisor.disk.vdi.VDI dissect.hypervisor.disk.vdi.VDIStream .. py:class:: VDI(fh: BinaryIO | pathlib.Path, parent: BinaryIO | None = None) VirtualBox Virtual Disk Image (VDI) implementation. Use :method:`open` to get a stream for reading from the VDI file. The stream will handle reading from the parent disk if necessary (and provided). If provided with a file-like object, the caller is responsible for closing it. When provided with a path, the VDI class will manage the file handle. If providing a parent file-like object, the caller is responsible for the lifecycle of that object. :param fh: File-like object or path of the VDI file. :param parent: Optional file-like object for the parent disk (for differencing disks). .. py:attribute:: parent :value: None .. py:attribute:: preheader .. py:attribute:: header .. py:method:: __enter__() -> Self .. py:method:: __exit__(exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: types.TracebackType | None) -> None .. py:property:: type :type: dissect.hypervisor.disk.c_vdi.c_vdi.VDI_IMAGE_TYPE The type of the VDI file. .. py:property:: flags :type: dissect.hypervisor.disk.c_vdi.c_vdi.VDI_IMAGE_FLAGS The flags of the VDI file. .. py:property:: size :type: int The size of the virtual disk. .. py:property:: block_size :type: int The size of each block in the VDI file. .. py:property:: data_offset :type: int The offset to the data blocks. .. py:property:: blocks_offset :type: int The offset to the block allocation table. .. py:property:: number_of_blocks :type: int The number of blocks in the VDI file. .. py:method:: open() -> VDIStream Open a stream to read from the VDI file. .. py:method:: close() -> None Close the VDI file handle. .. py:class:: VDIStream(vdi: VDI) Bases: :py:obj:`dissect.util.stream.AlignedStream` Basic buffered stream that provides aligned reads. Must be subclassed for various stream implementations. Subclasses can implement: - :meth:`~AlignedStream._read` - :meth:`~AlignedStream._seek` The offset and length for ``_read`` are guaranteed to be aligned for streams of a known size. If your stream has an unknown size (i.e. ``size == None``), reads of length ``-1`` (i.e. read until EOF) will be passed through to your implementation of ``_read``. The only time that overriding ``_seek`` would make sense is if there's no known size of your stream, but still want to provide ``SEEK_END`` functionality. Most subclasses of ``AlignedStream`` take one or more file-like objects as source. Operations on these subclasses, like reading, will modify the source file-like object as a side effect. :param size: The size of the stream. This is used in read and seek operations. ``None`` if unknown. :param align: The alignment size. Read operations are aligned on this boundary. Also determines buffer size. .. automethod:: _read .. automethod:: _seek .. py:attribute:: vdi .. py:attribute:: block_size .. py:attribute:: fh .. py:attribute:: map