#include #include typedef void (*fill_fn)(struct game_data *buf); struct name_fn_pair { const char *name; fill_fn fill; }; const struct name_fn_pair GAMES[] = { { "bh3.exe", &hi3_fill_data }, { "starrail.exe", &hsr_fill_data } }; void game_detect(struct game_data *buf) { char exePath[MAX_PATH]; GetModuleFileNameA(NULL, exePath, MAX_PATH); char *exeName = strrchr(exePath, '\\') + 1; strlwr(exeName); for (size_t i = 0; i < sizeof(GAMES) / sizeof(struct name_fn_pair); i++) { if (strcmp(exeName, GAMES[i].name) == 0) { GAMES[i].fill(buf); return; } } err_mb_a("Unknown game: %s", exeName); }