MangoHud/src/blacklist.cpp

68 lines
1.6 KiB
C++
Raw Normal View History

#include <vector>
2020-04-18 16:02:30 +00:00
#include <string>
#include <algorithm>
#include "blacklist.h"
#include "string_utils.h"
#include "file_utils.h"
static std::string get_proc_name() {
// Note: It is possible to use GNU program_invocation_short_name.
const std::string proc_name = get_wine_exe_name(/*keep_ext=*/true);
if (!proc_name.empty()) {
return proc_name;
2020-04-18 16:02:30 +00:00
}
return get_basename(get_exe_path());
2020-04-18 16:02:30 +00:00
}
static std::vector<std::string> blacklist {
"Battle.net.exe",
"BethesdaNetLauncher.exe",
"EpicGamesLauncher.exe",
"IGOProxy.exe",
"IGOProxy64.exe",
"Origin.exe",
"OriginThinSetupInternal.exe",
"steam",
"steamwebhelper",
"gldriverquery",
"vulkandriverquery",
"Steam.exe",
"ffxivlauncher.exe",
"ffxivlauncher64.exe",
"LeagueClient.exe",
"LeagueClientUxRender.exe",
"SocialClubHelper.exe",
};
2020-04-18 16:02:30 +00:00
static bool check_blacklisted() {
2020-04-18 16:02:30 +00:00
std::string proc_name = get_proc_name();
bool blacklisted = std::find(blacklist.begin(), blacklist.end(), proc_name) != blacklist.end();
2020-05-05 19:37:47 +00:00
if(blacklisted) {
fprintf(stderr, "INFO: process %s is blacklisted in MangoHud\n", proc_name.c_str());
}
2020-04-18 16:02:30 +00:00
return blacklisted;
}
bool is_blacklisted(bool force_recheck) {
2020-04-29 09:18:17 +00:00
static bool blacklisted = check_blacklisted();
if (force_recheck)
blacklisted = check_blacklisted();
2020-04-18 16:02:30 +00:00
return blacklisted;
}
void add_blacklist(const std::string& new_item) {
// check if item exits in blacklist before adding new item
if(std::find(blacklist.begin(), blacklist.end(), new_item) != blacklist.end()) {
return;
}
blacklist.push_back (new_item);
is_blacklisted(true);
}