jadeite/game_payload/src/game.c
2023-06-08 21:44:42 +03:00

33 lines
708 B
C

#include <msg.h>
#include <game.h>
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;
}
}
msg_err_a("Unknown game: %s", exeName);
}