1

我想使用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);

}

但是得到了错误,'函数式转换为内置类型只能接受一个参数。

所以不管怎样,他们都说有点当众羞辱对灵魂有好处,我的灵魂一定是度过了最美好的时光……

谢谢。

4

2 回答 2

1

您的函数的类型是 FnType:

typedef void (QPainter::*FnType)(const QPointF &, const QString &);

但看起来他们期望的是一个WINIAPI= __stdcallC 函数。您可能会想是否可以将您的函数包装到 C 函数中。

于 2011-01-07T22:52:07.323 回答
1

请记住,非静态成员函数确实将隐式this指针作为参数,您必须在绕行时声明。

于 2011-01-07T23:09:37.987 回答