How to hook OpenGL extensions? #274
-
Hi, I'm trying to hook into some of the OpenGL extensions, especially the However, in order for Is there anyway to hook into those OpenGL extensions without having to go into hooking already running process? Thank you so much for your time and help. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Took awhile but I'm finally able to answer my own question. Using apitrace I noticed that the call to Something like this if I want to hook into static BOOL(* TruewglMakeCurrent)(HDC, HGLRC) = wglMakeCurrent;
static void(*TrueglShaderSource)(GLuint, GLsizei, const GLchar* const*, const GLint*) = nullptr;
void CustomglShaderSource(GLuint, GLsizei, const GLchar* const*, const GLint*);
BOOL CustomwglMakeCurrent(HDC unnamedParam1, HGLRC unnamedParam2)
{
const auto result = TruewglMakeCurrent(unnamedParam1, unnamedParam2);
if (result)
{
if (glewInit())
{
// Can't init glew. Handle error
return result;
}
TrueglShaderSource = glShaderSource;
// Detour attach like normal here and everything else
DetourAttach(&(PVOID&)TrueglShaderSource, CustomglShaderSource);
}
return result;
}
|
Beta Was this translation helpful? Give feedback.
Took awhile but I'm finally able to answer my own question. Using apitrace I noticed that the call to
wglMakeCurrent
to at the almost very top of the application I want to hook into, and it's one of the few API that Detours can hook. So I just hooked into it, made context as current, then used Glew to finally find all the other functions', that I wanted to hook into, addresses. And that worked like a charm.Something like this if I want to hook into
glShaderSource
: