Skip to content

Comments

comments

Classes:

  • CommentInfo

    Represents information about a Comment.

  • CommentKind

    Enumeration for IDA comment types.

  • Comments

    Provides access to user-defined comments in the IDA database.

CommentInfo dataclass

CommentInfo(ea: ea_t, comment: str, repeatable: bool)

Represents information about a Comment.

Attributes:

comment instance-attribute

comment: str

ea instance-attribute

ea: ea_t

repeatable instance-attribute

repeatable: bool

CommentKind

Bases: Enum

Enumeration for IDA comment types.

Attributes:

ALL class-attribute instance-attribute

ALL = 'all'

REGULAR class-attribute instance-attribute

REGULAR = 'regular'

REPEATABLE class-attribute instance-attribute

REPEATABLE = 'repeatable'

Comments

Comments(database: Database)

Bases: DatabaseEntity

Provides access to user-defined comments in the IDA database.

Can be used to iterate over all comments in the opened database.

IDA supports two types of comments: - Regular comments: Displayed at specific addresses - Repeatable comments: Displayed at all references to the same address

Args: database: Reference to the active IDA database.

Methods:

  • delete

    Deletes a comment at the specified address.

  • get

    Retrieves the comment at the specified address.

  • get_all

    Creates an iterator for comments in the database.

  • get_any

    Retrieves any comment at the specified address, checking both regular and repeatable.

  • set

    Sets a comment at the specified address.

Attributes:

database property

database: Database

Get the database reference, guaranteed to be non-None when called from methods decorated with @check_db_open.

Returns: The active database instance.

Note: This property should only be used in methods decorated with @check_db_open, which ensures m_database is not None.

m_database instance-attribute

m_database = database

delete

delete(
    ea: int, comment_kind: CommentKind = REGULAR
) -> bool

Deletes a comment at the specified address.

Args: ea: The effective address. comment_kind: Type of comment to delete (REGULAR or REPEATABLE).

Raises: InvalidEAError: If the effective address is invalid.

Returns: True if the comment was successfully deleted, False otherwise.

get

get(
    ea: ea_t, comment_kind: CommentKind = REGULAR
) -> CommentInfo | None

Retrieves the comment at the specified address.

Args: ea: The effective address. comment_kind: Type of comment to retrieve (REGULAR or REPEATABLE).

Raises: InvalidEAError: If the effective address is invalid.

Returns: The comment string, or None if no comment exists.

get_all

get_all(
    comment_kind: CommentKind = REGULAR,
) -> Iterator[CommentInfo]

Creates an iterator for comments in the database.

Args: comment_kind: Type of comments to retrieve: - CommentKind.REGULAR: Only regular comments - CommentKind.REPEATABLE: Only repeatable comments - CommentKind.ALL: Both regular and repeatable comments

Yields: Tuples of (address, comment_text, is_repeatable) for each comment found.

get_any

get_any(ea: ea_t) -> CommentInfo | None

Retrieves any comment at the specified address, checking both regular and repeatable.

Args: ea: The effective address.

Raises: InvalidEAError: If the effective address is invalid.

Returns: A tuple (success, comment string). If no comment exists, success is False.

set

set(
    ea: int,
    comment: str,
    comment_kind: CommentKind = REGULAR,
) -> bool

Sets a comment at the specified address.

Args: ea: The effective address. comment: The comment text to assign. comment_kind: Type of comment to set (REGULAR or REPEATABLE).

Raises: InvalidEAError: If the effective address is invalid.

Returns: True if the comment was successfully set, False otherwise.