Files
jadeite/game_payload/src/game.c

40 lines
873 B
C
Raw Normal View History

2023-06-08 21:44:42 +03:00
#include <msg.h>
2023-08-10 01:00:24 +03:00
#include <utils.h>
2023-06-06 00:23:08 +03:00
#include <game.h>
2023-06-08 18:36:22 +03:00
typedef void (*fill_fn)(struct game_data *buf);
struct name_fn_pair {
2023-08-10 01:00:24 +03:00
const wchar_t *name;
2023-06-08 18:36:22 +03:00
fill_fn fill;
};
const struct name_fn_pair GAMES[] = {
2023-08-10 01:00:24 +03:00
{ L"BH3", &hi3_fill_data },
{ L"StarRail", &hsr_fill_data }
2023-06-08 18:36:22 +03:00
};
2023-06-06 00:23:08 +03:00
void game_detect(struct game_data *buf) {
2023-08-10 01:00:24 +03:00
wchar_t exePath[MAX_PATH];
GetModuleFileNameW(NULL, exePath, MAX_PATH);
2023-06-06 00:23:08 +03:00
2023-08-10 01:00:24 +03:00
// Leave only the basename
wchar_t *exeName = wcsrchr(exePath, L'\\') + 1;
2023-06-06 00:23:08 +03:00
2023-08-10 01:00:24 +03:00
// Cut off extension (.exe)
wchar_t *extensionDot = wcsrchr(exeName, L'.');
if (extensionDot != NULL) {
*extensionDot = L'\0';
}
for (size_t i = 0; i < UTILS_COUNT(GAMES); i++) {
if (wcsicmp(exeName, GAMES[i].name) == 0) {
2023-06-08 18:36:22 +03:00
GAMES[i].fill(buf);
return;
}
2023-06-06 00:23:08 +03:00
}
2023-06-08 18:36:22 +03:00
2023-08-10 01:00:24 +03:00
msg_err_w(L"Unknown game: %ls", exeName);
2023-06-06 00:23:08 +03:00
}