Can't get Mach-O text segment size in iOS executableiPhone executable (MACH-O) decryptionHow to get the size of symbols in the symbol table of Mach-O file?thread 1: signal SIGABRT error app crashesTrying to send mail and app crashedSelected cell not persisting in UICollectionView. Cannot save. *** Terminating app due to uncaught exceptionreact-native FBSDK LoginManager not workingFat Mach-O Executable Multi-purpose?Objective-c deallocated when opening a new form?Smallest size of valid executable Mach-o fileHow to inspect a MacOS executable file (Mach-O)?

Manager manipulates my leaves, what's in it for him?

Can Northern Ireland's border issue be solved by repartition?

Is the Necromancer's "Half-Formed Golem" pet available for all classes?

Install specific version and arch, without specifying the release

Is there any reason nowadays to use a neon indicator lamp instead of an LED?

Are there hydrocarbons on the Moon?

GitHub repo with Apache License version 2 in package.json, but no full license copy nor comment headers

What is a Heptagon Number™?

Which museums have artworks of all four ninja turtles' namesakes?

Simulate a 1D Game-of-Life-ish Model

How do rulers get rich from war?

What is the need of methods like GET and POST in the HTTP protocol?

How to create a grid following points in QGIS?

Is there an in-universe reason Harry says this or is this simply a Rowling mistake?

What informations can we obtain with these voltage and current measurements of a little electronic device?

Could someone please show me the steps of this sum?

As an employer, can I compel my employees to vote?

Create a magic square of 4-digit numbers

Social leper versus social leopard

Paradox regarding phase transitions in relativistic systems

Is it true that, "just ten trading days represent 63 per cent of the returns of the past 50 years"?

How to fix folder structure in Windows 7 and 10

Should the pagination be reset when changing the order?

Are actors contractually obligated to certain things like going nude/ Sensual Scenes/ Gory Scenes?



Can't get Mach-O text segment size in iOS executable


iPhone executable (MACH-O) decryptionHow to get the size of symbols in the symbol table of Mach-O file?thread 1: signal SIGABRT error app crashesTrying to send mail and app crashedSelected cell not persisting in UICollectionView. Cannot save. *** Terminating app due to uncaught exceptionreact-native FBSDK LoginManager not workingFat Mach-O Executable Multi-purpose?Objective-c deallocated when opening a new form?Smallest size of valid executable Mach-o fileHow to inspect a MacOS executable file (Mach-O)?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I'm trying to get .text segment size of Mach-O executable of my iOS app.



size_t size_of_image(struct mach_header *header) 
size_t sz = sizeof(*header); // Size of the header
sz += header->sizeofcmds; // Size of the load commands

struct load_command *lc = (struct load_command *) (header + 1);
for (uint32_t i = 0; i < header->ncmds; i++)
if (lc->cmd == LC_SEGMENT_64)
sz += ((struct segment_command *) lc)->vmsize; // Size of segments

lc = (struct load_command *) ((char *) lc + lc->cmdsize);

return sz;



and i call this function from main



int main(int argc, char * argv[]) dlinfo.dli_fbase == NULL)
return 0; // Can't find symbol for main
//
header = dlinfo.dli_fbase; // Pointer on the Mach-O header
size_of_image(header);
@autoreleasepool
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));




Problem is lc->cmd is always 0, and i never get LC_SEGMENT_64 command.



I've tried LC_SEGMENT - same result



Running iOS 12 on iPhone 6.
I need to get the .text segment of the executable for reverse - engineering protection functions.



It seems my ** mach_header *header** is wrongly field by dladdr function.



Any ideas what is wrong?










share|improve this question
























  • Hello Andrew, did you manage to solve this? I am having the same issue.

    – Agustin Pazos
    Jul 12 at 14:54











  • see answer below. it worked for me @AgustinPazos

    – Andrew
    Jul 17 at 10:56

















3















I'm trying to get .text segment size of Mach-O executable of my iOS app.



size_t size_of_image(struct mach_header *header) 
size_t sz = sizeof(*header); // Size of the header
sz += header->sizeofcmds; // Size of the load commands

struct load_command *lc = (struct load_command *) (header + 1);
for (uint32_t i = 0; i < header->ncmds; i++)
if (lc->cmd == LC_SEGMENT_64)
sz += ((struct segment_command *) lc)->vmsize; // Size of segments

lc = (struct load_command *) ((char *) lc + lc->cmdsize);

return sz;



and i call this function from main



int main(int argc, char * argv[]) dlinfo.dli_fbase == NULL)
return 0; // Can't find symbol for main
//
header = dlinfo.dli_fbase; // Pointer on the Mach-O header
size_of_image(header);
@autoreleasepool
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));




Problem is lc->cmd is always 0, and i never get LC_SEGMENT_64 command.



I've tried LC_SEGMENT - same result



Running iOS 12 on iPhone 6.
I need to get the .text segment of the executable for reverse - engineering protection functions.



It seems my ** mach_header *header** is wrongly field by dladdr function.



Any ideas what is wrong?










share|improve this question
























  • Hello Andrew, did you manage to solve this? I am having the same issue.

    – Agustin Pazos
    Jul 12 at 14:54











  • see answer below. it worked for me @AgustinPazos

    – Andrew
    Jul 17 at 10:56













3












3








3








I'm trying to get .text segment size of Mach-O executable of my iOS app.



size_t size_of_image(struct mach_header *header) 
size_t sz = sizeof(*header); // Size of the header
sz += header->sizeofcmds; // Size of the load commands

struct load_command *lc = (struct load_command *) (header + 1);
for (uint32_t i = 0; i < header->ncmds; i++)
if (lc->cmd == LC_SEGMENT_64)
sz += ((struct segment_command *) lc)->vmsize; // Size of segments

lc = (struct load_command *) ((char *) lc + lc->cmdsize);

return sz;



and i call this function from main



int main(int argc, char * argv[]) dlinfo.dli_fbase == NULL)
return 0; // Can't find symbol for main
//
header = dlinfo.dli_fbase; // Pointer on the Mach-O header
size_of_image(header);
@autoreleasepool
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));




Problem is lc->cmd is always 0, and i never get LC_SEGMENT_64 command.



I've tried LC_SEGMENT - same result



Running iOS 12 on iPhone 6.
I need to get the .text segment of the executable for reverse - engineering protection functions.



It seems my ** mach_header *header** is wrongly field by dladdr function.



Any ideas what is wrong?










share|improve this question














I'm trying to get .text segment size of Mach-O executable of my iOS app.



size_t size_of_image(struct mach_header *header) 
size_t sz = sizeof(*header); // Size of the header
sz += header->sizeofcmds; // Size of the load commands

struct load_command *lc = (struct load_command *) (header + 1);
for (uint32_t i = 0; i < header->ncmds; i++)
if (lc->cmd == LC_SEGMENT_64)
sz += ((struct segment_command *) lc)->vmsize; // Size of segments

lc = (struct load_command *) ((char *) lc + lc->cmdsize);

return sz;



and i call this function from main



int main(int argc, char * argv[]) dlinfo.dli_fbase == NULL)
return 0; // Can't find symbol for main
//
header = dlinfo.dli_fbase; // Pointer on the Mach-O header
size_of_image(header);
@autoreleasepool
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));




Problem is lc->cmd is always 0, and i never get LC_SEGMENT_64 command.



I've tried LC_SEGMENT - same result



Running iOS 12 on iPhone 6.
I need to get the .text segment of the executable for reverse - engineering protection functions.



It seems my ** mach_header *header** is wrongly field by dladdr function.



Any ideas what is wrong?







ios executable reverse-engineering segment mach-o






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 14:51









AndrewAndrew

3233 silver badges15 bronze badges




3233 silver badges15 bronze badges















  • Hello Andrew, did you manage to solve this? I am having the same issue.

    – Agustin Pazos
    Jul 12 at 14:54











  • see answer below. it worked for me @AgustinPazos

    – Andrew
    Jul 17 at 10:56

















  • Hello Andrew, did you manage to solve this? I am having the same issue.

    – Agustin Pazos
    Jul 12 at 14:54











  • see answer below. it worked for me @AgustinPazos

    – Andrew
    Jul 17 at 10:56
















Hello Andrew, did you manage to solve this? I am having the same issue.

– Agustin Pazos
Jul 12 at 14:54





Hello Andrew, did you manage to solve this? I am having the same issue.

– Agustin Pazos
Jul 12 at 14:54













see answer below. it worked for me @AgustinPazos

– Andrew
Jul 17 at 10:56





see answer below. it worked for me @AgustinPazos

– Andrew
Jul 17 at 10:56












1 Answer
1






active

oldest

votes


















2
















The culprit is in struct mach_header *header.

Replace it with struct mach_header_64 *header instead.

Keep using LC_SEGMENT_64 for modern binaries.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );














    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55400596%2fcant-get-mach-o-text-segment-size-in-ios-executable%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2
















    The culprit is in struct mach_header *header.

    Replace it with struct mach_header_64 *header instead.

    Keep using LC_SEGMENT_64 for modern binaries.






    share|improve this answer





























      2
















      The culprit is in struct mach_header *header.

      Replace it with struct mach_header_64 *header instead.

      Keep using LC_SEGMENT_64 for modern binaries.






      share|improve this answer



























        2














        2










        2









        The culprit is in struct mach_header *header.

        Replace it with struct mach_header_64 *header instead.

        Keep using LC_SEGMENT_64 for modern binaries.






        share|improve this answer













        The culprit is in struct mach_header *header.

        Replace it with struct mach_header_64 *header instead.

        Keep using LC_SEGMENT_64 for modern binaries.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 28 at 15:38









        Kamil.SKamil.S

        2,4902 gold badges12 silver badges26 bronze badges




        2,4902 gold badges12 silver badges26 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















            draft saved

            draft discarded















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55400596%2fcant-get-mach-o-text-segment-size-in-ios-executable%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현