

This is a common pattern used to initialize subclasses. Each of the four Objective-C calls above corresponds to the function calls indicated in the following excerpt.Īs shown, call is translated into a call to objc_msgSendSuper2(). This example is actually decompiler output from IDA Pro, but it illustrates how Objective-C calls are converted into C by the compiler. This init method includes four Objective-C method calls.Ĭonceptually, the compiler takes the Objective-C method calls above and compiles them into C code that resembles the following. To better demonstrate how Objective-C source is compiled and assembled, the following code example introduces source code using common Objective-C patterns. Objective-C methods that take arguments pass those arguments in order after the selector. This implies that for any Objective-C method call you make, the first two arguments are the object’s self pointer, and the selector, which is a string representation of the method being called on self. This function is defined with the following function signature: One effect of this is that IDA Pro cross references do not reflect the actual functions being called at runtime. Objective-C calls from one method to another are compiled as calls to objc_msgSend(). Here we’ll take a closer look at an IDA Pro module, REobjc, that adds proper cross references from calls to objc_msgSend() to the actual function being called. Objective-C source code method calls are converted by the compiler into calls to the runtime function objc_msgSend().

The runtime dynamically resolves method calls at runtime. Objective-C objects receive these messages, which typically results in one of the object’s methods being called. The Objective-C nomenclature refers to these function calls as message passing. One feature of this design goal affects function calls being performed on objects. One of the goals of the Objective-C runtime is to be as dynamic as possible. This library implements the entire object model supporting Objective-C. Programs developed in this language are linked against the Objective-C runtime shared library. It’s a variant of the C programming language. If you’ve never programmed on macOS or iOS, you might be unfamiliar with the Objective-C language. I used Hex-Rays’ Interactive Disassembler (IDA) Pro to perform disassembly and decompilation of these binaries. As part of this work, I performed an analysis of Objective-C binaries running on managed macOS endpoints.

Recently I took a look at a product that manages Apple Inc.’s macOS and iOS devices in an enterprise environment. Duo Labs MaTodd Manning Reversing Objective-C Binaries With the REobjc Module for IDA Pro
