From d64f221a9256f7b8cbfcce3fe5efaa6b86ed9e80 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 18 Feb 2018 18:43:51 +0100 Subject: [PATCH] [ALL] Added more fields to the metadata - Now the plugin it holds the build timestamp and a description - Added descriptions for all plugins --- loader/src/main.cpp | 2 +- loader/src/plugin/PluginInformation.cpp | 41 ++++++++++++++++--------- loader/src/plugin/PluginInformation.h | 18 +++++++++++ loader/src/plugin/PluginLoader.cpp | 6 ++-- plugins/example_plugin/src/main.cpp | 3 +- plugins/hid_to_vpad/src/main.cpp | 1 + plugins/padcon/src/main.c | 1 + plugins/sdcafiine/src/main.cpp | 1 + plugins/swipswapme/src/main.c | 1 + wups_include/wups.h | 3 +- 10 files changed, 56 insertions(+), 21 deletions(-) diff --git a/loader/src/main.cpp b/loader/src/main.cpp index bb0477b..d87779b 100644 --- a/loader/src/main.cpp +++ b/loader/src/main.cpp @@ -79,7 +79,7 @@ extern "C" int Menu_Main(int argc, char **argv){ DEBUG_FUNCTION_LINE("Wii U Plugin System Loader %s\n",APP_VERSION); - //setup_os_exceptions(); + setup_os_exceptions(); DEBUG_FUNCTION_LINE("Mount SD partition\n"); Init_SD_USB(); diff --git a/loader/src/plugin/PluginInformation.cpp b/loader/src/plugin/PluginInformation.cpp index 2a2aeca..3a3a896 100644 --- a/loader/src/plugin/PluginInformation.cpp +++ b/loader/src/plugin/PluginInformation.cpp @@ -239,7 +239,7 @@ exit_error: bool PluginInformation::metadataRead(Elf *elf, Elf32_Sym *symtab, size_t symtab_count, size_t symtab_strndx) { char *metadata = NULL, *metadata_cur, *metadata_end; - const char *game, *name, *author, *version, *license, *wups; + const char *name, *author, *version, *license, *wups, *buildtimestamp, *description; Elf_Scn *scn; size_t shstrndx; @@ -300,12 +300,13 @@ bool PluginInformation::metadataRead(Elf *elf, Elf32_Sym *symtab, size_t symtab_ goto exit_error; } - game = NULL; name = NULL; author = NULL; version = NULL; license = NULL; wups = NULL; + buildtimestamp = NULL; + description = NULL; for (metadata_cur = metadata; metadata_cur < metadata_end; metadata_cur = strchr(metadata_cur, '\0') + 1) { @@ -324,13 +325,7 @@ bool PluginInformation::metadataRead(Elf *elf, Elf32_Sym *symtab, size_t symtab_ continue; } - if (strncmp(metadata_cur, "game", eq - metadata_cur) == 0) { - if (game != NULL) { - DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_PLUGIN_GAME declarations.\n", path); - goto exit_error; - } - game = eq + 1; - } else if (strncmp(metadata_cur, "name", eq - metadata_cur) == 0) { + if (strncmp(metadata_cur, "name", eq - metadata_cur) == 0) { if (name != NULL) { DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_PLUGIN_NAME declarations.\n", path); goto exit_error; @@ -354,6 +349,18 @@ bool PluginInformation::metadataRead(Elf *elf, Elf32_Sym *symtab, size_t symtab_ goto exit_error; } license = eq + 1; + } else if (strncmp(metadata_cur, "buildtimestamp", eq - metadata_cur) == 0) { + if (buildtimestamp != NULL) { + DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_PLUGIN_TIMESTAMP declarations.\n", path); + goto exit_error; + } + buildtimestamp = eq + 1; + } else if (strncmp(metadata_cur, "description", eq - metadata_cur) == 0) { + if (description != NULL) { + DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_PLUGIN_LICENSE declarations.\n", path); + goto exit_error; + } + description = eq + 1; } else if (strncmp(metadata_cur, "wups", eq - metadata_cur) == 0) { if (wups != NULL) { DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Multiple WUPS_PLUGIN_NAME declarations.\n", path); @@ -363,14 +370,18 @@ bool PluginInformation::metadataRead(Elf *elf, Elf32_Sym *symtab, size_t symtab_ } } - if (game == NULL){ - game = ""; + if (description == NULL){ + description = ""; } - // TODO: - /*if (wups == NULL || strcmp(wups, "0.1") != 0) { + + if (wups == NULL || strcmp(wups, "0.1") != 0) { DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Unrecognised WUPS version.\n", path); goto exit_error; - }*/ + } + if (buildtimestamp == NULL) { + DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Couldn't find buildtimestamp.\n", path); + goto exit_error; + } if (name == NULL) { DEBUG_FUNCTION_LINE("Warning: Ignoring '%s' - Missing WUPS_PLUGIN_NAME declaration.\n",path); goto exit_error; @@ -392,6 +403,8 @@ bool PluginInformation::metadataRead(Elf *elf, Elf32_Sym *symtab, size_t symtab_ this->setAuthor(author); this->setVersion(version); this->setLicense(license); + this->setBuildTimestamp(buildtimestamp); + this->setDescription(description); return true; diff --git a/loader/src/plugin/PluginInformation.h b/loader/src/plugin/PluginInformation.h index 1027f72..a8f9ce9 100644 --- a/loader/src/plugin/PluginInformation.h +++ b/loader/src/plugin/PluginInformation.h @@ -79,6 +79,14 @@ class PluginInformation{ return this->license; } + std::string getBuildTimestamp(){ + return this->buildtimestamp; + } + + std::string getDescription(){ + return this->description; + } + std::string getPath(){ return path; } @@ -107,6 +115,14 @@ class PluginInformation{ this->license = license; } + void setBuildTimestamp(const char * buildtimestamp){ + this->buildtimestamp = buildtimestamp; + } + + void setDescription(const char * description){ + this->description = description; + } + void setSize(size_t size){ this->size = size; } @@ -126,6 +142,8 @@ class PluginInformation{ std::string author; std::string version; std::string license; + std::string buildtimestamp; + std::string description; size_t size; }; diff --git a/loader/src/plugin/PluginLoader.cpp b/loader/src/plugin/PluginLoader.cpp index 8f70d00..621fc15 100644 --- a/loader/src/plugin/PluginLoader.cpp +++ b/loader/src/plugin/PluginLoader.cpp @@ -66,7 +66,8 @@ std::vector PluginLoader::getPluginInformation(const char * DEBUG_FUNCTION_LINE("Found file: %s\n",full_file_path.c_str()) ; PluginInformation * plugin = PluginInformation::loadPluginInformation(full_file_path); if(plugin != NULL){ - DEBUG_FUNCTION_LINE("Found plugin %s by %s. Size: %d kb \n",plugin->getName().c_str(),plugin->getAuthor().c_str(),plugin->getSize()/1024) ; + DEBUG_FUNCTION_LINE("Found plugin %s by %s. Built on %s Size: %d kb \n",plugin->getName().c_str(),plugin->getAuthor().c_str(),plugin->getBuildTimestamp().c_str(),plugin->getSize()/1024) ; + DEBUG_FUNCTION_LINE("Description: %s \n",plugin->getDescription().c_str()) ; result.push_back(plugin); } else { DEBUG_FUNCTION_LINE("%s is not a valid plugin\n",full_file_path.c_str()) ; @@ -92,7 +93,6 @@ std::vector PluginLoader::getPluginsLoadedInMemory(){ void PluginLoader::loadAndLinkPlugins(std::vector pluginInformation){ std::vector loadedPlugins; for(size_t i = 0;i < pluginInformation.size(); i++){ - DEBUG_FUNCTION_LINE("loadAndLinkPlugins for %d\n",i) ; PluginInformation * cur_info = pluginInformation[i]; PluginData * pluginData = loadAndLinkPlugin(cur_info); if(pluginData == NULL){ @@ -126,7 +126,6 @@ void PluginLoader::clearPluginInformation(std::vector plugi } PluginData * PluginLoader::loadAndLinkPlugin(PluginInformation * pluginInformation){ - DEBUG_FUNCTION_LINE("\n"); PluginData * result = NULL; int fd = -1; Elf *elf = NULL; @@ -160,7 +159,6 @@ PluginData * PluginLoader::loadAndLinkPlugin(PluginInformation * pluginInformati goto exit_error; } - DEBUG_FUNCTION_LINE("\n"); result = new PluginData(pluginInformation); if(result == NULL){ DEBUG_FUNCTION_LINE("Failed to create object\n"); diff --git a/plugins/example_plugin/src/main.cpp b/plugins/example_plugin/src/main.cpp index dedbd7b..9d45af6 100644 --- a/plugins/example_plugin/src/main.cpp +++ b/plugins/example_plugin/src/main.cpp @@ -6,7 +6,8 @@ #include "dynamic_libs/fs_functions.h" #include "utils/logger.h" -WUPS_PLUGIN_NAME("test PLUGIN"); +WUPS_PLUGIN_NAME("Example plugin"); +WUPS_PLUGIN_DESCRIPTION("This is just an example plugin and will log the FSOpenFile function."); WUPS_PLUGIN_VERSION("v1.0"); WUPS_PLUGIN_AUTHOR("Maschell"); WUPS_PLUGIN_LICENSE("BSD"); diff --git a/plugins/hid_to_vpad/src/main.cpp b/plugins/hid_to_vpad/src/main.cpp index 0c4d216..d9f65af 100644 --- a/plugins/hid_to_vpad/src/main.cpp +++ b/plugins/hid_to_vpad/src/main.cpp @@ -10,6 +10,7 @@ #include WUPS_PLUGIN_NAME("HID to VPAD lite"); +WUPS_PLUGIN_DESCRIPTION("Enables HID devices as controllers on your Wii U"); WUPS_PLUGIN_VERSION("v1.0"); WUPS_PLUGIN_AUTHOR("Maschell"); WUPS_PLUGIN_LICENSE("GPL"); diff --git a/plugins/padcon/src/main.c b/plugins/padcon/src/main.c index ced0162..f9c5060 100644 --- a/plugins/padcon/src/main.c +++ b/plugins/padcon/src/main.c @@ -6,6 +6,7 @@ #include "utils/logger.h" WUPS_PLUGIN_NAME("Padcon"); +WUPS_PLUGIN_DESCRIPTION("Turns the gamepad screen on/off when pressing the right stick."); WUPS_PLUGIN_VERSION("v1.0"); WUPS_PLUGIN_AUTHOR("Maschell"); WUPS_PLUGIN_LICENSE("GPL"); diff --git a/plugins/sdcafiine/src/main.cpp b/plugins/sdcafiine/src/main.cpp index 63de938..7b6c1fa 100644 --- a/plugins/sdcafiine/src/main.cpp +++ b/plugins/sdcafiine/src/main.cpp @@ -15,6 +15,7 @@ #include "modpackSelector.h" WUPS_PLUGIN_NAME("SDCaffiine lite"); +WUPS_PLUGIN_DESCRIPTION("Replaces the game files on the fly. Can be used for gamemods"); WUPS_PLUGIN_VERSION("v1.0"); WUPS_PLUGIN_AUTHOR("Maschell"); WUPS_PLUGIN_LICENSE("GPL"); diff --git a/plugins/swipswapme/src/main.c b/plugins/swipswapme/src/main.c index 15757b8..d6f772d 100644 --- a/plugins/swipswapme/src/main.c +++ b/plugins/swipswapme/src/main.c @@ -35,6 +35,7 @@ #include WUPS_PLUGIN_NAME("SwipSwapMe"); +WUPS_PLUGIN_DESCRIPTION("Swaps the gamepad and tv screen when pressing a certain button (TV is default)"); WUPS_PLUGIN_VERSION("v1.0"); WUPS_PLUGIN_AUTHOR("Maschell"); WUPS_PLUGIN_LICENSE("GPL"); diff --git a/wups_include/wups.h b/wups_include/wups.h index 881a3f9..3b8229d 100644 --- a/wups_include/wups.h +++ b/wups_include/wups.h @@ -215,10 +215,11 @@ typedef struct wups_loader_entry_t { extern const char wups_meta_ ## id [] WUPS_SECTION("meta"); \ const char wups_meta_ ## id [] = #id "=" value -#define WUPS_PLUGIN_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"); WUPS_META(buildtimestamp, __DATE__ " " __TIME__) #define WUPS_PLUGIN_AUTHOR(x) WUPS_META(author, x) #define WUPS_PLUGIN_VERSION(x) WUPS_META(version, x) #define WUPS_PLUGIN_LICENSE(x) WUPS_META(license, x) +#define WUPS_PLUGIN_DESCRIPTION(x) WUPS_META(description, x) void WUPS_InitFS(wups_loader_init_args_t* args);