Get rid of game_id

This commit is contained in:
mkrsym1 2023-08-04 23:00:42 +03:00
parent 400729a3dc
commit 6b9f9b6d93
4 changed files with 14 additions and 55 deletions

Binary file not shown.

View File

@ -2,26 +2,11 @@
#include <windows.h> #include <windows.h>
enum game_id {
GAME_INVALID,
GAME_HI3_GLB,
GAME_HI3_SEA,
GAME_HI3_CN,
GAME_HI3_TW,
GAME_HI3_KR,
GAME_HI3_JP,
GAME_HSR_OS,
GAME_HSR_CN
};
#define INVOKE_CALLBACK(callback, ...) if (callback) { callback(__VA_ARGS__); } #define INVOKE_CALLBACK(callback, ...) if (callback) { callback(__VA_ARGS__); }
typedef void (*unityplayer_callback_t)(HMODULE unityModule); typedef void (*unityplayer_callback_t)(HMODULE unityModule);
struct game_data { struct game_data {
enum game_id id; // Temporary
const char *base_module_name; const char *base_module_name;
const char *assembly_name; const char *assembly_name;
const char *txs_section_name; const char *txs_section_name;

View File

@ -8,37 +8,8 @@ const char *HI3_ASSEMBLY_NAME = "UserAssembly.dll";
const char *HI3_TXS_SECTION_NAME = ".bh3"; const char *HI3_TXS_SECTION_NAME = ".bh3";
const char *HI3_TVM_SECTION_NAME = ".tvm0"; const char *HI3_TVM_SECTION_NAME = ".tvm0";
struct crc_id_pair {
uint32_t crc;
enum game_id id;
};
const struct crc_id_pair HI3_REGIONS[] = {
// It may be possible to get rid of region-specific data altogether in the future
{ 0xcb8041ff, GAME_HI3_GLB }, // glb v6.8.0
{ 0x104cbfc5, GAME_HI3_SEA }, // sea v6.8.0
{ 0x2efd9099, GAME_HI3_CN }, // cn v6.8.0
{ 0x30fa5b0f, GAME_HI3_TW }, // tw v6.8.0
{ 0xe47327fb, GAME_HI3_KR }, // kr v6.8.0
{ 0x992b6b63, GAME_HI3_JP } // jp v6.8.0
};
void hi3_fill_data(struct game_data *buf) { void hi3_fill_data(struct game_data *buf) {
uint32_t crc = utils_file_crc32c(L"UnityPlayer.dll");
enum game_id id = GAME_INVALID;
for (size_t i = 0; i < sizeof(HI3_REGIONS) / sizeof(struct crc_id_pair); i++) {
if (HI3_REGIONS[i].crc == crc) {
id = HI3_REGIONS[i].id;
}
}
if (id == GAME_INVALID) {
msg_err_a("Invalid UnityPlayer.dll checksum: %x", crc);
}
buf->id = id;
buf->base_module_name = HI3_BASE_MODULE_NAME; buf->base_module_name = HI3_BASE_MODULE_NAME;
buf->assembly_name = HI3_ASSEMBLY_NAME; buf->assembly_name = HI3_ASSEMBLY_NAME;
buf->txs_section_name = HI3_TXS_SECTION_NAME; buf->txs_section_name = HI3_TXS_SECTION_NAME;

View File

@ -9,16 +9,20 @@ const char *HSR_ASSEMBLY_NAME = "GameAssembly.dll";
const char *HSR_TXS_SECTION_NAME = ".ace"; const char *HSR_TXS_SECTION_NAME = ".ace";
const char *HSR_TVM_SECTION_NAME = ".tvm0"; const char *HSR_TVM_SECTION_NAME = ".tvm0";
struct crc_id_pair { enum hsr_region {
uint32_t crc; HSR_INVALID,
enum game_id id; HSR_OS,
HSR_CN
}; };
const struct crc_id_pair HSR_REGIONS[] = { struct crc_region_pair {
// It may be possible to get rid of region-specific data altogether in the future uint32_t crc;
enum hsr_region id;
};
{ 0x9eb3084e, GAME_HSR_OS }, // os v1.2.0 const struct crc_region_pair HSR_REGIONS[] = {
{ 0x14be07e9, GAME_HSR_CN } // cn v1.2.0 { 0x9eb3084e, HSR_OS }, // os v1.2.0
{ 0x14be07e9, HSR_CN } // cn v1.2.0
}; };
#define JUMP_SIZE (6 + sizeof(void*)) #define JUMP_SIZE (6 + sizeof(void*))
@ -73,18 +77,17 @@ static void _unityplayer_callback(HMODULE unityModule) {
void hsr_fill_data(struct game_data *buf) { void hsr_fill_data(struct game_data *buf) {
uint32_t crc = utils_file_crc32c(L"UnityPlayer.dll"); uint32_t crc = utils_file_crc32c(L"UnityPlayer.dll");
enum game_id id = GAME_INVALID; enum hsr_region id = HSR_INVALID;
for (size_t i = 0; i < sizeof(HSR_REGIONS) / sizeof(struct crc_id_pair); i++) { for (size_t i = 0; i < sizeof(HSR_REGIONS) / sizeof(struct crc_region_pair); i++) {
if (HSR_REGIONS[i].crc == crc) { if (HSR_REGIONS[i].crc == crc) {
id = HSR_REGIONS[i].id; id = HSR_REGIONS[i].id;
} }
} }
if (id == GAME_INVALID) { if (id == HSR_INVALID) {
msg_err_a("Invalid UnityPlayer.dll checksum: %x", crc); msg_err_a("Invalid UnityPlayer.dll checksum: %x", crc);
} }
buf->id = id;
buf->base_module_name = HSR_BASE_MODULE_NAME; buf->base_module_name = HSR_BASE_MODULE_NAME;
buf->assembly_name = HSR_ASSEMBLY_NAME; buf->assembly_name = HSR_ASSEMBLY_NAME;
buf->txs_section_name = HSR_TXS_SECTION_NAME; buf->txs_section_name = HSR_TXS_SECTION_NAME;