Python¶
Metadata¶
- class lief.objc.Metadata¶
Bases:
objectThis 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 0x7f3b0b9f7b30>) str¶
Generate a header-like of all the Objective-C metadata identified in the binary.
The generated output can be configured with the provided
DeclOptparameter.
Class¶
- class lief.objc.Class¶
Bases:
objectThis 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 isNoneeven thoughsuper_name/demangled_super_namemay 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 0x7f3b0b9f7b90>) str¶
Generate a header-like string for this specific class.
The generated output can be configured with the provided
DeclOptparameter.
Category¶
- class lief.objc.Category¶
Bases:
objectThis 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 0x7f3b0b9f7bf0>) str¶
Generate a header-like string for this specific category.
The generated output can be configured with the provided
DeclOptparameter.
Protocol¶
- class lief.objc.Protocol¶
Bases:
objectThis 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 0x7f3b0b9f7c90>) str¶
Generate a header-like string for this specific protocol.
The generated output can be configured with the provided
DeclOptparameter.
Method¶
- class lief.objc.Method¶
Bases:
objectThis 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¶
Property¶
DeclOpt¶
- class lief.objc.DeclOpt(self)¶
Bases:
objectThis 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.