Hooks are not that hard.....
Here is the code of a hook function that would monitor when windows are created.... g_hGlobalHook is the a global, the handle of the hook which would be set via another function after loading the *.dll - that handle is retrieved via SetWindowsHookEx() which is called by the app that loads the *.dll to inject the hook.
Code:
int __stdcall MyWindowHook(int nCode,WPARAM wParam,LPARAM lParam)
{
if (nCode < 0)
{
return ::CallNextHookEx(g_hGlobalHook,nCode,wParam,lParam);
}
else
{
CWPSTRUCT * pStruct = reinterpret_cast<CWPSTRUCT *>(lParam);
if (pStruct->message == WM_CREATE)
{
// Do something now that a window is being created.....
// Just don't create another window, that includes a MessageBox() call.
}
return ::CallNextHookEx(::g_hGlobalHook,nCode,wParam,lParam);
}
}
In fact, hooks are one of the easiest parts of the WINAPI to understand. How easy, never used one until 10 minutes ago.