用于调试的已编译库的C++钩子函数
问题描述:
用于调试目的,希望在每次调用时获取已编译库中某些函数的参数。我知道我可以重新编译库,但对于某些库(例如Qt)可能需要半天时间。用于调试的已编译库的C++钩子函数
考虑这个功能在编译库
class SomeClass
{
public:
static QString getUpper(const QString &str);
};
方案,其中包括从图书馆
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
}
这个SomeClass的我已经找到了一些similar question,但我不`吨需要DLL注入。这是我的程序,包括图书馆。