mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-22 04:39:17 +01:00
Organize imports and format code
This commit is contained in:
parent
80a0712519
commit
7a7a1f7a63
@ -9,7 +9,6 @@
|
|||||||
#include "PluginManagement.h"
|
#include "PluginManagement.h"
|
||||||
#include "hooks.h"
|
#include "hooks.h"
|
||||||
|
|
||||||
|
|
||||||
bool PluginManagement::doRelocation(const std::vector<RelocationData> &relocData, relocation_trampolin_entry_t *tramp_data, uint32_t tramp_length, uint32_t trampolinID) {
|
bool PluginManagement::doRelocation(const std::vector<RelocationData> &relocData, relocation_trampolin_entry_t *tramp_data, uint32_t tramp_length, uint32_t trampolinID) {
|
||||||
std::map<std::string, OSDynLoad_Module> moduleHandleCache;
|
std::map<std::string, OSDynLoad_Module> moduleHandleCache;
|
||||||
for (auto const &cur : relocData) {
|
for (auto const &cur : relocData) {
|
||||||
|
@ -17,7 +17,7 @@ public:
|
|||||||
|
|
||||||
static bool doRelocation(const std::vector<RelocationData> &relocData, relocation_trampolin_entry_t *tramp_data, uint32_t tramp_length, uint32_t trampolinID);
|
static bool doRelocation(const std::vector<RelocationData> &relocData, relocation_trampolin_entry_t *tramp_data, uint32_t tramp_length, uint32_t trampolinID);
|
||||||
|
|
||||||
static void unloadPlugins(plugin_information_t * pluginInformation, MEMHeapHandle pluginHeap, BOOL freePluginData);
|
static void unloadPlugins(plugin_information_t *pluginInformation, MEMHeapHandle pluginHeap, BOOL freePluginData);
|
||||||
|
|
||||||
static std::vector<PluginContainer> loadPlugins(const std::vector<PluginData> &pluginList, MEMHeapHandle pHeader, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length);
|
static std::vector<PluginContainer> loadPlugins(const std::vector<PluginData> &pluginList, MEMHeapHandle pHeader, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length);
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ static const char **hook_names = (const char *[]) {
|
|||||||
"WUPS_LOADER_HOOK_APPLET_START"};
|
"WUPS_LOADER_HOOK_APPLET_START"};
|
||||||
|
|
||||||
void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type, int32_t plugin_index_needed) {
|
void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type, int32_t plugin_index_needed) {
|
||||||
|
DEBUG_FUNCTION_LINE("Calling hook of type %s [%d]", hook_names[hook_type], hook_type);
|
||||||
for (int32_t plugin_index = 0; plugin_index < pluginInformation->number_used_plugins; plugin_index++) {
|
for (int32_t plugin_index = 0; plugin_index < pluginInformation->number_used_plugins; plugin_index++) {
|
||||||
plugin_information_single_t *plugin_data = &pluginInformation->plugin_data[plugin_index];
|
plugin_information_single_t *plugin_data = &pluginInformation->plugin_data[plugin_index];
|
||||||
if (plugin_index_needed != -1 && plugin_index_needed != plugin_index) {
|
if (plugin_index_needed != -1 && plugin_index_needed != plugin_index) {
|
||||||
|
@ -1,28 +1,15 @@
|
|||||||
#include <wups.h>
|
|
||||||
#include <whb/log.h>
|
#include <whb/log.h>
|
||||||
#include <whb/log_udp.h>
|
#include <whb/log_udp.h>
|
||||||
#include <exception>
|
|
||||||
#include <sysapp/launch.h>
|
|
||||||
#include <coreinit/debug.h>
|
#include <coreinit/debug.h>
|
||||||
#include <coreinit/memexpheap.h>
|
#include <coreinit/memexpheap.h>
|
||||||
#include <coreinit/dynload.h>
|
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
#include "plugin/PluginDataFactory.h"
|
#include "plugin/PluginDataFactory.h"
|
||||||
#include "plugin/PluginContainerPersistence.h"
|
#include "plugin/PluginContainerPersistence.h"
|
||||||
#include "plugin/PluginInformationFactory.h"
|
#include "plugin/PluginInformationFactory.h"
|
||||||
#include "plugin/PluginMetaInformationFactory.h"
|
#include "plugin/PluginMetaInformationFactory.h"
|
||||||
#include "plugin/FunctionData.h"
|
|
||||||
#include "plugin/PluginContainer.h"
|
|
||||||
#include "utils/logger.h"
|
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
#include "kernel/kernel_utils.h"
|
|
||||||
|
|
||||||
#include "utils/ElfUtils.h"
|
|
||||||
#include "common/relocation_defines.h"
|
|
||||||
#include "common/plugin_defines.h"
|
|
||||||
#include "common/plugin_defines.h"
|
|
||||||
#include "common/module_defines.h"
|
#include "common/module_defines.h"
|
||||||
#include "hooks.h"
|
|
||||||
#include "PluginManagement.h"
|
#include "PluginManagement.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include <whb/sdcard.h>
|
#include <whb/sdcard.h>
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
class PluginContainer {
|
class PluginContainer {
|
||||||
public:
|
public:
|
||||||
PluginContainer(const PluginContainer& other) {
|
PluginContainer(const PluginContainer &other) {
|
||||||
this->pluginData = other.pluginData;
|
this->pluginData = other.pluginData;
|
||||||
this->pluginInformation = other.pluginInformation;
|
this->pluginInformation = other.pluginInformation;
|
||||||
this->metaInformation = other.metaInformation;
|
this->metaInformation = other.metaInformation;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "PluginData.h"
|
#include "PluginData.h"
|
||||||
|
|
||||||
bool PluginDataPersistence::save(plugin_data_t *pluginDataStruct, PluginData &plugin) {
|
bool PluginDataPersistence::save(plugin_data_t *pluginDataStruct, PluginData &plugin) {
|
||||||
if(pluginDataStruct == NULL){
|
if (pluginDataStruct == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pluginDataStruct->buffer = (char *) plugin.buffer;
|
pluginDataStruct->buffer = (char *) plugin.buffer;
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#include "PluginInformation.h"
|
#include "PluginInformation.h"
|
||||||
|
|
||||||
PluginInformation::PluginInformation(const PluginInformation& other) {
|
PluginInformation::PluginInformation(const PluginInformation &other) {
|
||||||
for (size_t i=0; i<other.hook_data_list.size(); i++){
|
for (size_t i = 0; i < other.hook_data_list.size(); i++) {
|
||||||
hook_data_list.push_back(other.hook_data_list[i]);
|
hook_data_list.push_back(other.hook_data_list[i]);
|
||||||
}
|
}
|
||||||
for (size_t i=0; i<other.function_data_list.size(); i++){
|
for (size_t i = 0; i < other.function_data_list.size(); i++) {
|
||||||
function_data_list.push_back(other.function_data_list[i]);
|
function_data_list.push_back(other.function_data_list[i]);
|
||||||
}
|
}
|
||||||
for (size_t i=0; i<other.relocation_data_list.size(); i++){
|
for (size_t i = 0; i < other.relocation_data_list.size(); i++) {
|
||||||
relocation_data_list.push_back(other.relocation_data_list[i]);
|
relocation_data_list.push_back(other.relocation_data_list[i]);
|
||||||
}
|
}
|
||||||
section_info_list = other.section_info_list;
|
section_info_list = other.section_info_list;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
class PluginInformation {
|
class PluginInformation {
|
||||||
public:
|
public:
|
||||||
PluginInformation(const PluginInformation& other);
|
PluginInformation(const PluginInformation &other);
|
||||||
|
|
||||||
PluginInformation() {
|
PluginInformation() {
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "PluginMetaInformation.h"
|
#include "PluginMetaInformation.h"
|
||||||
|
|
||||||
PluginMetaInformation::PluginMetaInformation(const PluginMetaInformation& other) {
|
PluginMetaInformation::PluginMetaInformation(const PluginMetaInformation &other) {
|
||||||
this->name = other.name;
|
this->name = other.name;
|
||||||
this->author = other.author;
|
this->author = other.author;
|
||||||
this->version = other.version;
|
this->version = other.version;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
class PluginMetaInformation {
|
class PluginMetaInformation {
|
||||||
public:
|
public:
|
||||||
PluginMetaInformation(const PluginMetaInformation& other);
|
PluginMetaInformation(const PluginMetaInformation &other);
|
||||||
|
|
||||||
const std::string getName() const {
|
const std::string getName() const {
|
||||||
return name;
|
return name;
|
||||||
|
@ -36,6 +36,7 @@ std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(co
|
|||||||
}
|
}
|
||||||
return loadPlugin(readerOpt.value());
|
return loadPlugin(readerOpt.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(const std::string filePath) {
|
std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(const std::string filePath) {
|
||||||
auto reader = new elfio;
|
auto reader = new elfio;
|
||||||
if (reader == NULL || !reader->load(filePath)) {
|
if (reader == NULL || !reader->load(filePath)) {
|
||||||
|
@ -64,7 +64,7 @@ int32_t WUPSDeletePluginData(const plugin_data_handle *plugin_data_handle_list,
|
|||||||
return ERROR_NONE;
|
return ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t WUPSLoadPluginAsData(GetPluginInformationInputType inputType, const char* path, char* buffer, size_t size, plugin_data_handle * out) {
|
int32_t WUPSLoadPluginAsData(GetPluginInformationInputType inputType, const char *path, char *buffer, size_t size, plugin_data_handle *out) {
|
||||||
std::optional<PluginData> pluginData;
|
std::optional<PluginData> pluginData;
|
||||||
if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_PATH) {
|
if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_PATH) {
|
||||||
pluginData = PluginDataFactory::load(path, pluginDataHeap);
|
pluginData = PluginDataFactory::load(path, pluginDataHeap);
|
||||||
@ -93,15 +93,15 @@ int32_t WUPSLoadPluginAsData(GetPluginInformationInputType inputType, const char
|
|||||||
return ERROR_NONE;
|
return ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t WUPSLoadPluginAsDataByPath(plugin_data_handle * output, const char* path){
|
int32_t WUPSLoadPluginAsDataByPath(plugin_data_handle *output, const char *path) {
|
||||||
return WUPSLoadPluginAsData(PLUGIN_INFORMATION_INPUT_TYPE_PATH, path, NULL, 0, output);
|
return WUPSLoadPluginAsData(PLUGIN_INFORMATION_INPUT_TYPE_PATH, path, NULL, 0, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t WUPSLoadPluginAsDataByBuffer(plugin_data_handle * output, char* buffer, size_t size){
|
int32_t WUPSLoadPluginAsDataByBuffer(plugin_data_handle *output, char *buffer, size_t size) {
|
||||||
return WUPSLoadPluginAsData(PLUGIN_INFORMATION_INPUT_TYPE_BUFFER, NULL, buffer, size, output);
|
return WUPSLoadPluginAsData(PLUGIN_INFORMATION_INPUT_TYPE_BUFFER, NULL, buffer, size, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t WUPSGetPluginMetaInformation(GetPluginInformationInputType inputType, const char* path, char* buffer, size_t size, plugin_information * output) {
|
int32_t WUPSGetPluginMetaInformation(GetPluginInformationInputType inputType, const char *path, char *buffer, size_t size, plugin_information *output) {
|
||||||
std::optional<PluginMetaInformation> pluginInfo;
|
std::optional<PluginMetaInformation> pluginInfo;
|
||||||
if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_PATH && path != NULL) {
|
if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_PATH && path != NULL) {
|
||||||
DEBUG_FUNCTION_LINE("PLUGIN_INFORMATION_INPUT_TYPE_PATH %s", path);
|
DEBUG_FUNCTION_LINE("PLUGIN_INFORMATION_INPUT_TYPE_PATH %s", path);
|
||||||
@ -128,15 +128,15 @@ int32_t WUPSGetPluginMetaInformation(GetPluginInformationInputType inputType, co
|
|||||||
return ERROR_NONE;
|
return ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t WUPSGetPluginMetaInformationByPath(plugin_information * output, const char* path) {
|
int32_t WUPSGetPluginMetaInformationByPath(plugin_information *output, const char *path) {
|
||||||
return WUPSGetPluginMetaInformation(PLUGIN_INFORMATION_INPUT_TYPE_PATH, path, NULL, 0, output);
|
return WUPSGetPluginMetaInformation(PLUGIN_INFORMATION_INPUT_TYPE_PATH, path, NULL, 0, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t WUPSGetPluginMetaInformationByBuffer(plugin_information * output, char* buffer, size_t size) {
|
int32_t WUPSGetPluginMetaInformationByBuffer(plugin_information *output, char *buffer, size_t size) {
|
||||||
return WUPSGetPluginMetaInformation(PLUGIN_INFORMATION_INPUT_TYPE_BUFFER, NULL, buffer, size, output);
|
return WUPSGetPluginMetaInformation(PLUGIN_INFORMATION_INPUT_TYPE_BUFFER, NULL, buffer, size, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t WUPSGetPluginDataForContainerHandles(const plugin_container_handle *plugin_container_handle_list, plugin_data_handle *plugin_data_list , uint32_t buffer_size) {
|
int32_t WUPSGetPluginDataForContainerHandles(const plugin_container_handle *plugin_container_handle_list, plugin_data_handle *plugin_data_list, uint32_t buffer_size) {
|
||||||
int res;
|
int res;
|
||||||
if (plugin_container_handle_list != NULL && buffer_size != 0) {
|
if (plugin_container_handle_list != NULL && buffer_size != 0) {
|
||||||
for (uint32_t i = 0; i < buffer_size; i++) {
|
for (uint32_t i = 0; i < buffer_size; i++) {
|
||||||
@ -152,7 +152,7 @@ int32_t WUPSGetPluginDataForContainerHandles(const plugin_container_handle *plug
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t WUPSGetMetaInformation(plugin_container_handle * plugin_container_handle_list, plugin_information * plugin_information_list, uint32_t buffer_size) {
|
int32_t WUPSGetMetaInformation(plugin_container_handle *plugin_container_handle_list, plugin_information *plugin_information_list, uint32_t buffer_size) {
|
||||||
int res = ERROR_NONE;
|
int res = ERROR_NONE;
|
||||||
if (plugin_container_handle_list != NULL && buffer_size != 0) {
|
if (plugin_container_handle_list != NULL && buffer_size != 0) {
|
||||||
for (uint32_t i = 0; i < buffer_size; i++) {
|
for (uint32_t i = 0; i < buffer_size; i++) {
|
||||||
@ -173,7 +173,7 @@ int32_t WUPSGetMetaInformation(plugin_container_handle * plugin_container_handle
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t WUPSGetLoadedPlugins(plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t * outSize) {
|
int32_t WUPSGetLoadedPlugins(plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize) {
|
||||||
auto plugins = PluginContainerPersistence::loadPlugins(gPluginInformation);
|
auto plugins = PluginContainerPersistence::loadPlugins(gPluginInformation);
|
||||||
uint32_t counter = 0;
|
uint32_t counter = 0;
|
||||||
for (auto &plugin: plugins) {
|
for (auto &plugin: plugins) {
|
||||||
@ -186,7 +186,7 @@ int32_t WUPSGetLoadedPlugins(plugin_container_handle *io_handles, uint32_t buffe
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(*outSize){
|
if (*outSize) {
|
||||||
*outSize = counter;
|
*outSize = counter;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -204,4 +204,4 @@ WUMS_EXPORT_FUNCTION(WUPSGetPluginMetaInformationByPath);
|
|||||||
WUMS_EXPORT_FUNCTION(WUPSGetPluginMetaInformationByBuffer);
|
WUMS_EXPORT_FUNCTION(WUPSGetPluginMetaInformationByBuffer);
|
||||||
WUMS_EXPORT_FUNCTION(WUPSGetMetaInformation);
|
WUMS_EXPORT_FUNCTION(WUPSGetMetaInformation);
|
||||||
WUMS_EXPORT_FUNCTION(WUPSGetLoadedPlugins);
|
WUMS_EXPORT_FUNCTION(WUPSGetLoadedPlugins);
|
||||||
WUMS_EXPORT_FUNCTION(WUPSGetPluginDataForContainerHandles);
|
WUMS_EXPORT_FUNCTION(WUPSGetPluginDataForContainerHandles);
|
Loading…
Reference in New Issue
Block a user