diff --git a/game_payload/include/utils.h b/game_payload/include/utils.h index a308fe6..237c3e5 100644 --- a/game_payload/include/utils.h +++ b/game_payload/include/utils.h @@ -2,6 +2,7 @@ #include -uint32_t utils_file_crc32c(const char *filePath); +int utils_file_exists(const wchar_t *filePath); +uint32_t utils_file_crc32c(const wchar_t *filePath); char utils_env_enabled(const char *env); diff --git a/game_payload/src/hi3.c b/game_payload/src/hi3.c index 22f0da8..77354e2 100644 --- a/game_payload/src/hi3.c +++ b/game_payload/src/hi3.c @@ -24,7 +24,7 @@ const struct crc_id_pair HI3_REGIONS[] = { }; void hi3_fill_data(struct game_data *buf) { - uint32_t crc = utils_file_crc32c("UnityPlayer.dll"); + 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++) { diff --git a/game_payload/src/hsr.c b/game_payload/src/hsr.c index f855362..5c02225 100644 --- a/game_payload/src/hsr.c +++ b/game_payload/src/hsr.c @@ -70,7 +70,7 @@ static void _unityplayer_callback(HMODULE unityModule) { } void hsr_fill_data(struct game_data *buf) { - uint32_t crc = utils_file_crc32c("UnityPlayer.dll"); + uint32_t crc = utils_file_crc32c(L"UnityPlayer.dll"); enum game_id id = GAME_INVALID; for (size_t i = 0; i < sizeof(HSR_REGIONS) / sizeof(struct crc_id_pair); i++) { diff --git a/game_payload/src/utils.c b/game_payload/src/utils.c index 42d48c2..b94e735 100644 --- a/game_payload/src/utils.c +++ b/game_payload/src/utils.c @@ -5,10 +5,14 @@ #include -uint32_t utils_file_crc32c(const char *filePath) { - HANDLE file = CreateFileA(filePath, FILE_READ_ACCESS, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); +int utils_file_exists(const wchar_t *filePath) { + return GetFileAttributesW(filePath) != INVALID_FILE_ATTRIBUTES; +} + +uint32_t utils_file_crc32c(const wchar_t *filePath) { + HANDLE file = CreateFileW(filePath, FILE_READ_ACCESS, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (!file) { - msg_err_a("Could not open file: %s", filePath); + msg_err_w(L"Could not open file: %ls", filePath); } LARGE_INTEGER fileSize; @@ -17,7 +21,7 @@ uint32_t utils_file_crc32c(const char *filePath) { HANDLE hMap = CreateFileMappingA(file, NULL, PAGE_READONLY, 0, 0, NULL); char *map = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0); if (!map) { - msg_err_a("Could not create file mapping for %s", filePath); + msg_err_w(L"Could not create file mapping for %ls", filePath); } uint32_t crc = crc32c(0, (unsigned char*)map, fileSize.QuadPart);