Skip to content

How to hook OpenGL extensions? #274

Answered by phuongtran7
phuongtran7 asked this question in Q&A
Discussion options

You must be logged in to vote

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:

static BOOL(* TruewglMakeCurrent)(HDC, HGLRC) = wglMakeCurrent;
static void(*TrueglShaderSource)(GLuint, GLsizei, const GLchar* const*, const GLint*) = nullptr;
void CustomglShaderSource(GLuint, GLsizei, const GLchar* const*, c…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by phuongtran7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant