Python

Metadata

class lief.objc.Metadata

Bases: object

This class is the main interface to inspect Objective-C metadata

It can be instantiated using the function lief.MachO.Binary.objc_metadata

property categories Iterator[lief.objc.Category | None]

Return an iterator over the Objective-C categories declared in this binary (e.g. @interface NSString (MyAdditions)).

property classes Iterator[lief.objc.Class | None]

Return an iterator over the different Objective-C classes (@interface).

get_class(self, name: str) lief._lief.objc.Class | None

Try to find the Objective-C class with the given mangled name.

get_protocol(self, name: str) lief._lief.objc.Protocol | None

Try to find the Objective-C protocol with the given mangled name.

property protocols Iterator[lief.objc.Protocol | None]

Return an iterator over the Objective-C protocols declared in this binary (@protocol).

to_decl(self, opt: lief._lief.objc.DeclOpt = <lief._lief.objc.DeclOpt object at 0x7fe9039c9db0>) str

Generate a header-like of all the Objective-C metadata identified in the binary.

The generated output can be configured with the provided DeclOpt parameter.


Class

class lief.objc.Class

Bases: object

This class represents an Objective-C class (@interface)

property demangled_name str

Demangled name of the class

property demangled_super_name str

Demangled name of the superclass.

property is_meta bool
property ivars Iterator[lief.objc.IVar | None]

Iterator over the different instance variables defined in this class.

property methods Iterator[lief.objc.Method | None]

Iterator over the different methods defined by this class.

property name str

Name of the class

property properties Iterator[lief.objc.Property | None]

Iterator over the properties of this class.

property protocols Iterator[lief.objc.Protocol | None]

Iterator over the different protocols implemented by this class.

property super_class lief.objc.Class | None

Parent class in case of inheritance.

This is set only when the superclass is defined in the same binary. For root classes (e.g. NSObject) or superclasses imported from another image, it is None even though super_name / demangled_super_name may still be resolved.

property super_name str

(raw) name of the superclass (empty for root classes or when it could not be resolved).

to_decl(self, opt: lief._lief.objc.DeclOpt = <lief._lief.objc.DeclOpt object at 0x7fe9039c9e10>) str

Generate a header-like string for this specific class.

The generated output can be configured with the provided DeclOpt parameter.


Category

class lief.objc.Category

Bases: object

This class represents an Objective-C category (e.g. @interface NSString (MyAdditions))

property class_name str

(demangled) name of the class extended by this category

property methods Iterator[lief.objc.Method | None]

Iterator over the different methods defined by this category.

property name str

Name of the category

property properties Iterator[lief.objc.Property | None]

Iterator over the properties of this category.

property protocols Iterator[lief.objc.Protocol | None]

Iterator over the different protocols adopted by this category.

to_decl(self, opt: lief._lief.objc.DeclOpt = <lief._lief.objc.DeclOpt object at 0x7fe9039c9e70>) str

Generate a header-like string for this specific category.

The generated output can be configured with the provided DeclOpt parameter.


Protocol

class lief.objc.Protocol

Bases: object

This class represents an Objective-C @protocol

property mangled_name str

Mangled name of the protocol

property optional_methods Iterator[lief.objc.Method | None]

Iterator over the methods that could be overridden

property properties Iterator[lief.objc.Property | None]

Iterator over the properties defined in this protocol

property protocols Iterator[lief.objc.Protocol | None]

Iterator over the protocols adopted by this protocol (e.g. the <Bar, Baz> in @protocol Foo <Bar, Baz>).

property required_methods Iterator[lief.objc.Method | None]

Iterator over the methods of this protocol that must be implemented

to_decl(self, opt: lief._lief.objc.DeclOpt = <lief._lief.objc.DeclOpt object at 0x7fe9039c9f10>) str

Generate a header-like string for this specific protocol.

The generated output can be configured with the provided DeclOpt parameter.


Method

class lief.objc.Method

Bases: object

This class represents an Objective-C Method.

property address int

Virtual address where this method is implemented in the binary

property is_instance bool

Whether it’s an instance method or not.

property mangled_type str

Prototype of the method in its mangled representation (e.g. @16@0:8)

property name str

Name of the method


IVar

class lief.objc.IVar

Bases: object

This class represents an instance variable (ivar)

property mangled_type str

Type of the instance var in its mangled representation (e.g. [29i])

property name str

Name of the instance variable


Property

class lief.objc.Property

Bases: object

This class represents a @property in Objective-C

property attribute str

(raw) property’s attributes (e.g. T@"NSString",C,D,N)

property name str

Name of the property


DeclOpt

class lief.objc.DeclOpt(self)

Bases: object

This structure wraps options to tweak the generated output of functions like lief.objc.Metadata.to_decl()

property show_annotations bool

Whether annotations like method’s address should be printed.