2018-02-25 13:07:49 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Copyright (C) 2018 Maschell
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
2018-03-11 17:12:46 +01:00
|
|
|
|
2018-02-25 13:07:49 +01:00
|
|
|
#ifndef WUPS_HOOKS_DEF_H_
|
|
|
|
#define WUPS_HOOKS_DEF_H_
|
|
|
|
|
2018-02-25 15:18:52 +01:00
|
|
|
#include "common.h"
|
2018-06-30 16:49:49 +02:00
|
|
|
#include "utils.h"
|
2018-02-25 13:07:49 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define WUPS_HOOK_EX(type_def,original_func) \
|
2018-02-25 15:18:52 +01:00
|
|
|
extern const wups_loader_hook_t wups_hooks_ ## original_func WUPS_SECTION("hooks"); \
|
2018-02-25 13:07:49 +01:00
|
|
|
const wups_loader_hook_t wups_hooks_ ## original_func = { \
|
|
|
|
.type = type_def, \
|
|
|
|
.target = (const void*)&(original_func) \
|
|
|
|
}
|
2018-03-11 17:12:46 +01:00
|
|
|
|
2018-02-25 13:07:49 +01:00
|
|
|
typedef enum wups_loader_hook_type_t {
|
2018-02-25 15:18:52 +01:00
|
|
|
WUPS_LOADER_HOOK_INIT_FS, /* Only for internal usage */
|
2018-03-11 17:12:46 +01:00
|
|
|
WUPS_LOADER_HOOK_INIT_OVERLAY, /* Only for internal usage */
|
|
|
|
|
2018-02-25 13:07:49 +01:00
|
|
|
WUPS_LOADER_HOOK_INIT_PLUGIN, /* Called when exiting the plugin loader */
|
2018-03-11 17:12:46 +01:00
|
|
|
WUPS_LOADER_HOOK_DEINIT_PLUGIN, /* Called when re-entering the plugin loader */
|
2018-02-25 13:07:49 +01:00
|
|
|
WUPS_LOADER_HOOK_STARTING_APPLICATION, /* Called when an application gets started */
|
2018-03-07 18:53:43 +01:00
|
|
|
WUPS_LOADER_HOOK_FUNCTIONS_PATCHED, /* Called when the functions where patched */
|
2018-02-25 13:07:49 +01:00
|
|
|
WUPS_LOADER_HOOK_ENDING_APPLICATION, /* Called when an application ends */
|
|
|
|
WUPS_LOADER_HOOK_VSYNC, /* Called when an application calls GX2WaitForVsync (most times each frame) */
|
|
|
|
WUPS_LOADER_HOOK_APP_STATUS_CHANGED, /* Called when the app status changes (foreground, background, closing) */
|
2018-06-30 19:40:59 +02:00
|
|
|
|
|
|
|
WUPS_LOADER_HOOK_INIT_KERNEL, /* Only for internal usage */
|
2018-07-17 15:26:52 +02:00
|
|
|
WUPS_LOADER_HOOK_GET_CONFIG, /* Called when the config-menu will be loaded */
|
2018-02-25 13:07:49 +01:00
|
|
|
} wups_loader_hook_type_t;
|
|
|
|
|
|
|
|
typedef struct wups_loader_hook_t {
|
|
|
|
wups_loader_hook_type_t type; /* Defines the type of the hook */
|
|
|
|
const void *target; /* Address of our own, new function */
|
|
|
|
} wups_loader_hook_t;
|
|
|
|
|
|
|
|
typedef enum wups_loader_app_status_t {
|
|
|
|
WUPS_APP_STATUS_FOREGROUND, /* App is now running in foreground */
|
|
|
|
WUPS_APP_STATUS_BACKGROUND, /* App is now running in background */
|
|
|
|
WUPS_APP_STATUS_CLOSED, /* App is going to be closed */
|
|
|
|
WUPS_APP_STATUS_UNKNOWN, /* Unknown status _should_ never happen.*/
|
|
|
|
} wups_loader_app_status_t;
|
2018-03-11 17:12:46 +01:00
|
|
|
|
2018-02-25 13:07:49 +01:00
|
|
|
typedef struct wups_loader_app_started_args_t {
|
2018-06-20 16:16:16 +02:00
|
|
|
bool sd_mounted;
|
|
|
|
bool usb_mounted;
|
2018-06-30 19:40:59 +02:00
|
|
|
bool kernel_access;
|
2018-02-25 13:07:49 +01:00
|
|
|
} wups_loader_app_started_args_t;
|
|
|
|
|
2018-02-25 15:18:52 +01:00
|
|
|
#define WUPS_FS_ACCESS() \
|
|
|
|
void init_fs(wups_loader_init_fs_args_t);\
|
|
|
|
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_FS,init_fs); \
|
|
|
|
void init_fs(wups_loader_init_fs_args_t args){ \
|
|
|
|
WUPS_InitFS(args);\
|
|
|
|
}
|
2018-03-11 17:12:46 +01:00
|
|
|
|
2018-02-25 15:18:52 +01:00
|
|
|
#define WUPS_ALLOW_OVERLAY() \
|
|
|
|
void init_overlay(wups_loader_init_overlay_args_t);\
|
|
|
|
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_OVERLAY,init_overlay); \
|
|
|
|
void init_overlay(wups_loader_init_overlay_args_t args){ \
|
|
|
|
WUPS_InitOverlay(args);\
|
|
|
|
}
|
2018-06-30 19:40:59 +02:00
|
|
|
|
|
|
|
#define WUPS_ALLOW_KERNEL() \
|
|
|
|
void init_kernel(wups_loader_init_kernel_args_t);\
|
|
|
|
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_KERNEL,init_kernel); \
|
|
|
|
void init_kernel(wups_loader_init_kernel_args_t args){ \
|
|
|
|
WUPS_InitKernel(args);\
|
|
|
|
}
|
2018-07-17 15:26:52 +02:00
|
|
|
|
2018-02-25 13:07:49 +01:00
|
|
|
#define INITIALIZE_PLUGIN() \
|
2018-02-25 15:18:52 +01:00
|
|
|
void init_plugin(void);\
|
2018-02-25 13:07:49 +01:00
|
|
|
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_PLUGIN,init_plugin); \
|
2018-02-25 15:18:52 +01:00
|
|
|
void init_plugin()
|
2018-03-11 17:12:46 +01:00
|
|
|
|
2018-02-25 13:07:49 +01:00
|
|
|
#define DEINITIALIZE_PLUGIN() \
|
|
|
|
void deinit_plugin(void);\
|
|
|
|
WUPS_HOOK_EX(WUPS_LOADER_HOOK_DEINIT_PLUGIN,deinit_plugin); \
|
|
|
|
void deinit_plugin()
|
2018-03-11 17:12:46 +01:00
|
|
|
|
2018-02-25 13:07:49 +01:00
|
|
|
#define ON_APPLICATION_START(myargs) \
|
|
|
|
void on_app_starting(wups_loader_app_started_args_t);\
|
|
|
|
WUPS_HOOK_EX(WUPS_LOADER_HOOK_STARTING_APPLICATION,on_app_starting); \
|
2018-03-11 17:12:46 +01:00
|
|
|
void on_app_starting(wups_loader_app_started_args_t myargs)
|
|
|
|
|
2018-03-07 18:53:43 +01:00
|
|
|
#define ON_FUNCTIONS_PATCHED() \
|
|
|
|
void on_functions_patched();\
|
|
|
|
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FUNCTIONS_PATCHED,on_functions_patched); \
|
|
|
|
void on_functions_patched()
|
2018-02-25 13:07:49 +01:00
|
|
|
|
|
|
|
#define ON_APPLICATION_ENDING() \
|
|
|
|
void on_app_ending(void);\
|
|
|
|
WUPS_HOOK_EX(WUPS_LOADER_HOOK_ENDING_APPLICATION,on_app_ending); \
|
|
|
|
void on_app_ending(void)
|
|
|
|
|
|
|
|
#define ON_VYSNC() \
|
|
|
|
void on_vsync(void);\
|
|
|
|
WUPS_HOOK_EX(WUPS_LOADER_HOOK_VSYNC,on_vsync); \
|
|
|
|
void on_vsync(void)
|
2018-03-11 17:12:46 +01:00
|
|
|
|
2018-02-25 13:07:49 +01:00
|
|
|
#define ON_APP_STATUS_CHANGED(status) \
|
|
|
|
void on_app_status_changed(wups_loader_app_status_t);\
|
|
|
|
WUPS_HOOK_EX(WUPS_LOADER_HOOK_APP_STATUS_CHANGED,on_app_status_changed); \
|
|
|
|
void on_app_status_changed(wups_loader_app_status_t status)
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-03-11 17:12:46 +01:00
|
|
|
#endif /* WUPS_WUPS_H_ */
|