Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b2d33ad24 | |||
| ba6a054ec3 | |||
| 7693e63619 | |||
| 5d5d2117ec | |||
| ca65bbd70c | |||
| c17cf00409 | |||
| c80635fc71 | |||
| e9d2130105 |
Binary file not shown.
@ -2,10 +2,12 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define UTILS_COUNT(arr) (sizeof(arr) / sizeof(*arr))
|
||||
|
||||
int utils_path_exists(const wchar_t *filePath);
|
||||
uint32_t utils_file_crc32c(const wchar_t *filePath);
|
||||
|
||||
void utils_create_dir_recursively(const wchar_t *path);
|
||||
void utils_create_parent_dirs(const wchar_t *path);
|
||||
|
||||
void utils_save_to_file(const wchar_t *filePath, const void *buf, size_t length);
|
||||
|
||||
|
||||
@ -23,6 +23,9 @@
|
||||
### 3.0.1
|
||||
- Fixed a bug that caused HI3 to crash
|
||||
|
||||
### branch/master
|
||||
### 3.0.2
|
||||
- Fixed multiple error messageboxes showing invalid characters
|
||||
- Added handling for more error conditions
|
||||
|
||||
### 3.0.4
|
||||
- Moved LoadLibrary call into core from main
|
||||
|
||||
@ -1,32 +1,39 @@
|
||||
#include <msg.h>
|
||||
#include <utils.h>
|
||||
|
||||
#include <game.h>
|
||||
|
||||
typedef void (*fill_fn)(struct game_data *buf);
|
||||
|
||||
struct name_fn_pair {
|
||||
const char *name;
|
||||
const wchar_t *name;
|
||||
fill_fn fill;
|
||||
};
|
||||
|
||||
const struct name_fn_pair GAMES[] = {
|
||||
{ "bh3.exe", &hi3_fill_data },
|
||||
{ "starrail.exe", &hsr_fill_data }
|
||||
{ L"BH3", &hi3_fill_data },
|
||||
{ L"StarRail", &hsr_fill_data }
|
||||
};
|
||||
|
||||
void game_detect(struct game_data *buf) {
|
||||
char exePath[MAX_PATH];
|
||||
GetModuleFileNameA(NULL, exePath, MAX_PATH);
|
||||
wchar_t exePath[MAX_PATH];
|
||||
GetModuleFileNameW(NULL, exePath, MAX_PATH);
|
||||
|
||||
char *exeName = strrchr(exePath, '\\') + 1;
|
||||
strlwr(exeName);
|
||||
// Leave only the basename
|
||||
wchar_t *exeName = wcsrchr(exePath, L'\\') + 1;
|
||||
|
||||
for (size_t i = 0; i < sizeof(GAMES) / sizeof(struct name_fn_pair); i++) {
|
||||
if (strcmp(exeName, GAMES[i].name) == 0) {
|
||||
// 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) {
|
||||
GAMES[i].fill(buf);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
msg_err_a("Unknown game: %s", exeName);
|
||||
msg_err_w(L"Unknown game: %ls", exeName);
|
||||
}
|
||||
|
||||
@ -78,14 +78,15 @@ void hsr_fill_data(struct game_data *buf) {
|
||||
uint32_t crc = utils_file_crc32c(L"UnityPlayer.dll");
|
||||
|
||||
enum hsr_region id = HSR_INVALID;
|
||||
for (size_t i = 0; i < sizeof(HSR_REGIONS) / sizeof(struct crc_region_pair); i++) {
|
||||
for (size_t i = 0; i < UTILS_COUNT(HSR_REGIONS); i++) {
|
||||
if (HSR_REGIONS[i].crc == crc) {
|
||||
id = HSR_REGIONS[i].id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (id == HSR_INVALID) {
|
||||
msg_err_a("Invalid UnityPlayer.dll checksum: %x", crc);
|
||||
msg_err_a("Invalid UnityPlayer.dll checksum: 0x%08x. This usually happens when the patch is outdated", crc);
|
||||
}
|
||||
|
||||
buf->base_module_name = HSR_BASE_MODULE_NAME;
|
||||
|
||||
@ -51,18 +51,12 @@ static void _run_game(struct game_data *game, wchar_t *txFile) {
|
||||
}
|
||||
|
||||
static void _run_tx(struct game_data *game, wchar_t *txFile) {
|
||||
// Load unpatched base module
|
||||
HMODULE baseModule = LoadLibraryA(game->base_module_name);
|
||||
if (!baseModule) {
|
||||
msg_err_a("Failed to load base module: %s", game->base_module_name);
|
||||
}
|
||||
|
||||
// ...more magic
|
||||
size_t tableSize;
|
||||
void *table = core_perform_tx(game, &tableSize);
|
||||
|
||||
// Save to file
|
||||
utils_create_dir_recursively(txFile);
|
||||
utils_create_parent_dirs(txFile);
|
||||
utils_save_to_file(txFile, table, tableSize);
|
||||
|
||||
// Cleanup
|
||||
|
||||
@ -34,21 +34,18 @@ uint32_t utils_file_crc32c(const wchar_t *filePath) {
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/a/16719260
|
||||
void utils_create_dir_recursively(const wchar_t *path) {
|
||||
void utils_create_parent_dirs(const wchar_t *path) {
|
||||
wchar_t dir[MAX_PATH];
|
||||
ZeroMemory(dir, MAX_PATH * sizeof(wchar_t));
|
||||
ZeroMemory(dir, sizeof(dir));
|
||||
|
||||
wchar_t *end = wcschr(path, L'\\');
|
||||
const wchar_t *end = path - 1;
|
||||
|
||||
while(end != NULL)
|
||||
{
|
||||
while((end = wcschr(++end, L'\\')) != NULL) {
|
||||
wcsncpy(dir, path, end - path + 1);
|
||||
|
||||
if (!utils_path_exists(dir) && !CreateDirectoryW(dir, NULL)) {
|
||||
msg_err_w(L"Failed to create directory: %ls", dir);
|
||||
}
|
||||
|
||||
end = wcschr(++end, L'\\');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -88,7 +88,7 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved) {
|
||||
&pi
|
||||
)) {
|
||||
wchar_t message[1024];
|
||||
wsprintfW(message, L"Failed to start game process: %ld", GetLastError());
|
||||
wsprintfW(message, L"Failed to start game process: %ld\nGame executable path: '%ls'", GetLastError(), targetExe);
|
||||
MessageBoxW(NULL, message, J_MB_TITLE, MB_OK | MB_ICONERROR);
|
||||
|
||||
exit(1);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
project('jadeite', 'c', version: '3.0.3')
|
||||
project('jadeite', 'c', version: '3.0.5')
|
||||
|
||||
nasm = find_program('nasm')
|
||||
gen_res = find_program('gen_resources.sh')
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"jadeite": {
|
||||
"version": "3.0.3"
|
||||
"version": "3.0.5"
|
||||
},
|
||||
"games": {
|
||||
"hi3rd": {
|
||||
|
||||
Reference in New Issue
Block a user