typeprinter module

binaryninja.typeprinter.CoreTypePrinter([handle])

binaryninja.typeprinter.TypePrinter([handle])

Class for turning Type objects into strings and tokens.

class CoreTypePrinter(handle=None)[source]

Bases: TypePrinter

get_type_lines(type: Type, container: TypeContainer, name: Iterable[str | bytes] | str | QualifiedName, padding_cols=64, collapsed=False, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) List[TypeDefinitionLine][source]

Generate a multi-line representation of a type

Parameters:
  • type (Type) – Type to print

  • container (TypeContainer) – Type Container containing the type and dependencies

  • name (Iterable[str | bytes] | str | QualifiedName) – Name of the type

  • padding_cols – Maximum number of bytes represented by each padding line

  • collapsed – Whether to collapse structure/enum blocks

  • escaping (TokenEscapingType) – Style of escaping literals which may not be parsable

Returns:

List of type definition lines

Return type:

List[TypeDefinitionLine]

get_type_string(type: Type, platform: Platform | None = None, name: Iterable[str | bytes] | str | QualifiedName = '', escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) str[source]

Generate a single-line text representation of a type

Parameters:
Returns:

String representing the type

Return type:

str

get_type_string_after_name(type: Type, platform: Platform | None = None, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) str[source]

In a single-line text representation of a type, generate the string that should be printed after the type’s name.

Parameters:
  • type (Type) – Type to print

  • platform (Platform | None) – Platform responsible for this type

  • escaping (TokenEscapingType) – Style of escaping literals which may not be parsable

Returns:

String representing the type

Return type:

str

get_type_string_before_name(type: Type, platform: Platform | None = None, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) str[source]

In a single-line text representation of a type, generate the string that should be printed before the type’s name.

Parameters:
  • type (Type) – Type to print

  • platform (Platform | None) – Platform responsible for this type

  • escaping (TokenEscapingType) – Style of escaping literals which may not be parsable

Returns:

String representing the type

Return type:

str

get_type_tokens(type: Type, platform: Platform | None = None, name: Iterable[str | bytes] | str | QualifiedName = '', base_confidence: int = 255, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) List[InstructionTextToken][source]

Generate a single-line text representation of a type

Parameters:
  • type (Type) – Type to print

  • platform (Platform | None) – Platform responsible for this type

  • name (Iterable[str | bytes] | str | QualifiedName) – Name of the type

  • base_confidence (int) – Confidence to use for tokens created for this type

  • escaping (TokenEscapingType) – Style of escaping literals which may not be parsable

Returns:

List of text tokens representing the type

Return type:

List[InstructionTextToken]

get_type_tokens_after_name(type: Type, platform: Platform | None = None, base_confidence: int = 255, parent_type: Type | None = None, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) List[InstructionTextToken][source]

In a single-line text representation of a type, generate the tokens that should be printed after the type’s name.

Parameters:
  • type (Type) – Type to print

  • platform (Platform | None) – Platform responsible for this type

  • base_confidence (int) – Confidence to use for tokens created for this type

  • parent_type (Type | None) – Type of the parent of this type, or None

  • escaping (TokenEscapingType) – Style of escaping literals which may not be parsable

Returns:

List of text tokens representing the type

Return type:

List[InstructionTextToken]

get_type_tokens_before_name(type: Type, platform: Platform | None = None, base_confidence: int = 255, parent_type: Type | None = None, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) List[InstructionTextToken][source]

In a single-line text representation of a type, generate the tokens that should be printed before the type’s name.

Parameters:
  • type (Type) – Type to print

  • platform (Platform | None) – Platform responsible for this type

  • base_confidence (int) – Confidence to use for tokens created for this type

  • parent_type (Type | None) – Type of the parent of this type, or None

  • escaping (TokenEscapingType) – Style of escaping literals which may not be parsable

Returns:

List of text tokens representing the type

Return type:

List[InstructionTextToken]

print_all_types(types_: List[Tuple[Iterable[str | bytes] | str | QualifiedName, Type]], data: BinaryView, padding_cols=64, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) str[source]

Print all types to a single big string, including headers, sections, etc

Parameters:
Returns:

All the types in a string

Return type:

str

class TypePrinter(handle=None)[source]

Bases: object

Class for turning Type objects into strings and tokens.

get_type_lines(type: Type, container: TypeContainer, name: Iterable[str | bytes] | str | QualifiedName, padding_cols=64, collapsed=False, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) List[TypeDefinitionLine][source]

Generate a multi-line representation of a type

Parameters:
  • type (Type) – Type to print

  • container (TypeContainer) – Type Container containing the type and dependencies

  • name (Iterable[str | bytes] | str | QualifiedName) – Name of the type

  • padding_cols – Maximum number of bytes represented by each padding line

  • collapsed – Whether to collapse structure/enum blocks

  • escaping (TokenEscapingType) – Style of escaping literals which may not be parsable

Returns:

List of type definition lines

Return type:

List[TypeDefinitionLine]

get_type_string(type: Type, platform: Platform | None = None, name: Iterable[str | bytes] | str | QualifiedName = '', escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) str[source]

Generate a single-line text representation of a type

Parameters:
Returns:

String representing the type

Return type:

str

get_type_string_after_name(type: Type, platform: Platform | None = None, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) str[source]

In a single-line text representation of a type, generate the string that should be printed after the type’s name.

Parameters:
  • type (Type) – Type to print

  • platform (Platform | None) – Platform responsible for this type

  • escaping (TokenEscapingType) – Style of escaping literals which may not be parsable

Returns:

String representing the type

Return type:

str

get_type_string_before_name(type: Type, platform: Platform | None = None, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) str[source]

In a single-line text representation of a type, generate the string that should be printed before the type’s name.

Parameters:
  • type (Type) – Type to print

  • platform (Platform | None) – Platform responsible for this type

  • escaping (TokenEscapingType) – Style of escaping literals which may not be parsable

Returns:

String representing the type

Return type:

str

get_type_tokens(type: Type, platform: Platform | None = None, name: Iterable[str | bytes] | str | QualifiedName = '', base_confidence: int = 255, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) List[InstructionTextToken][source]

Generate a single-line text representation of a type

Parameters:
  • type (Type) – Type to print

  • platform (Platform | None) – Platform responsible for this type

  • name (Iterable[str | bytes] | str | QualifiedName) – Name of the type

  • base_confidence (int) – Confidence to use for tokens created for this type

  • escaping (TokenEscapingType) – Style of escaping literals which may not be parsable

Returns:

List of text tokens representing the type

Return type:

List[InstructionTextToken]

get_type_tokens_after_name(type: Type, platform: Platform | None = None, base_confidence: int = 255, parent_type: Type | None = None, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) List[InstructionTextToken][source]

In a single-line text representation of a type, generate the tokens that should be printed after the type’s name.

Parameters:
  • type (Type) – Type to print

  • platform (Platform | None) – Platform responsible for this type

  • base_confidence (int) – Confidence to use for tokens created for this type

  • parent_type (Type | None) – Type of the parent of this type, or None

  • escaping (TokenEscapingType) – Style of escaping literals which may not be parsable

Returns:

List of text tokens representing the type

Return type:

List[InstructionTextToken]

get_type_tokens_before_name(type: Type, platform: Platform | None = None, base_confidence: int = 255, parent_type: Type | None = None, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) List[InstructionTextToken][source]

In a single-line text representation of a type, generate the tokens that should be printed before the type’s name.

Parameters:
  • type (Type) – Type to print

  • platform (Platform | None) – Platform responsible for this type

  • base_confidence (int) – Confidence to use for tokens created for this type

  • parent_type (Type | None) – Type of the parent of this type, or None

  • escaping (TokenEscapingType) – Style of escaping literals which may not be parsable

Returns:

List of text tokens representing the type

Return type:

List[InstructionTextToken]

print_all_types(types: List[Tuple[Iterable[str | bytes] | str | QualifiedName, Type]], data: BinaryView, padding_cols=64, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) str[source]

Print all types to a single big string, including headers, sections, etc

Parameters:
Returns:

All the types in a string

Return type:

str

register()[source]
name = None
to_bytes(field)[source]