QtDebugger/src/injector.cpp

33 lines
510 B
C++
Raw Normal View History

2023-01-08 15:08:07 +01:00
// this file injects the debugger into the QApplication
#include "qtdebugger.h"
#include <iostream>
#include <dlfcn.h>
#include <QApplication>
class QApplication;
int QApplication::exec() {
// init debugger
QtDebugger debugger;
// get real exec call
static int (*real_exec)() = (int (*)())dlsym(RTLD_NEXT, "_ZN12QApplication4execEv");
if ( !real_exec ) {
// failed to init real exec
return -1;
}
// call real exec call
int returnVal = real_exec();
// end debugger
return returnVal;
}