[ALL] Renamed the EntryData into FunctionData, fixed some comments.

- Also
This commit is contained in:
Maschell 2018-02-18 19:03:51 +01:00
parent d64f221a92
commit 2b1b46363d
7 changed files with 42 additions and 46 deletions

View File

@ -75,7 +75,7 @@ before_deploy:
- git config --global user.name "Travis CI" - git config --global user.name "Travis CI"
- export GIT_TAG=WiiUPluginLoader-$versiontag - export GIT_TAG=WiiUPluginLoader-$versiontag
- commitLog="$(git log -1 --pretty=%B)" - 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 tag $GIT_TAG -a -m "$commitMessage" -m "$commitLog"
- git push --quiet https://$GITHUBKEY@github.com/Maschell/WiiUPluginSystem $GIT_TAG > /dev/null 2>&1 - git push --quiet https://$GITHUBKEY@github.com/Maschell/WiiUPluginSystem $GIT_TAG > /dev/null 2>&1

View File

@ -50,37 +50,33 @@ struct replacement_data_function_t{
u32 realAddr; /* [will be filled] Address of the real 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 */ 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. */ 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] */ 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{ struct replacement_data_hook_t{
void * func_pointer = NULL; /* [will be filled] */ void * func_pointer = NULL; /* [will be filled] */
wups_loader_hook_type_t type; /* [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_HOOKS_PER_PLUGIN 10
#define MAXIMUM_FUNCTION_PER_PLUGIN 100 #define MAXIMUM_FUNCTION_PER_PLUGIN 100
struct replacement_data_plugin_t{ struct replacement_data_plugin_t{
char path[MAXIMUM_PLUGIN_PATH_NAME_LENGTH]; char path[MAXIMUM_PLUGIN_PATH_NAME_LENGTH] = ""; // Path where the plugin is stored
char plugin_name[MAXIMUM_PLUGIN_NAME_LENGTH] = ""; // Name of this plugin char plugin_name[MAXIMUM_PLUGIN_NAME_LENGTH] = ""; // Name of this plugin
int priority; // Priority of this plugin int priority; // Priority of this plugin
int number_used_functions; // Number of used function. Maximum is MAXIMUM_FUNCTION_PER_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. 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 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 #define MAXIMUM_PLUGINS 32
struct replacement_data_t{ 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]; replacement_data_plugin_t plugin_data[MAXIMUM_PLUGINS];
}; };

View File

@ -15,23 +15,23 @@
* 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 _ENTRY_DATA_H_ #ifndef _FUNCTION_DATA_H_
#define _ENTRY_DATA_H_ #define _FUNCTION_DATA_H_
#include <wups.h> #include <wups.h>
#include <string> #include <string>
class EntryData{ class FunctionData{
public: 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->name = name;
this->library = library; this->library = library;
this->replaceAddr = target; this->replaceAddr = target;
this->replaceCall = call_addr; this->replaceCall = call_addr;
} }
~EntryData(){ ~FunctionData(){
} }

View File

@ -20,7 +20,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "EntryData.h" #include "FunctionData.h"
#include "HookData.h" #include "HookData.h"
#include "PluginInformation.h" #include "PluginInformation.h"
#include <utils/logger.h> #include <utils/logger.h>
@ -42,9 +42,9 @@ class PluginData{
} }
~PluginData(){ ~PluginData(){
for(size_t i = 0;i< entry_data_list.size();i++){ for(size_t i = 0;i< function_data_list.size();i++){
if(entry_data_list[i] != NULL){ if(function_data_list[i] != NULL){
delete entry_data_list[i]; delete function_data_list[i];
} }
} }
@ -55,12 +55,12 @@ class PluginData{
} }
} }
void addEntryData(EntryData * entry_data){ void addFunctionData(FunctionData * function_data){
entry_data_list.push_back(entry_data); function_data_list.push_back(function_data);
} }
std::vector<EntryData *> getEntryDataList(){ std::vector<FunctionData *> getFunctionDataList(){
return entry_data_list; return function_data_list;
} }
void addHookData(HookData * hook_data){ void addHookData(HookData * hook_data){
@ -79,7 +79,7 @@ class PluginData{
PluginInformation * pluginInformation; PluginInformation * pluginInformation;
std::vector<EntryData *> entry_data_list; std::vector<FunctionData *> function_data_list;
std::vector<HookData *> hook_data_list; std::vector<HookData *> hook_data_list;
}; };

View File

@ -28,7 +28,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "EntryData.h" #include "FunctionData.h"
#include "HookData.h" #include "HookData.h"
#include <utils/logger.h> #include <utils/logger.h>

View File

@ -200,7 +200,7 @@ bool PluginLoader::loadAndLinkElf(PluginData * pluginData, Elf *elf, void * endA
std::vector<wups_loader_entry_t *> entry_t_list; std::vector<wups_loader_entry_t *> entry_t_list;
std::vector<wups_loader_hook_t *> hook_t_list; std::vector<wups_loader_hook_t *> hook_t_list;
std::vector<EntryData *> entry_data_list; std::vector<FunctionData *> function_data_list;
std::vector<HookData *> hook_data_list; std::vector<HookData *> hook_data_list;
if (!ElfTools::loadElfSymtab(elf, &symtab, &symtab_count, &symtab_strndx)){ 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<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 * cur_function = entry_t_list[j];
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); 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);
EntryData * entry_data = new EntryData(entry->_function.name,entry->_function.library, (void *) entry->_function.target, (void *) entry->_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->addEntryData(entry_data); pluginData->addFunctionData(function_data);
} }
this->setCurrentStoreAddress((void *) curAddress); this->setCurrentStoreAddress((void *) curAddress);
@ -376,14 +376,14 @@ void PluginLoader::copyPluginDataIntoGlobalStruct(std::vector<PluginData *> plug
PluginData * cur_plugin = plugins.at(i); PluginData * cur_plugin = plugins.at(i);
PluginInformation * cur_pluginInformation = cur_plugin->getPluginInformation(); PluginInformation * cur_pluginInformation = cur_plugin->getPluginInformation();
std::vector<EntryData *> entry_data_list = cur_plugin->getEntryDataList(); std::vector<FunctionData *> function_data_list = cur_plugin->getFunctionDataList();
std::vector<HookData *> hook_data_list = cur_plugin->getHookDataList(); std::vector<HookData *> hook_data_list = cur_plugin->getHookDataList();
if(plugin_index >= MAXIMUM_PLUGINS ){ 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()); 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_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(),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(),function_data_list.size(),MAXIMUM_FUNCTION_PER_PLUGIN);
continue; continue;
} }
if(hook_data_list.size() > MAXIMUM_HOOKS_PER_PLUGIN){ if(hook_data_list.size() > MAXIMUM_HOOKS_PER_PLUGIN){
@ -396,18 +396,18 @@ void PluginLoader::copyPluginDataIntoGlobalStruct(std::vector<PluginData *> plug
strncpy(plugin_data->plugin_name,cur_pluginInformation->getName().c_str(),MAXIMUM_PLUGIN_NAME_LENGTH-1); 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); 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]; replacement_data_function_t * function_data = &plugin_data->functions[j];
EntryData * cur_entry = entry_data_list[j]; FunctionData * cur_function = function_data_list[j];
DEBUG_FUNCTION_LINE("Adding entry \"%s\" for plugin \"%s\"\n",cur_entry->getName().c_str(),plugin_data->plugin_name); 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. //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->library = cur_function->getLibrary();
function_data->replaceAddr = (u32) cur_entry->getReplaceAddress(); function_data->replaceAddr = (u32) cur_function->getReplaceAddress();
function_data->replaceCall = (u32) cur_entry->getReplaceCall(); function_data->replaceCall = (u32) cur_function->getReplaceCall();
plugin_data->number_used_functions++; plugin_data->number_used_functions++;
} }

View File

@ -190,8 +190,8 @@ typedef struct wups_loader_entry_t {
const char *name; /* Name of the function that will be replaced */ const char *name; /* Name of the function that will be replaced */
const wups_loader_library_type_t library; /**/ const wups_loader_library_type_t library; /**/
const char *my_function_name; /* Function name of your own, new function (my_XXX) */ 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 void *target; /*Address of our own, new function (my_XXX)*/ const void *call_addr; /* Address for calling the real function.(real_XXX) */
} _function; } _function;
} wups_loader_entry_t; } wups_loader_entry_t;
@ -206,8 +206,8 @@ typedef struct wups_loader_entry_t {
.name = #replace_function_name, \ .name = #replace_function_name, \
.library = rpl_type, \ .library = rpl_type, \
.my_function_name = #replace_func, \ .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) \
} \ } \
} }