Re: Application entry point
Re: Application entry point
- Subject: Re: Application entry point
- From: Greg Parker <email@hidden>
- Date: Sun, 12 Jul 2009 22:16:07 -0700
On Jul 12, 2009, at 8:58 PM, Aron-Zvi wrote:
I'd like to know if it's possible to retrieve an application's entry
point programatically on OS X.
More specifically, I'd like to retrieve the thread state in the
LC_UNIXTHREAD load command and extract eip's value.
I've found getsectdatafromheader() which requires a mach header.
I've only found _dyld_get_image_header to get the mach header,
however, I found nothing that retrieves a regular executable's (not
a loaded shared library...) mach header.
_dyld_get_image_header() should provide the executable's header itself
in addition to all dylibs and bundles.
If your code is compiled as part of the executable, you can use
_mh_execute_header from mach-o/ldsyms.h. But that won't work if your
code is part of a library or bundle.
Note that the functions in mach-o/getsect.h will only look up
LC_SEGMENT contents. You probably need to scan the load commands
manually to find LC_UNIXTHREAD.
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden