From 2b1b46363d01eca5a056659c5e07faef576a416a Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 18 Feb 2018 19:03:51 +0100 Subject: [PATCH] [ALL] Renamed the EntryData into FunctionData, fixed some comments. - Also --- .travis.yml | 2 +- loader/src/patcher/function_patcher.h | 14 ++++----- .../plugin/{EntryData.h => FunctionData.h} | 10 +++---- loader/src/plugin/PluginData.h | 18 +++++------ loader/src/plugin/PluginInformation.h | 2 +- loader/src/plugin/PluginLoader.cpp | 30 +++++++++---------- wups_include/wups.h | 12 ++++---- 7 files changed, 42 insertions(+), 46 deletions(-) rename loader/src/plugin/{EntryData.h => FunctionData.h} (87%) diff --git a/.travis.yml b/.travis.yml index e3bc520..c972c13 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,7 +75,7 @@ before_deploy: - git config --global user.name "Travis CI" - export GIT_TAG=WiiUPluginLoader-$versiontag - commitLog="$(git log -1 --pretty=%B)" -- commitMessage="$(echo -e "-\n" && echo "WiiUPluginLoader nightly build. Not a stable release. Expect bugs!" && echo -e "\nCommitlog:\n")" +- commitMessage="$(echo -e "-\n" && echo "WiiUPluginLoader nightly build. Not a stable release. Expect bugs!\n Only use the plugins with the bundled loaded as they may not work on others." && echo -e "\nCommitlog:\n")" - git tag $GIT_TAG -a -m "$commitMessage" -m "$commitLog" - git push --quiet https://$GITHUBKEY@github.com/Maschell/WiiUPluginSystem $GIT_TAG > /dev/null 2>&1 diff --git a/loader/src/patcher/function_patcher.h b/loader/src/patcher/function_patcher.h index 66244c3..6400f0e 100644 --- a/loader/src/patcher/function_patcher.h +++ b/loader/src/patcher/function_patcher.h @@ -50,37 +50,33 @@ struct replacement_data_function_t{ 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. */ - u8 functionType; /* [needs to be filled] name of the function we want to replace */ + u8 functionType; /* [will be filled] */ u8 alreadyPatched; /* [will be filled] */ - u32 entry_index; /* [needs to be filled] name of the function we want to replace */ - }; struct replacement_data_hook_t{ void * func_pointer = NULL; /* [will be filled] */ wups_loader_hook_type_t type; /* [will be filled] */ - u32 hook_index; /* [needs to be filled] name of the function we want to replace */ - }; #define MAXIMUM_HOOKS_PER_PLUGIN 10 #define MAXIMUM_FUNCTION_PER_PLUGIN 100 struct replacement_data_plugin_t{ - char path[MAXIMUM_PLUGIN_PATH_NAME_LENGTH]; - char plugin_name[MAXIMUM_PLUGIN_NAME_LENGTH] = ""; // Name of this plugin + char path[MAXIMUM_PLUGIN_PATH_NAME_LENGTH] = ""; // Path where the plugin is stored + char plugin_name[MAXIMUM_PLUGIN_NAME_LENGTH] = ""; // Name of this plugin 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. int number_used_hooks; // Number of used hooks. Maximum is MAXIMUM_HOOKS_PER_PLUGIN - replacement_data_hook_t hooks[MAXIMUM_HOOKS_PER_PLUGIN]; // Replacement information for each function. + replacement_data_hook_t hooks[MAXIMUM_HOOKS_PER_PLUGIN]; // Replacement information for each function. }; #define MAXIMUM_PLUGINS 32 struct replacement_data_t{ - int number_used_plugins = 0; // Number of used function. Maximum is MAXIMUM_FUNCTION_PER_PLUGIN + int number_used_plugins = 0; // Number of used function. Maximum is MAXIMUM_FUNCTION_PER_PLUGIN replacement_data_plugin_t plugin_data[MAXIMUM_PLUGINS]; }; diff --git a/loader/src/plugin/EntryData.h b/loader/src/plugin/FunctionData.h similarity index 87% rename from loader/src/plugin/EntryData.h rename to loader/src/plugin/FunctionData.h index 1206328..8bb5dda 100644 --- a/loader/src/plugin/EntryData.h +++ b/loader/src/plugin/FunctionData.h @@ -15,23 +15,23 @@ * along with this program. If not, see . ****************************************************************************/ -#ifndef _ENTRY_DATA_H_ -#define _ENTRY_DATA_H_ +#ifndef _FUNCTION_DATA_H_ +#define _FUNCTION_DATA_H_ #include #include -class EntryData{ +class FunctionData{ public: - EntryData(const char * name, wups_loader_library_type_t library, void * target, void * call_addr){ + FunctionData(const char * name, wups_loader_library_type_t library, void * target, void * call_addr){ this->name = name; this->library = library; this->replaceAddr = target; this->replaceCall = call_addr; } - ~EntryData(){ + ~FunctionData(){ } diff --git a/loader/src/plugin/PluginData.h b/loader/src/plugin/PluginData.h index c874bd0..58680a8 100644 --- a/loader/src/plugin/PluginData.h +++ b/loader/src/plugin/PluginData.h @@ -20,7 +20,7 @@ #include #include -#include "EntryData.h" +#include "FunctionData.h" #include "HookData.h" #include "PluginInformation.h" #include @@ -42,9 +42,9 @@ class PluginData{ } ~PluginData(){ - for(size_t i = 0;i< entry_data_list.size();i++){ - if(entry_data_list[i] != NULL){ - delete entry_data_list[i]; + for(size_t i = 0;i< function_data_list.size();i++){ + if(function_data_list[i] != NULL){ + delete function_data_list[i]; } } @@ -55,12 +55,12 @@ class PluginData{ } } - void addEntryData(EntryData * entry_data){ - entry_data_list.push_back(entry_data); + void addFunctionData(FunctionData * function_data){ + function_data_list.push_back(function_data); } - std::vector getEntryDataList(){ - return entry_data_list; + std::vector getFunctionDataList(){ + return function_data_list; } void addHookData(HookData * hook_data){ @@ -79,7 +79,7 @@ class PluginData{ PluginInformation * pluginInformation; - std::vector entry_data_list; + std::vector function_data_list; std::vector hook_data_list; }; diff --git a/loader/src/plugin/PluginInformation.h b/loader/src/plugin/PluginInformation.h index a8f9ce9..58c039a 100644 --- a/loader/src/plugin/PluginInformation.h +++ b/loader/src/plugin/PluginInformation.h @@ -28,7 +28,7 @@ #include #include -#include "EntryData.h" +#include "FunctionData.h" #include "HookData.h" #include diff --git a/loader/src/plugin/PluginLoader.cpp b/loader/src/plugin/PluginLoader.cpp index 621fc15..d370c3e 100644 --- a/loader/src/plugin/PluginLoader.cpp +++ b/loader/src/plugin/PluginLoader.cpp @@ -200,7 +200,7 @@ bool PluginLoader::loadAndLinkElf(PluginData * pluginData, Elf *elf, void * endA std::vector entry_t_list; std::vector hook_t_list; - std::vector entry_data_list; + std::vector function_data_list; std::vector hook_data_list; if (!ElfTools::loadElfSymtab(elf, &symtab, &symtab_count, &symtab_strndx)){ @@ -341,10 +341,10 @@ bool PluginLoader::loadAndLinkElf(PluginData * pluginData, Elf *elf, void * endA } for(size_t j=0;j_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); - pluginData->addEntryData(entry_data); + wups_loader_entry_t * cur_function = entry_t_list[j]; + DEBUG_FUNCTION_LINE("Saving function \"%s\" of plugin \"%s\". Library: %08X, target: %08X, call_addr: %08X\n",cur_function->_function.name,pluginData->getPluginInformation()->getName().c_str(),cur_function->_function.library,cur_function->_function.target, (void *) cur_function->_function.call_addr); + FunctionData * function_data = new FunctionData(cur_function->_function.name,cur_function->_function.library, (void *) cur_function->_function.target, (void *) cur_function->_function.call_addr); + pluginData->addFunctionData(function_data); } this->setCurrentStoreAddress((void *) curAddress); @@ -376,14 +376,14 @@ void PluginLoader::copyPluginDataIntoGlobalStruct(std::vector plug PluginData * cur_plugin = plugins.at(i); PluginInformation * cur_pluginInformation = cur_plugin->getPluginInformation(); - std::vector entry_data_list = cur_plugin->getEntryDataList(); + std::vector function_data_list = cur_plugin->getFunctionDataList(); std::vector hook_data_list = cur_plugin->getHookDataList(); if(plugin_index >= MAXIMUM_PLUGINS ){ DEBUG_FUNCTION_LINE("Maximum of %d plugins reached. %s won't be loaded!\n",MAXIMUM_PLUGINS,cur_pluginInformation->getName().c_str()); continue; } - if(entry_data_list.size() > MAXIMUM_FUNCTION_PER_PLUGIN){ - 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); + if(function_data_list.size() > MAXIMUM_FUNCTION_PER_PLUGIN){ + 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(),function_data_list.size(),MAXIMUM_FUNCTION_PER_PLUGIN); continue; } if(hook_data_list.size() > MAXIMUM_HOOKS_PER_PLUGIN){ @@ -396,18 +396,18 @@ void PluginLoader::copyPluginDataIntoGlobalStruct(std::vector plug strncpy(plugin_data->plugin_name,cur_pluginInformation->getName().c_str(),MAXIMUM_PLUGIN_NAME_LENGTH-1); strncpy(plugin_data->path,cur_pluginInformation->getPath().c_str(),MAXIMUM_PLUGIN_PATH_NAME_LENGTH-1); - for(size_t j = 0; j < entry_data_list.size();j++){ + for(size_t j = 0; j < function_data_list.size();j++){ replacement_data_function_t * function_data = &plugin_data->functions[j]; - EntryData * cur_entry = entry_data_list[j]; - DEBUG_FUNCTION_LINE("Adding entry \"%s\" for plugin \"%s\"\n",cur_entry->getName().c_str(),plugin_data->plugin_name); + FunctionData * cur_function = function_data_list[j]; + DEBUG_FUNCTION_LINE("Adding function \"%s\" for plugin \"%s\"\n",cur_function->getName().c_str(),plugin_data->plugin_name); //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_function->getName().c_str(),MAXIMUM_FUNCTION_NAME_LENGTH-1); - function_data->library = cur_entry->getLibrary(); - function_data->replaceAddr = (u32) cur_entry->getReplaceAddress(); - function_data->replaceCall = (u32) cur_entry->getReplaceCall(); + function_data->library = cur_function->getLibrary(); + function_data->replaceAddr = (u32) cur_function->getReplaceAddress(); + function_data->replaceCall = (u32) cur_function->getReplaceCall(); plugin_data->number_used_functions++; } diff --git a/wups_include/wups.h b/wups_include/wups.h index 3b8229d..21c6265 100644 --- a/wups_include/wups.h +++ b/wups_include/wups.h @@ -188,10 +188,10 @@ typedef struct wups_loader_entry_t { wups_loader_entry_type_t type; struct { const char *name; /* Name of the function that will be replaced */ - const wups_loader_library_type_t library; /**/ - const char *my_function_name; /* Function name of your own, new function (my_XXX) */ - const void *call_addr; /* Function name of function, to call the real function.(real_XXX) */ - const void *target; /*Address of our own, new function (my_XXX)*/ + const wups_loader_library_type_t library; /**/ + const char *my_function_name; /* Function name of your own, new function (my_XXX) */ + const void *target; /* Address of our own, new function (my_XXX)*/ + const void *call_addr; /* Address for calling the real function.(real_XXX) */ } _function; } wups_loader_entry_t; @@ -206,8 +206,8 @@ typedef struct wups_loader_entry_t { .name = #replace_function_name, \ .library = rpl_type, \ .my_function_name = #replace_func, \ - .call_addr = (const void*)&(original_func), \ - .target = (const void*)&(replace_func) \ + .target = (const void*)&(replace_func), \ + .call_addr = (const void*)&(original_func) \ } \ }