diff --git a/src/platform/unix.c b/src/platform/unix.c index 7ee7d9a8da..6401814e14 100644 --- a/src/platform/unix.c +++ b/src/platform/unix.c @@ -43,8 +43,35 @@ char platform_get_path_separator() } */ +// See http://syprog.blogspot.ru/2011/12/listing-loaded-shared-objects-in-linux.html +struct lmap { + void* base_address; + char* path; + void* unused; + struct lmap *next, *prev; +}; + +struct dummy { + void* pointers[3]; + struct dummy* ptr; +}; + bool platform_is_steam_overlay_attached() { - return dlopen("gameoverlayrenderer.so", RTLD_NOW | RTLD_NOLOAD) != NULL; + void* processHandle = dlopen(NULL, RTLD_NOW); + + struct dummy* p = (struct dummy*) processHandle; + p = p->ptr; + + struct lmap* pl = (struct lmap*) p->ptr; + + while (pl != NULL) { + if (strstr(pl->path, "gameoverlayrenderer.so") != NULL) { + return true; + } + pl = pl->next; + } + + return false; } #endif