Unhooking the hooked function throws exception.
Posted: Wed Mar 25, 2015 12:55 pm
I am a newbie to madshi hooking api's. I have created a code to hook a function in QTGui4.dll which is of QT framework.
The function is of class' ,named . I have hooked it using function. Function drawText is hooked successfully, but unhooking it gives exception.
Following is my code:
So , please can anyone tell me what i am making a mistake.Thanx in advance for any help.
The function is of class
Code: Select all
QPaninter
Code: Select all
drawText
Code: Select all
HookCode
Following is my code:
Code: Select all
void MyHook()
{
__try
{
hMod=(HMODULE)GetModuleHandleA("QtGui4.dll");
DWORD drawText = (DWORD)(((DWORD)hMod)+((DWORD)0x001207B0));//4.7.4:QPainter::drawText(class QRect const &,int,class QString const &,class QRect *) : 0x001207B0
HookCode((PVOID)drawText,NewdrawText ,(PVOID*) &UnhookdrawText);
}
__except(filter(GetExceptionCode(),GetExceptionInformation(),L"HK_API")) //catch(...)
{
;
}
}
Code: Select all
void (WINAPI * UnhookdrawText) ( const QRect & rectangle, int flags, const QString & text, QRect * boundingRect );
void WINAPI NewdrawText ( const QRect & rectangle, int flags, const QString & text, QRect * boundingRect = 0 )
{
__try
{
WriteLog_String(L"NewdrawText",L"Entered * * * *");
UnhookdrawText(rectangle,flags,text,boundingRect);
}
__except(filter(GetExceptionCode(),GetExceptionInformation(),L"DRTXT_API")) //catch(...)
{
;
}
}