mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2026-04-15 21:15:48 -05:00
Replace "hook_names" array with helper function and move it into utils
This commit is contained in:
parent
6a3e051827
commit
e1efc665ca
|
|
@ -8,6 +8,7 @@
|
|||
#include "utils/buttoncombo/ButtonComboUtils.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/storage/StorageUtils.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#include <wups/button_combo/api.h>
|
||||
#include <wups/button_combo_internal.h>
|
||||
|
|
@ -15,45 +16,13 @@
|
|||
|
||||
#include <functional>
|
||||
|
||||
static const char **hook_names = (const char *[]){
|
||||
"WUPS_LOADER_HOOK_INIT_WUT_MALLOC",
|
||||
"WUPS_LOADER_HOOK_FINI_WUT_MALLOC",
|
||||
"WUPS_LOADER_HOOK_INIT_WUT_NEWLIB",
|
||||
"WUPS_LOADER_HOOK_FINI_WUT_NEWLIB",
|
||||
"WUPS_LOADER_HOOK_INIT_WUT_STDCPP",
|
||||
"WUPS_LOADER_HOOK_FINI_WUT_STDCPP",
|
||||
"WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB",
|
||||
"WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB",
|
||||
"WUPS_LOADER_HOOK_INIT_WUT_SOCKETS",
|
||||
"WUPS_LOADER_HOOK_FINI_WUT_SOCKETS",
|
||||
|
||||
"WUPS_LOADER_HOOK_INIT_WRAPPER",
|
||||
"WUPS_LOADER_HOOK_FINI_WRAPPER",
|
||||
|
||||
"WUPS_LOADER_HOOK_GET_CONFIG_DEPRECATED",
|
||||
"WUPS_LOADER_HOOK_CONFIG_CLOSED_DEPRECATED",
|
||||
|
||||
"WUPS_LOADER_HOOK_INIT_STORAGE_DEPRECATED",
|
||||
|
||||
"WUPS_LOADER_HOOK_INIT_PLUGIN",
|
||||
"WUPS_LOADER_HOOK_DEINIT_PLUGIN",
|
||||
"WUPS_LOADER_HOOK_APPLICATION_STARTS",
|
||||
"WUPS_LOADER_HOOK_RELEASE_FOREGROUND",
|
||||
"WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND",
|
||||
"WUPS_LOADER_HOOK_APPLICATION_REQUESTS_EXIT",
|
||||
"WUPS_LOADER_HOOK_APPLICATION_ENDS",
|
||||
"WUPS_LOADER_HOOK_INIT_STORAGE",
|
||||
"WUPS_LOADER_HOOK_INIT_CONFIG",
|
||||
"WUPS_LOADER_HOOK_INIT_BUTTON_COMBO",
|
||||
"WUPS_LOADER_HOOK_INIT_WUT_THREAD",
|
||||
};
|
||||
|
||||
void CallHook(const std::vector<PluginContainer> &plugins, const wups_loader_hook_type_t hook_type) {
|
||||
CallHook(plugins, hook_type, [](const auto &) { return true; });
|
||||
}
|
||||
|
||||
void CallHook(const std::vector<PluginContainer> &plugins, const wups_loader_hook_type_t hook_type, const std::function<bool(const PluginContainer &)> &pred) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Calling hook of type %s [%d]", hook_names[hook_type], hook_type);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Calling hook of type %s [%d]", hookNameToString(hook.getType()).c_str(), hook_type);
|
||||
for (const auto &plugin : plugins) {
|
||||
if (pred(plugin)) {
|
||||
CallHook(plugin, hook_type);
|
||||
|
|
@ -67,7 +36,7 @@ void CallHook(const PluginContainer &plugin, const wups_loader_hook_type_t hook_
|
|||
}
|
||||
for (const auto &hook : plugin.getPluginLinkInformation().getHookDataList()) {
|
||||
if (hook.getType() == hook_type) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Calling hook of type %s for plugin %s [%d]", hook_names[hook.getType()], plugin.getMetaInformation().getName().c_str(), hook_type);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Calling hook of type %s for plugin %s [%d]", hookNameToString(hook.getType()).c_str(), plugin.getMetaInformation().getName().c_str(), hook_type);
|
||||
void *func_ptr = hook.getFunctionPointer();
|
||||
if (func_ptr != nullptr) {
|
||||
switch (hook_type) {
|
||||
|
|
@ -172,7 +141,7 @@ void CallHook(const PluginContainer &plugin, const wups_loader_hook_type_t hook_
|
|||
}
|
||||
default: {
|
||||
DEBUG_FUNCTION_LINE_ERR("######################################");
|
||||
DEBUG_FUNCTION_LINE_ERR("Hook is not implemented %s [%d]", hook_names[hook_type], hook_type);
|
||||
DEBUG_FUNCTION_LINE_ERR("Hook is not implemented %s [%d]", hookNameToString(hook_type).c_str(), hook_type);
|
||||
DEBUG_FUNCTION_LINE_ERR("######################################");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <coreinit/debug.h>
|
||||
#include <coreinit/ios.h>
|
||||
|
||||
#include <wups/hooks.h>
|
||||
#include <wups/storage.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
|
@ -265,4 +266,62 @@ void PrintCapturedStackTrace(std::span<uint32_t> trace) {
|
|||
}
|
||||
|
||||
DEBUG_FUNCTION_LINE_INFO("└────────────────────────────────────────────────────────────┘");
|
||||
}
|
||||
|
||||
std::string hookNameToString(const wups_loader_hook_type_t type) {
|
||||
switch (type) {
|
||||
case WUPS_LOADER_HOOK_INIT_WUT_MALLOC:
|
||||
return "WUPS_LOADER_HOOK_INIT_WUT_MALLOC";
|
||||
case WUPS_LOADER_HOOK_FINI_WUT_MALLOC:
|
||||
return "WUPS_LOADER_HOOK_FINI_WUT_MALLOC";
|
||||
case WUPS_LOADER_HOOK_INIT_WUT_NEWLIB:
|
||||
return "WUPS_LOADER_HOOK_INIT_WUT_NEWLIB";
|
||||
case WUPS_LOADER_HOOK_FINI_WUT_NEWLIB:
|
||||
return "WUPS_LOADER_HOOK_FINI_WUT_NEWLIB";
|
||||
case WUPS_LOADER_HOOK_INIT_WUT_STDCPP:
|
||||
return "WUPS_LOADER_HOOK_INIT_WUT_STDCPP";
|
||||
case WUPS_LOADER_HOOK_FINI_WUT_STDCPP:
|
||||
return "WUPS_LOADER_HOOK_FINI_WUT_STDCPP";
|
||||
case WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB:
|
||||
return "WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB";
|
||||
case WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB:
|
||||
return "WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB";
|
||||
case WUPS_LOADER_HOOK_INIT_WUT_SOCKETS:
|
||||
return "WUPS_LOADER_HOOK_INIT_WUT_SOCKETS";
|
||||
case WUPS_LOADER_HOOK_FINI_WUT_SOCKETS:
|
||||
return "WUPS_LOADER_HOOK_FINI_WUT_SOCKETS";
|
||||
case WUPS_LOADER_HOOK_INIT_WRAPPER:
|
||||
return "WUPS_LOADER_HOOK_INIT_WRAPPER";
|
||||
case WUPS_LOADER_HOOK_FINI_WRAPPER:
|
||||
return "WUPS_LOADER_HOOK_FINI_WRAPPER";
|
||||
case WUPS_LOADER_HOOK_GET_CONFIG_DEPRECATED:
|
||||
return "WUPS_LOADER_HOOK_GET_CONFIG_DEPRECATED";
|
||||
case WUPS_LOADER_HOOK_CONFIG_CLOSED_DEPRECATED:
|
||||
return "WUPS_LOADER_HOOK_CONFIG_CLOSED_DEPRECATED";
|
||||
case WUPS_LOADER_HOOK_INIT_STORAGE_DEPRECATED:
|
||||
return "WUPS_LOADER_HOOK_INIT_STORAGE_DEPRECATED";
|
||||
case WUPS_LOADER_HOOK_INIT_PLUGIN:
|
||||
return "WUPS_LOADER_HOOK_INIT_PLUGIN";
|
||||
case WUPS_LOADER_HOOK_DEINIT_PLUGIN:
|
||||
return "WUPS_LOADER_HOOK_DEINIT_PLUGIN";
|
||||
case WUPS_LOADER_HOOK_APPLICATION_STARTS:
|
||||
return "WUPS_LOADER_HOOK_APPLICATION_STARTS";
|
||||
case WUPS_LOADER_HOOK_RELEASE_FOREGROUND:
|
||||
return "WUPS_LOADER_HOOK_RELEASE_FOREGROUND";
|
||||
case WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND:
|
||||
return "WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND";
|
||||
case WUPS_LOADER_HOOK_APPLICATION_REQUESTS_EXIT:
|
||||
return "WUPS_LOADER_HOOK_APPLICATION_REQUESTS_EXIT";
|
||||
case WUPS_LOADER_HOOK_APPLICATION_ENDS:
|
||||
return "WUPS_LOADER_HOOK_APPLICATION_ENDS";
|
||||
case WUPS_LOADER_HOOK_INIT_STORAGE:
|
||||
return "WUPS_LOADER_HOOK_INIT_STORAGE";
|
||||
case WUPS_LOADER_HOOK_INIT_CONFIG:
|
||||
return "WUPS_LOADER_HOOK_INIT_CONFIG";
|
||||
case WUPS_LOADER_HOOK_INIT_BUTTON_COMBO:
|
||||
return "WUPS_LOADER_HOOK_INIT_BUTTON_COMBO";
|
||||
case WUPS_LOADER_HOOK_INIT_WUT_THREAD:
|
||||
return "WUPS_LOADER_HOOK_INIT_WUT_THREAD";
|
||||
}
|
||||
return "<UNKNOWN>";
|
||||
}
|
||||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include <coreinit/dynload.h>
|
||||
|
||||
#include <wups/hooks.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <forward_list>
|
||||
#include <memory>
|
||||
|
|
@ -165,4 +167,6 @@ std::vector<std::string> getNonBaseAromaPluginFilenames(std::string_view basePat
|
|||
|
||||
std::vector<uint32_t> CaptureStackTrace(uint32_t maxDepth);
|
||||
|
||||
void PrintCapturedStackTrace(std::span<uint32_t> trace);
|
||||
void PrintCapturedStackTrace(std::span<uint32_t> trace);
|
||||
|
||||
std::string hookNameToString(wups_loader_hook_type_t type);
|
||||
Loading…
Reference in New Issue
Block a user