import ctypes


def struct_to_dict(struct: ctypes.Structure) -> dict:
    """Create a dict from a struct's fields and their values."""
    return {name: getattr(struct, name) for name, _ in getattr(struct, "_fields_")}