I want to use the windows detours library to detour a non win api function. The function is part of the Qt library (QtGui4.dll). I am wondering how I would set up the function signature for :
void QPainter::drawText ( const QPointF & position, const QString & text )
I had a go with this and it received my usual share of errors, a little explanation of requirements would be interesting as well:
void (QPainter * real_drawText)(const QPointF & position, const QString & text) = drawText
This is what they look like for TextOut, under the windows API:
BOOL (WINAPI * Real_TextOut)(HDC a0, int a1, int a2, LPCWSTR a3, int a4) = TextOutW;
BOOL WINAPI Mine_TextOut(HDC hdc,int X,int Y,LPCWSTR text,int textLen)
{
BOOL rv = Real_TextOut(hdc, X, Y, text, textLen);
HWND hWindow = WindowFromDC(hdc);
SendTextMessage(hWindow, text);
return rv;
}
So, following on from Gene’s suggestion I tried:
typedef void (QPainter::* Real_qp_drawText)(const QPointF & position, const QString & text);
void Mine_drawText(const QPointF & position, const QString & text)
{
Real_qp_drawText(position,text);
}
But got the error, ‘a function-style conversion to a built-in type can only take one parameter.
So anyway, they say a little public humiliation is good for the soul, my soul must be having the best time…
Thanks.
The type of your functions is FnType:
but it looks like what they expect is a
WINIAPI=__stdcallC function instead. You might think if you can wrap your function into a C function.