ComboundFileParser (version 0.0.1)
index
comboundfileparser.py

This module implements a Compound file parser (file format used by OLE
and base file format for macros, msi, msg, doc, xls...)

 
Classes
       
_CompoundFile(abc.ABC)
CompoundFile
CompoundFileFromBytes
CompoundFileFromName
_ctypes.PyCStructType(builtins.type)
CombinedMeta(abc.ABCMeta, _ctypes.PyCStructType)
_ctypes.Structure(_ctypes._CData)
CompoundFileHeaderVersion3
CompoundFileHeaderVersion4
StructureBuilder
CompoundFileHeader
DirectoryEntry
abc.ABCMeta(builtins.type)
CombinedMeta(abc.ABCMeta, _ctypes.PyCStructType)
builtins.object
Entry

 
class CombinedMeta(abc.ABCMeta, _ctypes.PyCStructType)
    CombinedMeta(name, bases, attrs)
 
This function makes a new "master type" to resolve conflicts
between two metaclasses.
 
 
Method resolution order:
CombinedMeta
abc.ABCMeta
_ctypes.PyCStructType
builtins.type
builtins.object

Static methods defined here:
__new__(cls, name, bases, attrs)
Create and return a new object.  See help(type) for accurate signature.

Data and other attributes defined here:
__annotations__ = {}

Methods inherited from abc.ABCMeta:
__instancecheck__(cls, instance)
Override for isinstance(instance, cls).
__subclasscheck__(cls, subclass)
Override for issubclass(subclass, cls).
register(cls, subclass)
Register a virtual subclass of an ABC.
 
Returns the subclass, to allow usage as a class decorator.

Methods inherited from _ctypes.PyCStructType:
__delattr__(self, name, /)
Implement delattr(self, name).
__mul__(self, value, /)
Return self*value.
__rmul__(self, value, /)
Return value*self.
__setattr__(self, name, value, /)
Implement setattr(self, name, value).
from_address(...)
C.from_address(integer) -> C instance
access a C instance at the specified address
from_buffer(...)
C.from_buffer(object, offset=0) -> C instance
create a C instance from a writeable buffer
from_buffer_copy(...)
C.from_buffer_copy(object, offset=0) -> C instance
create a C instance from a readable buffer
from_param(...)
Convert a Python object into a function call parameter.
in_dll(...)
C.in_dll(dll, name) -> C instance
access a C instance in a dll

Methods inherited from builtins.type:
__call__(self, /, *args, **kwargs)
Call self as a function.
__dir__(self, /)
Specialized __dir__ implementation for types.
__getattribute__(self, name, /)
Return getattr(self, name).
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.
__or__(self, value, /)
Return self|value.
__repr__(self, /)
Return repr(self).
__ror__(self, value, /)
Return value|self.
__sizeof__(self, /)
Return memory consumption of the type object.
__subclasses__(self, /)
Return a list of immediate subclasses.
mro(self, /)
Return a type's method resolution order.

Class methods inherited from builtins.type:
__prepare__(...) from builtins.type
__prepare__() -> dict
used to create the namespace for the class statement

Data descriptors inherited from builtins.type:
__abstractmethods__
__dict__
__text_signature__

Data and other attributes inherited from builtins.type:
__base__ = <class 'abc.ABCMeta'>
Metaclass for defining Abstract Base Classes (ABCs).
 
Use this metaclass to create an ABC.  An ABC can be subclassed
directly, and then acts as a mix-in class.  You can also register
unrelated concrete classes (even built-in classes) and unrelated
ABCs as 'virtual subclasses' -- these and their descendants will
be considered subclasses of the registering ABC by the built-in
issubclass() function, but the registering ABC won't show up in
their MRO (Method Resolution Order) nor will method
implementations defined by the registering ABC be callable (not
even via super()).
__bases__ = (<class 'abc.ABCMeta'>, <class '_ctypes.PyCStructType'>)
__basicsize__ = 888
__dictoffset__ = 264
__flags__ = 2148029952
__itemsize__ = 40
__mro__ = (<class 'ComboundFileParser.CombinedMeta'>, <class 'abc.ABCMeta'>, <class '_ctypes.PyCStructType'>, <class 'type'>, <class 'object'>)
__weakrefoffset__ = 368

 
class CompoundFile(_CompoundFile)
    CompoundFile(file: _io._BufferedIOBase)
 
This class implements methods for compound file parsing from a binary file.
 
 
Method resolution order:
CompoundFile
_CompoundFile
abc.ABC
builtins.object

Methods defined here:
__enter__(self)
__exit__(self, exc_type, exc_value, traceback) -> False
__init__(self, file: _io._BufferedIOBase)
Initialize self.  See help(type(self)) for accurate signature.
check_block_list(self, check_name: str, first_block: int, sectors_number: int) -> None
This methods performs checks on metadata before parsing blocks.
check_specials_values(self, sector: int, difat: bool = False)
This methods checks for special values.
close(self) -> None
This method closes the file.
follow_sectors(self, sectors: List[ctypes.c_ulong], sector: ctypes.c_ulong, difat: bool = False) -> None
This method loop over sector to find all sectors.
get_childs(self, index: int, indexes: Set[int] = set(), parent_name: str = './', recursive: bool = False) -> Iterable[ComboundFileParser.Entry]
This methods yields DirectoryEntries for a directory.
get_door_entries(self, index: int, indexes: Set[int], parent_name: str, recursive: bool) -> Iterable[ComboundFileParser.Entry]
This methods returns left an right sibling directory entry.
get_file_content(self, entry: ComboundFileParser.Entry)
This methods returns file content.
load_sector(self, sector: int) -> ~ArrayUInt32
This methods loads a sector from file.
parse(self) -> None
This method parses the compound file.
parse_get_blocks_list(self, first_block: int, block_list: List[ctypes.c_ulong] = None, size: int = None) -> Tuple[List[ctypes.c_ulong], List[ctypes.c_ulong]]
This methods uses the FAT table to retrieve
a list of sectors to identify data location.
process_directories(self) -> None
This methods is a part of parsing compound file to gets directories.
process_mini_fat(self) -> None
This methods gets mini FAT sectors.
process_sector(self, sector: ctypes.c_ulong, difat: bool = False) -> None
This method parses a FAT sector.
read(self, size: int) -> bytes
This method returns `size` next bytes of the binary file.
read_mini_sector(self, sector: int, size: int) -> bytes
This methods reads a mini sector from root entry.
read_sector(self, sector: int, size: int) -> bytes
This methods reads a sector from file.
seek(self, position: int, mode: int = 0) -> int
This method moves to the position relative to `mode`.

Data and other attributes defined here:
__abstractmethods__ = frozenset()

Data descriptors inherited from _CompoundFile:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class CompoundFileFromBytes(CompoundFile)
    CompoundFileFromBytes(data: bytes)
 
This class implements methods for compound file parsing from data bytes.
 
 
Method resolution order:
CompoundFileFromBytes
CompoundFile
_CompoundFile
abc.ABC
builtins.object

Methods defined here:
__init__(self, data: bytes)
Initialize self.  See help(type(self)) for accurate signature.

Data and other attributes defined here:
__abstractmethods__ = frozenset()

Methods inherited from CompoundFile:
__enter__(self)
__exit__(self, exc_type, exc_value, traceback) -> False
check_block_list(self, check_name: str, first_block: int, sectors_number: int) -> None
This methods performs checks on metadata before parsing blocks.
check_specials_values(self, sector: int, difat: bool = False)
This methods checks for special values.
close(self) -> None
This method closes the file.
follow_sectors(self, sectors: List[ctypes.c_ulong], sector: ctypes.c_ulong, difat: bool = False) -> None
This method loop over sector to find all sectors.
get_childs(self, index: int, indexes: Set[int] = set(), parent_name: str = './', recursive: bool = False) -> Iterable[ComboundFileParser.Entry]
This methods yields DirectoryEntries for a directory.
get_door_entries(self, index: int, indexes: Set[int], parent_name: str, recursive: bool) -> Iterable[ComboundFileParser.Entry]
This methods returns left an right sibling directory entry.
get_file_content(self, entry: ComboundFileParser.Entry)
This methods returns file content.
load_sector(self, sector: int) -> ~ArrayUInt32
This methods loads a sector from file.
parse(self) -> None
This method parses the compound file.
parse_get_blocks_list(self, first_block: int, block_list: List[ctypes.c_ulong] = None, size: int = None) -> Tuple[List[ctypes.c_ulong], List[ctypes.c_ulong]]
This methods uses the FAT table to retrieve
a list of sectors to identify data location.
process_directories(self) -> None
This methods is a part of parsing compound file to gets directories.
process_mini_fat(self) -> None
This methods gets mini FAT sectors.
process_sector(self, sector: ctypes.c_ulong, difat: bool = False) -> None
This method parses a FAT sector.
read(self, size: int) -> bytes
This method returns `size` next bytes of the binary file.
read_mini_sector(self, sector: int, size: int) -> bytes
This methods reads a mini sector from root entry.
read_sector(self, sector: int, size: int) -> bytes
This methods reads a sector from file.
seek(self, position: int, mode: int = 0) -> int
This method moves to the position relative to `mode`.

Data descriptors inherited from _CompoundFile:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class CompoundFileFromName(CompoundFile)
    CompoundFileFromName(filename: str)
 
This class implements methods for compound file parsing from a filename.
 
 
Method resolution order:
CompoundFileFromName
CompoundFile
_CompoundFile
abc.ABC
builtins.object

Methods defined here:
__init__(self, filename: str)
Initialize self.  See help(type(self)) for accurate signature.

Data and other attributes defined here:
__abstractmethods__ = frozenset()

Methods inherited from CompoundFile:
__enter__(self)
__exit__(self, exc_type, exc_value, traceback) -> False
check_block_list(self, check_name: str, first_block: int, sectors_number: int) -> None
This methods performs checks on metadata before parsing blocks.
check_specials_values(self, sector: int, difat: bool = False)
This methods checks for special values.
close(self) -> None
This method closes the file.
follow_sectors(self, sectors: List[ctypes.c_ulong], sector: ctypes.c_ulong, difat: bool = False) -> None
This method loop over sector to find all sectors.
get_childs(self, index: int, indexes: Set[int] = set(), parent_name: str = './', recursive: bool = False) -> Iterable[ComboundFileParser.Entry]
This methods yields DirectoryEntries for a directory.
get_door_entries(self, index: int, indexes: Set[int], parent_name: str, recursive: bool) -> Iterable[ComboundFileParser.Entry]
This methods returns left an right sibling directory entry.
get_file_content(self, entry: ComboundFileParser.Entry)
This methods returns file content.
load_sector(self, sector: int) -> ~ArrayUInt32
This methods loads a sector from file.
parse(self) -> None
This method parses the compound file.
parse_get_blocks_list(self, first_block: int, block_list: List[ctypes.c_ulong] = None, size: int = None) -> Tuple[List[ctypes.c_ulong], List[ctypes.c_ulong]]
This methods uses the FAT table to retrieve
a list of sectors to identify data location.
process_directories(self) -> None
This methods is a part of parsing compound file to gets directories.
process_mini_fat(self) -> None
This methods gets mini FAT sectors.
process_sector(self, sector: ctypes.c_ulong, difat: bool = False) -> None
This method parses a FAT sector.
read(self, size: int) -> bytes
This method returns `size` next bytes of the binary file.
read_mini_sector(self, sector: int, size: int) -> bytes
This methods reads a mini sector from root entry.
read_sector(self, sector: int, size: int) -> bytes
This methods reads a sector from file.
seek(self, position: int, mode: int = 0) -> int
This method moves to the position relative to `mode`.

Data descriptors inherited from _CompoundFile:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class CompoundFileHeader(StructureBuilder)
    This class implements a C Structure for the Combound File Headers.
 
 
Method resolution order:
CompoundFileHeader
StructureBuilder
_ctypes.Structure
_ctypes._CData
builtins.object

Methods defined here:
__init__(self)
Initialize self.  See help(type(self)) for accurate signature.

Data descriptors defined here:
DIFAT
byteOrder
firstDIFATSectorLocation
firstDirectorySectorLocation
firstMiniFATSectorLocation
headerCLSID
headerSignature
majorVersion
miniSectorShift
miniStreamCutoffSize
minorVersion
numDIFATSectors
numDirectorySectors
numFATSectors
numMiniFATSectors
reserved
sectorShift
transactionSignatureNumber

Class methods inherited from StructureBuilder:
from_bytes(data: bytes) -> ~CompoundFileHeader from _ctypes.PyCStructType
This classmethod is a constructor from bytes.

Data descriptors inherited from StructureBuilder:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) from _ctypes.PyCStructType
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(...)
__hash__(self, /)
Return hash(self).
__reduce__(...)
Helper for pickle.
__setstate__(...)

 
class CompoundFileHeaderVersion3(_ctypes.Structure)
    This class implements the compound file headers in version 3
(default for CompoundFileHeader).
 
 
Method resolution order:
CompoundFileHeaderVersion3
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from _ctypes.Structure:
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) from _ctypes.PyCStructType
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(...)
__hash__(self, /)
Return hash(self).
__reduce__(...)
Helper for pickle.
__setstate__(...)

 
class CompoundFileHeaderVersion4(_ctypes.Structure)
    This class implements the compound file headers in version 4.
 
 
Method resolution order:
CompoundFileHeaderVersion4
_ctypes.Structure
_ctypes._CData
builtins.object

Methods defined here:
__init__(self)
Initialize self.  See help(type(self)) for accurate signature.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) from _ctypes.PyCStructType
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(...)
__hash__(self, /)
Return hash(self).
__reduce__(...)
Helper for pickle.
__setstate__(...)

 
class DirectoryEntry(StructureBuilder)
    This class implements a C Structure for the Combound File Directory Entry.
 
 
Method resolution order:
DirectoryEntry
StructureBuilder
_ctypes.Structure
_ctypes._CData
builtins.object

Data descriptors defined here:
CLSID
ChildID
ColorFlag
CreationTime
DirectoryEntryName
DirectoryEntryNameLength
LeftSiblingID
ModifiedTime
ObjectType
RightSiblingID
StartingSectorLocation
StateBits
StreamSize

Class methods inherited from StructureBuilder:
from_bytes(data: bytes) -> ~CompoundFileHeader from _ctypes.PyCStructType
This classmethod is a constructor from bytes.

Data descriptors inherited from StructureBuilder:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from _ctypes.Structure:
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) from _ctypes.PyCStructType
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(...)
__hash__(self, /)
Return hash(self).
__reduce__(...)
Helper for pickle.
__setstate__(...)

 
class Entry(builtins.object)
    Entry(id: int, entry: ComboundFileParser.DirectoryEntry, parent_name: str) -&gt; None
 
Entry(id: int, entry: ComboundFileParser.DirectoryEntry, parent_name: str)
 
  Methods defined here:
__eq__(self, other)
Return self==value.
__init__(self, id: int, entry: ComboundFileParser.DirectoryEntry, parent_name: str) -> None
Initialize self.  See help(type(self)) for accurate signature.
__repr__(self)
Return repr(self).

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
__annotations__ = {'entry': <class 'ComboundFileParser.DirectoryEntry'>, 'id': <class 'int'>, 'parent_name': <class 'str'>}
__dataclass_fields__ = {'entry': Field(name='entry',type=<class 'ComboundFilePars...appingproxy({}),kw_only=False,_field_type=_FIELD), 'id': Field(name='id',type=<class 'int'>,default=<data...appingproxy({}),kw_only=False,_field_type=_FIELD), 'parent_name': Field(name='parent_name',type=<class 'str'>,defa...appingproxy({}),kw_only=False,_field_type=_FIELD)}
__dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)
__hash__ = None
__match_args__ = ('id', 'entry', 'parent_name')

 
class StructureBuilder(_ctypes.Structure)
    This class implements a ctypes.Structure with `from_bytes` class
method to create a new instance easily from bytes.
 
 
Method resolution order:
StructureBuilder
_ctypes.Structure
_ctypes._CData
builtins.object

Class methods defined here:
from_bytes(data: bytes) -> ~CompoundFileHeader from _ctypes.PyCStructType
This classmethod is a constructor from bytes.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from _ctypes.Structure:
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Static methods inherited from _ctypes.Structure:
__new__(*args, **kwargs) from _ctypes.PyCStructType
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from _ctypes._CData:
__ctypes_from_outparam__(...)
__hash__(self, /)
Return hash(self).
__reduce__(...)
Helper for pickle.
__setstate__(...)

 
Functions
       
metaclass_factory(bases: Iterable[type])
This function makes a new "master type" to resolve conflicts
between two metaclasses.
pointer(...)
sizeof(...)
sizeof(C type) -> integer
sizeof(C instance) -> integer
Return the size in bytes of a C instance

 
Data
        ArrayUInt32 = ~ArrayUInt32
DIFSECT = 4294967292
ENDOFCHAIN = 4294967294
FATSECT = 4294967293
FREESECT = 4294967295
Iterable = typing.Iterable
List = typing.List
MAXREGSECT = 4294967290
NOSTREAM = 4294967295
NOT_APPLICABLE = 4294967292
REGSECT_MAX = 4294967289
REGSECT_MIN = 0
ROOT_STORAGE_OBJECT = 5
STORAGE_OBJECT = 1
STREAM_OBJECT = 2
Set = typing.Set
Tuple = typing.Tuple
UNALLOCATED = 0
__author_email__ = 'mauricelambert434@gmail.com'
__copyright__ = '\nComboundFileParser Copyright (C) 2025 Maurice...ome to redistribute it\nunder certain conditions.\n'
__description__ = '\nThis module implements a Compound file parser (...e file format for macros, msi, msg, doc, xls...)\n'
__license__ = 'GPL-3.0 License'
__maintainer__ = 'Maurice Lambert'
__maintainer_email__ = 'mauricelambert434@gmail.com'
__url__ = 'https://github.com/mauricelambert/ComboundFileParser'
copyright = '\nComboundFileParser Copyright (C) 2025 Maurice...ome to redistribute it\nunder certain conditions.\n'
license = 'GPL-3.0 License'
memmove = <CFunctionType object>

 
Author
        Maurice Lambert