Here is my DLL code: I create a process to inject the dll to system wide process.And use another application to test the function,but everytime I call the glBegin(),first my MessageBox(for testing use) poping up,then the error Messagebox comes up.Help me:
#include "stdafx.h"
#include "madCHook.h"
#include "GL.H"
void (*glBeginNext)(GLenum cap);
void glBeginCallback(GLenum cap)
{
MessageBox(NULL,"Do you want to use this func?","haha",MB_OK);
glBeginNext(cap);
}
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch(ul_reason_for_call)
{
case(DLL_PROCESS_ATTACH):InitializeMadCHook();
HookAPI("opengl32.dll","glBegin",glBeginCallback,(PVOID*)&glBeginNext);
break;
case(DLL_PROCESS_DETACH):
FinalizeMadCHook();
break;
}
return TRUE;
}