[iOS reverse combat four] create OBJC objects

Source: Internet
Author: User

Personal Original, reprint please indicate source:Cnblogs.com/jailbreaker

OBJC is a completely object-oriented language, so the inverse focus is on the reverse class, which uses Ida's magical F5 function to reverse the creation of an object.

We look directly at the reverse arm code of the Main method in Ida:

Basically, we use Ida's F5 analysis to derive the pseudo-code of C syntax as follows:

I've turned off the automatic memory management arc in the source code to make it cleaner.

In 8, 9 rows are seen Objc_msgsend, this objc_msgsend is actually compiler generated code, in the source, OBJC call instance method is actually dynamic through message delivery, only in runtime to determine which method to deal with, This means that the function address cannot be determined at all during compilation.

The Objc_msgsend function includes at least 2 parameters, the first parameter type is the ID, which is the generic class, can pass any class, and the 2nd parameter type is Sel,selector, which temporarily understands the literal declaration of method, Later in the post will be described in detail selector. The parameters that follow the beginning of the 3rd are the specific parameters required by the Sel method, and in this case there are only 2 parameters.

Finally, take a look at main source code:

[iOS reverse combat four] create OBJC objects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.