mirror of
https://github.com/pumpitupdev/pumptools.git
synced 2026-09-29 18:27:55 +03:00
Appl new code style on whole code base
Use a similar code style to bemanitools though reduce indentation to 2 spaces. Also some other tweaks to be more similar to google style.
This commit is contained in:
+134
-122
@@ -14,8 +14,8 @@
|
||||
#include "hook/patch/hook-mon.h"
|
||||
#include "hook/patch/main-loop.h"
|
||||
#include "hook/patch/microdog34.h"
|
||||
#include "hook/patch/piuio.h"
|
||||
#include "hook/patch/piuio-exit.h"
|
||||
#include "hook/patch/piuio.h"
|
||||
#include "hook/patch/redir.h"
|
||||
#include "hook/patch/sigsegv.h"
|
||||
#include "hook/patch/sound.h"
|
||||
@@ -35,214 +35,226 @@
|
||||
extern const uint8_t _binary_x2hook_dog_key_start[];
|
||||
extern const uint8_t _binary_x2hook_dog_key_end[];
|
||||
|
||||
static void x2hook_bootstrapping(int argc, char** argv, struct x2hook_options* options, char** game_data_path)
|
||||
static void x2hook_bootstrapping(
|
||||
int argc,
|
||||
char **argv,
|
||||
struct x2hook_options *options,
|
||||
char **game_data_path)
|
||||
{
|
||||
log_assert(argc >= 0);
|
||||
log_assert(argv);
|
||||
log_assert(options);
|
||||
log_assert(game_data_path);
|
||||
log_assert(argc >= 0);
|
||||
log_assert(argv);
|
||||
log_assert(options);
|
||||
log_assert(game_data_path);
|
||||
|
||||
if (hook_core_piu_block_non_piu_process_recursion(argc, argv)) {
|
||||
return;
|
||||
}
|
||||
if (hook_core_piu_block_non_piu_process_recursion(argc, argv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
hook_core_piu_log_init(argc, argv);
|
||||
hook_core_piu_log_init(argc, argv);
|
||||
|
||||
if (!x2hook_options_init(argc, argv, options)) {
|
||||
exit(0);
|
||||
}
|
||||
if (!x2hook_options_init(argc, argv, options)) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
hook_core_piu_log_info(argc, argv);
|
||||
hook_core_piu_log_info(argc, argv);
|
||||
|
||||
*game_data_path = hook_core_piu_utils_get_and_verify_game_data_path(argc, argv);
|
||||
*game_data_path =
|
||||
hook_core_piu_utils_get_and_verify_game_data_path(argc, argv);
|
||||
|
||||
hook_core_piu_utils_verify_root_user();
|
||||
hook_core_piu_utils_verify_root_user();
|
||||
|
||||
log_info("Initializing, piu game data path: %s", *game_data_path);
|
||||
log_info("Initializing, piu game data path: %s", *game_data_path);
|
||||
}
|
||||
|
||||
static void x2hook_patch_fs_init(struct x2hook_options* options)
|
||||
static void x2hook_patch_fs_init(struct x2hook_options *options)
|
||||
{
|
||||
log_assert(options);
|
||||
log_assert(options);
|
||||
|
||||
patch_hook_mon_init(
|
||||
options->patch.hook_mon.io,
|
||||
options->patch.hook_mon.file,
|
||||
options->patch.hook_mon.fs,
|
||||
options->patch.hook_mon.usb,
|
||||
options->patch.hook_mon.open);
|
||||
patch_hook_mon_init(
|
||||
options->patch.hook_mon.io,
|
||||
options->patch.hook_mon.file,
|
||||
options->patch.hook_mon.fs,
|
||||
options->patch.hook_mon.usb,
|
||||
options->patch.hook_mon.open);
|
||||
|
||||
patch_redir_init();
|
||||
patch_redir_init();
|
||||
}
|
||||
|
||||
static void x2hook_fs_redir_settings(struct x2hook_options* options)
|
||||
static void x2hook_fs_redir_settings(struct x2hook_options *options)
|
||||
{
|
||||
log_assert(options);
|
||||
log_assert(options);
|
||||
|
||||
if (options->game.settings) {
|
||||
if (!util_fs_path_exists(options->game.settings)) {
|
||||
log_info("Settings path %s does not exist, creating", options->game.settings);
|
||||
if (options->game.settings) {
|
||||
if (!util_fs_path_exists(options->game.settings)) {
|
||||
log_info(
|
||||
"Settings path %s does not exist, creating", options->game.settings);
|
||||
|
||||
if (!util_fs_mkdir(options->game.settings)) {
|
||||
log_error("Creating directory %s failed", options->game.settings);
|
||||
}
|
||||
}
|
||||
|
||||
char* abs_path = util_fs_get_abs_path(options->game.settings);
|
||||
|
||||
cnh_redir_add("/SETTINGS", abs_path);
|
||||
free(abs_path);
|
||||
} else {
|
||||
log_warn("No settings path specified");
|
||||
if (!util_fs_mkdir(options->game.settings)) {
|
||||
log_error("Creating directory %s failed", options->game.settings);
|
||||
}
|
||||
}
|
||||
|
||||
char *abs_path = util_fs_get_abs_path(options->game.settings);
|
||||
|
||||
cnh_redir_add("/SETTINGS", abs_path);
|
||||
free(abs_path);
|
||||
} else {
|
||||
log_warn("No settings path specified");
|
||||
}
|
||||
}
|
||||
|
||||
static void x2hook_fs_redir_script(struct x2hook_options* options, const char* game_data_path)
|
||||
static void x2hook_fs_redir_script(
|
||||
struct x2hook_options *options, const char *game_data_path)
|
||||
{
|
||||
log_assert(options);
|
||||
log_assert(game_data_path);
|
||||
log_assert(options);
|
||||
log_assert(game_data_path);
|
||||
|
||||
char* path_tmp;
|
||||
char *path_tmp;
|
||||
|
||||
path_tmp = util_str_merge(game_data_path, "/SCRIPT");
|
||||
cnh_redir_add("/SCRIPT", path_tmp);
|
||||
free(path_tmp);
|
||||
path_tmp = util_str_merge(game_data_path, "/SCRIPT");
|
||||
cnh_redir_add("/SCRIPT", path_tmp);
|
||||
free(path_tmp);
|
||||
}
|
||||
|
||||
static void x2hook_fs_redir_usb()
|
||||
{
|
||||
/* Needed on newer kernels */
|
||||
cnh_redir_add("/proc/bus/usb/devices", "/sys/kernel/debug/usb/devices");
|
||||
/* Needed on newer kernels */
|
||||
cnh_redir_add("/proc/bus/usb/devices", "/sys/kernel/debug/usb/devices");
|
||||
}
|
||||
|
||||
static void x2hook_fs_redirs_init(struct x2hook_options* options, const char* game_data_path)
|
||||
static void x2hook_fs_redirs_init(
|
||||
struct x2hook_options *options, const char *game_data_path)
|
||||
{
|
||||
log_assert(options);
|
||||
log_assert(game_data_path);
|
||||
log_assert(options);
|
||||
log_assert(game_data_path);
|
||||
|
||||
/* Expecting all assets in the piu game (asset) folder. redirects for files
|
||||
that are not in there by default for reasons */
|
||||
x2hook_fs_redir_settings(options);
|
||||
x2hook_fs_redir_script(options, game_data_path);
|
||||
/* Expecting all assets in the piu game (asset) folder. redirects for files
|
||||
that are not in there by default for reasons */
|
||||
x2hook_fs_redir_settings(options);
|
||||
x2hook_fs_redir_script(options, game_data_path);
|
||||
|
||||
x2hook_fs_redir_usb();
|
||||
x2hook_fs_redir_usb();
|
||||
}
|
||||
|
||||
static void x2hook_patch_gfx_init(struct x2hook_options* options)
|
||||
static void x2hook_patch_gfx_init(struct x2hook_options *options)
|
||||
{
|
||||
log_assert(options);
|
||||
log_assert(options);
|
||||
|
||||
patch_gfx_init();
|
||||
patch_gfx_init();
|
||||
|
||||
if (options->patch.gfx.windowed) {
|
||||
patch_gfx_force_window_mode();
|
||||
}
|
||||
if (options->patch.gfx.windowed) {
|
||||
patch_gfx_force_window_mode();
|
||||
}
|
||||
}
|
||||
|
||||
static void x2hook_patch_game_init(struct x2hook_options* options)
|
||||
static void x2hook_patch_game_init(struct x2hook_options *options)
|
||||
{
|
||||
log_assert(options);
|
||||
log_assert(options);
|
||||
|
||||
if (options->game.force_unlock) {
|
||||
hook_x2_unlock_init();
|
||||
}
|
||||
if (options->game.force_unlock) {
|
||||
hook_x2_unlock_init();
|
||||
}
|
||||
|
||||
/* return from StopAllEffects to avoid killing the sound thread */
|
||||
log_warn("Applying memory patch only valid for version 102");
|
||||
util_patch_write_memory_byte(0x08074CE0, 0xC3);
|
||||
/* return from StopAllEffects to avoid killing the sound thread */
|
||||
log_warn("Applying memory patch only valid for version 102");
|
||||
util_patch_write_memory_byte(0x08074CE0, 0xC3);
|
||||
}
|
||||
|
||||
static void x2hook_patch_main_loop_init(struct x2hook_options* options)
|
||||
static void x2hook_patch_main_loop_init(struct x2hook_options *options)
|
||||
{
|
||||
log_assert(options);
|
||||
log_assert(options);
|
||||
|
||||
patch_main_loop_init(true, options->patch.main_loop.disable_built_in_inputs, false);
|
||||
patch_main_loop_init(
|
||||
true, options->patch.main_loop.disable_built_in_inputs, false);
|
||||
|
||||
if (options->patch.main_loop.x11_input_handler_api_lib) {
|
||||
char* abs_path_x11_input_hook_lib = util_fs_get_abs_path(options->patch.main_loop.x11_input_handler_api_lib);
|
||||
if (options->patch.main_loop.x11_input_handler_api_lib) {
|
||||
char *abs_path_x11_input_hook_lib = util_fs_get_abs_path(
|
||||
options->patch.main_loop.x11_input_handler_api_lib);
|
||||
|
||||
patch_main_loop_add_x11_input_handler(abs_path_x11_input_hook_lib);
|
||||
free(abs_path_x11_input_hook_lib);
|
||||
}
|
||||
patch_main_loop_add_x11_input_handler(abs_path_x11_input_hook_lib);
|
||||
free(abs_path_x11_input_hook_lib);
|
||||
}
|
||||
}
|
||||
|
||||
static void x2hook_patch_sound_init(struct x2hook_options* options)
|
||||
static void x2hook_patch_sound_init(struct x2hook_options *options)
|
||||
{
|
||||
log_assert(options);
|
||||
log_assert(options);
|
||||
|
||||
patch_sound_init(options->patch.sound.device);
|
||||
patch_sound_init(options->patch.sound.device);
|
||||
}
|
||||
|
||||
static void x2hook_patch_sigsegv_init(struct x2hook_options* options)
|
||||
static void x2hook_patch_sigsegv_init(struct x2hook_options *options)
|
||||
{
|
||||
log_assert(options);
|
||||
log_assert(options);
|
||||
|
||||
patch_sigsegv_init(options->patch.sigsegv.halt_on_segv);
|
||||
patch_sigsegv_init(options->patch.sigsegv.halt_on_segv);
|
||||
}
|
||||
|
||||
static void x2hook_patch_dongle_init()
|
||||
{
|
||||
patch_microdog34_init((const uint8_t*) _binary_x2hook_dog_key_start,
|
||||
((uintptr_t) &_binary_x2hook_dog_key_end - (uintptr_t) &_binary_x2hook_dog_key_start));
|
||||
patch_microdog34_init(
|
||||
(const uint8_t *) _binary_x2hook_dog_key_start,
|
||||
((uintptr_t) &_binary_x2hook_dog_key_end -
|
||||
(uintptr_t) &_binary_x2hook_dog_key_start));
|
||||
}
|
||||
|
||||
static void x2hook_patch_piuio_init(struct x2hook_options* options)
|
||||
static void x2hook_patch_piuio_init(struct x2hook_options *options)
|
||||
{
|
||||
log_assert(options);
|
||||
log_assert(options);
|
||||
|
||||
/* Hook before IO emulation */
|
||||
if (options->patch.piuio.exit_test_serv) {
|
||||
patch_piuio_exit_init();
|
||||
}
|
||||
/* Hook before IO emulation */
|
||||
if (options->patch.piuio.exit_test_serv) {
|
||||
patch_piuio_exit_init();
|
||||
}
|
||||
|
||||
patch_usb_init_fix_init();
|
||||
patch_usb_emu_init();
|
||||
patch_usb_init_fix_init();
|
||||
patch_usb_emu_init();
|
||||
|
||||
if (options->patch.piuio.api_lib) {
|
||||
char* abs_path_iolib = util_fs_get_abs_path(options->patch.piuio.api_lib);
|
||||
if (options->patch.piuio.api_lib) {
|
||||
char *abs_path_iolib = util_fs_get_abs_path(options->patch.piuio.api_lib);
|
||||
|
||||
patch_piuio_init(abs_path_iolib);
|
||||
free(abs_path_iolib);
|
||||
}
|
||||
patch_piuio_init(abs_path_iolib);
|
||||
free(abs_path_iolib);
|
||||
}
|
||||
}
|
||||
|
||||
void x2hook_constructor(void)
|
||||
{
|
||||
/* Nothing here */
|
||||
/* Nothing here */
|
||||
}
|
||||
|
||||
void x2hook_destructor(void)
|
||||
{
|
||||
/* Nothing here */
|
||||
/* Nothing here */
|
||||
}
|
||||
|
||||
void x2hook_trap_before_main(int argc, char** argv)
|
||||
void x2hook_trap_before_main(int argc, char **argv)
|
||||
{
|
||||
log_assert(argc >= 0);
|
||||
log_assert(argv);
|
||||
log_assert(argc >= 0);
|
||||
log_assert(argv);
|
||||
|
||||
char* game_data_path;
|
||||
struct x2hook_options options;
|
||||
char *game_data_path;
|
||||
struct x2hook_options options;
|
||||
|
||||
x2hook_bootstrapping(argc, argv, &options, &game_data_path);
|
||||
x2hook_patch_fs_init(&options);
|
||||
x2hook_fs_redirs_init(&options, game_data_path);
|
||||
x2hook_patch_gfx_init(&options);
|
||||
x2hook_patch_game_init(&options);
|
||||
x2hook_patch_main_loop_init(&options);
|
||||
x2hook_patch_sound_init(&options);
|
||||
x2hook_patch_sigsegv_init(&options);
|
||||
x2hook_patch_dongle_init();
|
||||
x2hook_patch_piuio_init(&options);
|
||||
x2hook_bootstrapping(argc, argv, &options, &game_data_path);
|
||||
x2hook_patch_fs_init(&options);
|
||||
x2hook_fs_redirs_init(&options, game_data_path);
|
||||
x2hook_patch_gfx_init(&options);
|
||||
x2hook_patch_game_init(&options);
|
||||
x2hook_patch_main_loop_init(&options);
|
||||
x2hook_patch_sound_init(&options);
|
||||
x2hook_patch_sigsegv_init(&options);
|
||||
x2hook_patch_dongle_init();
|
||||
x2hook_patch_piuio_init(&options);
|
||||
|
||||
free(game_data_path);
|
||||
free(game_data_path);
|
||||
|
||||
log_info("Hooking finished");
|
||||
log_info("Hooking finished");
|
||||
}
|
||||
|
||||
void x2hook_trap_after_main(void)
|
||||
{
|
||||
patch_piuio_shutdown();
|
||||
patch_piuio_shutdown();
|
||||
}
|
||||
|
||||
LIB_MAIN_CONSTRUCTOR(x2hook_constructor);
|
||||
|
||||
+20
-17
@@ -2,8 +2,9 @@
|
||||
* Module to fix weird OpenGL error that only appeared on Exceed 2 thus far.
|
||||
*
|
||||
* If OpenGL is not forced into single threaded mode, the backend will run in
|
||||
* multi-threaded mode for some reason and crash in __glDispatchCheckMultithreaded
|
||||
* when the game calls glXChooseVisual in its GFX init function.
|
||||
* multi-threaded mode for some reason and crash in
|
||||
* __glDispatchCheckMultithreaded when the game calls glXChooseVisual in its GFX
|
||||
* init function.
|
||||
*
|
||||
* The fix is quite simple (luckily) as this seems that Exceed 2 is not the only
|
||||
* game that requires the environment variable __GL_SINGLETHREADED to be set.
|
||||
@@ -14,25 +15,27 @@
|
||||
|
||||
#include "capnhook/hook/lib.h"
|
||||
|
||||
typedef char* (*getenv_t) (const char* name);
|
||||
typedef char *(*getenv_t)(const char *name);
|
||||
|
||||
static getenv_t _x2hook_ogl_fix_real_getenv;
|
||||
|
||||
char* getenv(const char* name)
|
||||
char *getenv(const char *name)
|
||||
{
|
||||
if (!_x2hook_ogl_fix_real_getenv) {
|
||||
_x2hook_ogl_fix_real_getenv = (getenv_t) cnh_lib_get_func_addr("getenv");
|
||||
if (!_x2hook_ogl_fix_real_getenv) {
|
||||
_x2hook_ogl_fix_real_getenv = (getenv_t) cnh_lib_get_func_addr("getenv");
|
||||
}
|
||||
|
||||
char *ret = _x2hook_ogl_fix_real_getenv(name);
|
||||
|
||||
if (!strcmp(name, "__GL_SINGLETHREADED")) {
|
||||
if (ret == NULL || strcmp(name, "1") != 0) {
|
||||
printf(
|
||||
"!!! x2hook: __GL_SINGLETHREADED not set or enabled, force patching "
|
||||
"OpenGL to single threaded to "
|
||||
"avoid crash !!!\n");
|
||||
return "1";
|
||||
}
|
||||
}
|
||||
|
||||
char* ret = _x2hook_ogl_fix_real_getenv(name);
|
||||
|
||||
if (!strcmp(name, "__GL_SINGLETHREADED")) {
|
||||
if (ret == NULL || strcmp(name, "1") != 0) {
|
||||
printf("!!! x2hook: __GL_SINGLETHREADED not set or enabled, force patching OpenGL to single threaded to "
|
||||
"avoid crash !!!\n");
|
||||
return "1";
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
+59
-39
@@ -10,19 +10,24 @@
|
||||
#define X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_IO "patch.hook_mon.io"
|
||||
#define X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_OPEN "patch.hook_mon.open"
|
||||
#define X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_USB "patch.hook_mon.usb"
|
||||
#define X2HOOK_OPTIONS_STR_PATCH_HOOK_MAIN_LOOP_DISABLE_BUILT_IN_INPUTS "patch.hook_main_loop.disable_built_in_inputs"
|
||||
#define X2HOOK_OPTIONS_STR_PATCH_HOOK_MAIN_LOOP_X11_INPUT_HANDLER "patch_hook_main_loop.x11_input_handler"
|
||||
#define X2HOOK_OPTIONS_STR_PATCH_HOOK_MAIN_LOOP_DISABLE_BUILT_IN_INPUTS \
|
||||
"patch.hook_main_loop.disable_built_in_inputs"
|
||||
#define X2HOOK_OPTIONS_STR_PATCH_HOOK_MAIN_LOOP_X11_INPUT_HANDLER \
|
||||
"patch_hook_main_loop.x11_input_handler"
|
||||
#define X2HOOK_OPTIONS_STR_PATCH_PIUIO_EMU_LIB "patch.piuio.emu_lib"
|
||||
#define X2HOOK_OPTIONS_STR_PATCH_PIUIO_EXIT_TEST_SERV "patch.piuio_exit.test_serv"
|
||||
#define X2HOOK_OPTIONS_STR_PATCH_PIUIO_EXIT_TEST_SERV \
|
||||
"patch.piuio_exit.test_serv"
|
||||
#define X2HOOK_OPTIONS_STR_PATCH_SOUND_DEVICE "patch.sound.device"
|
||||
#define X2HOOK_OPTIONS_STR_PATCH_SIGSEGV_HALT_ON_SEGV "patch.sigsegv.halt_on_segv"
|
||||
#define X2HOOK_OPTIONS_STR_PATCH_SIGSEGV_HALT_ON_SEGV \
|
||||
"patch.sigsegv.halt_on_segv"
|
||||
#define X2HOOK_OPTIONS_STR_PATCH_UTIL_LOG_FILE "util.log.file"
|
||||
#define X2HOOK_OPTIONS_STR_PATCH_UTIL_LOG_LEVEL "util.log.level"
|
||||
|
||||
static const struct util_options_def x2hook_options_def[] = {
|
||||
{
|
||||
.name = X2HOOK_OPTIONS_STR_GAME_FORCE_UNLOCK,
|
||||
.description = "Force unlock the game. Modifies the current and any new PIUEXCEED.INI settings file permanently",
|
||||
.description = "Force unlock the game. Modifies the current and any "
|
||||
"new PIUEXCEED.INI settings file permanently",
|
||||
.param = 'z',
|
||||
.type = UTIL_OPTIONS_TYPE_BOOL,
|
||||
.default_value.b = false,
|
||||
@@ -78,21 +83,24 @@ static const struct util_options_def x2hook_options_def[] = {
|
||||
},
|
||||
{
|
||||
.name = X2HOOK_OPTIONS_STR_PATCH_HOOK_MAIN_LOOP_DISABLE_BUILT_IN_INPUTS,
|
||||
.description = "Disable the built in keyboard inputs for test (F1), service (F2) and clear (F3)",
|
||||
.description = "Disable the built in keyboard inputs for test (F1), "
|
||||
"service (F2) and clear (F3)",
|
||||
.param = 'k',
|
||||
.type = UTIL_OPTIONS_TYPE_BOOL,
|
||||
.default_value.b = false,
|
||||
},
|
||||
{
|
||||
.name = X2HOOK_OPTIONS_STR_PATCH_HOOK_MAIN_LOOP_X11_INPUT_HANDLER,
|
||||
.description = "Path to a library implementing the x11-input-handler api to capture X11 keyboard inputs",
|
||||
.description = "Path to a library implementing the x11-input-handler "
|
||||
"api to capture X11 keyboard inputs",
|
||||
.param = 'q',
|
||||
.type = UTIL_OPTIONS_TYPE_STR,
|
||||
.default_value.str = NULL,
|
||||
},
|
||||
{
|
||||
.name = X2HOOK_OPTIONS_STR_PATCH_PIUIO_EMU_LIB,
|
||||
.description = "Path to library implementing the piuio api for piuio emulation",
|
||||
.description =
|
||||
"Path to library implementing the piuio api for piuio emulation",
|
||||
.param = 'p',
|
||||
.type = UTIL_OPTIONS_TYPE_STR,
|
||||
.default_value.str = NULL,
|
||||
@@ -143,41 +151,53 @@ static const struct util_options_defs x2hook_options_defs = {
|
||||
.ndefs = lengthof(x2hook_options_def)
|
||||
};
|
||||
|
||||
bool x2hook_options_init(int argc, char** argv, struct x2hook_options* options)
|
||||
bool x2hook_options_init(int argc, char **argv, struct x2hook_options *options)
|
||||
{
|
||||
log_assert(argv);
|
||||
log_assert(options);
|
||||
log_assert(argv);
|
||||
log_assert(options);
|
||||
|
||||
struct util_options_opts* options_opt;
|
||||
struct util_options_opts *options_opt;
|
||||
|
||||
util_options_init(argc, argv);
|
||||
options_opt = util_options_get(&x2hook_options_defs);
|
||||
util_options_init(argc, argv);
|
||||
options_opt = util_options_get(&x2hook_options_defs);
|
||||
|
||||
if (!options_opt) {
|
||||
return false;
|
||||
}
|
||||
if (!options_opt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
options->game.force_unlock = util_options_get_bool(options_opt, X2HOOK_OPTIONS_STR_GAME_FORCE_UNLOCK);
|
||||
options->game.settings = util_options_get_str(options_opt, X2HOOK_OPTIONS_STR_GAME_SETTINGS);
|
||||
options->patch.gfx.windowed = util_options_get_bool(options_opt, X2HOOK_OPTIONS_STR_PATCH_GFX_WINDOWED);
|
||||
options->patch.hook_mon.file = util_options_get_bool(options_opt, X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE);
|
||||
options->patch.hook_mon.fs = util_options_get_bool(options_opt, X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_FS);
|
||||
options->patch.hook_mon.io = util_options_get_bool(options_opt, X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_IO);
|
||||
options->patch.hook_mon.open = util_options_get_bool(options_opt, X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_OPEN);
|
||||
options->patch.hook_mon.usb = util_options_get_bool(options_opt, X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_USB);
|
||||
options->patch.main_loop.disable_built_in_inputs = util_options_get_bool(options_opt,
|
||||
X2HOOK_OPTIONS_STR_PATCH_HOOK_MAIN_LOOP_DISABLE_BUILT_IN_INPUTS);
|
||||
options->patch.main_loop.x11_input_handler_api_lib =
|
||||
util_options_get_str(options_opt, X2HOOK_OPTIONS_STR_PATCH_HOOK_MAIN_LOOP_X11_INPUT_HANDLER);
|
||||
options->patch.piuio.api_lib = util_options_get_str(options_opt, X2HOOK_OPTIONS_STR_PATCH_PIUIO_EMU_LIB);
|
||||
options->patch.piuio.exit_test_serv =
|
||||
util_options_get_bool(options_opt, X2HOOK_OPTIONS_STR_PATCH_PIUIO_EXIT_TEST_SERV);
|
||||
options->patch.sound.device = util_options_get_str(options_opt, X2HOOK_OPTIONS_STR_PATCH_SOUND_DEVICE);
|
||||
options->patch.sigsegv.halt_on_segv =
|
||||
util_options_get_bool(options_opt, X2HOOK_OPTIONS_STR_PATCH_SIGSEGV_HALT_ON_SEGV);
|
||||
options->log.file = util_options_get_str(options_opt, X2HOOK_OPTIONS_STR_PATCH_UTIL_LOG_FILE);
|
||||
options->log.level =
|
||||
(enum util_log_level) util_options_get_int(options_opt, X2HOOK_OPTIONS_STR_PATCH_UTIL_LOG_LEVEL);
|
||||
options->game.force_unlock =
|
||||
util_options_get_bool(options_opt, X2HOOK_OPTIONS_STR_GAME_FORCE_UNLOCK);
|
||||
options->game.settings =
|
||||
util_options_get_str(options_opt, X2HOOK_OPTIONS_STR_GAME_SETTINGS);
|
||||
options->patch.gfx.windowed =
|
||||
util_options_get_bool(options_opt, X2HOOK_OPTIONS_STR_PATCH_GFX_WINDOWED);
|
||||
options->patch.hook_mon.file = util_options_get_bool(
|
||||
options_opt, X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_FILE);
|
||||
options->patch.hook_mon.fs =
|
||||
util_options_get_bool(options_opt, X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_FS);
|
||||
options->patch.hook_mon.io =
|
||||
util_options_get_bool(options_opt, X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_IO);
|
||||
options->patch.hook_mon.open = util_options_get_bool(
|
||||
options_opt, X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_OPEN);
|
||||
options->patch.hook_mon.usb =
|
||||
util_options_get_bool(options_opt, X2HOOK_OPTIONS_STR_PATCH_HOOK_MON_USB);
|
||||
options->patch.main_loop.disable_built_in_inputs = util_options_get_bool(
|
||||
options_opt,
|
||||
X2HOOK_OPTIONS_STR_PATCH_HOOK_MAIN_LOOP_DISABLE_BUILT_IN_INPUTS);
|
||||
options->patch.main_loop.x11_input_handler_api_lib = util_options_get_str(
|
||||
options_opt, X2HOOK_OPTIONS_STR_PATCH_HOOK_MAIN_LOOP_X11_INPUT_HANDLER);
|
||||
options->patch.piuio.api_lib =
|
||||
util_options_get_str(options_opt, X2HOOK_OPTIONS_STR_PATCH_PIUIO_EMU_LIB);
|
||||
options->patch.piuio.exit_test_serv = util_options_get_bool(
|
||||
options_opt, X2HOOK_OPTIONS_STR_PATCH_PIUIO_EXIT_TEST_SERV);
|
||||
options->patch.sound.device =
|
||||
util_options_get_str(options_opt, X2HOOK_OPTIONS_STR_PATCH_SOUND_DEVICE);
|
||||
options->patch.sigsegv.halt_on_segv = util_options_get_bool(
|
||||
options_opt, X2HOOK_OPTIONS_STR_PATCH_SIGSEGV_HALT_ON_SEGV);
|
||||
options->log.file =
|
||||
util_options_get_str(options_opt, X2HOOK_OPTIONS_STR_PATCH_UTIL_LOG_FILE);
|
||||
options->log.level = (enum util_log_level) util_options_get_int(
|
||||
options_opt, X2HOOK_OPTIONS_STR_PATCH_UTIL_LOG_LEVEL);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
+35
-35
@@ -7,49 +7,49 @@
|
||||
#include "util/log.h"
|
||||
|
||||
struct x2hook_options {
|
||||
struct game {
|
||||
bool force_unlock;
|
||||
const char* settings;
|
||||
} game;
|
||||
struct game {
|
||||
bool force_unlock;
|
||||
const char *settings;
|
||||
} game;
|
||||
|
||||
struct patch {
|
||||
struct gfx {
|
||||
bool windowed;
|
||||
} gfx;
|
||||
struct patch {
|
||||
struct gfx {
|
||||
bool windowed;
|
||||
} gfx;
|
||||
|
||||
struct hook_mon {
|
||||
bool file;
|
||||
bool fs;
|
||||
bool io;
|
||||
bool open;
|
||||
bool usb;
|
||||
} hook_mon;
|
||||
struct hook_mon {
|
||||
bool file;
|
||||
bool fs;
|
||||
bool io;
|
||||
bool open;
|
||||
bool usb;
|
||||
} hook_mon;
|
||||
|
||||
struct main_loop {
|
||||
bool disable_built_in_inputs;
|
||||
const char* x11_input_handler_api_lib;
|
||||
} main_loop;
|
||||
struct main_loop {
|
||||
bool disable_built_in_inputs;
|
||||
const char *x11_input_handler_api_lib;
|
||||
} main_loop;
|
||||
|
||||
struct piuio {
|
||||
const char* api_lib;
|
||||
bool exit_test_serv;
|
||||
} piuio;
|
||||
struct piuio {
|
||||
const char *api_lib;
|
||||
bool exit_test_serv;
|
||||
} piuio;
|
||||
|
||||
struct sound {
|
||||
const char* device;
|
||||
} sound;
|
||||
struct sound {
|
||||
const char *device;
|
||||
} sound;
|
||||
|
||||
struct sigsegv {
|
||||
bool halt_on_segv;
|
||||
} sigsegv;
|
||||
} patch;
|
||||
struct sigsegv {
|
||||
bool halt_on_segv;
|
||||
} sigsegv;
|
||||
} patch;
|
||||
|
||||
struct log {
|
||||
const char* file;
|
||||
enum util_log_level level;
|
||||
} log;
|
||||
struct log {
|
||||
const char *file;
|
||||
enum util_log_level level;
|
||||
} log;
|
||||
};
|
||||
|
||||
bool x2hook_options_init(int argc, char** argv, struct x2hook_options* options);
|
||||
bool x2hook_options_init(int argc, char **argv, struct x2hook_options *options);
|
||||
|
||||
#endif
|
||||
|
||||
+49
-48
@@ -10,72 +10,73 @@
|
||||
#include "util/log.h"
|
||||
#include "util/str.h"
|
||||
|
||||
static FILE* _hook_x2_unlock_settings_file = NULL;
|
||||
static FILE *_hook_x2_unlock_settings_file = NULL;
|
||||
|
||||
static enum cnh_result _hook_x2_unlock_filehook(struct cnh_filehook_irp *irp);
|
||||
|
||||
void hook_x2_unlock_init(void)
|
||||
{
|
||||
cnh_filehook_push_handler(_hook_x2_unlock_filehook);
|
||||
cnh_filehook_push_handler(_hook_x2_unlock_filehook);
|
||||
|
||||
log_info("Initialized");
|
||||
log_info("Initialized");
|
||||
}
|
||||
|
||||
static enum cnh_result _hook_x2_unlock_filehook(struct cnh_filehook_irp *irp)
|
||||
{
|
||||
enum cnh_result result;
|
||||
enum cnh_result result;
|
||||
|
||||
assert(irp);
|
||||
assert(irp);
|
||||
|
||||
if (irp->op != CNH_FILEHOOK_IRP_OP_OPEN && irp->file != _hook_x2_unlock_settings_file) {
|
||||
return cnh_filehook_invoke_next(irp);
|
||||
if (irp->op != CNH_FILEHOOK_IRP_OP_OPEN &&
|
||||
irp->file != _hook_x2_unlock_settings_file) {
|
||||
return cnh_filehook_invoke_next(irp);
|
||||
}
|
||||
|
||||
switch (irp->op) {
|
||||
case CNH_FILEHOOK_IRP_OP_OPEN: {
|
||||
/* Let it open the real file */
|
||||
result = cnh_filehook_invoke_next(irp);
|
||||
|
||||
if (util_str_ends_with(irp->open_filename, ASSET_X2_SETTINGS_FILE_NAME)) {
|
||||
if (result == CNH_RESULT_SUCCESS) {
|
||||
log_debug("Intercepting settings file open");
|
||||
_hook_x2_unlock_settings_file = irp->file;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
switch (irp->op) {
|
||||
case CNH_FILEHOOK_IRP_OP_OPEN:
|
||||
{
|
||||
/* Let it open the real file */
|
||||
result = cnh_filehook_invoke_next(irp);
|
||||
case CNH_FILEHOOK_IRP_OP_READ: {
|
||||
/* Let it read the real file */
|
||||
result = cnh_filehook_invoke_next(irp);
|
||||
|
||||
if (util_str_ends_with(irp->open_filename, ASSET_X2_SETTINGS_FILE_NAME)) {
|
||||
if (result == CNH_RESULT_SUCCESS) {
|
||||
log_debug("Intercepting settings file open");
|
||||
_hook_x2_unlock_settings_file = irp->file;
|
||||
}
|
||||
}
|
||||
if (result == CNH_RESULT_SUCCESS) {
|
||||
struct asset_x2_settings *settings =
|
||||
(struct asset_x2_settings *) irp->read.bytes;
|
||||
|
||||
break;
|
||||
}
|
||||
asset_x2_settings_unlock_all(settings);
|
||||
|
||||
case CNH_FILEHOOK_IRP_OP_READ:
|
||||
{
|
||||
/* Let it read the real file */
|
||||
result = cnh_filehook_invoke_next(irp);
|
||||
log_debug(
|
||||
"Applied unlock patch to loaded settings (buffer size %d)",
|
||||
irp->read.pos);
|
||||
}
|
||||
|
||||
if (result == CNH_RESULT_SUCCESS) {
|
||||
struct asset_x2_settings* settings = (struct asset_x2_settings*) irp->read.bytes;
|
||||
|
||||
asset_x2_settings_unlock_all(settings);
|
||||
|
||||
log_debug("Applied unlock patch to loaded settings (buffer size %d)", irp->read.pos);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CNH_FILEHOOK_IRP_OP_CLOSE:
|
||||
{
|
||||
_hook_x2_unlock_settings_file = NULL;
|
||||
|
||||
result = cnh_filehook_invoke_next(irp);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
result = cnh_filehook_invoke_next(irp);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
case CNH_FILEHOOK_IRP_OP_CLOSE: {
|
||||
_hook_x2_unlock_settings_file = NULL;
|
||||
|
||||
result = cnh_filehook_invoke_next(irp);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
result = cnh_filehook_invoke_next(irp);
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
/**
|
||||
* Patch module to force unlock all permanently unlockable songs and additional difficulties in the game.
|
||||
* Patch module to force unlock all permanently unlockable songs and additional
|
||||
* difficulties in the game.
|
||||
*/
|
||||
#ifndef HOOK_X2_UNLOCK_H
|
||||
#define HOOK_X2_UNLOCK_H
|
||||
|
||||
Reference in New Issue
Block a user