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;
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
add a comment
|
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
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
add a comment
|
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
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
ios executable reverse-engineering segment mach-o
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
add a comment
|
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
add a comment
|
1 Answer
1
active
oldest
votes
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.
add a comment
|
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment
|
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.
add a comment
|
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.
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.
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
add a comment
|
add a comment
|
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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