MS Detours Library,绕行非win api函数
我想使用 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
这就是 TextOut 的样子,在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;
}
因此,按照 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);
}
但收到错误,“到内置类型的函数样式转换只能采用一个参数”。
所以无论如何,他们说一点公开羞辱对灵魂有好处,我的灵魂一定度过了最美好的时光……
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的函数的类型是 FnType:
但看起来他们期望的是
WINIAPI
=__stdcall
C 函数。您可能会想是否可以将函数包装到 C 函数中。The type of your functions is FnType:
but it looks like what they expect is a
WINIAPI
=__stdcall
C function instead. You might think if you can wrap your function into a C function.请记住,非静态成员函数确实会获取隐式
this
指针作为参数,您必须在绕行时声明该指针。Remember that non-static member functions do get an implicit
this
pointer as parameter, that you have to declare when detouring.