• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting a mach_header from dlopen
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting a mach_header from dlopen


  • Subject: Re: Getting a mach_header from dlopen
  • From: "Peter O'Gorman" <email@hidden>
  • Date: Tue, 03 May 2005 09:44:43 +0900

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Spencer Nielsen wrote:
| Does anybody know offhand a good way to get a code image's  mach_header
| (for use with getsectdatafromheader) of a specific file?   In 10.3 I
| used the structure that dlopen returned (dlstatus) and it  had a pointer
| right in there.  However, things have changed in 10.4  and dlopen now
| returns a different structure (dlopen_handle).  The  structure returned
| now contains the NSModule for the file among other  things.  I tried
| running through all the loaded images with  _dyld_get_image_header and
| comparing the names (using  _dyld_get_image_name) with the
| NSNameOfModule() called on the  NSModule in the structure returned by
| dlopen but NSNameOfModule()  always returns nil.  I know that depending
| on what is returned by  dlopen is probably not the best of strategies
| (perhaps that is why  the man page still documents it as returning
| void*).  All I need to  be able to do it get the mach_header of code
| images that I am loading  in with dlopen.  Thanks!
|

Well, you really shouldn't be making any assumptions about what dlopen()
returns, it already broke for you 10.3->10.4 and it may break even on minor
OS updates because it is just an implementation detail.

Since NSAddImage returns a mach_header, I'd suggest using NSAddImage with
the path you used to dlopen and NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED |
NSADDIMAGE_OPTION_RETURN_ON_ERROR, but I am not quite sure what you are
trying to do.

Please file an enhancement request with Apple for an api to get information
on the handle returned by dlopen. I know that they are trying to reduce the
number of dyld apis and standardize on dlopen et.al. where possible, but
there are a bunch of things that require a mach_header, so some method of
getting a mach_header from a dlopen handle is required.

Peter
- --
Peter O'Gorman - http://www.pogma.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Darwin)

iQCVAwUBQnbJe7iDAg3OZTLPAQKREwQAr7v95LWZQEW6+vEuoOnb3tpyzIEPFvb8
jgRLFkPsNeVl5lR0gf1L2UG+S6HiV5mXIKVA2yvlzhln7OsG1uykXCWQfFnF6rN0
IpeKIJnK65Yq1Gd+nA7PPhdNZnksPsijkvfdaEl8rxy9A/oUbIlSjDMRkuCYEjbR
YOq154YPTL4=
=f+36
-----END PGP SIGNATURE-----
_______________________________________________
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


References: 
 >Getting a mach_header from dlopen (From: Spencer Nielsen <email@hidden>)

  • Prev by Date: Getting a mach_header from dlopen
  • Next by Date: Tiger 1024-char limits on tcsh shell command length ... maybe?
  • Previous by thread: Getting a mach_header from dlopen
  • Next by thread: Tiger 1024-char limits on tcsh shell command length ... maybe?
  • Index(es):
    • Date
    • Thread