title: How to discover the Paths to Loading Binaries
body: <p>I have a problem where I need to know the filesystem path of the current binary, as well as those of any loading (as opposed to loaded) binaries. Here is an example (for Windows):  Say we have an executable <code>A.exe</code>, which dynamically binds to <code>B.dll</code>, which in turn binds to <code>C.dll</code>. How could code executing in <code>C.dll</code> get the file paths of <code>C.dll</code>, <code>B.dll</code>, and <code>A.exe</code>?</p>
  
  <p>Oh, and I need to be able to do it on Linux, Mac, and Windows.</p>
  
  <ul>
  <li><p>On <strong>Linux</strong>, the closest thing I've found is <code>dl_iterate_phdr</code>, but the who-loaded-who info is missing.</p></li>
  <li><p>On <strong>Windows</strong>, The <code>Dynamic-Link</code> functions don't have quite the right functionality.</p></li>
  <li><p>On <strong>Mac</strong>, all I can find is what's in dlfcn.h, which is rather pithy for this purpose.</p></li>
  </ul>
  
  <p>Thanks.</p>