Yuriy Pryyma
Yuriy Pryyma

Reputation: 603

C++ hook function of compiled library for debugging

For debugging purposes in want to get arguments of some function in compiled library on each call. I know I could recompile library, but it could take half of day for some libraries(Qt for example).

Consider this function in compiled library

class SomeClass
{
public:
    static QString getUpper(const QString &str);
};

Program that includes this SomeClass from library

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
}

I have found some similar question, but I don`t need dll injection. This is my program that include library.

Upvotes: 1

Views: 1623

Answers (1)

Yuriy Pryyma
Yuriy Pryyma

Reputation: 603

I have found solution

This library(PolyHook) do what I want.

Upvotes: 1

Related Questions