调试编译库的C++钩子函数
C++ hook function of compiled library for debugging
出于调试目的,希望在每次调用时获取已编译库中某些函数的参数。我知道我可以重新编译库,但是对于某些库(例如 Qt)可能需要半天的时间。
在编译库中考虑这个函数
class SomeClass
{
public:
static QString getUpper(const QString &str);
};
包含库中这个 SomeClass 的程序
void printArguments(const QString &str)
{
qDebug() << str; //here we print argument
}
int main()
{
//function that I need
hookFunction((void*)&SomeClass::getUpper, (void*)&printArguments);
SomeClass::getUpper("Hi"); // here I will see "Hi" in console
}
我找到了一些 ,但我不需要 dll 注入。这是我的包含库的程序。
我找到了解决方案
这library(PolyHook)做我想做的。
出于调试目的,希望在每次调用时获取已编译库中某些函数的参数。我知道我可以重新编译库,但是对于某些库(例如 Qt)可能需要半天的时间。
在编译库中考虑这个函数
class SomeClass
{
public:
static QString getUpper(const QString &str);
};
包含库中这个 SomeClass 的程序
void printArguments(const QString &str)
{
qDebug() << str; //here we print argument
}
int main()
{
//function that I need
hookFunction((void*)&SomeClass::getUpper, (void*)&printArguments);
SomeClass::getUpper("Hi"); // here I will see "Hi" in console
}
我找到了一些
我找到了解决方案
这library(PolyHook)做我想做的。