Files
Work/hookproc/MSGHOOK.HPP
2024-08-07 09:16:27 -04:00

42 lines
1012 B
C++

#ifndef _HOOKPROC_MESSAGEHOOK_HPP_
#define _HOOKPROC_MESSAGEHOOK_HPP_
#ifndef _HOOKPROC_APIENTRY_HPP_
#include <hookproc/apientry.hpp>
#endif
#ifndef _HOOKPROC_PROCADDRESS_HPP_
#include <hookproc/procaddr.hpp>
#endif
class MsgHook;
typedef ProcAddress<MsgHook> MessageHook;
class MsgHook : protected APIEntry, private MessageHook
{
public:
MsgHook(void);
virtual ~MsgHook();
protected:
virtual int hookProc(int code,WPARAM wParam,LPARAM lParam);
private:
enum {ParamLength=12};
MsgHook &operator=(const MsgHook &someMsgHook);
int entryProc(int code,WPARAM wParam,LPARAM lParam);
HHOOK mhPrevHook;
};
inline
MsgHook::MsgHook(void)
: APIEntry(ParamLength,(DWORD)this,getProcAddress((ProcAddress<MsgHook>::LPFNMETHODVOID)&MsgHook::entryProc)),
mhPrevHook(0)
{
mhPrevHook=::SetWindowsHookEx(WH_GETMESSAGE,(HOOKPROC)codeBase(),(HINSTANCE)::GetModuleHandle(0),::GetCurrentThreadId());
}
inline
MsgHook &MsgHook::operator=(const MsgHook &someMsgHook)
{ // no implementation
return *this;
}
#endif