我想使用windows detours库来绕过一个非win api函数。该函数是 Qt 库 (QtGui4.dll) 的一部分。我想知道如何设置函数签名:
void QPainter::drawText ( const QPointF & position, const QString & text )
我对此进行了尝试,它收到了我通常的错误份额,对需求的一些解释也会很有趣:
void (QPainter * real_drawText)(const QPointF & position, const QString & text) = drawText
这是它们在 Windows API 下 TextOut 的样子:
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;
}
因此,按照 Gene 的建议,我尝试了:
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);
}
但是得到了错误,'函数式转换为内置类型只能接受一个参数。
所以不管怎样,他们都说有点当众羞辱对灵魂有好处,我的灵魂一定是度过了最美好的时光……
谢谢。