-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsplish_splash.cpp
More file actions
34 lines (27 loc) · 1.06 KB
/
splish_splash.cpp
File metadata and controls
34 lines (27 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <QApplication>
#include <QSplashScreen>
#include <stdio.h>
#include <stdlib.h>
#include <cstdlib>
#define _GNU_SOURCE
#include <dlfcn.h>
const char* FUNC_SYMBOL = "_ZN13QSplashScreen9setPixmapERK7QPixmap";
const char* ENV_VAR_NAME = "OVERRIDE_QT_SPLASH";
typedef void (*orig_setpixmap_f_type)(QSplashScreen *, const QPixmap &pixmap);
void QSplashScreen::setPixmap(const QPixmap &pixmap){
const char* img_path = std::getenv(ENV_VAR_NAME);
// At least let people know something is afoot...
printf("hacked splash: %s\n", img_path);
// If loading the hacked pixmap doesn't work, fall back on the original
QPixmap hacked_pixmap;
if(!hacked_pixmap.load(img_path)){
hacked_pixmap = pixmap;
}
// Use some nuts function pointer black magic to replace the
// compiled QSplashScreen::setPixmap() with ours...
//
// Big thanks to Antonio Patriarca for the assist here!
orig_setpixmap_f_type orig_setpixmap;
orig_setpixmap = (orig_setpixmap_f_type)dlsym(RTLD_NEXT, FUNC_SYMBOL);
orig_setpixmap(this, hacked_pixmap);
}