Android openGL hook
hook头文件
#ifndef _GL_INTERFACETEST_H_
#define _GL_INTERFACETEST_H_
namespace android {
void hook_eglSwapBuffers();
}
#endif
hook实现
#include <log/log.h>
#include "egl_hook.h"
namespace android {
void hook_eglSwapBuffers() {
ALOGD("hook successfully! eglSwapBuffer...");
return;
}
}
hook调用点
在eglApi.cpp内增加hook点
EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
{
hook_eglSwapBuffers();
return eglSwapBuffersWithDamageKHR(dpy, surface, NULL, 0);
}
makefile
Android.bp
cc_library_shared {
name: "libEGL",
defaults: ["egl_libs_defaults"],
srcs: [
"EGL/egl_hook.cpp",
"EGL/egl_tls.cpp",
"EGL/egl_cache.cpp",
"EGL/egl_display.cpp",
"EGL/egl_object.cpp",
"EGL/egl.cpp",
"EGL/eglApi.cpp",
"EGL/Loader.cpp",
],
shared_libs: [
"libvndksupport",
"android.hardware.configstore@1.0",
"android.hardware.configstore-utils",
"libhidlbase",
"libhidltransport",
"libutils",
],
static_libs: [
"libEGL_getProcAddress",
"libEGL_blobCache",
],
ldflags: ["-Wl,--exclude-libs=ALL"],
export_include_dirs: ["EGL/include"],
}
其他
可以将hook封装成库调用
可以在hook库中新建线程实现某些吓死人的技术