0

I'd like to detect if the Steam overlay has been loaded in my program, which is using LD_PRELOAD with a gameoverlayrenderer.so. I would use dlopen with RTLD_NOLOAD to check, but unfortunately the path of the shared library is not in LD_LIBARY_PATH and the full path differs between setups.

Is there a way to get a full list of shared libraries loaded in my program so that I can manually search the list of paths for the string gameoverlayrenderer.so? Essentially the equivalent of EnumProcessModules.

Overv
  • 8,433
  • 2
  • 40
  • 70
  • You essentially need the information at `/proc/self/maps`, open that file and dump it's content to figure out how to use it. `/proc/self/` helps you avoid building the path of the `maps` file with the process *pid*. – Iharob Al Asimi Oct 04 '15 at 14:07
  • @iharob Is reading that file the cleanest way to do it? – Overv Oct 04 '15 at 14:08
  • Yes, as many things in linux. It's probably similar to the way `EnumProcessModules` works internally. But reading from `/proc/self/` directory is realy reliable. The `proc` filesystem is a special filesystem that is mounted when the system boots, it's always mounted and every process is guaranteed to have an entry in the `/proc` directory AFAIK. – Iharob Al Asimi Oct 04 '15 at 14:10
  • I think this [answer](http://stackoverflow.com/a/27522149/2668109) might be of help. – gbs Oct 04 '15 at 14:11
  • @iharob I just found [dl_iterate_phdr](http://linux.die.net/man/3/dl_iterate_phdr), which seems to do the same as well. – Overv Oct 04 '15 at 14:13
  • Yes and [the link](http://syprog.blogspot.ru/2011/12/listing-loaded-shared-objects-in-linux.html) at the answer seems interesting too. – Iharob Al Asimi Oct 04 '15 at 14:14
  • @iharob Hah, that's perfect. Thanks. – Overv Oct 04 '15 at 14:15
  • But please read the manual page [dlopen(3)](http://man7.org/linux/man-pages/man3/dlopen.3.html). – Iharob Al Asimi Oct 04 '15 at 14:16
  • @iharob I did, but it's only mentioned at the bottom in related. – Overv Oct 04 '15 at 14:17

0 Answers0