Remove RENDERDOC_ANDROID_LIBRARY as a 'hooked library'. Refs #1140

* We only need to check for it in intercept_dlopen to return a consistent handle
  to our own library regardless of how the library is opened, to prevent
  multiple copies of the library being loaded.
This commit is contained in:
baldurk
2018-10-29 17:20:25 +00:00
parent 944e37c47a
commit 90ef8815e3
+13 -4
View File
@@ -215,8 +215,19 @@ HookingInfo &GetHookInfo()
void *intercept_dlopen(const char *filename, int flag)
{
if(filename && GetHookInfo().IsLibHook(std::string(filename)))
return dlopen(RENDERDOC_ANDROID_LIBRARY, flag);
if(filename)
{
// if this is a library we're hooking, or a request for our own library in any form, return our
// own library.
// We need to intercept requests for our own library, because the android loader makes the
// completely ridiculous decision to load multiple copies of the same library into a process if
// it's dlopen'd with different paths. This obviously breaks with our hook install.
if(strstr(filename, RENDERDOC_ANDROID_LIBRARY) || GetHookInfo().IsLibHook(std::string(filename)))
{
HOOK_DEBUG_PRINT("Intercepting dlopen for %s", filename);
return dlopen(RENDERDOC_ANDROID_LIBRARY, flag);
}
}
return NULL;
}
@@ -520,8 +531,6 @@ static void InstallHooksCommon()
GetHookInfo().SetHooked("libc.so");
GetHookInfo().SetHooked("libvndksupport.so");
GetHookInfo().AddLibHook(RENDERDOC_ANDROID_LIBRARY);
real_android_dlopen_ext = &android_dlopen_ext;
loader_dlopen = (pfn__loader_dlopen)dlsym(RTLD_NEXT, "__loader_dlopen");