2018-02-10 14:58:58 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Copyright (C) 2016-2018 Maschell
|
|
|
|
* With code from chadderz and dimok
|
|
|
|
*
|
|
|
|
* 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-02-14 19:46:14 +01:00
|
|
|
#ifndef _FUNCTION_PATCHER_HOOKS_H_
|
|
|
|
#define _FUNCTION_PATCHER_HOOKS_H_
|
2018-02-10 14:58:58 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <dynamic_libs/os_functions.h>
|
|
|
|
#include <wups.h>
|
|
|
|
|
|
|
|
struct rpl_handling {
|
|
|
|
wups_loader_library_type_t library;
|
|
|
|
const char rplname[15];
|
|
|
|
u32 handle;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define FUNCTION_PATCHER_METHOD_STORE_SIZE 7
|
|
|
|
|
|
|
|
#define STATIC_FUNCTION 0
|
|
|
|
#define DYNAMIC_FUNCTION 1
|
|
|
|
|
|
|
|
#define FUNCTION_PATCHER_METHOD_STORE_SIZE 7
|
2018-02-18 17:47:03 +01:00
|
|
|
#define MAXIMUM_PLUGIN_PATH_NAME_LENGTH 256
|
2018-02-18 16:10:27 +01:00
|
|
|
#define MAXIMUM_PLUGIN_NAME_LENGTH 51
|
2018-02-10 14:58:58 +01:00
|
|
|
#define MAXIMUM_FUNCTION_NAME_LENGTH 51
|
|
|
|
|
|
|
|
struct replacement_data_function_t{
|
|
|
|
u32 replaceAddr; /* [needs to be filled] Address of our replacement function */
|
|
|
|
u32 replaceCall; /* [needs to be filled] Address to access the real_function */
|
|
|
|
wups_loader_library_type_t library; /* [needs to be filled] rpl where the function we want to replace is. */
|
|
|
|
char function_name[MAXIMUM_FUNCTION_NAME_LENGTH]; /* [needs to be filled] name of the function we want to replace */
|
|
|
|
u32 realAddr; /* [will be filled] Address of the real function we want to replace. */
|
|
|
|
volatile u32 replace_data [FUNCTION_PATCHER_METHOD_STORE_SIZE]; /* [will be filled] Space for us to store some jump instructions */
|
|
|
|
u32 restoreInstruction; /* [will be filled] Copy of the instruction we replaced to jump to our code. */
|
2018-02-18 19:03:51 +01:00
|
|
|
u8 functionType; /* [will be filled] */
|
2018-02-10 14:58:58 +01:00
|
|
|
u8 alreadyPatched; /* [will be filled] */
|
|
|
|
};
|
|
|
|
|
2018-02-10 17:05:11 +01:00
|
|
|
struct replacement_data_hook_t{
|
|
|
|
void * func_pointer = NULL; /* [will be filled] */
|
|
|
|
wups_loader_hook_type_t type; /* [will be filled] */
|
|
|
|
};
|
|
|
|
|
2018-02-18 16:10:27 +01:00
|
|
|
#define MAXIMUM_HOOKS_PER_PLUGIN 10
|
|
|
|
#define MAXIMUM_FUNCTION_PER_PLUGIN 100
|
2018-02-10 14:58:58 +01:00
|
|
|
|
2018-02-18 16:10:27 +01:00
|
|
|
struct replacement_data_plugin_t{
|
2018-02-18 19:03:51 +01:00
|
|
|
char path[MAXIMUM_PLUGIN_PATH_NAME_LENGTH] = ""; // Path where the plugin is stored
|
|
|
|
char plugin_name[MAXIMUM_PLUGIN_NAME_LENGTH] = ""; // Name of this plugin
|
2018-02-18 16:10:27 +01:00
|
|
|
int priority; // Priority of this plugin
|
|
|
|
int number_used_functions; // Number of used function. Maximum is MAXIMUM_FUNCTION_PER_PLUGIN
|
|
|
|
replacement_data_function_t functions[MAXIMUM_FUNCTION_PER_PLUGIN]; // Replacement information for each function.
|
2018-02-10 17:05:11 +01:00
|
|
|
|
2018-02-18 16:10:27 +01:00
|
|
|
int number_used_hooks; // Number of used hooks. Maximum is MAXIMUM_HOOKS_PER_PLUGIN
|
2018-02-18 19:03:51 +01:00
|
|
|
replacement_data_hook_t hooks[MAXIMUM_HOOKS_PER_PLUGIN]; // Replacement information for each function.
|
2018-02-10 14:58:58 +01:00
|
|
|
};
|
|
|
|
|
2018-02-18 16:10:27 +01:00
|
|
|
#define MAXIMUM_PLUGINS 32
|
2018-02-10 14:58:58 +01:00
|
|
|
|
|
|
|
struct replacement_data_t{
|
2018-02-18 19:03:51 +01:00
|
|
|
int number_used_plugins = 0; // Number of used function. Maximum is MAXIMUM_FUNCTION_PER_PLUGIN
|
2018-02-18 16:10:27 +01:00
|
|
|
replacement_data_plugin_t plugin_data[MAXIMUM_PLUGINS];
|
2018-02-10 14:58:58 +01:00
|
|
|
};
|
|
|
|
|
2018-02-18 16:10:27 +01:00
|
|
|
void new_PatchInvidualMethodHooks(replacement_data_plugin_t * data);
|
|
|
|
void new_RestoreInvidualInstructions(replacement_data_plugin_t * plugin_data);
|
2018-02-10 14:58:58 +01:00
|
|
|
u32 new_GetAddressOfFunction(const char * functionName,wups_loader_library_type_t library);
|
|
|
|
s32 new_isDynamicFunction(u32 physicalAddress);
|
|
|
|
void new_resetLibs();
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-02-14 19:46:14 +01:00
|
|
|
#endif /* _FUNCTION_PATCHER_HOOKS_H_ */
|