81 lines
1.9 KiB
C++
81 lines
1.9 KiB
C++
#ifndef _HOOKPROC_EXCEPTIONHOOK_HPP_
|
|
#define _HOOKPROC_EXCEPTIONHOOK_HPP_
|
|
#ifndef _HOOKPROC_APIENTRY_HPP_
|
|
#include <hookproc/apientry.hpp>
|
|
#endif
|
|
#ifndef _HOOKPROC_PROCADDRESS_HPP_
|
|
#include <hookproc/procaddr.hpp>
|
|
#endif
|
|
#ifndef _DEBUG_EXCEPTIONREGISTRATION_HPP_
|
|
#include <debug/excptreg.hpp>
|
|
#endif
|
|
|
|
class ExcptHook;
|
|
typedef ProcAddress<ExcptHook> ExceptionHook;
|
|
|
|
extern "C"
|
|
{
|
|
void registerHandler(PureExceptionRegistration::ExceptionHandler pExceptionHandler);
|
|
void unregisterHandler(void);
|
|
}
|
|
|
|
class ExcptHook : protected APIEntry, private ExceptionHook
|
|
{
|
|
public:
|
|
ExcptHook(void);
|
|
virtual ~ExcptHook();
|
|
void registerHandler(void);
|
|
protected:
|
|
virtual PureExceptionRegistration::ExceptionDisposition exceptionHandler(EXCEPTION_RECORD *pExceptionRecord,void *pEstablisherFrame,CONTEXT *pContext,void *pDispatcherContext);
|
|
private:
|
|
enum {ParamLength=16};
|
|
ExcptHook &operator=(const ExcptHook &someExcptHook);
|
|
PureExceptionRegistration::ExceptionDisposition entryProc(EXCEPTION_RECORD *pExceptionRecord,void *pEstablisherFrame,CONTEXT *pContext,void *pDispatcherContext);
|
|
WORD isRegistered(void)const;
|
|
void isRegistered(WORD isRegistered);
|
|
|
|
WORD mIsRegistered;
|
|
};
|
|
|
|
inline
|
|
ExcptHook::ExcptHook(void)
|
|
: APIEntry(ParamLength,(DWORD)this,getProcAddress((ProcAddress<ExcptHook>::LPFNMETHODVOID)&ExcptHook::entryProc)),
|
|
mIsRegistered(FALSE)
|
|
{
|
|
}
|
|
|
|
inline
|
|
ExcptHook::~ExcptHook()
|
|
{
|
|
if(!isRegistered())return;
|
|
::unregisterHandler();
|
|
}
|
|
|
|
inline
|
|
ExcptHook &ExcptHook::operator=(const ExcptHook &someExcptHook)
|
|
{ // no implementation
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
void ExcptHook::registerHandler(void)
|
|
{
|
|
if(isRegistered())return;
|
|
::registerHandler((PureExceptionRegistration::ExceptionHandler)codeBase());
|
|
isRegistered(TRUE);
|
|
}
|
|
|
|
inline
|
|
WORD ExcptHook::isRegistered(void)const
|
|
{
|
|
return mIsRegistered;
|
|
}
|
|
|
|
inline
|
|
void ExcptHook::isRegistered(WORD isRegistered)
|
|
{
|
|
mIsRegistered=isRegistered;
|
|
}
|
|
#endif
|
|
|