• 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: Finding process path from Cocoa?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding process path from Cocoa?


  • Subject: Re: Finding process path from Cocoa?
  • From: "email@hidden" <email@hidden>
  • Date: Wed, 9 Dec 2009 10:02:23 +0000

On 9 Dec 2009, at 09:53, Alastair Houghton wrote:
>
> It is possible to get the path to your executable using the dyld API, but before doing such a thing you need to be very clear as to why you need it and what it is that you're going to do with it.  It's very easy to end up with major security holes or just plain broken behaviour.
>
I have used the following in the past. Just curious to know what the holes and dodgy behaviour is likely to be.

Dl_info info;
int errDlAddr = dladdr( (const void *)__func__, &info );
if(errDlAddr == 0) {
	return nil;
}
char *exec_path = (char *)(info.dli_fname);

NSString *path = [NSString stringWithCString:exec_path encoding:NSUTF8StringEncoding];


> Kind regards,
>
> Alastair.
>
> --
> http://alastairs-place.net
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Finding process path from Cocoa?
      • From: Alastair Houghton <email@hidden>
References: 
 >Finding process path from Cocoa? (From: Laurent Daudelin <email@hidden>)
 >Re: Finding process path from Cocoa? (From: Nick Zitzmann <email@hidden>)
 >Re: Finding process path from Cocoa? (From: Alastair Houghton <email@hidden>)

  • Prev by Date: Re: Finding process path from Cocoa?
  • Next by Date: Re: Finding process path from Cocoa?
  • Previous by thread: Re: Finding process path from Cocoa?
  • Next by thread: Re: Finding process path from Cocoa?
  • Index(es):
    • Date
    • Thread