我关注了this example拦截类中的 C++ 函数。
但是现在我想拦截类的构造函数和析构函数,而不仅仅是成员函数。
在示例中,他执行了 typedef unsigned int (Foo::*methodType)() const;
。我不认为你可以在 C++ 中使用 typedef 构造函数/析构函数。
我该怎么做?
最佳答案
我试过了
typedef void (QDBusConnection::*MyFunction)();
它有效,我可以用 (this->*origMethod)();
调用它,即使 origMethod 是一个析构函数并且没有返回说明符。
我在这里写了关于如何拦截析构函数和静态类函数的步骤
http://www.osletek.com/learning-center/150/Intercepting_C%2B%2B_functions_using_LD_PRELOAD
关于c++ - 使用 LD_PRELOAD 拦截 c++ 类构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26244378/