site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com -- Greg Parker gparker@apple.com Runtime Wrangler _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... 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. This email sent to site_archiver@lists.apple.com