From 7a7a1f7a635440bc2f4bbce8f186b56e631aa638 Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 28 May 2020 20:51:31 +0200 Subject: [PATCH] Organize imports and format code --- source/PluginManagement.cpp | 1 - source/PluginManagement.h | 2 +- source/hooks.cpp | 1 + source/main.cpp | 13 ----------- source/plugin/PluginContainer.h | 2 +- source/plugin/PluginDataPersistence.cpp | 2 +- source/plugin/PluginInformation.cpp | 8 +++---- source/plugin/PluginInformation.h | 2 +- source/plugin/PluginMetaInformation.cpp | 2 +- source/plugin/PluginMetaInformation.h | 2 +- .../plugin/PluginMetaInformationFactory.cpp | 1 + source/utils/exports.cpp | 22 +++++++++---------- 12 files changed, 23 insertions(+), 35 deletions(-) diff --git a/source/PluginManagement.cpp b/source/PluginManagement.cpp index 9cfa4f8..5854f1a 100644 --- a/source/PluginManagement.cpp +++ b/source/PluginManagement.cpp @@ -9,7 +9,6 @@ #include "PluginManagement.h" #include "hooks.h" - bool PluginManagement::doRelocation(const std::vector &relocData, relocation_trampolin_entry_t *tramp_data, uint32_t tramp_length, uint32_t trampolinID) { std::map moduleHandleCache; for (auto const &cur : relocData) { diff --git a/source/PluginManagement.h b/source/PluginManagement.h index 2145d34..9ef13e4 100644 --- a/source/PluginManagement.h +++ b/source/PluginManagement.h @@ -17,7 +17,7 @@ public: static bool doRelocation(const std::vector &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 loadPlugins(const std::vector &pluginList, MEMHeapHandle pHeader, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length); diff --git a/source/hooks.cpp b/source/hooks.cpp index 5564e53..53f00f8 100644 --- a/source/hooks.cpp +++ b/source/hooks.cpp @@ -48,6 +48,7 @@ static const char **hook_names = (const char *[]) { "WUPS_LOADER_HOOK_APPLET_START"}; 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++) { plugin_information_single_t *plugin_data = &pluginInformation->plugin_data[plugin_index]; if (plugin_index_needed != -1 && plugin_index_needed != plugin_index) { diff --git a/source/main.cpp b/source/main.cpp index d2493b6..a7ca8d1 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,28 +1,15 @@ -#include #include #include -#include -#include #include #include -#include #include #include "plugin/PluginDataFactory.h" #include "plugin/PluginContainerPersistence.h" #include "plugin/PluginInformationFactory.h" #include "plugin/PluginMetaInformationFactory.h" -#include "plugin/FunctionData.h" -#include "plugin/PluginContainer.h" -#include "utils/logger.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 "hooks.h" #include "PluginManagement.h" #include "globals.h" #include diff --git a/source/plugin/PluginContainer.h b/source/plugin/PluginContainer.h index 677b0a5..59980d1 100644 --- a/source/plugin/PluginContainer.h +++ b/source/plugin/PluginContainer.h @@ -23,7 +23,7 @@ class PluginContainer { public: - PluginContainer(const PluginContainer& other) { + PluginContainer(const PluginContainer &other) { this->pluginData = other.pluginData; this->pluginInformation = other.pluginInformation; this->metaInformation = other.metaInformation; diff --git a/source/plugin/PluginDataPersistence.cpp b/source/plugin/PluginDataPersistence.cpp index 90c7641..3234ecb 100644 --- a/source/plugin/PluginDataPersistence.cpp +++ b/source/plugin/PluginDataPersistence.cpp @@ -3,7 +3,7 @@ #include "PluginData.h" bool PluginDataPersistence::save(plugin_data_t *pluginDataStruct, PluginData &plugin) { - if(pluginDataStruct == NULL){ + if (pluginDataStruct == NULL) { return false; } pluginDataStruct->buffer = (char *) plugin.buffer; diff --git a/source/plugin/PluginInformation.cpp b/source/plugin/PluginInformation.cpp index e978739..dfedbf5 100644 --- a/source/plugin/PluginInformation.cpp +++ b/source/plugin/PluginInformation.cpp @@ -1,13 +1,13 @@ #include "PluginInformation.h" -PluginInformation::PluginInformation(const PluginInformation& other) { - for (size_t i=0; iname = other.name; this->author = other.author; this->version = other.version; diff --git a/source/plugin/PluginMetaInformation.h b/source/plugin/PluginMetaInformation.h index 7bc328a..167c8b5 100644 --- a/source/plugin/PluginMetaInformation.h +++ b/source/plugin/PluginMetaInformation.h @@ -22,7 +22,7 @@ class PluginMetaInformation { public: - PluginMetaInformation(const PluginMetaInformation& other); + PluginMetaInformation(const PluginMetaInformation &other); const std::string getName() const { return name; diff --git a/source/plugin/PluginMetaInformationFactory.cpp b/source/plugin/PluginMetaInformationFactory.cpp index 205ed57..473d264 100644 --- a/source/plugin/PluginMetaInformationFactory.cpp +++ b/source/plugin/PluginMetaInformationFactory.cpp @@ -36,6 +36,7 @@ std::optional PluginMetaInformationFactory::loadPlugin(co } return loadPlugin(readerOpt.value()); } + std::optional PluginMetaInformationFactory::loadPlugin(const std::string filePath) { auto reader = new elfio; if (reader == NULL || !reader->load(filePath)) { diff --git a/source/utils/exports.cpp b/source/utils/exports.cpp index 50f41c3..ce36b51 100644 --- a/source/utils/exports.cpp +++ b/source/utils/exports.cpp @@ -64,7 +64,7 @@ int32_t WUPSDeletePluginData(const plugin_data_handle *plugin_data_handle_list, 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; if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_PATH) { pluginData = PluginDataFactory::load(path, pluginDataHeap); @@ -93,15 +93,15 @@ int32_t WUPSLoadPluginAsData(GetPluginInformationInputType inputType, const char 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); } -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); } -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 pluginInfo; if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_PATH && path != NULL) { DEBUG_FUNCTION_LINE("PLUGIN_INFORMATION_INPUT_TYPE_PATH %s", path); @@ -128,15 +128,15 @@ int32_t WUPSGetPluginMetaInformation(GetPluginInformationInputType inputType, co 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); } -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); } -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; if (plugin_container_handle_list != NULL && buffer_size != 0) { for (uint32_t i = 0; i < buffer_size; i++) { @@ -152,7 +152,7 @@ int32_t WUPSGetPluginDataForContainerHandles(const plugin_container_handle *plug 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; if (plugin_container_handle_list != NULL && buffer_size != 0) { for (uint32_t i = 0; i < buffer_size; i++) { @@ -173,7 +173,7 @@ int32_t WUPSGetMetaInformation(plugin_container_handle * plugin_container_handle 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); uint32_t counter = 0; for (auto &plugin: plugins) { @@ -186,7 +186,7 @@ int32_t WUPSGetLoadedPlugins(plugin_container_handle *io_handles, uint32_t buffe break; } } - if(*outSize){ + if (*outSize) { *outSize = counter; } return 0; @@ -204,4 +204,4 @@ WUMS_EXPORT_FUNCTION(WUPSGetPluginMetaInformationByPath); WUMS_EXPORT_FUNCTION(WUPSGetPluginMetaInformationByBuffer); WUMS_EXPORT_FUNCTION(WUPSGetMetaInformation); WUMS_EXPORT_FUNCTION(WUPSGetLoadedPlugins); -WUMS_EXPORT_FUNCTION(WUPSGetPluginDataForContainerHandles); +WUMS_EXPORT_FUNCTION(WUPSGetPluginDataForContainerHandles); \ No newline at end of file