Sign in to follow this  
LlamaFood

GetProcAddress Function Returns NULL For Hook Proc

Recommended Posts

I'm making a global hook but for some reason GetProcAddress is returning NULL. Here's my WM_CREATE msg:
case WM_CREATE:
	HOOKPROC KBhkprc; 
	static HINSTANCE DLL;
	DLL=LoadLibrary((LPCTSTR)("c:\\hook.dll"));
	KBhkprc=(HOOKPROC)GetProcAddress(DLL,"KBHkPrc");
	if(KBhkprc==NULL) {
		MessageBox(0,"GetProcAdress Returns NULL",0,MB_OK);
	}
	kbhook=SetWindowsHookEx(WH_SYSMSGFILTER,KBhkprc,DLL,0);
And here's my DLL header:
#include <windows.h>

__declspec(dllexport) LRESULT __cdecl KBHkPrc(int code,WPARAM wParam,LPARAM lParam);

Share this post


Link to post
Share on other sites
and to be source that DLL is loaded add:


DLL=LoadLibrary((LPCTSTR)("c:\\hook.dll"));
if(DLL==NULL) {
MessageBox(0,"Can not load DLL",0,MB_OK);
return();
}

KBhkprc=(HOOKPROC)GetProcAddress(DLL,"KBHkPrc");
if(KBhkprc==NULL) {
MessageBox(0,"GetProcAdress Returns NULL",0,MB_OK);
}
kbhook=SetWindowsHookEx(WH_SYSMSGFILTER,KBhkprc,DLL,0);



Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this