matrix
matrix copied to clipboard
OpenGL Leak原理
Matrix中有针对open gl泄露的检测,针对最新代码进行了研究,没有特别理解背后的原理,有几个问题希望能够解答一下,或者提供一下相应的资料
OpenglIndexDetectorService作用
在OpenglLeakPlugin的start方法中,在开启的Thread中调用了startImpl方法,随后启动了OpenglIndexDetectorService,Service中的onBind返回了一个IBinder对象,为何要跨进程?在Service中的onServiceConnected中进行了hook操作,这样做的原因是什么,为什么不直接hook?
get_gl_hooks作用
以Java_com_tencent_matrix_openglleak_hook_OpenGLHook_hookGlGenTextures这个方法为例 `extern "C" JNIEXPORT jboolean JNICALL Java_com_tencent_matrix_openglleak_hook_OpenGLHook_hookGlGenTextures (JNIEnv *, jclass, jint index) { gl_hooks_t *hooks = get_gl_hooks(); if (NULL == hooks) { return false; }
void **origFunPtr = NULL;
origFunPtr = (void **) (&hooks->gl.foo1 + index);
system_glGenTextures = (System_GlNormal_TYPE) *origFunPtr;
*origFunPtr = (void *) my_glGenTextures;
return true;
}` 为什么针对get_gl_hooks返回的指针进行(void **) (&hooks->gl.foo1 + index);就能够拿到origFunPtr的地址?get_gl_hooks中的__get_tls()这个宏函数具体是什么意思?
native hook
open gl leak的检测没有采用GOT/PLT hook 或者inline hook针对native底层进行hook,是出于什么的考虑?
- 1,最近在解决GL内存增长的问题,看到了 Matrix 这里有相关的,但是 完全不知道原理是啥。 接入后,也没有看到 有什么回调。
下面这样 底层 hack 之后的 代理的时候,为什么要过滤掉 原生的 RenderThread 的 申请???