# Question on Extending the Steps in Chapter 4 to \*Any\* Program/Command (Especially Those Where We Have No Source)

**URL:** <https://forums.kodeco.com/t/question-on-extending-the-steps-in-chapter-4-to-any-program-command-especially-those-where-we-have-no-source/70558>\
**Category:** Advanced Apple Debugging\
**Created:** [May 11, 2019, 8:02am UTC](https://forums.kodeco.com/t/question-on-extending-the-steps-in-chapter-4-to-any-program-command-especially-those-where-we-have-no-source/70558 "2019-05-11T08:02:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![junxiang99](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/junxiang99/32/81494_2.png) [@junxiang99](https://forums.kodeco.com/u/junxiang99)\
**Post date:** [May 11, 2019, 8:02am UTC](https://forums.kodeco.com/t/question-on-extending-the-steps-in-chapter-4-to-any-program-command-especially-those-where-we-have-no-source/70558/1 "2019-05-11T08:02:42Z")

</div>

Hi, I have read Chapter 4 of the book, and like to ask how would one know what symbols to search with the `image` command, if one didn’t have the source code and hence didn’t know what functions existed, and even what language the program was originally written in?

Also, just for Xcode specifically, how, in Chapter 1 pg 29, did the author know that the Xcode program invoked the method `-[NSView hitTest:]`? Was it because Xcode source was available or was this an educated guess?

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [July 9, 2019, 1:22am UTC](https://forums.kodeco.com/t/question-on-extending-the-steps-in-chapter-4-to-any-program-command-especially-those-where-we-have-no-source/70558/2 "2019-07-09T01:22:09Z")

</div>

@lolgrep Can you please help with this when you get a chance? Thank you - much appreciated! :]

---

<div class="post-metadata">

**Author:** ![lolgrep](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lolgrep/32/106950_2.png) [@lolgrep](https://forums.kodeco.com/u/lolgrep)\
**Post date:** [July 16, 2019, 10:17pm UTC](https://forums.kodeco.com/t/question-on-extending-the-steps-in-chapter-4-to-any-program-command-especially-those-where-we-have-no-source/70558/3 "2019-07-16T22:17:05Z")

</div>

@junxiang99 Oooh I could write a paper on this, but I’ll keep it brief :]

An executable or plugins will typically have the symbols stripped out. No other program needs to reference these methods/functions (via a name) so the program can just use offsets to reference a function or method. That’s not always the case with frameworks where you need to export your symbols which can be used by another consumer (i.e. another executable or another framework). C stripping will get rid of (most) symbols, Objective-C stripped will get rid of symbols but they can be found in other parts of the executable. Swift sorta depends. It’s a bit like C, but there are many cases where you can infer the method’s name (or functionality).

Even if you don’t know the symbols name, you can still find references to a where functions are called (assembly knowledge) and the start of all functions (LC\_FUNCTION\_STARTS load command).

You can infer what language(s) are used by what the program links to for libraries (see `otool -L` and `otool -l`) and the program’s MachO sections. If you have the latest edition of the book check out the MachO chapter. For example, if a program uses swift, you’ll see a ` __TEXT.__ swift*` load command or Objective-C with a ` __DATA.__ objc_calist`, or if I see any symbols starting with `__Z`, then I know c++ is being used.

Now to Xcode: I know that the hitTest: method is going to be called because I’ve read the AppKit/Cocoa documentation. That method gets called for all GUI programs on your computer when you click down on your mouse/trackpad. That method is a public method frequently used by OS X developers. I just am using that knowledge on Xcode to figure out what the view is

---

<div class="post-metadata">

**Author:** ![system](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@system](https://forums.kodeco.com/u/system)\
**Post date:** [October 25, 2019, 12:02am UTC](https://forums.kodeco.com/t/question-on-extending-the-steps-in-chapter-4-to-any-program-command-especially-those-where-we-have-no-source/70558/4 "2019-10-25T00:02:45Z")

</div>

This topic was automatically closed after 166 days. New replies are no longer allowed.
