mirror of
https://github.com/wiiu-env/WiiUPluginSystem.git
synced 2024-10-01 18:39:50 +02:00
Replaced all instances of the word "module" with "plugin"
This commit is contained in:
parent
d0908e7eb6
commit
41da4db58c
@ -37,9 +37,9 @@ SOURCES := src/common \
|
|||||||
src/libelf \
|
src/libelf \
|
||||||
src/menu/content \
|
src/menu/content \
|
||||||
src/menu \
|
src/menu \
|
||||||
src/modules \
|
|
||||||
src/myutils \
|
src/myutils \
|
||||||
src/patcher \
|
src/patcher \
|
||||||
|
src/plugin \
|
||||||
src/resources \
|
src/resources \
|
||||||
src/settings \
|
src/settings \
|
||||||
src/
|
src/
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "common/retain_vars.h"
|
#include "common/retain_vars.h"
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "modules/ModuleLoader.h"
|
#include "plugin/PluginLoader.h"
|
||||||
#include "modules/ModuleData.h"
|
#include "plugin/PluginInformation.h"
|
||||||
|
|
||||||
#include <utils/function_patcher.h>
|
#include <utils/function_patcher.h>
|
||||||
|
|
||||||
@ -89,9 +89,9 @@ extern "C" int Menu_Main(int argc, char **argv){
|
|||||||
if(isFirstBoot){
|
if(isFirstBoot){
|
||||||
memset((void*)&gbl_replacement_data,0,sizeof(gbl_replacement_data));
|
memset((void*)&gbl_replacement_data,0,sizeof(gbl_replacement_data));
|
||||||
|
|
||||||
ModuleLoader * moduleLoader = ModuleLoader::getInstance();
|
PluginLoader * pluginLoader = PluginLoader::getInstance();
|
||||||
std::vector<ModuleInformation *> moduleList = moduleLoader->getModuleInformation("sd:/wiiu/plugins/");
|
std::vector<PluginInformation *> pluginList = pluginLoader->getPluginInformation("sd:/wiiu/plugins/");
|
||||||
moduleLoader->loadAndLinkModules(moduleList);
|
pluginLoader->loadAndLinkPlugins(pluginList);
|
||||||
|
|
||||||
//!*******************************************************************
|
//!*******************************************************************
|
||||||
//! Initialize heap memory *
|
//! Initialize heap memory *
|
||||||
@ -149,18 +149,18 @@ extern "C" int Menu_Main(int argc, char **argv){
|
|||||||
|
|
||||||
void ApplyPatches(){
|
void ApplyPatches(){
|
||||||
PatchInvidualMethodHooks(method_hooks_hooks, method_hooks_size_hooks, method_calls_hooks);
|
PatchInvidualMethodHooks(method_hooks_hooks, method_hooks_size_hooks, method_calls_hooks);
|
||||||
for(int module_index=0;module_index<gbl_replacement_data.number_used_modules;module_index++){
|
for(int plugin_index=0;plugin_index<gbl_replacement_data.number_used_plugins;plugin_index++){
|
||||||
new_PatchInvidualMethodHooks(&gbl_replacement_data.module_data[module_index]);
|
new_PatchInvidualMethodHooks(&gbl_replacement_data.plugin_data[plugin_index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallHook(wups_loader_hook_type_t hook_type){
|
void CallHook(wups_loader_hook_type_t hook_type){
|
||||||
for(int module_index=0;module_index<gbl_replacement_data.number_used_modules;module_index++){
|
for(int plugin_index=0;plugin_index<gbl_replacement_data.number_used_plugins;plugin_index++){
|
||||||
replacement_data_module_t * module_data = &gbl_replacement_data.module_data[module_index];
|
replacement_data_plugin_t * plugin_data = &gbl_replacement_data.plugin_data[plugin_index];
|
||||||
DEBUG_FUNCTION_LINE("Checking hook functions for %s.\n",module_data->module_name);
|
DEBUG_FUNCTION_LINE("Checking hook functions for %s.\n",plugin_data->plugin_name);
|
||||||
DEBUG_FUNCTION_LINE("Found hooks: %d\n",module_data->number_used_hooks);
|
DEBUG_FUNCTION_LINE("Found hooks: %d\n",plugin_data->number_used_hooks);
|
||||||
for(int j=0;j<module_data->number_used_hooks;j++){
|
for(int j=0;j<plugin_data->number_used_hooks;j++){
|
||||||
replacement_data_hook_t * hook_data = &module_data->hooks[j];
|
replacement_data_hook_t * hook_data = &plugin_data->hooks[j];
|
||||||
if(hook_data->type == hook_type){
|
if(hook_data->type == hook_type){
|
||||||
DEBUG_FUNCTION_LINE("Calling hook of type %d\n",hook_data->type);
|
DEBUG_FUNCTION_LINE("Calling hook of type %d\n",hook_data->type);
|
||||||
void * func_ptr = hook_data->func_pointer;
|
void * func_ptr = hook_data->func_pointer;
|
||||||
@ -198,9 +198,9 @@ void DeInit(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RestorePatches(){
|
void RestorePatches(){
|
||||||
for(int module_index=gbl_replacement_data.number_used_modules-1;module_index>=0;module_index--){
|
for(int plugin_index=gbl_replacement_data.number_used_plugins-1;plugin_index>=0;plugin_index--){
|
||||||
DEBUG_FUNCTION_LINE("Restoring function for module: %d\n",module_index);
|
DEBUG_FUNCTION_LINE("Restoring function for plugin: %d\n",plugin_index);
|
||||||
new_RestoreInvidualInstructions(&gbl_replacement_data.module_data[module_index]);
|
new_RestoreInvidualInstructions(&gbl_replacement_data.plugin_data[plugin_index]);
|
||||||
}
|
}
|
||||||
RestoreInvidualInstructions(method_hooks_hooks, method_hooks_size_hooks);
|
RestoreInvidualInstructions(method_hooks_hooks, method_hooks_size_hooks);
|
||||||
}
|
}
|
||||||
|
@ -99,20 +99,20 @@ rpl_handling rpl_handles[] __attribute__((section(".data"))) = {
|
|||||||
{WUPS_LOADER_LIBRARY_ZLIB125, "zlib125.rpl" ,0}
|
{WUPS_LOADER_LIBRARY_ZLIB125, "zlib125.rpl" ,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
void new_PatchInvidualMethodHooks(replacement_data_module_t * module_data){
|
void new_PatchInvidualMethodHooks(replacement_data_plugin_t * plugin_data){
|
||||||
InitAcquireOS();
|
InitAcquireOS();
|
||||||
new_resetLibs();
|
new_resetLibs();
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Patching %d given functions\n",module_data->number_used_functions);
|
DEBUG_FUNCTION_LINE("Patching %d given functions\n",plugin_data->number_used_functions);
|
||||||
|
|
||||||
s32 method_hooks_count = module_data->number_used_functions;
|
s32 method_hooks_count = plugin_data->number_used_functions;
|
||||||
|
|
||||||
u32 skip_instr = 1;
|
u32 skip_instr = 1;
|
||||||
u32 my_instr_len = 6;
|
u32 my_instr_len = 6;
|
||||||
u32 instr_len = my_instr_len + skip_instr;
|
u32 instr_len = my_instr_len + skip_instr;
|
||||||
u32 flush_len = 4*instr_len;
|
u32 flush_len = 4*instr_len;
|
||||||
for(s32 i = 0; i < method_hooks_count; i++){
|
for(s32 i = 0; i < method_hooks_count; i++){
|
||||||
replacement_data_function_t * function_data = &module_data->functions[i];
|
replacement_data_function_t * function_data = &plugin_data->functions[i];
|
||||||
/* Patch branches to it. */
|
/* Patch branches to it. */
|
||||||
volatile u32 *space = function_data->replace_data;
|
volatile u32 *space = function_data->replace_data;
|
||||||
|
|
||||||
@ -209,15 +209,15 @@ void new_PatchInvidualMethodHooks(replacement_data_module_t * module_data){
|
|||||||
/* ****************************************************************** */
|
/* ****************************************************************** */
|
||||||
/* RESTORE ORIGINAL INSTRUCTIONS */
|
/* RESTORE ORIGINAL INSTRUCTIONS */
|
||||||
/* ****************************************************************** */
|
/* ****************************************************************** */
|
||||||
void new_RestoreInvidualInstructions(replacement_data_module_t * module_data){
|
void new_RestoreInvidualInstructions(replacement_data_plugin_t * plugin_data){
|
||||||
InitAcquireOS();
|
InitAcquireOS();
|
||||||
new_resetLibs();
|
new_resetLibs();
|
||||||
DEBUG_FUNCTION_LINE("Restoring given functions!\n");
|
DEBUG_FUNCTION_LINE("Restoring given functions!\n");
|
||||||
|
|
||||||
s32 method_hooks_count = module_data->number_used_functions;
|
s32 method_hooks_count = plugin_data->number_used_functions;
|
||||||
|
|
||||||
for(s32 i = 0; i < method_hooks_count; i++){
|
for(s32 i = 0; i < method_hooks_count; i++){
|
||||||
replacement_data_function_t * function_data = &module_data->functions[i];
|
replacement_data_function_t * function_data = &plugin_data->functions[i];
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Restoring %s... ",function_data->function_name);
|
DEBUG_FUNCTION_LINE("Restoring %s... ",function_data->function_name);
|
||||||
if(function_data->restoreInstruction == 0 || function_data->realAddr == 0){
|
if(function_data->restoreInstruction == 0 || function_data->realAddr == 0){
|
||||||
|
@ -38,7 +38,7 @@ struct rpl_handling {
|
|||||||
#define DYNAMIC_FUNCTION 1
|
#define DYNAMIC_FUNCTION 1
|
||||||
|
|
||||||
#define FUNCTION_PATCHER_METHOD_STORE_SIZE 7
|
#define FUNCTION_PATCHER_METHOD_STORE_SIZE 7
|
||||||
#define MAXIMUM_MODULE_NAME_LENGTH 51
|
#define MAXIMUM_PLUGIN_NAME_LENGTH 51
|
||||||
#define MAXIMUM_FUNCTION_NAME_LENGTH 51
|
#define MAXIMUM_FUNCTION_NAME_LENGTH 51
|
||||||
|
|
||||||
struct replacement_data_function_t{
|
struct replacement_data_function_t{
|
||||||
@ -62,28 +62,28 @@ struct replacement_data_hook_t{
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAXIMUM_HOOKS_PER_MODULE 10
|
#define MAXIMUM_HOOKS_PER_PLUGIN 10
|
||||||
#define MAXIMUM_FUNCTION_PER_MODULE 100
|
#define MAXIMUM_FUNCTION_PER_PLUGIN 100
|
||||||
|
|
||||||
struct replacement_data_module_t{
|
struct replacement_data_plugin_t{
|
||||||
char module_name[MAXIMUM_MODULE_NAME_LENGTH] = ""; // Name of this module
|
char plugin_name[MAXIMUM_PLUGIN_NAME_LENGTH] = ""; // Name of this plugin
|
||||||
int priority; // Priority of this module
|
int priority; // Priority of this plugin
|
||||||
int number_used_functions; // Number of used function. Maximum is MAXIMUM_FUNCTION_PER_MODULE
|
int number_used_functions; // Number of used function. Maximum is MAXIMUM_FUNCTION_PER_PLUGIN
|
||||||
replacement_data_function_t functions[MAXIMUM_FUNCTION_PER_MODULE]; // Replacement information for each function.
|
replacement_data_function_t functions[MAXIMUM_FUNCTION_PER_PLUGIN]; // Replacement information for each function.
|
||||||
|
|
||||||
int number_used_hooks; // Number of used hooks. Maximum is MAXIMUM_HOOKS_PER_MODULE
|
int number_used_hooks; // Number of used hooks. Maximum is MAXIMUM_HOOKS_PER_PLUGIN
|
||||||
replacement_data_hook_t hooks[MAXIMUM_HOOKS_PER_MODULE]; // Replacement information for each function.
|
replacement_data_hook_t hooks[MAXIMUM_HOOKS_PER_PLUGIN]; // Replacement information for each function.
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAXIMUM_MODULES 32
|
#define MAXIMUM_PLUGINS 32
|
||||||
|
|
||||||
struct replacement_data_t{
|
struct replacement_data_t{
|
||||||
int number_used_modules = 0; // Number of used function. Maximum is MAXIMUM_FUNCTION_PER_MODULE
|
int number_used_plugins = 0; // Number of used function. Maximum is MAXIMUM_FUNCTION_PER_PLUGIN
|
||||||
replacement_data_module_t module_data[MAXIMUM_MODULES];
|
replacement_data_plugin_t plugin_data[MAXIMUM_PLUGINS];
|
||||||
};
|
};
|
||||||
|
|
||||||
void new_PatchInvidualMethodHooks(replacement_data_module_t * data);
|
void new_PatchInvidualMethodHooks(replacement_data_plugin_t * data);
|
||||||
void new_RestoreInvidualInstructions(replacement_data_module_t * module_data);
|
void new_RestoreInvidualInstructions(replacement_data_plugin_t * plugin_data);
|
||||||
u32 new_GetAddressOfFunction(const char * functionName,wups_loader_library_type_t library);
|
u32 new_GetAddressOfFunction(const char * functionName,wups_loader_library_type_t library);
|
||||||
s32 new_isDynamicFunction(u32 physicalAddress);
|
s32 new_isDynamicFunction(u32 physicalAddress);
|
||||||
void new_resetLibs();
|
void new_resetLibs();
|
||||||
|
@ -175,7 +175,7 @@ bool ElfTools::elfLink(Elf *elf, size_t shndx, void *destination, Elf32_Sym *sym
|
|||||||
sizeof(module_unresolved_relocation_t), 1,
|
sizeof(module_unresolved_relocation_t), 1,
|
||||||
&module_relocations_capacity,
|
&module_relocations_capacity,
|
||||||
&module_relocations_count,
|
&module_relocations_count,
|
||||||
MODULE_RELOCATIONS_CAPCITY_DEFAULT);
|
PLUGIN_RELOCATIONS_CAPCITY_DEFAULT);
|
||||||
if (reloc == NULL)
|
if (reloc == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ bool ElfTools::elfLink(Elf *elf, size_t shndx, void *destination, Elf32_Sym *sym
|
|||||||
sizeof(module_unresolved_relocation_t), 1,
|
sizeof(module_unresolved_relocation_t), 1,
|
||||||
&module_relocations_capacity,
|
&module_relocations_capacity,
|
||||||
&module_relocations_count,
|
&module_relocations_count,
|
||||||
MODULE_RELOCATIONS_CAPCITY_DEFAULT);
|
PLUGIN_RELOCATIONS_CAPCITY_DEFAULT);
|
||||||
if (reloc == NULL)
|
if (reloc == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -422,7 +422,7 @@ bool ElfTools::elfLinkOne(char type, size_t offset, int addend, void *destinatio
|
|||||||
|
|
||||||
result = true;
|
result = true;
|
||||||
exit_error:
|
exit_error:
|
||||||
if (!result) DEBUG_FUNCTION_LINE("Module_ElfLinkOne: exit_error\n");
|
if (!result) DEBUG_FUNCTION_LINE("Plugin_ElfLinkOne: exit_error\n");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -15,14 +15,14 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef _MODULE_DATA_H_
|
#ifndef _PLUGIN_DATA_H_
|
||||||
#define _MODULE_DATA_H_
|
#define _PLUGIN_DATA_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "EntryData.h"
|
#include "EntryData.h"
|
||||||
#include "HookData.h"
|
#include "HookData.h"
|
||||||
#include "ModuleInformation.h"
|
#include "PluginInformation.h"
|
||||||
#include <utils/logger.h>
|
#include <utils/logger.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -35,13 +35,13 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class ModuleData{
|
class PluginData{
|
||||||
public:
|
public:
|
||||||
ModuleData(ModuleInformation * moduleInformation){
|
PluginData(PluginInformation * pluginInformation){
|
||||||
this->moduleInformation = moduleInformation;
|
this->pluginInformation = pluginInformation;
|
||||||
}
|
}
|
||||||
|
|
||||||
~ModuleData(){
|
~PluginData(){
|
||||||
for(size_t i = 0;i< entry_data_list.size();i++){
|
for(size_t i = 0;i< entry_data_list.size();i++){
|
||||||
if(entry_data_list[i] != NULL){
|
if(entry_data_list[i] != NULL){
|
||||||
delete entry_data_list[i];
|
delete entry_data_list[i];
|
||||||
@ -71,13 +71,13 @@ class ModuleData{
|
|||||||
return hook_data_list;
|
return hook_data_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModuleInformation * getModuleInformation(){
|
PluginInformation * getPluginInformation(){
|
||||||
return moduleInformation;
|
return pluginInformation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ModuleInformation * moduleInformation;
|
PluginInformation * pluginInformation;
|
||||||
|
|
||||||
std::vector<EntryData *> entry_data_list;
|
std::vector<EntryData *> entry_data_list;
|
||||||
std::vector<HookData *> hook_data_list;
|
std::vector<HookData *> hook_data_list;
|
@ -1,4 +1,4 @@
|
|||||||
/* based on module.c
|
/* based on plugin.c
|
||||||
* by Alex Chadwick
|
* by Alex Chadwick
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014, Alex Chadwick
|
* Copyright (C) 2014, Alex Chadwick
|
||||||
@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ModuleInformation.h"
|
#include "PluginInformation.h"
|
||||||
#include <utils/logger.h>
|
#include <utils/logger.h>
|
||||||
#include <dynamic_libs/os_types.h>
|
#include <dynamic_libs/os_types.h>
|
||||||
#include <libelf.h>
|
#include <libelf.h>
|
||||||
@ -36,7 +36,7 @@
|
|||||||
#include <utils/utils.h>
|
#include <utils/utils.h>
|
||||||
#include "ElfTools.h"
|
#include "ElfTools.h"
|
||||||
|
|
||||||
bool ModuleInformation::checkFileExtenstion(const char * path) {
|
bool PluginInformation::checkFileExtenstion(const char * path) {
|
||||||
if(path == NULL){
|
if(path == NULL){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ bool ModuleInformation::checkFileExtenstion(const char * path) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModuleInformation::openAndParseElf() {
|
bool PluginInformation::openAndParseElf() {
|
||||||
bool result = false;
|
bool result = false;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
Elf *elf = NULL;
|
Elf *elf = NULL;
|
||||||
@ -110,7 +110,7 @@ exit_error:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModuleInformation::parseElf( Elf *elf) {
|
bool PluginInformation::parseElf( Elf *elf) {
|
||||||
bool res = false;
|
bool res = false;
|
||||||
Elf_Scn *scn;
|
Elf_Scn *scn;
|
||||||
Elf32_Ehdr *ehdr;
|
Elf32_Ehdr *ehdr;
|
||||||
@ -237,7 +237,7 @@ exit_error:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModuleInformation::metadataRead(Elf *elf, Elf32_Sym *symtab, size_t symtab_count, size_t symtab_strndx) {
|
bool PluginInformation::metadataRead(Elf *elf, Elf32_Sym *symtab, size_t symtab_count, size_t symtab_strndx) {
|
||||||
char *metadata = NULL, *metadata_cur, *metadata_end;
|
char *metadata = NULL, *metadata_cur, *metadata_end;
|
||||||
const char *game, *name, *author, *version, *license, *wups;
|
const char *game, *name, *author, *version, *license, *wups;
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ bool ModuleInformation::metadataRead(Elf *elf, Elf32_Sym *symtab, size_t symtab_
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (metadata == NULL) {
|
if (metadata == NULL) {
|
||||||
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Not a WUPS module file.\n", path);
|
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Not a WUPS plugin file.\n", path);
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,37 +326,37 @@ bool ModuleInformation::metadataRead(Elf *elf, Elf32_Sym *symtab, size_t symtab_
|
|||||||
|
|
||||||
if (strncmp(metadata_cur, "game", eq - metadata_cur) == 0) {
|
if (strncmp(metadata_cur, "game", eq - metadata_cur) == 0) {
|
||||||
if (game != NULL) {
|
if (game != NULL) {
|
||||||
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_MODULE_GAME declarations.\n", path);
|
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_PLUGIN_GAME declarations.\n", path);
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
}
|
}
|
||||||
game = eq + 1;
|
game = eq + 1;
|
||||||
} else if (strncmp(metadata_cur, "name", eq - metadata_cur) == 0) {
|
} else if (strncmp(metadata_cur, "name", eq - metadata_cur) == 0) {
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_MODULE_NAME declarations.\n", path);
|
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_PLUGIN_NAME declarations.\n", path);
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
}
|
}
|
||||||
name = eq + 1;
|
name = eq + 1;
|
||||||
} else if (strncmp(metadata_cur, "author", eq - metadata_cur) == 0) {
|
} else if (strncmp(metadata_cur, "author", eq - metadata_cur) == 0) {
|
||||||
if (author != NULL) {
|
if (author != NULL) {
|
||||||
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_MODULE_AUTHOR declarations.\n", path);
|
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_PLUGIN_AUTHOR declarations.\n", path);
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
}
|
}
|
||||||
author = eq + 1;
|
author = eq + 1;
|
||||||
} else if (strncmp(metadata_cur, "version", eq - metadata_cur) == 0) {
|
} else if (strncmp(metadata_cur, "version", eq - metadata_cur) == 0) {
|
||||||
if (version != NULL) {
|
if (version != NULL) {
|
||||||
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_MODULE_VERSION declarations.\n", path);
|
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_PLUGIN_VERSION declarations.\n", path);
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
}
|
}
|
||||||
version = eq + 1;
|
version = eq + 1;
|
||||||
} else if (strncmp(metadata_cur, "license", eq - metadata_cur) == 0) {
|
} else if (strncmp(metadata_cur, "license", eq - metadata_cur) == 0) {
|
||||||
if (license != NULL) {
|
if (license != NULL) {
|
||||||
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_MODULE_LICENSE declarations.\n", path);
|
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_PLUGIN_LICENSE declarations.\n", path);
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
}
|
}
|
||||||
license = eq + 1;
|
license = eq + 1;
|
||||||
} else if (strncmp(metadata_cur, "wups", eq - metadata_cur) == 0) {
|
} else if (strncmp(metadata_cur, "wups", eq - metadata_cur) == 0) {
|
||||||
if (wups != NULL) {
|
if (wups != NULL) {
|
||||||
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_MODULE_NAME declarations.\n", path);
|
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_PLUGIN_NAME declarations.\n", path);
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
}
|
}
|
||||||
wups = eq + 1;
|
wups = eq + 1;
|
||||||
@ -372,19 +372,19 @@ bool ModuleInformation::metadataRead(Elf *elf, Elf32_Sym *symtab, size_t symtab_
|
|||||||
goto exit_error;
|
goto exit_error;
|
||||||
}*/
|
}*/
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Missing WUPS_MODULE_NAME declaration.\n",path);
|
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Missing WUPS_PLUGIN_NAME declaration.\n",path);
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
}
|
}
|
||||||
if (author == NULL) {
|
if (author == NULL) {
|
||||||
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Missing WUPS_MODULE_AUTHOR declaration.\n", path);
|
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Missing WUPS_PLUGIN_AUTHOR declaration.\n", path);
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
}
|
}
|
||||||
if (version == NULL) {
|
if (version == NULL) {
|
||||||
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Missing WUPS_MODULE_VERSION declaration.\n", path);
|
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Missing WUPS_PLUGIN_VERSION declaration.\n", path);
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
}
|
}
|
||||||
if (license == NULL) {
|
if (license == NULL) {
|
||||||
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Missing WUPS_MODULE_LICENSE declaration.\n", path);
|
DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Missing WUPS_PLUGIN_LICENSE declaration.\n", path);
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
}
|
}
|
||||||
|
|
@ -23,8 +23,8 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _MODULE_INFORMATION_H_
|
#ifndef _PLUGIN_INFORMATION_H_
|
||||||
#define _MODULE_INFORMATION_H_
|
#define _PLUGIN_INFORMATION_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -42,20 +42,20 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class ModuleInformation{
|
class PluginInformation{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
||||||
returns ModuleInformation* if a valid plugin was found at the given path. Otherwise returns NULL
|
returns PluginInformation* if a valid plugin was found at the given path. Otherwise returns NULL
|
||||||
**/
|
**/
|
||||||
static ModuleInformation * loadModuleInformation(std::string path){
|
static PluginInformation * loadPluginInformation(std::string path){
|
||||||
if(ModuleInformation::checkFileExtenstion(path.c_str())){
|
if(PluginInformation::checkFileExtenstion(path.c_str())){
|
||||||
DEBUG_FUNCTION_LINE("Checkfile successfully, loading now Module Information\n");
|
DEBUG_FUNCTION_LINE("Checkfile successfully, loading now Plugin Information\n");
|
||||||
ModuleInformation * moduleInformation = new ModuleInformation(path);
|
PluginInformation * pluginInformation = new PluginInformation(path);
|
||||||
if(moduleInformation->openAndParseElf()){
|
if(pluginInformation->openAndParseElf()){
|
||||||
return moduleInformation;
|
return pluginInformation;
|
||||||
}else{
|
}else{
|
||||||
delete moduleInformation;
|
delete pluginInformation;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -87,7 +87,7 @@ class ModuleInformation{
|
|||||||
return this->size;
|
return this->size;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
ModuleInformation(std::string path){
|
PluginInformation(std::string path){
|
||||||
this->path = path;
|
this->path = path;
|
||||||
}
|
}
|
||||||
|
|
@ -29,15 +29,15 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "ElfTools.h"
|
#include "ElfTools.h"
|
||||||
#include "ModuleData.h"
|
#include "PluginData.h"
|
||||||
#include "ModuleLoader.h"
|
#include "PluginLoader.h"
|
||||||
#include "utils/StringTools.h"
|
#include "utils/StringTools.h"
|
||||||
#include "common/retain_vars.h"
|
#include "common/retain_vars.h"
|
||||||
|
|
||||||
ModuleLoader * ModuleLoader::instance = NULL;
|
PluginLoader * PluginLoader::instance = NULL;
|
||||||
|
|
||||||
std::vector<ModuleInformation *> ModuleLoader::getModuleInformation(const char * path){
|
std::vector<PluginInformation *> PluginLoader::getPluginInformation(const char * path){
|
||||||
std::vector<ModuleInformation *> result;
|
std::vector<PluginInformation *> result;
|
||||||
struct dirent *dp;
|
struct dirent *dp;
|
||||||
DIR *dfd = NULL;
|
DIR *dfd = NULL;
|
||||||
|
|
||||||
@ -64,10 +64,10 @@ std::vector<ModuleInformation *> ModuleLoader::getModuleInformation(const char *
|
|||||||
continue;
|
continue;
|
||||||
}else{
|
}else{
|
||||||
DEBUG_FUNCTION_LINE("Found file: %s\n",full_file_path.c_str()) ;
|
DEBUG_FUNCTION_LINE("Found file: %s\n",full_file_path.c_str()) ;
|
||||||
ModuleInformation * module = ModuleInformation::loadModuleInformation(full_file_path);
|
PluginInformation * plugin = PluginInformation::loadPluginInformation(full_file_path);
|
||||||
if(module != NULL){
|
if(plugin != NULL){
|
||||||
DEBUG_FUNCTION_LINE("Found plugin %s by %s. Size: %d kb \n",module->getName().c_str(),module->getAuthor().c_str(),module->getSize()/1024) ;
|
DEBUG_FUNCTION_LINE("Found plugin %s by %s. Size: %d kb \n",plugin->getName().c_str(),plugin->getAuthor().c_str(),plugin->getSize()/1024) ;
|
||||||
result.push_back(module);
|
result.push_back(plugin);
|
||||||
} else {
|
} else {
|
||||||
DEBUG_FUNCTION_LINE("%s is not a valid plugin\n",full_file_path.c_str()) ;
|
DEBUG_FUNCTION_LINE("%s is not a valid plugin\n",full_file_path.c_str()) ;
|
||||||
}
|
}
|
||||||
@ -77,46 +77,46 @@ std::vector<ModuleInformation *> ModuleLoader::getModuleInformation(const char *
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleLoader::loadAndLinkModules(std::vector<ModuleInformation *> moduleInformation){
|
void PluginLoader::loadAndLinkPlugins(std::vector<PluginInformation *> pluginInformation){
|
||||||
std::vector<ModuleData *> loadedModules;
|
std::vector<PluginData *> loadedPlugins;
|
||||||
for(size_t i = 0;i < moduleInformation.size(); i++){
|
for(size_t i = 0;i < pluginInformation.size(); i++){
|
||||||
DEBUG_FUNCTION_LINE("loadAndLinkModules for %d\n",i) ;
|
DEBUG_FUNCTION_LINE("loadAndLinkPlugins for %d\n",i) ;
|
||||||
ModuleInformation * cur_info = moduleInformation[i];
|
PluginInformation * cur_info = pluginInformation[i];
|
||||||
ModuleData * moduleData = loadAndLinkModule(cur_info);
|
PluginData * pluginData = loadAndLinkPlugin(cur_info);
|
||||||
if(moduleData == NULL){
|
if(pluginData == NULL){
|
||||||
DEBUG_FUNCTION_LINE("loadAndLinkModules failed for %d\n",i) ;
|
DEBUG_FUNCTION_LINE("loadAndLinkPlugins failed for %d\n",i) ;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
loadedModules.push_back(moduleData);
|
loadedPlugins.push_back(pluginData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
copyModuleDataIntoGlobalStruct(loadedModules);
|
copyPluginDataIntoGlobalStruct(loadedPlugins);
|
||||||
clearModuleData(loadedModules);
|
clearPluginData(loadedPlugins);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleLoader::clearModuleData(std::vector<ModuleData *> moduleData){
|
void PluginLoader::clearPluginData(std::vector<PluginData *> pluginData){
|
||||||
for(size_t i = 0;i < moduleData.size(); i++){
|
for(size_t i = 0;i < pluginData.size(); i++){
|
||||||
ModuleData * curModuleData = moduleData[i];
|
PluginData * curPluginData = pluginData[i];
|
||||||
if(curModuleData != NULL){
|
if(curPluginData != NULL){
|
||||||
delete curModuleData;
|
delete curPluginData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ModuleData * ModuleLoader::loadAndLinkModule(ModuleInformation * moduleInformation){
|
PluginData * PluginLoader::loadAndLinkPlugin(PluginInformation * pluginInformation){
|
||||||
DEBUG_FUNCTION_LINE("\n");
|
DEBUG_FUNCTION_LINE("\n");
|
||||||
ModuleData * result = NULL;
|
PluginData * result = NULL;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
Elf *elf = NULL;
|
Elf *elf = NULL;
|
||||||
|
|
||||||
if(moduleInformation == NULL){
|
if(pluginInformation == NULL){
|
||||||
DEBUG_FUNCTION_LINE("moduleInformation was NULL\n");
|
DEBUG_FUNCTION_LINE("pluginInformation was NULL\n");
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(moduleInformation->getSize() > ((u32) this->getCurrentStoreAddress() - (u32) this->startAddress)){
|
if(pluginInformation->getSize() > ((u32) this->getCurrentStoreAddress() - (u32) this->startAddress)){
|
||||||
DEBUG_FUNCTION_LINE("Not enough space left to loader the plugin into memory\n");
|
DEBUG_FUNCTION_LINE("Not enough space left to loader the plugin into memory\n");
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
}
|
}
|
||||||
@ -126,10 +126,10 @@ ModuleData * ModuleLoader::loadAndLinkModule(ModuleInformation * moduleInformati
|
|||||||
goto exit_error;
|
goto exit_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = open(moduleInformation->getPath().c_str(), O_RDONLY, 0);
|
fd = open(pluginInformation->getPath().c_str(), O_RDONLY, 0);
|
||||||
|
|
||||||
if (fd == -1){
|
if (fd == -1){
|
||||||
DEBUG_FUNCTION_LINE("failed to open '%s' \n", moduleInformation->getPath().c_str());
|
DEBUG_FUNCTION_LINE("failed to open '%s' \n", pluginInformation->getPath().c_str());
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ ModuleData * ModuleLoader::loadAndLinkModule(ModuleInformation * moduleInformati
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("\n");
|
DEBUG_FUNCTION_LINE("\n");
|
||||||
result = new ModuleData(moduleInformation);
|
result = new PluginData(pluginInformation);
|
||||||
if(result == NULL){
|
if(result == NULL){
|
||||||
DEBUG_FUNCTION_LINE("Failed to create object\n");
|
DEBUG_FUNCTION_LINE("Failed to create object\n");
|
||||||
goto exit_error;
|
goto exit_error;
|
||||||
@ -162,8 +162,8 @@ exit_error:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModuleLoader::loadAndLinkElf(ModuleData * moduleData, Elf *elf, void * endAddress) {
|
bool PluginLoader::loadAndLinkElf(PluginData * pluginData, Elf *elf, void * endAddress) {
|
||||||
if(moduleData == NULL || elf == NULL || endAddress == NULL){
|
if(pluginData == NULL || elf == NULL || endAddress == NULL){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,16 +317,16 @@ bool ModuleLoader::loadAndLinkElf(ModuleData * moduleData, Elf *elf, void * endA
|
|||||||
for(size_t j=0;j<hook_t_list.size();j++){
|
for(size_t j=0;j<hook_t_list.size();j++){
|
||||||
wups_loader_hook_t * hook = hook_t_list[j];
|
wups_loader_hook_t * hook = hook_t_list[j];
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Saving hook of module \"%s\". Type: %08X, target: %08X\n",moduleData->getModuleInformation()->getName().c_str(),hook->type,(void*) hook->target);
|
DEBUG_FUNCTION_LINE("Saving hook of plugin \"%s\". Type: %08X, target: %08X\n",pluginData->getPluginInformation()->getName().c_str(),hook->type,(void*) hook->target);
|
||||||
HookData * hook_data = new HookData((void *) hook->target,hook->type);
|
HookData * hook_data = new HookData((void *) hook->target,hook->type);
|
||||||
moduleData->addHookData(hook_data);
|
pluginData->addHookData(hook_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(size_t j=0;j<entry_t_list.size();j++){
|
for(size_t j=0;j<entry_t_list.size();j++){
|
||||||
wups_loader_entry_t * entry = entry_t_list[j];
|
wups_loader_entry_t * entry = entry_t_list[j];
|
||||||
DEBUG_FUNCTION_LINE("Saving entry \"%s\" of module \"%s\". Library: %08X, target: %08X, call_addr: %08X\n",entry->_function.name,moduleData->getModuleInformation()->getName().c_str(),entry->_function.library,entry->_function.target, (void *) entry->_function.call_addr);
|
DEBUG_FUNCTION_LINE("Saving entry \"%s\" of plugin \"%s\". Library: %08X, target: %08X, call_addr: %08X\n",entry->_function.name,pluginData->getPluginInformation()->getName().c_str(),entry->_function.library,entry->_function.target, (void *) entry->_function.call_addr);
|
||||||
EntryData * entry_data = new EntryData(entry->_function.name,entry->_function.library, (void *) entry->_function.target, (void *) entry->_function.call_addr);
|
EntryData * entry_data = new EntryData(entry->_function.name,entry->_function.library, (void *) entry->_function.target, (void *) entry->_function.call_addr);
|
||||||
moduleData->addEntryData(entry_data);
|
pluginData->addEntryData(entry_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->setCurrentStoreAddress((void *) curAddress);
|
this->setCurrentStoreAddress((void *) curAddress);
|
||||||
@ -349,39 +349,39 @@ exit_error:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleLoader::copyModuleDataIntoGlobalStruct(std::vector<ModuleData *> modules){
|
void PluginLoader::copyPluginDataIntoGlobalStruct(std::vector<PluginData *> plugins){
|
||||||
// Reset data
|
// Reset data
|
||||||
memset((void*)&gbl_replacement_data,0,sizeof(gbl_replacement_data));
|
memset((void*)&gbl_replacement_data,0,sizeof(gbl_replacement_data));
|
||||||
int module_index = 0;
|
int plugin_index = 0;
|
||||||
// Copy data to global struct.
|
// Copy data to global struct.
|
||||||
for(size_t i = 0; i< modules.size();i++){
|
for(size_t i = 0; i< plugins.size();i++){
|
||||||
ModuleData * cur_module = modules.at(i);
|
PluginData * cur_plugin = plugins.at(i);
|
||||||
ModuleInformation * cur_moduleInformation = cur_module->getModuleInformation();
|
PluginInformation * cur_pluginInformation = cur_plugin->getPluginInformation();
|
||||||
|
|
||||||
std::vector<EntryData *> entry_data_list = cur_module->getEntryDataList();
|
std::vector<EntryData *> entry_data_list = cur_plugin->getEntryDataList();
|
||||||
std::vector<HookData *> hook_data_list = cur_module->getHookDataList();
|
std::vector<HookData *> hook_data_list = cur_plugin->getHookDataList();
|
||||||
if(module_index >= MAXIMUM_MODULES ){
|
if(plugin_index >= MAXIMUM_PLUGINS ){
|
||||||
DEBUG_FUNCTION_LINE("Maximum of %d modules reached. %s won't be loaded!\n",MAXIMUM_MODULES,cur_moduleInformation->getName().c_str());
|
DEBUG_FUNCTION_LINE("Maximum of %d plugins reached. %s won't be loaded!\n",MAXIMUM_PLUGINS,cur_pluginInformation->getName().c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(entry_data_list.size() > MAXIMUM_FUNCTION_PER_MODULE){
|
if(entry_data_list.size() > MAXIMUM_FUNCTION_PER_PLUGIN){
|
||||||
DEBUG_FUNCTION_LINE("Module %s would replace to many function (%d, maximum is %d). It won't be loaded.\n",cur_moduleInformation->getName().c_str(),entry_data_list.size(),MAXIMUM_FUNCTION_PER_MODULE);
|
DEBUG_FUNCTION_LINE("Plugin %s would replace to many function (%d, maximum is %d). It won't be loaded.\n",cur_pluginInformation->getName().c_str(),entry_data_list.size(),MAXIMUM_FUNCTION_PER_PLUGIN);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(hook_data_list.size() > MAXIMUM_HOOKS_PER_MODULE){
|
if(hook_data_list.size() > MAXIMUM_HOOKS_PER_PLUGIN){
|
||||||
DEBUG_FUNCTION_LINE("Module %s would set too many hooks (%d, maximum is %d). It won't be loaded.\n",cur_moduleInformation->getName().c_str(),hook_data_list.size(),MAXIMUM_HOOKS_PER_MODULE);
|
DEBUG_FUNCTION_LINE("Plugin %s would set too many hooks (%d, maximum is %d). It won't be loaded.\n",cur_pluginInformation->getName().c_str(),hook_data_list.size(),MAXIMUM_HOOKS_PER_PLUGIN);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
replacement_data_module_t * module_data = &gbl_replacement_data.module_data[module_index];
|
replacement_data_plugin_t * plugin_data = &gbl_replacement_data.plugin_data[plugin_index];
|
||||||
|
|
||||||
strncpy(module_data->module_name,cur_moduleInformation->getName().c_str(),MAXIMUM_MODULE_NAME_LENGTH-1);
|
strncpy(plugin_data->plugin_name,cur_pluginInformation->getName().c_str(),MAXIMUM_PLUGIN_NAME_LENGTH-1);
|
||||||
|
|
||||||
for(size_t j = 0; j < entry_data_list.size();j++){
|
for(size_t j = 0; j < entry_data_list.size();j++){
|
||||||
replacement_data_function_t * function_data = &module_data->functions[j];
|
replacement_data_function_t * function_data = &plugin_data->functions[j];
|
||||||
|
|
||||||
EntryData * cur_entry = entry_data_list[j];
|
EntryData * cur_entry = entry_data_list[j];
|
||||||
DEBUG_FUNCTION_LINE("Adding entry \"%s\" for module \"%s\"\n",cur_entry->getName().c_str(),module_data->module_name);
|
DEBUG_FUNCTION_LINE("Adding entry \"%s\" for plugin \"%s\"\n",cur_entry->getName().c_str(),plugin_data->plugin_name);
|
||||||
|
|
||||||
//TODO: Warning/Error if string is too long.
|
//TODO: Warning/Error if string is too long.
|
||||||
strncpy(function_data->function_name,cur_entry->getName().c_str(),MAXIMUM_FUNCTION_NAME_LENGTH-1);
|
strncpy(function_data->function_name,cur_entry->getName().c_str(),MAXIMUM_FUNCTION_NAME_LENGTH-1);
|
||||||
@ -390,25 +390,25 @@ void ModuleLoader::copyModuleDataIntoGlobalStruct(std::vector<ModuleData *> modu
|
|||||||
function_data->replaceAddr = (u32) cur_entry->getReplaceAddress();
|
function_data->replaceAddr = (u32) cur_entry->getReplaceAddress();
|
||||||
function_data->replaceCall = (u32) cur_entry->getReplaceCall();
|
function_data->replaceCall = (u32) cur_entry->getReplaceCall();
|
||||||
|
|
||||||
module_data->number_used_functions++;
|
plugin_data->number_used_functions++;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Entries for module \"%s\": %d\n",module_data->module_name,module_data->number_used_functions);
|
DEBUG_FUNCTION_LINE("Entries for plugin \"%s\": %d\n",plugin_data->plugin_name,plugin_data->number_used_functions);
|
||||||
|
|
||||||
for(size_t j = 0; j < hook_data_list.size();j++){
|
for(size_t j = 0; j < hook_data_list.size();j++){
|
||||||
replacement_data_hook_t * hook_data = &module_data->hooks[j];
|
replacement_data_hook_t * hook_data = &plugin_data->hooks[j];
|
||||||
|
|
||||||
HookData * hook_entry = hook_data_list[j];
|
HookData * hook_entry = hook_data_list[j];
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Set hook for module \"%s\" of type %08X to target %08X\n",module_data->module_name,hook_entry->getType(),(void*) hook_entry->getFunctionPointer());
|
DEBUG_FUNCTION_LINE("Set hook for plugin \"%s\" of type %08X to target %08X\n",plugin_data->plugin_name,hook_entry->getType(),(void*) hook_entry->getFunctionPointer());
|
||||||
hook_data->func_pointer = (void*) hook_entry->getFunctionPointer();
|
hook_data->func_pointer = (void*) hook_entry->getFunctionPointer();
|
||||||
hook_data->type = hook_entry->getType();
|
hook_data->type = hook_entry->getType();
|
||||||
module_data->number_used_hooks++;
|
plugin_data->number_used_hooks++;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Hooks for module \"%s\": %d\n",module_data->module_name,module_data->number_used_hooks);
|
DEBUG_FUNCTION_LINE("Hooks for plugin \"%s\": %d\n",plugin_data->plugin_name,plugin_data->number_used_hooks);
|
||||||
|
|
||||||
module_index++;
|
plugin_index++;
|
||||||
gbl_replacement_data.number_used_modules++;
|
gbl_replacement_data.number_used_plugins++;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -23,12 +23,12 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _MODULE_LOADER_H_
|
#ifndef _PLUGIN_LOADER_H_
|
||||||
#define _MODULE_LOADER_H_
|
#define _PLUGIN_LOADER_H_
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "ModuleInformation.h"
|
#include "PluginInformation.h"
|
||||||
#include "ModuleData.h"
|
#include "PluginData.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -43,12 +43,12 @@ extern "C" {
|
|||||||
|
|
||||||
#define PLUGIN_LOCATION_END_ADDRESS 0x01000000
|
#define PLUGIN_LOCATION_END_ADDRESS 0x01000000
|
||||||
|
|
||||||
class ModuleLoader{
|
class PluginLoader{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ModuleLoader *getInstance() {
|
static PluginLoader *getInstance() {
|
||||||
if(!instance){
|
if(!instance){
|
||||||
instance = new ModuleLoader((void*)getApplicationEndAddr(),(void *)PLUGIN_LOCATION_END_ADDRESS);
|
instance = new PluginLoader((void*)getApplicationEndAddr(),(void *)PLUGIN_LOCATION_END_ADDRESS);
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
@ -65,9 +65,9 @@ public:
|
|||||||
|
|
||||||
\param path the path of the directory which should be scanned.
|
\param path the path of the directory which should be scanned.
|
||||||
|
|
||||||
\return a list of ModuleInformation objects, one for each valid plugin.
|
\return a list of PluginInformation objects, one for each valid plugin.
|
||||||
**/
|
**/
|
||||||
std::vector<ModuleInformation *> getModuleInformation(const char * path);
|
std::vector<PluginInformation *> getPluginInformation(const char * path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Gets plugin information from the global struct.
|
\brief Gets plugin information from the global struct.
|
||||||
@ -75,64 +75,64 @@ public:
|
|||||||
\return a list of MetaInformation objects for all plugins currently loaded and linked (relocated). Will only contain
|
\return a list of MetaInformation objects for all plugins currently loaded and linked (relocated). Will only contain
|
||||||
plugin which are still on the sd card.
|
plugin which are still on the sd card.
|
||||||
**/
|
**/
|
||||||
//std::vector<ModuleInformation *> getModulesLoadedInMemory();
|
//std::vector<PluginInformation *> getPluginsLoadedInMemory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Takes a list of modules that should be linked (relocated) loaded into the memory.
|
\brief Takes a list of plugins that should be linked (relocated) loaded into the memory.
|
||||||
The function that should be replaced will be replaced in the order of the given plugin list.
|
The function that should be replaced will be replaced in the order of the given plugin list.
|
||||||
So two plugin will override the same function, the plugin first in this list will override the function first.
|
So two plugin will override the same function, the plugin first in this list will override the function first.
|
||||||
Also the hooks of the plugins will be called in the order their plugin where passed to this method.
|
Also the hooks of the plugins will be called in the order their plugin where passed to this method.
|
||||||
|
|
||||||
\param A list of plugin that should be linked (relocated) an loaded into memory
|
\param A list of plugin that should be linked (relocated) an loaded into memory
|
||||||
**/
|
**/
|
||||||
void loadAndLinkModules(std::vector<ModuleInformation *> moduleInformation);
|
void loadAndLinkPlugins(std::vector<PluginInformation *> pluginInformation);
|
||||||
private:
|
private:
|
||||||
ModuleLoader(void * startAddress, void * endAddress){
|
PluginLoader(void * startAddress, void * endAddress){
|
||||||
// TODO: Check if endAddress > startAddress.
|
// TODO: Check if endAddress > startAddress.
|
||||||
this->startAddress = startAddress;
|
this->startAddress = startAddress;
|
||||||
this->endAddress = endAddress;
|
this->endAddress = endAddress;
|
||||||
this->currentStoreAddress = endAddress;
|
this->currentStoreAddress = endAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
~ModuleLoader(){
|
~PluginLoader(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ModuleLoader *instance;
|
static PluginLoader *instance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Iterates through the vector and delete all it's elements
|
\brief Iterates through the vector and delete all it's elements
|
||||||
|
|
||||||
\param A list of ModuleData* that should be deleted.
|
\param A list of PluginData* that should be deleted.
|
||||||
**/
|
**/
|
||||||
void clearModuleData(std::vector<ModuleData *> moduleData);
|
void clearPluginData(std::vector<PluginData *> pluginData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Load
|
\brief Load
|
||||||
|
|
||||||
\param moduleInformation a ModuleInformation object of the plugin that should be linked (relocated) and loaded.
|
\param pluginInformation a PluginInformation object of the plugin that should be linked (relocated) and loaded.
|
||||||
|
|
||||||
\return NULL on error. On success it will return a ModuleData object.
|
\return NULL on error. On success it will return a PluginData object.
|
||||||
**/
|
**/
|
||||||
ModuleData * loadAndLinkModule(ModuleInformation * moduleInformation);
|
PluginData * loadAndLinkPlugin(PluginInformation * pluginInformation);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Loads a plugin into memory (in the startAddress/endAddress range defined in this loader) and relocates it.
|
\brief Loads a plugin into memory (in the startAddress/endAddress range defined in this loader) and relocates it.
|
||||||
Modifies the moduleData param. Adds loaded functions and hooks.
|
Modifies the pluginData param. Adds loaded functions and hooks.
|
||||||
\param moduleData object where the result should be stored
|
\param pluginData object where the result should be stored
|
||||||
\param elf source elf from where the sections will be loaded
|
\param elf source elf from where the sections will be loaded
|
||||||
\param storeAddressEnd the address where the plugin data will be stored in memory. Saving BACKWARD.
|
\param storeAddressEnd the address where the plugin data will be stored in memory. Saving BACKWARD.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
bool loadAndLinkElf(ModuleData * moduleData, Elf *elf, void * storeAddressEnd);
|
bool loadAndLinkElf(PluginData * pluginData, Elf *elf, void * storeAddressEnd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Copies the needed information into a global, persistent struct. This struct holds information on which
|
\brief Copies the needed information into a global, persistent struct. This struct holds information on which
|
||||||
function should be override in which order and which hook should be called.
|
function should be override in which order and which hook should be called.
|
||||||
\param modules list of modules that should be used.
|
\param plugins list of plugins that should be used.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
void copyModuleDataIntoGlobalStruct(std::vector<ModuleData *> modules);
|
void copyPluginDataIntoGlobalStruct(std::vector<PluginData *> plugins);
|
||||||
|
|
||||||
void * getCurrentStoreAddress(){
|
void * getCurrentStoreAddress(){
|
||||||
return this->currentStoreAddress;
|
return this->currentStoreAddress;
|
@ -6,10 +6,10 @@
|
|||||||
#include "dynamic_libs/fs_functions.h"
|
#include "dynamic_libs/fs_functions.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
|
||||||
WUPS_MODULE_NAME("test module");
|
WUPS_PLUGIN_NAME("test PLUGIN");
|
||||||
WUPS_MODULE_VERSION("v1.0");
|
WUPS_PLUGIN_VERSION("v1.0");
|
||||||
WUPS_MODULE_AUTHOR("Maschell");
|
WUPS_PLUGIN_AUTHOR("Maschell");
|
||||||
WUPS_MODULE_LICENSE("BSD");
|
WUPS_PLUGIN_LICENSE("BSD");
|
||||||
|
|
||||||
INITIALIZE(args){
|
INITIALIZE(args){
|
||||||
InitOSFunctionPointers();
|
InitOSFunctionPointers();
|
||||||
|
@ -9,10 +9,10 @@
|
|||||||
#include <utils/logger.h>
|
#include <utils/logger.h>
|
||||||
#include <fs/sd_fat_devoptab.h>
|
#include <fs/sd_fat_devoptab.h>
|
||||||
|
|
||||||
WUPS_MODULE_NAME("HID to VPAD lite");
|
WUPS_PLUGIN_NAME("HID to VPAD lite");
|
||||||
WUPS_MODULE_VERSION("v1.0");
|
WUPS_PLUGIN_VERSION("v1.0");
|
||||||
WUPS_MODULE_AUTHOR("Maschell");
|
WUPS_PLUGIN_AUTHOR("Maschell");
|
||||||
WUPS_MODULE_LICENSE("GPL");
|
WUPS_PLUGIN_LICENSE("GPL");
|
||||||
|
|
||||||
#define SD_PATH "sd:"
|
#define SD_PATH "sd:"
|
||||||
#define WIIU_PATH "/wiiu"
|
#define WIIU_PATH "/wiiu"
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
#include "dynamic_libs/socket_functions.h"
|
#include "dynamic_libs/socket_functions.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
|
||||||
WUPS_MODULE_NAME("Padcon");
|
WUPS_PLUGIN_NAME("Padcon");
|
||||||
WUPS_MODULE_VERSION("v1.0");
|
WUPS_PLUGIN_VERSION("v1.0");
|
||||||
WUPS_MODULE_AUTHOR("Maschell");
|
WUPS_PLUGIN_AUTHOR("Maschell");
|
||||||
WUPS_MODULE_LICENSE("GPL");
|
WUPS_PLUGIN_LICENSE("GPL");
|
||||||
|
|
||||||
|
|
||||||
INITIALIZE(args){
|
INITIALIZE(args){
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "modpackSelector.h"
|
#include "modpackSelector.h"
|
||||||
|
|
||||||
WUPS_MODULE_NAME("SDCaffiine lite");
|
WUPS_PLUGIN_NAME("SDCaffiine lite");
|
||||||
WUPS_MODULE_VERSION("v1.0");
|
WUPS_PLUGIN_VERSION("v1.0");
|
||||||
WUPS_MODULE_AUTHOR("Maschell");
|
WUPS_PLUGIN_AUTHOR("Maschell");
|
||||||
WUPS_MODULE_LICENSE("GPL");
|
WUPS_PLUGIN_LICENSE("GPL");
|
||||||
|
|
||||||
INITIALIZE(args){
|
INITIALIZE(args){
|
||||||
WUPS_InitFS(args);
|
WUPS_InitFS(args);
|
||||||
|
@ -34,10 +34,10 @@
|
|||||||
#include <utils/logger.h>
|
#include <utils/logger.h>
|
||||||
#include <common/c_retain_vars.h>
|
#include <common/c_retain_vars.h>
|
||||||
|
|
||||||
WUPS_MODULE_NAME("SwipSwapMe");
|
WUPS_PLUGIN_NAME("SwipSwapMe");
|
||||||
WUPS_MODULE_VERSION("v1.0");
|
WUPS_PLUGIN_VERSION("v1.0");
|
||||||
WUPS_MODULE_AUTHOR("Maschell");
|
WUPS_PLUGIN_AUTHOR("Maschell");
|
||||||
WUPS_MODULE_LICENSE("GPL");
|
WUPS_PLUGIN_LICENSE("GPL");
|
||||||
|
|
||||||
u8 isFirstBoot __attribute__((section(".data"))) = 1;
|
u8 isFirstBoot __attribute__((section(".data"))) = 1;
|
||||||
|
|
||||||
|
@ -215,10 +215,10 @@ typedef struct wups_loader_entry_t {
|
|||||||
extern const char wups_meta_ ## id [] WUPS_SECTION("meta"); \
|
extern const char wups_meta_ ## id [] WUPS_SECTION("meta"); \
|
||||||
const char wups_meta_ ## id [] = #id "=" value
|
const char wups_meta_ ## id [] = #id "=" value
|
||||||
|
|
||||||
#define WUPS_MODULE_NAME(x) WUPS_META(name, x); WUPS_META(wups, "0.1")
|
#define WUPS_PLUGIN_NAME(x) WUPS_META(name, x); WUPS_META(wups, "0.1")
|
||||||
#define WUPS_MODULE_AUTHOR(x) WUPS_META(author, x)
|
#define WUPS_PLUGIN_AUTHOR(x) WUPS_META(author, x)
|
||||||
#define WUPS_MODULE_VERSION(x) WUPS_META(version, x)
|
#define WUPS_PLUGIN_VERSION(x) WUPS_META(version, x)
|
||||||
#define WUPS_MODULE_LICENSE(x) WUPS_META(license, x)
|
#define WUPS_PLUGIN_LICENSE(x) WUPS_META(license, x)
|
||||||
|
|
||||||
void WUPS_InitFS(wups_loader_init_args_t* args);
|
void WUPS_InitFS(wups_loader_init_args_t* args);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user