C++

Note

You can also find the Doxygen documentation here: here

Metadata

class Metadata

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

It can be instantiated using the function LIEF::MachO::Binary::objc_metadata

Public Types

using classes_it = iterator_range<Class::Iterator>
using protocols_it = iterator_range<Protocol::Iterator>

Public Functions

Metadata(std::unique_ptr<details::Metadata> impl)
classes_it classes() const

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

protocols_it protocols() const

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

std::unique_ptr<Class> get_class(const std::string &name) const

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

std::unique_ptr<Protocol> get_protocol(const std::string &name) const

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

std::string to_decl(const DeclOpt &opt = DeclOpt()) const

Generate a header-like of all the Objective-C metadata identified in the binary. The generated output can be configured with the DeclOpt.

~Metadata()

Class

class Class

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

Public Types

using methods_t = iterator_range<Method::Iterator>

Iterator for the class’s method.

using protocols_t = iterator_range<Protocol::Iterator>

Iterator for the protocols implemented by this class.

using properties_t = iterator_range<Property::Iterator>

Iterator for the properties declared by this class.

using ivars_t = iterator_range<IVar::Iterator>

Iterator for the instance variables defined by this class.

Public Functions

Class(std::unique_ptr<details::Class> impl)
std::string name() const

Name of the class.

std::string demangled_name() const

Demangled name of the class.

std::unique_ptr<Class> super_class() const

Parent class in case of inheritance.

bool is_meta() const
methods_t methods() const

Iterator over the different methods defined by this class.

protocols_t protocols() const

Iterator over the different protocols implemented by this class.

properties_t properties() const

Iterator over the properties of this class.

ivars_t ivars() const

Iterator over the different instance variables defined in this class.

std::string to_decl(const DeclOpt &opt = DeclOpt()) const

Generate a header-like string for this specific class.

The generated output can be configured with DeclOpt

~Class()
class Iterator

Public Types

using iterator_category = std::bidirectional_iterator_tag
using value_type = std::unique_ptr<Class>
using difference_type = std::ptrdiff_t
using pointer = Class*
using reference = std::unique_ptr<Class>&
using implementation = details::ClassIt

Public Functions

Iterator(const Iterator&)
Iterator(Iterator&&) noexcept
Iterator(std::unique_ptr<details::ClassIt> impl)
~Iterator()
Iterator &operator++()
Iterator &operator--()
inline Iterator operator--(int)
inline Iterator operator++(int)
std::unique_ptr<Class> operator*() const
inline PointerProxy operator->() const

Friends

friend bool operator==(const Iterator &LHS, const Iterator &RHS)
inline friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
class PointerProxy

Public Functions

inline pointer operator->() const

Protocol

class Protocol

This class represents an Objective-C @protocol

Public Types

using methods_it = iterator_range<Method::Iterator>
using properties_it = iterator_range<Property::Iterator>

Public Functions

Protocol(std::unique_ptr<details::Protocol> impl)
std::string mangled_name() const

Mangled name of the protocol.

methods_it optional_methods() const

Iterator over the methods that could be overridden.

methods_it required_methods() const

Iterator over the methods of this protocol that must be implemented.

properties_it properties() const

Iterator over the properties defined in this protocol.

std::string to_decl(const DeclOpt &opt = DeclOpt()) const

Generate a header-like string for this specific protocol.

The generated output can be configured with DeclOpt

~Protocol()
class Iterator

Public Types

using iterator_category = std::bidirectional_iterator_tag
using value_type = std::unique_ptr<Protocol>
using difference_type = std::ptrdiff_t
using pointer = Protocol*
using reference = std::unique_ptr<Protocol>&
using implementation = details::ProtocolIt

Public Functions

Iterator(const Iterator&)
Iterator(Iterator&&) noexcept
Iterator(std::unique_ptr<details::ProtocolIt> impl)
~Iterator()
Iterator &operator++()
Iterator &operator--()
inline Iterator operator--(int)
inline Iterator operator++(int)
std::unique_ptr<Protocol> operator*() const
inline PointerProxy operator->() const

Friends

friend bool operator==(const Iterator &LHS, const Iterator &RHS)
inline friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
class PointerProxy

Public Functions

inline pointer operator->() const

Instance Variable (IVar)

class IVar

This class represents an instance variable (ivar)

Public Functions

IVar(std::unique_ptr<details::IVar> impl)
std::string name() const

Name of the instance variable.

std::string mangled_type() const

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

~IVar()
class Iterator

Public Types

using iterator_category = std::bidirectional_iterator_tag
using value_type = std::unique_ptr<IVar>
using difference_type = std::ptrdiff_t
using pointer = IVar*
using reference = std::unique_ptr<IVar>&
using implementation = details::IVarIt

Public Functions

Iterator(const Iterator&)
Iterator(Iterator&&) noexcept
Iterator(std::unique_ptr<details::IVarIt> impl)
~Iterator()
Iterator &operator++()
Iterator &operator--()
inline Iterator operator--(int)
inline Iterator operator++(int)
std::unique_ptr<IVar> operator*() const
inline PointerProxy operator->() const

Friends

friend bool operator==(const Iterator &LHS, const Iterator &RHS)
inline friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
class PointerProxy

Public Functions

inline pointer operator->() const

Method

class Method

This class represents an Objective-C Method.

Public Functions

Method(std::unique_ptr<details::Method> impl)
std::string name() const

Name of the method.

std::string mangled_type() const

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

uintptr_t address() const

Virtual address where this method is implemented in the binary.

bool is_instance() const

Whether it’s an instance method.

~Method()
class Iterator

Public Types

using iterator_category = std::bidirectional_iterator_tag
using value_type = std::unique_ptr<Method>
using difference_type = std::ptrdiff_t
using pointer = Method*
using reference = std::unique_ptr<Method>&
using implementation = details::MethodIt

Public Functions

Iterator(const Iterator&)
Iterator(Iterator&&) noexcept
Iterator(std::unique_ptr<details::MethodIt> impl)
~Iterator()
Iterator &operator++()
Iterator &operator--()
inline Iterator operator--(int)
inline Iterator operator++(int)
std::unique_ptr<Method> operator*() const
inline PointerProxy operator->() const

Friends

friend bool operator==(const Iterator &LHS, const Iterator &RHS)
inline friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
class PointerProxy

Public Functions

inline pointer operator->() const

Property

class Property

This class represents a @property in Objective-C.

Public Functions

Property(std::unique_ptr<details::Property> impl)
std::string name() const

Name of the property.

std::string attribute() const

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

~Property()
class Iterator

Public Types

using iterator_category = std::bidirectional_iterator_tag
using value_type = std::unique_ptr<Property>
using difference_type = std::ptrdiff_t
using pointer = Property*
using reference = std::unique_ptr<Property>&
using implementation = details::PropertyIt

Public Functions

Iterator(const Iterator&)
Iterator(Iterator&&) noexcept
Iterator(std::unique_ptr<details::PropertyIt> impl)
~Iterator()
Iterator &operator++()
Iterator &operator--()
inline Iterator operator--(int)
inline Iterator operator++(int)
std::unique_ptr<Property> operator*() const
inline PointerProxy operator->() const

Friends

friend bool operator==(const Iterator &LHS, const Iterator &RHS)
inline friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
class PointerProxy

Public Functions

inline pointer operator->() const

DeclOpt

struct DeclOpt

This structure wraps options to tweak the generated output of functions like LIEF::objc::Metadata::to_decl.

Public Members

bool show_annotations = true

Whether annotations like method’s address should be printed.