mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-22 04:39:17 +01:00
Remove unnecessary std::unique_ptr usages
This commit is contained in:
parent
b8647b94fc
commit
7d07f6525b
@ -12,9 +12,9 @@
|
|||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
std::vector<std::unique_ptr<PluginContainer>>
|
std::vector<PluginContainer>
|
||||||
PluginManagement::loadPlugins(const std::set<std::shared_ptr<PluginData>> &pluginDataList, std::vector<relocation_trampoline_entry_t> &trampolineData) {
|
PluginManagement::loadPlugins(const std::set<std::shared_ptr<PluginData>> &pluginDataList, std::vector<relocation_trampoline_entry_t> &trampolineData) {
|
||||||
std::vector<std::unique_ptr<PluginContainer>> plugins;
|
std::vector<PluginContainer> plugins;
|
||||||
|
|
||||||
uint32_t trampolineID = 0;
|
uint32_t trampolineID = 0;
|
||||||
for (const auto &pluginData : pluginDataList) {
|
for (const auto &pluginData : pluginDataList) {
|
||||||
@ -29,13 +29,7 @@ PluginManagement::loadPlugins(const std::set<std::shared_ptr<PluginData>> &plugi
|
|||||||
DisplayErrorNotificationMessage(errMsg, 15.0f);
|
DisplayErrorNotificationMessage(errMsg, 15.0f);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
std::string nameCpy = metaInfo->getName();
|
plugins.emplace_back(std::move(*metaInfo), std::move(*info), pluginData);
|
||||||
auto container = make_unique_nothrow<PluginContainer>(std::move(metaInfo), std::move(info), pluginData);
|
|
||||||
if (!container) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to create PluginContainer, skipping %s", nameCpy.c_str());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
plugins.push_back(std::move(container));
|
|
||||||
} else {
|
} else {
|
||||||
auto errMsg = string_format("Failed to load plugin: %s", pluginData->getSource().c_str());
|
auto errMsg = string_format("Failed to load plugin: %s", pluginData->getSource().c_str());
|
||||||
if (error == PLUGIN_PARSE_ERROR_INCOMPATIBLE_VERSION) {
|
if (error == PLUGIN_PARSE_ERROR_INCOMPATIBLE_VERSION) {
|
||||||
@ -54,13 +48,13 @@ PluginManagement::loadPlugins(const std::set<std::shared_ptr<PluginData>> &plugi
|
|||||||
return plugins;
|
return plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PluginManagement::doRelocation(const std::vector<std::unique_ptr<RelocationData>> &relocData,
|
bool PluginManagement::doRelocation(const std::vector<RelocationData> &relocData,
|
||||||
std::vector<relocation_trampoline_entry_t> &trampData,
|
std::vector<relocation_trampoline_entry_t> &trampData,
|
||||||
uint32_t trampolineID,
|
uint32_t trampolineID,
|
||||||
std::map<std::string, OSDynLoad_Module> &usedRPls) {
|
std::map<std::string, OSDynLoad_Module> &usedRPls) {
|
||||||
for (auto const &cur : relocData) {
|
for (auto const &cur : relocData) {
|
||||||
uint32_t functionAddress = 0;
|
uint32_t functionAddress = 0;
|
||||||
auto &functionName = cur->getName();
|
auto &functionName = cur.getName();
|
||||||
|
|
||||||
if (functionName == "MEMAllocFromDefaultHeap") {
|
if (functionName == "MEMAllocFromDefaultHeap") {
|
||||||
OSDynLoad_Module rplHandle;
|
OSDynLoad_Module rplHandle;
|
||||||
@ -77,8 +71,8 @@ bool PluginManagement::doRelocation(const std::vector<std::unique_ptr<Relocation
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (functionAddress == 0) {
|
if (functionAddress == 0) {
|
||||||
auto rplName = cur->getImportRPLInformation().getRPLName();
|
auto rplName = cur.getImportRPLInformation().getRPLName();
|
||||||
int32_t isData = cur->getImportRPLInformation().isData();
|
int32_t isData = cur.getImportRPLInformation().isData();
|
||||||
OSDynLoad_Module rplHandle = nullptr;
|
OSDynLoad_Module rplHandle = nullptr;
|
||||||
|
|
||||||
if (!usedRPls.contains(rplName)) {
|
if (!usedRPls.contains(rplName)) {
|
||||||
@ -106,7 +100,7 @@ bool PluginManagement::doRelocation(const std::vector<std::unique_ptr<Relocation
|
|||||||
//DEBUG_FUNCTION_LINE("Found export for %s %s", rplName.c_str(), functionName.c_str());
|
//DEBUG_FUNCTION_LINE("Found export for %s %s", rplName.c_str(), functionName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ElfUtils::elfLinkOne(cur->getType(), cur->getOffset(), cur->getAddend(), (uint32_t) cur->getDestination(), functionAddress, trampData, RELOC_TYPE_IMPORT, trampolineID)) {
|
if (!ElfUtils::elfLinkOne(cur.getType(), cur.getOffset(), cur.getAddend(), (uint32_t) cur.getDestination(), functionAddress, trampData, RELOC_TYPE_IMPORT, trampolineID)) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("elfLinkOne failed");
|
DEBUG_FUNCTION_LINE_ERR("elfLinkOne failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -127,7 +121,7 @@ bool PluginManagement::doRelocation(const std::vector<std::unique_ptr<Relocation
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PluginManagement::doRelocations(const std::vector<std::unique_ptr<PluginContainer>> &plugins,
|
bool PluginManagement::doRelocations(const std::vector<PluginContainer> &plugins,
|
||||||
std::vector<relocation_trampoline_entry_t> &trampData,
|
std::vector<relocation_trampoline_entry_t> &trampData,
|
||||||
std::map<std::string, OSDynLoad_Module> &usedRPls) {
|
std::map<std::string, OSDynLoad_Module> &usedRPls) {
|
||||||
for (auto &cur : trampData) {
|
for (auto &cur : trampData) {
|
||||||
@ -143,10 +137,10 @@ bool PluginManagement::doRelocations(const std::vector<std::unique_ptr<PluginCon
|
|||||||
OSDynLoad_SetAllocator(CustomDynLoadAlloc, CustomDynLoadFree);
|
OSDynLoad_SetAllocator(CustomDynLoadAlloc, CustomDynLoadFree);
|
||||||
|
|
||||||
for (const auto &pluginContainer : plugins) {
|
for (const auto &pluginContainer : plugins) {
|
||||||
DEBUG_FUNCTION_LINE_VERBOSE("Doing relocations for plugin: %s", pluginContainer->getMetaInformation().getName().c_str());
|
DEBUG_FUNCTION_LINE_VERBOSE("Doing relocations for plugin: %s", pluginContainer.getMetaInformation().getName().c_str());
|
||||||
if (!PluginManagement::doRelocation(pluginContainer->getPluginInformation().getRelocationDataList(),
|
if (!PluginManagement::doRelocation(pluginContainer.getPluginInformation().getRelocationDataList(),
|
||||||
trampData,
|
trampData,
|
||||||
pluginContainer->getPluginInformation().getTrampolineId(),
|
pluginContainer.getPluginInformation().getTrampolineId(),
|
||||||
usedRPls)) {
|
usedRPls)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -157,10 +151,10 @@ bool PluginManagement::doRelocations(const std::vector<std::unique_ptr<PluginCon
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PluginManagement::RestoreFunctionPatches(const std::vector<std::unique_ptr<PluginContainer>> &plugins) {
|
bool PluginManagement::RestoreFunctionPatches(std::vector<PluginContainer> &plugins) {
|
||||||
for (const auto &cur : std::ranges::reverse_view(plugins)) {
|
for (auto &cur : std::ranges::reverse_view(plugins)) {
|
||||||
for (const auto &curFunction : std::ranges::reverse_view(cur->getPluginInformation().getFunctionDataList())) {
|
for (auto &curFunction : std::ranges::reverse_view(cur.getPluginInformation().getFunctionDataList())) {
|
||||||
if (!curFunction->RemovePatch()) {
|
if (!curFunction.RemovePatch()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,11 +162,11 @@ bool PluginManagement::RestoreFunctionPatches(const std::vector<std::unique_ptr<
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PluginManagement::DoFunctionPatches(const std::vector<std::unique_ptr<PluginContainer>> &plugins) {
|
bool PluginManagement::DoFunctionPatches(std::vector<PluginContainer> &plugins) {
|
||||||
for (const auto &cur : plugins) {
|
for (auto &cur : plugins) {
|
||||||
for (const auto &curFunction : cur->getPluginInformation().getFunctionDataList()) {
|
for (auto &curFunction : cur.getPluginInformation().getFunctionDataList()) {
|
||||||
if (!curFunction->AddPatch()) {
|
if (!curFunction.AddPatch()) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to add function patch for: plugin %s", cur->getMetaInformation().getName().c_str());
|
DEBUG_FUNCTION_LINE_ERR("Failed to add function patch for: plugin %s", cur.getMetaInformation().getName().c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,7 +174,7 @@ bool PluginManagement::DoFunctionPatches(const std::vector<std::unique_ptr<Plugi
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginManagement::callInitHooks(const std::vector<std::unique_ptr<PluginContainer>> &plugins) {
|
void PluginManagement::callInitHooks(const std::vector<PluginContainer> &plugins) {
|
||||||
CallHook(plugins, WUPS_LOADER_HOOK_INIT_CONFIG);
|
CallHook(plugins, WUPS_LOADER_HOOK_INIT_CONFIG);
|
||||||
CallHook(plugins, WUPS_LOADER_HOOK_INIT_STORAGE_DEPRECATED);
|
CallHook(plugins, WUPS_LOADER_HOOK_INIT_STORAGE_DEPRECATED);
|
||||||
CallHook(plugins, WUPS_LOADER_HOOK_INIT_STORAGE);
|
CallHook(plugins, WUPS_LOADER_HOOK_INIT_STORAGE);
|
||||||
|
@ -9,22 +9,22 @@
|
|||||||
|
|
||||||
class PluginManagement {
|
class PluginManagement {
|
||||||
public:
|
public:
|
||||||
static std::vector<std::unique_ptr<PluginContainer>> loadPlugins(
|
static std::vector<PluginContainer> loadPlugins(
|
||||||
const std::set<std::shared_ptr<PluginData>> &pluginDataList,
|
const std::set<std::shared_ptr<PluginData>> &pluginDataList,
|
||||||
std::vector<relocation_trampoline_entry_t> &trampolineData);
|
std::vector<relocation_trampoline_entry_t> &trampolineData);
|
||||||
|
|
||||||
static void callInitHooks(const std::vector<std::unique_ptr<PluginContainer>> &plugins);
|
static void callInitHooks(const std::vector<PluginContainer> &plugins);
|
||||||
|
|
||||||
static bool doRelocations(const std::vector<std::unique_ptr<PluginContainer>> &plugins,
|
static bool doRelocations(const std::vector<PluginContainer> &plugins,
|
||||||
std::vector<relocation_trampoline_entry_t> &trampData,
|
std::vector<relocation_trampoline_entry_t> &trampData,
|
||||||
std::map<std::string, OSDynLoad_Module> &usedRPls);
|
std::map<std::string, OSDynLoad_Module> &usedRPls);
|
||||||
|
|
||||||
static bool doRelocation(const std::vector<std::unique_ptr<RelocationData>> &relocData,
|
static bool doRelocation(const std::vector<RelocationData> &relocData,
|
||||||
std::vector<relocation_trampoline_entry_t> &trampData,
|
std::vector<relocation_trampoline_entry_t> &trampData,
|
||||||
uint32_t trampolineID,
|
uint32_t trampolineID,
|
||||||
std::map<std::string, OSDynLoad_Module> &usedRPls);
|
std::map<std::string, OSDynLoad_Module> &usedRPls);
|
||||||
|
|
||||||
static bool DoFunctionPatches(const std::vector<std::unique_ptr<PluginContainer>> &plugins);
|
static bool DoFunctionPatches(std::vector<PluginContainer> &plugins);
|
||||||
|
|
||||||
static bool RestoreFunctionPatches(const std::vector<std::unique_ptr<PluginContainer>> &plugins);
|
static bool RestoreFunctionPatches(std::vector<PluginContainer> &plugins);
|
||||||
};
|
};
|
@ -140,7 +140,7 @@ namespace WUPSConfigAPIBackend {
|
|||||||
return WUPSCONFIG_API_RESULT_INVALID_ARGUMENT;
|
return WUPSCONFIG_API_RESULT_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
for (auto &cur : gLoadedPlugins) {
|
for (auto &cur : gLoadedPlugins) {
|
||||||
if (cur->getHandle() == pluginIdentifier) {
|
if (cur.getHandle() == pluginIdentifier) {
|
||||||
if (options.version != 1) {
|
if (options.version != 1) {
|
||||||
return WUPSCONFIG_API_RESULT_UNSUPPORTED_VERSION;
|
return WUPSCONFIG_API_RESULT_UNSUPPORTED_VERSION;
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ namespace WUPSConfigAPIBackend {
|
|||||||
DEBUG_FUNCTION_LINE_WARN("Failed to create config data for %08X", pluginIdentifier);
|
DEBUG_FUNCTION_LINE_WARN("Failed to create config data for %08X", pluginIdentifier);
|
||||||
return WUPSCONFIG_API_RESULT_UNSUPPORTED_VERSION;
|
return WUPSCONFIG_API_RESULT_UNSUPPORTED_VERSION;
|
||||||
}
|
}
|
||||||
cur->setConfigData(configDat.value());
|
cur.setConfigData(configDat.value());
|
||||||
return WUPSCONFIG_API_RESULT_SUCCESS;
|
return WUPSCONFIG_API_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
StoredBuffer gStoredTVBuffer = {};
|
StoredBuffer gStoredTVBuffer = {};
|
||||||
StoredBuffer gStoredDRCBuffer = {};
|
StoredBuffer gStoredDRCBuffer = {};
|
||||||
|
|
||||||
std::vector<std::unique_ptr<PluginContainer>> gLoadedPlugins;
|
std::vector<PluginContainer> gLoadedPlugins;
|
||||||
std::vector<relocation_trampoline_entry_t> gTrampData;
|
std::vector<relocation_trampoline_entry_t> gTrampData;
|
||||||
|
|
||||||
std::set<std::shared_ptr<PluginData>> gLoadedData;
|
std::set<std::shared_ptr<PluginData>> gLoadedData;
|
||||||
|
@ -17,7 +17,7 @@ extern StoredBuffer gStoredDRCBuffer;
|
|||||||
|
|
||||||
#define TRAMP_DATA_SIZE 1024
|
#define TRAMP_DATA_SIZE 1024
|
||||||
extern std::vector<relocation_trampoline_entry_t> gTrampData;
|
extern std::vector<relocation_trampoline_entry_t> gTrampData;
|
||||||
extern std::vector<std::unique_ptr<PluginContainer>> gLoadedPlugins;
|
extern std::vector<PluginContainer> gLoadedPlugins;
|
||||||
|
|
||||||
extern std::set<std::shared_ptr<PluginData>> gLoadedData;
|
extern std::set<std::shared_ptr<PluginData>> gLoadedData;
|
||||||
extern std::set<std::shared_ptr<PluginData>> gLoadOnNextLaunch;
|
extern std::set<std::shared_ptr<PluginData>> gLoadOnNextLaunch;
|
||||||
|
@ -35,18 +35,18 @@ static const char **hook_names = (const char *[]){
|
|||||||
"WUPS_LOADER_HOOK_INIT_STORAGE",
|
"WUPS_LOADER_HOOK_INIT_STORAGE",
|
||||||
"WUPS_LOADER_HOOK_INIT_CONFIG"};
|
"WUPS_LOADER_HOOK_INIT_CONFIG"};
|
||||||
|
|
||||||
void CallHook(const std::vector<std::unique_ptr<PluginContainer>> &plugins, wups_loader_hook_type_t hook_type) {
|
void CallHook(const std::vector<PluginContainer> &plugins, wups_loader_hook_type_t hook_type) {
|
||||||
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]", hook_names[hook_type], hook_type);
|
||||||
for (const auto &plugin : plugins) {
|
for (const auto &plugin : plugins) {
|
||||||
CallHook(*plugin, hook_type);
|
CallHook(plugin, hook_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallHook(const PluginContainer &plugin, wups_loader_hook_type_t hook_type) {
|
void CallHook(const PluginContainer &plugin, wups_loader_hook_type_t hook_type) {
|
||||||
for (const auto &hook : plugin.getPluginInformation().getHookDataList()) {
|
for (const auto &hook : plugin.getPluginInformation().getHookDataList()) {
|
||||||
if (hook->getType() == hook_type) {
|
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]", hook_names[hook.getType()], plugin.getMetaInformation().getName().c_str(), hook_type);
|
||||||
void *func_ptr = hook->getFunctionPointer();
|
void *func_ptr = hook.getFunctionPointer();
|
||||||
if (func_ptr != nullptr) {
|
if (func_ptr != nullptr) {
|
||||||
switch (hook_type) {
|
switch (hook_type) {
|
||||||
case WUPS_LOADER_HOOK_INIT_WUT_MALLOC:
|
case WUPS_LOADER_HOOK_INIT_WUT_MALLOC:
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <wups/hooks.h>
|
#include <wups/hooks.h>
|
||||||
|
|
||||||
void CallHook(const std::vector<std::unique_ptr<PluginContainer>> &plugins, wups_loader_hook_type_t hook_type);
|
void CallHook(const std::vector<PluginContainer> &plugins, wups_loader_hook_type_t hook_type);
|
||||||
|
|
||||||
void CallHook(const PluginContainer &plugin, wups_loader_hook_type_t hook_type);
|
void CallHook(const PluginContainer &plugin, wups_loader_hook_type_t hook_type);
|
@ -67,7 +67,7 @@ WUMS_APPLICATION_ENDS() {
|
|||||||
deinitLogging();
|
deinitLogging();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckCleanupCallbackUsage(const std::vector<std::unique_ptr<PluginContainer>> &plugins);
|
void CheckCleanupCallbackUsage(const std::vector<PluginContainer> &plugins);
|
||||||
|
|
||||||
WUMS_APPLICATION_STARTS() {
|
WUMS_APPLICATION_STARTS() {
|
||||||
uint32_t upid = OSGetUPID();
|
uint32_t upid = OSGetUPID();
|
||||||
@ -132,9 +132,9 @@ WUMS_APPLICATION_STARTS() {
|
|||||||
PluginManagement::RestoreFunctionPatches(gLoadedPlugins);
|
PluginManagement::RestoreFunctionPatches(gLoadedPlugins);
|
||||||
|
|
||||||
for (auto &plugin : gLoadedPlugins) {
|
for (auto &plugin : gLoadedPlugins) {
|
||||||
WUPSStorageError err = plugin->CloseStorage();
|
WUPSStorageError err = plugin.CloseStorage();
|
||||||
if (err != WUPS_STORAGE_ERROR_SUCCESS) {
|
if (err != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to close storage for plugin: %s", plugin->getMetaInformation().getName().c_str());
|
DEBUG_FUNCTION_LINE_ERR("Failed to close storage for plugin: %s", plugin.getMetaInformation().getName().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,9 +174,9 @@ WUMS_APPLICATION_STARTS() {
|
|||||||
|
|
||||||
if (initNeeded) {
|
if (initNeeded) {
|
||||||
for (auto &plugin : gLoadedPlugins) {
|
for (auto &plugin : gLoadedPlugins) {
|
||||||
WUPSStorageError err = plugin->OpenStorage();
|
WUPSStorageError err = plugin.OpenStorage();
|
||||||
if (err != WUPS_STORAGE_ERROR_SUCCESS) {
|
if (err != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to open storage for plugin: %s. (%s)", plugin->getMetaInformation().getName().c_str(), WUPSStorageAPI_GetStatusStr(err));
|
DEBUG_FUNCTION_LINE_ERR("Failed to open storage for plugin: %s. (%s)", plugin.getMetaInformation().getName().c_str(), WUPSStorageAPI_GetStatusStr(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PluginManagement::callInitHooks(gLoadedPlugins);
|
PluginManagement::callInitHooks(gLoadedPlugins);
|
||||||
@ -186,16 +186,16 @@ WUMS_APPLICATION_STARTS() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckCleanupCallbackUsage(const std::vector<std::unique_ptr<PluginContainer>> &plugins) {
|
void CheckCleanupCallbackUsage(const std::vector<PluginContainer> &plugins) {
|
||||||
auto *curThread = OSGetCurrentThread();
|
auto *curThread = OSGetCurrentThread();
|
||||||
for (const auto &cur : plugins) {
|
for (const auto &cur : plugins) {
|
||||||
auto textSection = cur->getPluginInformation().getSectionInfo(".text");
|
auto textSection = cur.getPluginInformation().getSectionInfo(".text");
|
||||||
if (!textSection) {
|
if (!textSection) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
uint32_t startAddress = textSection->getAddress();
|
uint32_t startAddress = textSection->getAddress();
|
||||||
uint32_t endAddress = textSection->getAddress() + textSection->getSize();
|
uint32_t endAddress = textSection->getAddress() + textSection->getSize();
|
||||||
auto *pluginName = cur->getMetaInformation().getName().c_str();
|
auto *pluginName = cur.getMetaInformation().getName().c_str();
|
||||||
{
|
{
|
||||||
__OSLockScheduler(curThread);
|
__OSLockScheduler(curThread);
|
||||||
int state = OSDisableInterrupts();
|
int state = OSDisableInterrupts();
|
||||||
|
@ -121,7 +121,7 @@ DECL_FUNCTION(uint32_t, SC17_FindClosestSymbol,
|
|||||||
char *moduleNameBuffer,
|
char *moduleNameBuffer,
|
||||||
uint32_t moduleNameBufferLength) {
|
uint32_t moduleNameBufferLength) {
|
||||||
for (const auto &plugin : gLoadedPlugins) {
|
for (const auto &plugin : gLoadedPlugins) {
|
||||||
auto sectionInfo = plugin->getPluginInformation().getSectionInfo(".text");
|
const auto sectionInfo = plugin.getPluginInformation().getSectionInfo(".text");
|
||||||
if (!sectionInfo) {
|
if (!sectionInfo) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -130,8 +130,8 @@ DECL_FUNCTION(uint32_t, SC17_FindClosestSymbol,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(moduleNameBuffer, plugin->getMetaInformation().getName().c_str(), moduleNameBufferLength - 1);
|
strncpy(moduleNameBuffer, plugin.getMetaInformation().getName().c_str(), moduleNameBufferLength - 1);
|
||||||
auto functionSymbolData = plugin->getPluginInformation().getNearestFunctionSymbolData(addr);
|
auto functionSymbolData = plugin.getPluginInformation().getNearestFunctionSymbolData(addr);
|
||||||
if (functionSymbolData) {
|
if (functionSymbolData) {
|
||||||
strncpy(symbolNameBuffer, functionSymbolData->getName().c_str(), moduleNameBufferLength - 1);
|
strncpy(symbolNameBuffer, functionSymbolData->getName().c_str(), moduleNameBufferLength - 1);
|
||||||
if (outDistance) {
|
if (outDistance) {
|
||||||
@ -154,7 +154,7 @@ DECL_FUNCTION(uint32_t, SC17_FindClosestSymbol,
|
|||||||
|
|
||||||
DECL_FUNCTION(uint32_t, KiGetAppSymbolName, uint32_t addr, char *buffer, int32_t bufSize) {
|
DECL_FUNCTION(uint32_t, KiGetAppSymbolName, uint32_t addr, char *buffer, int32_t bufSize) {
|
||||||
for (const auto &plugin : gLoadedPlugins) {
|
for (const auto &plugin : gLoadedPlugins) {
|
||||||
auto sectionInfo = plugin->getPluginInformation().getSectionInfo(".text");
|
const auto sectionInfo = plugin.getPluginInformation().getSectionInfo(".text");
|
||||||
if (!sectionInfo) {
|
if (!sectionInfo) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -163,14 +163,14 @@ DECL_FUNCTION(uint32_t, KiGetAppSymbolName, uint32_t addr, char *buffer, int32_t
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pluginNameLen = strlen(plugin->getMetaInformation().getName().c_str());
|
auto pluginNameLen = strlen(plugin.getMetaInformation().getName().c_str());
|
||||||
int32_t spaceLeftInBuffer = (int32_t) bufSize - (int32_t) pluginNameLen - 1;
|
int32_t spaceLeftInBuffer = (int32_t) bufSize - (int32_t) pluginNameLen - 1;
|
||||||
if (spaceLeftInBuffer < 0) {
|
if (spaceLeftInBuffer < 0) {
|
||||||
spaceLeftInBuffer = 0;
|
spaceLeftInBuffer = 0;
|
||||||
}
|
}
|
||||||
strncpy(buffer, plugin->getMetaInformation().getName().c_str(), bufSize - 1);
|
strncpy(buffer, plugin.getMetaInformation().getName().c_str(), bufSize - 1);
|
||||||
|
|
||||||
auto functionSymbolData = plugin->getPluginInformation().getNearestFunctionSymbolData(addr);
|
const auto functionSymbolData = plugin.getPluginInformation().getNearestFunctionSymbolData(addr);
|
||||||
if (functionSymbolData) {
|
if (functionSymbolData) {
|
||||||
buffer[pluginNameLen] = '|';
|
buffer[pluginNameLen] = '|';
|
||||||
buffer[pluginNameLen + 1] = '\0';
|
buffer[pluginNameLen + 1] = '\0';
|
||||||
|
@ -14,7 +14,7 @@ public:
|
|||||||
mClosedCallback(closedCallback) {
|
mClosedCallback(closedCallback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<WUPSConfigHandle> createConfig() {
|
[[nodiscard]] std::optional<WUPSConfigHandle> createConfig() const{
|
||||||
WUPSConfigHandle handle;
|
WUPSConfigHandle handle;
|
||||||
if (WUPSConfigAPIBackend::Intern::CreateConfig(mName.c_str(), &handle) == WUPSCONFIG_API_RESULT_SUCCESS) {
|
if (WUPSConfigAPIBackend::Intern::CreateConfig(mName.c_str(), &handle) == WUPSCONFIG_API_RESULT_SUCCESS) {
|
||||||
return handle;
|
return handle;
|
||||||
@ -22,7 +22,7 @@ public:
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
WUPSConfigAPIStatus CallMenuOpenendCallback(WUPSConfigHandle config) {
|
[[nodiscard]] WUPSConfigAPIStatus CallMenuOpenendCallback(WUPSConfigHandle config) const {
|
||||||
if (mOpenedCallback == nullptr) {
|
if (mOpenedCallback == nullptr) {
|
||||||
return WUPSCONFIG_API_RESULT_MISSING_CALLBACK;
|
return WUPSCONFIG_API_RESULT_MISSING_CALLBACK;
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ public:
|
|||||||
return WUPSCONFIG_API_RESULT_SUCCESS;
|
return WUPSCONFIG_API_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
WUPSConfigAPIStatus CallMenuClosedCallback() {
|
[[nodiscard]] WUPSConfigAPIStatus CallMenuClosedCallback() const {
|
||||||
if (mClosedCallback == nullptr) {
|
if (mClosedCallback == nullptr) {
|
||||||
return WUPSCONFIG_API_RESULT_MISSING_CALLBACK;
|
return WUPSCONFIG_API_RESULT_MISSING_CALLBACK;
|
||||||
}
|
}
|
||||||
|
@ -28,18 +28,49 @@
|
|||||||
|
|
||||||
class PluginContainer {
|
class PluginContainer {
|
||||||
public:
|
public:
|
||||||
PluginContainer(std::unique_ptr<PluginMetaInformation> metaInformation, std::unique_ptr<PluginInformation> pluginInformation, std::shared_ptr<PluginData> pluginData)
|
PluginContainer(PluginMetaInformation metaInformation, PluginInformation pluginInformation, std::shared_ptr<PluginData> pluginData)
|
||||||
: mMetaInformation(std::move(metaInformation)),
|
: mMetaInformation(std::move(metaInformation)),
|
||||||
mPluginInformation(std::move(pluginInformation)),
|
mPluginInformation(std::move(pluginInformation)),
|
||||||
mPluginData(std::move(pluginData)) {
|
mPluginData(std::move(pluginData)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PluginContainer(const PluginContainer &) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
PluginContainer(PluginContainer &&src) : mMetaInformation(std::move(src.mMetaInformation)),
|
||||||
|
mPluginInformation(std::move(src.mPluginInformation)),
|
||||||
|
mPluginData(std::move(src.mPluginData)),
|
||||||
|
mPluginConfigData(std::move(src.mPluginConfigData)),
|
||||||
|
storageRootItem(src.storageRootItem)
|
||||||
|
|
||||||
|
{
|
||||||
|
src.storageRootItem = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginContainer &operator=(PluginContainer &&src) {
|
||||||
|
if (this != &src) {
|
||||||
|
this->mMetaInformation = src.mMetaInformation;
|
||||||
|
this->mPluginInformation = std::move(src.mPluginInformation);
|
||||||
|
this->mPluginData = std::move(src.mPluginData);
|
||||||
|
this->mPluginConfigData = std::move(src.mPluginConfigData);
|
||||||
|
this->storageRootItem = src.storageRootItem;
|
||||||
|
|
||||||
|
storageRootItem = nullptr;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] const PluginMetaInformation &getMetaInformation() const {
|
[[nodiscard]] const PluginMetaInformation &getMetaInformation() const {
|
||||||
return *this->mMetaInformation;
|
return this->mMetaInformation;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const PluginInformation &getPluginInformation() const {
|
[[nodiscard]] const PluginInformation &getPluginInformation() const {
|
||||||
return *this->mPluginInformation;
|
return this->mPluginInformation;
|
||||||
|
}
|
||||||
|
[[nodiscard]] PluginInformation &getPluginInformation() {
|
||||||
|
return this->mPluginInformation;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] std::shared_ptr<PluginData> getPluginDataCopy() const {
|
[[nodiscard]] std::shared_ptr<PluginData> getPluginDataCopy() const {
|
||||||
@ -88,9 +119,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::unique_ptr<PluginMetaInformation> mMetaInformation;
|
PluginMetaInformation mMetaInformation;
|
||||||
const std::unique_ptr<PluginInformation> mPluginInformation;
|
PluginInformation mPluginInformation;
|
||||||
const std::shared_ptr<PluginData> mPluginData;
|
std::shared_ptr<PluginData> mPluginData;
|
||||||
|
|
||||||
std::optional<PluginConfigData> mPluginConfigData;
|
std::optional<PluginConfigData> mPluginConfigData;
|
||||||
wups_storage_root_item storageRootItem = nullptr;
|
wups_storage_root_item storageRootItem = nullptr;
|
||||||
|
@ -34,53 +34,89 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct FunctionSymbolDataComparator {
|
struct FunctionSymbolDataComparator {
|
||||||
bool operator()(const std::unique_ptr<FunctionSymbolData> &lhs,
|
bool operator()(const FunctionSymbolData &lhs,
|
||||||
const std::unique_ptr<FunctionSymbolData> &rhs) const {
|
const FunctionSymbolData &rhs) const {
|
||||||
return *lhs < *rhs;
|
return lhs < rhs;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PluginInformation {
|
class PluginInformation {
|
||||||
public:
|
public:
|
||||||
void addHookData(std::unique_ptr<HookData> hook_data) {
|
PluginInformation(const PluginInformation &) = delete;
|
||||||
mHookDataList.push_back(std::move(hook_data));
|
|
||||||
|
|
||||||
|
PluginInformation(PluginInformation &&src) : mHookDataList(std::move(src.mHookDataList)),
|
||||||
|
mFunctionDataList(std::move(src.mFunctionDataList)),
|
||||||
|
mRelocationDataList(std::move(src.mRelocationDataList)),
|
||||||
|
mSymbolDataList(std::move(src.mSymbolDataList)),
|
||||||
|
mSectionInfoList(std::move(src.mSectionInfoList)),
|
||||||
|
mTrampolineId(src.mTrampolineId),
|
||||||
|
mAllocatedTextMemoryAddress(std::move(src.mAllocatedTextMemoryAddress)),
|
||||||
|
mAllocatedDataMemoryAddress(std::move(src.mAllocatedDataMemoryAddress))
|
||||||
|
|
||||||
|
{
|
||||||
|
src.mTrampolineId = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const std::vector<std::unique_ptr<HookData>> &getHookDataList() const {
|
PluginInformation &operator=(PluginInformation &&src) {
|
||||||
|
if (this != &src) {
|
||||||
|
this->mHookDataList = std::move(src.mHookDataList);
|
||||||
|
this->mFunctionDataList = std::move(src.mFunctionDataList);
|
||||||
|
this->mRelocationDataList = std::move(src.mRelocationDataList);
|
||||||
|
this->mSymbolDataList = std::move(src.mSymbolDataList);
|
||||||
|
this->mSectionInfoList = std::move(src.mSectionInfoList);
|
||||||
|
this->mTrampolineId = src.mTrampolineId;
|
||||||
|
this->mAllocatedTextMemoryAddress = std::move(src.mAllocatedTextMemoryAddress);
|
||||||
|
this->mAllocatedDataMemoryAddress = std::move(src.mAllocatedDataMemoryAddress);
|
||||||
|
src.mTrampolineId = {};
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void addHookData(HookData hook_data) {
|
||||||
|
mHookDataList.push_back(hook_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] const std::vector<HookData> &getHookDataList() const {
|
||||||
return mHookDataList;
|
return mHookDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addFunctionData(std::unique_ptr<FunctionData> function_data) {
|
void addFunctionData(FunctionData function_data) {
|
||||||
mFunctionDataList.push_back(std::move(function_data));
|
mFunctionDataList.push_back(std::move(function_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const std::vector<std::unique_ptr<FunctionData>> &getFunctionDataList() const {
|
[[nodiscard]] const std::vector<FunctionData> &getFunctionDataList() const {
|
||||||
return mFunctionDataList;
|
return mFunctionDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addRelocationData(std::unique_ptr<RelocationData> relocation_data) {
|
[[nodiscard]] std::vector<FunctionData> &getFunctionDataList() {
|
||||||
|
return mFunctionDataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addRelocationData(RelocationData relocation_data) {
|
||||||
mRelocationDataList.push_back(std::move(relocation_data));
|
mRelocationDataList.push_back(std::move(relocation_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const std::vector<std::unique_ptr<RelocationData>> &getRelocationDataList() const {
|
[[nodiscard]] const std::vector<RelocationData> &getRelocationDataList() const {
|
||||||
return mRelocationDataList;
|
return mRelocationDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addFunctionSymbolData(std::unique_ptr<FunctionSymbolData> symbol_data) {
|
void addFunctionSymbolData(const FunctionSymbolData &symbol_data) {
|
||||||
mSymbolDataList.insert(std::move(symbol_data));
|
mSymbolDataList.insert(symbol_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addSectionInfo(std::unique_ptr<SectionInfo> sectionInfo) {
|
void addSectionInfo(const SectionInfo §ionInfo) {
|
||||||
mSectionInfoList[sectionInfo->getName()] = std::move(sectionInfo);
|
mSectionInfoList.insert(std::pair(sectionInfo.getName(), sectionInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const std::map<std::string, std::unique_ptr<SectionInfo>> &getSectionInfoList() const {
|
[[nodiscard]] const std::map<std::string, SectionInfo> &getSectionInfoList() const {
|
||||||
return mSectionInfoList;
|
return mSectionInfoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] std::optional<SectionInfo> getSectionInfo(const std::string §ionName) const {
|
[[nodiscard]] std::optional<SectionInfo> getSectionInfo(const std::string §ionName) const {
|
||||||
if (getSectionInfoList().contains(sectionName)) {
|
if (getSectionInfoList().contains(sectionName)) {
|
||||||
return *mSectionInfoList.at(sectionName);
|
return mSectionInfoList.at(sectionName);
|
||||||
}
|
}
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
@ -93,16 +129,16 @@ public:
|
|||||||
return mTrampolineId;
|
return mTrampolineId;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] FunctionSymbolData *getNearestFunctionSymbolData(uint32_t address) const {
|
[[nodiscard]] const FunctionSymbolData *getNearestFunctionSymbolData(uint32_t address) const {
|
||||||
FunctionSymbolData *result = nullptr;
|
const FunctionSymbolData *result = nullptr;
|
||||||
|
|
||||||
bool foundHit = false;
|
bool foundHit = false;
|
||||||
for (auto &cur : mSymbolDataList) {
|
for (auto &cur : mSymbolDataList) {
|
||||||
if (foundHit && address < (uint32_t) cur->getAddress()) {
|
if (foundHit && address < (uint32_t) cur.getAddress()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (address >= (uint32_t) cur->getAddress()) {
|
if (address >= (uint32_t) cur.getAddress()) {
|
||||||
result = cur.get();
|
result = &cur;
|
||||||
foundHit = true;
|
foundHit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,11 +158,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::unique_ptr<HookData>> mHookDataList;
|
PluginInformation(){
|
||||||
std::vector<std::unique_ptr<FunctionData>> mFunctionDataList;
|
|
||||||
std::vector<std::unique_ptr<RelocationData>> mRelocationDataList;
|
}
|
||||||
std::set<std::unique_ptr<FunctionSymbolData>, FunctionSymbolDataComparator> mSymbolDataList;
|
std::vector<HookData> mHookDataList;
|
||||||
std::map<std::string, std::unique_ptr<SectionInfo>> mSectionInfoList;
|
std::vector<FunctionData> mFunctionDataList;
|
||||||
|
std::vector<RelocationData> mRelocationDataList;
|
||||||
|
std::set<FunctionSymbolData, FunctionSymbolDataComparator> mSymbolDataList;
|
||||||
|
std::map<std::string, SectionInfo> mSectionInfoList;
|
||||||
|
|
||||||
uint8_t mTrampolineId = 0;
|
uint8_t mTrampolineId = 0;
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include "PluginInformationFactory.h"
|
#include "PluginInformationFactory.h"
|
||||||
#include "../utils/ElfUtils.h"
|
#include "../utils/ElfUtils.h"
|
||||||
#include "../utils/utils.h"
|
|
||||||
#include "utils/HeapMemoryFixedSize.h"
|
#include "utils/HeapMemoryFixedSize.h"
|
||||||
#include "utils/wiiu_zlib.hpp"
|
#include "utils/wiiu_zlib.hpp"
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
@ -28,32 +27,28 @@
|
|||||||
|
|
||||||
using namespace ELFIO;
|
using namespace ELFIO;
|
||||||
|
|
||||||
std::unique_ptr<PluginInformation>
|
std::optional<PluginInformation>
|
||||||
PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocation_trampoline_entry_t> &trampolineData, uint8_t trampolineId) {
|
PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocation_trampoline_entry_t> &trampolineData, uint8_t trampolineId) {
|
||||||
auto buffer = pluginData.getBuffer();
|
auto buffer = pluginData.getBuffer();
|
||||||
if (buffer.empty()) {
|
if (buffer.empty()) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Buffer was empty");
|
DEBUG_FUNCTION_LINE_ERR("Buffer was empty");
|
||||||
return nullptr;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
elfio reader(new wiiu_zlib);
|
elfio reader(new wiiu_zlib);
|
||||||
|
|
||||||
if (!reader.load(reinterpret_cast<const char *>(buffer.data()), buffer.size())) {
|
if (!reader.load(reinterpret_cast<const char *>(buffer.data()), buffer.size())) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Can't process PluginData in elfio");
|
DEBUG_FUNCTION_LINE_ERR("Can't process PluginData in elfio");
|
||||||
return nullptr;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pluginInfo = make_unique_nothrow<PluginInformation>();
|
PluginInformation pluginInfo;
|
||||||
if (!pluginInfo) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to allocate PluginInformation");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t sec_num = reader.sections.size();
|
uint32_t sec_num = reader.sections.size();
|
||||||
|
|
||||||
auto destinationsData = make_unique_nothrow<uint8_t *[]>(sec_num);
|
auto destinationsData = make_unique_nothrow<uint8_t *[]>(sec_num);
|
||||||
if (!destinationsData) {
|
if (!destinationsData) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed alloc memory for destinations array");
|
DEBUG_FUNCTION_LINE_ERR("Failed alloc memory for destinations array");
|
||||||
return nullptr;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
std::span<uint8_t *> destinations(destinationsData.get(), sec_num);
|
std::span<uint8_t *> destinations(destinationsData.get(), sec_num);
|
||||||
|
|
||||||
@ -85,13 +80,13 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
|
|||||||
HeapMemoryFixedSize text_data(text_size);
|
HeapMemoryFixedSize text_data(text_size);
|
||||||
if (!text_data) {
|
if (!text_data) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to alloc memory for the .text section (%d bytes)", text_size);
|
DEBUG_FUNCTION_LINE_ERR("Failed to alloc memory for the .text section (%d bytes)", text_size);
|
||||||
return nullptr;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapMemoryFixedSize data_data(data_size);
|
HeapMemoryFixedSize data_data(data_size);
|
||||||
if (!data_data) {
|
if (!data_data) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to alloc memory for the .data section (%d bytes)", data_size);
|
DEBUG_FUNCTION_LINE_ERR("Failed to alloc memory for the .data section (%d bytes)", data_size);
|
||||||
return nullptr;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < sec_num; ++i) {
|
for (uint32_t i = 0; i < sec_num; ++i) {
|
||||||
@ -125,10 +120,10 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
|
|||||||
}
|
}
|
||||||
} else if (address >= 0xC0000000) {
|
} else if (address >= 0xC0000000) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Loading section from 0xC0000000 is NOT supported");
|
DEBUG_FUNCTION_LINE_ERR("Loading section from 0xC0000000 is NOT supported");
|
||||||
return nullptr;
|
return std::nullopt;
|
||||||
} else {
|
} else {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Unhandled case");
|
DEBUG_FUNCTION_LINE_ERR("Unhandled case");
|
||||||
return nullptr;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *p = psec->get_data();
|
const char *p = psec->get_data();
|
||||||
@ -140,14 +135,7 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
|
|||||||
DEBUG_FUNCTION_LINE_VERBOSE("Copy section %s %08X -> %08X (%d bytes)", psec->get_name().c_str(), p, destination, sectionSize);
|
DEBUG_FUNCTION_LINE_VERBOSE("Copy section %s %08X -> %08X (%d bytes)", psec->get_name().c_str(), p, destination, sectionSize);
|
||||||
memcpy((void *) destination, p, sectionSize);
|
memcpy((void *) destination, p, sectionSize);
|
||||||
}
|
}
|
||||||
|
pluginInfo.addSectionInfo(SectionInfo(psec->get_name(), destination, sectionSize));
|
||||||
auto sectionInfo = make_unique_nothrow<SectionInfo>(psec->get_name(), destination, sectionSize);
|
|
||||||
if (!sectionInfo) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to allocat SectionInfo");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
pluginInfo->addSectionInfo(std::move(sectionInfo));
|
|
||||||
DEBUG_FUNCTION_LINE_VERBOSE("Saved %s section info. Location: %08X size: %08X", psec->get_name().c_str(), destination, sectionSize);
|
DEBUG_FUNCTION_LINE_VERBOSE("Saved %s section info. Location: %08X size: %08X", psec->get_name().c_str(), destination, sectionSize);
|
||||||
|
|
||||||
totalSize += sectionSize;
|
totalSize += sectionSize;
|
||||||
@ -164,14 +152,14 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
|
|||||||
if (!linkSection(reader, psec->get_index(), (uint32_t) destinations[psec->get_index()], (uint32_t) text_data.data(), (uint32_t) data_data.data(), trampolineData,
|
if (!linkSection(reader, psec->get_index(), (uint32_t) destinations[psec->get_index()], (uint32_t) text_data.data(), (uint32_t) data_data.data(), trampolineData,
|
||||||
trampolineId)) {
|
trampolineId)) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("linkSection failed");
|
DEBUG_FUNCTION_LINE_ERR("linkSection failed");
|
||||||
return nullptr;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PluginInformationFactory::addImportRelocationData(*pluginInfo, reader, destinations)) {
|
if (!PluginInformationFactory::addImportRelocationData(pluginInfo, reader, destinations)) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("addImportRelocationData failed");
|
DEBUG_FUNCTION_LINE_ERR("addImportRelocationData failed");
|
||||||
return nullptr;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
DCFlushRange((void *) text_data.data(), text_data.size());
|
DCFlushRange((void *) text_data.data(), text_data.size());
|
||||||
@ -179,9 +167,9 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
|
|||||||
DCFlushRange((void *) data_data.data(), data_data.size());
|
DCFlushRange((void *) data_data.data(), data_data.size());
|
||||||
ICInvalidateRange((void *) data_data.data(), data_data.size());
|
ICInvalidateRange((void *) data_data.data(), data_data.size());
|
||||||
|
|
||||||
pluginInfo->setTrampolineId(trampolineId);
|
pluginInfo.setTrampolineId(trampolineId);
|
||||||
|
|
||||||
auto secInfo = pluginInfo->getSectionInfo(".wups.hooks");
|
auto secInfo = pluginInfo.getSectionInfo(".wups.hooks");
|
||||||
if (secInfo && secInfo->getSize() > 0) {
|
if (secInfo && secInfo->getSize() > 0) {
|
||||||
size_t entries_count = secInfo->getSize() / sizeof(wups_loader_hook_t);
|
size_t entries_count = secInfo->getSize() / sizeof(wups_loader_hook_t);
|
||||||
auto *entries = (wups_loader_hook_t *) secInfo->getAddress();
|
auto *entries = (wups_loader_hook_t *) secInfo->getAddress();
|
||||||
@ -189,17 +177,12 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
|
|||||||
for (size_t j = 0; j < entries_count; j++) {
|
for (size_t j = 0; j < entries_count; j++) {
|
||||||
wups_loader_hook_t *hook = &entries[j];
|
wups_loader_hook_t *hook = &entries[j];
|
||||||
DEBUG_FUNCTION_LINE_VERBOSE("Saving hook of plugin Type: %08X, target: %08X", hook->type, (void *) hook->target);
|
DEBUG_FUNCTION_LINE_VERBOSE("Saving hook of plugin Type: %08X, target: %08X", hook->type, (void *) hook->target);
|
||||||
auto hookData = make_unique_nothrow<HookData>((void *) hook->target, hook->type);
|
pluginInfo.addHookData(HookData((void *) hook->target, hook->type));
|
||||||
if (!hookData) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to allocate HookData");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
pluginInfo->addHookData(std::move(hookData));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
secInfo = pluginInfo->getSectionInfo(".wups.load");
|
secInfo = pluginInfo.getSectionInfo(".wups.load");
|
||||||
if (secInfo && secInfo->getSize() > 0) {
|
if (secInfo && secInfo->getSize() > 0) {
|
||||||
size_t entries_count = secInfo->getSize() / sizeof(wups_loader_entry_t);
|
size_t entries_count = secInfo->getSize() / sizeof(wups_loader_entry_t);
|
||||||
auto *entries = (wups_loader_entry_t *) secInfo->getAddress();
|
auto *entries = (wups_loader_entry_t *) secInfo->getAddress();
|
||||||
@ -210,19 +193,13 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
|
|||||||
cur_function->_function.name /*,mPluginData->getPluginInformation()->getName().c_str()*/,
|
cur_function->_function.name /*,mPluginData->getPluginInformation()->getName().c_str()*/,
|
||||||
cur_function->_function.physical_address, cur_function->_function.virtual_address, cur_function->_function.library, cur_function->_function.target,
|
cur_function->_function.physical_address, cur_function->_function.virtual_address, cur_function->_function.library, cur_function->_function.target,
|
||||||
(void *) cur_function->_function.call_addr);
|
(void *) cur_function->_function.call_addr);
|
||||||
|
pluginInfo.addFunctionData(FunctionData((void *) cur_function->_function.physical_address,
|
||||||
auto functionData = make_unique_nothrow<FunctionData>((void *) cur_function->_function.physical_address,
|
(void *) cur_function->_function.virtual_address,
|
||||||
(void *) cur_function->_function.virtual_address,
|
cur_function->_function.name,
|
||||||
cur_function->_function.name,
|
(function_replacement_library_type_t) cur_function->_function.library,
|
||||||
(function_replacement_library_type_t) cur_function->_function.library,
|
(void *) cur_function->_function.target,
|
||||||
(void *) cur_function->_function.target,
|
(void *) cur_function->_function.call_addr,
|
||||||
(void *) cur_function->_function.call_addr,
|
(FunctionPatcherTargetProcess) cur_function->_function.targetProcess));
|
||||||
(FunctionPatcherTargetProcess) cur_function->_function.targetProcess);
|
|
||||||
if (!functionData) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to allocate FunctionData");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
pluginInfo->addFunctionData(std::move(functionData));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,18 +225,13 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
|
|||||||
if (type == STT_FUNC) { // We only care about functions.
|
if (type == STT_FUNC) { // We only care about functions.
|
||||||
auto sectionVal = reader.sections[section];
|
auto sectionVal = reader.sections[section];
|
||||||
auto offsetVal = value - sectionVal->get_address();
|
auto offsetVal = value - sectionVal->get_address();
|
||||||
auto sectionInfo = pluginInfo->getSectionInfo(sectionVal->get_name());
|
auto sectionInfo = pluginInfo.getSectionInfo(sectionVal->get_name());
|
||||||
if (!sectionInfo) {
|
if (!sectionInfo) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto finalAddress = offsetVal + sectionInfo->getAddress();
|
auto finalAddress = offsetVal + sectionInfo->getAddress();
|
||||||
auto functionSymbolData = make_unique_nothrow<FunctionSymbolData>(name, (void *) finalAddress, (uint32_t) size);
|
pluginInfo.addFunctionSymbolData(FunctionSymbolData(name, (void *) finalAddress, (uint32_t) size));
|
||||||
if (!functionSymbolData) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to allocate FunctionSymbolData");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
pluginInfo->addFunctionSymbolData(std::move(functionSymbolData));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,13 +242,13 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
|
|||||||
|
|
||||||
if (totalSize > text_size + data_size) {
|
if (totalSize > text_size + data_size) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("We didn't allocate enough memory!!");
|
DEBUG_FUNCTION_LINE_ERR("We didn't allocate enough memory!!");
|
||||||
return nullptr;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Save the addresses for the allocated memory. This way we can free it again :)
|
// Save the addresses for the allocated memory. This way we can free it again :)
|
||||||
pluginInfo->mAllocatedDataMemoryAddress = std::move(data_data);
|
pluginInfo.mAllocatedDataMemoryAddress = std::move(data_data);
|
||||||
pluginInfo->mAllocatedTextMemoryAddress = std::move(text_data);
|
pluginInfo.mAllocatedTextMemoryAddress = std::move(text_data);
|
||||||
|
|
||||||
return pluginInfo;
|
return pluginInfo;
|
||||||
}
|
}
|
||||||
@ -340,18 +312,12 @@ bool PluginInformationFactory::addImportRelocationData(PluginInformation &plugin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto relocationData = make_unique_nothrow<RelocationData>(type,
|
pluginInfo.addRelocationData(RelocationData(type,
|
||||||
offset - 0x02000000,
|
offset - 0x02000000,
|
||||||
addend,
|
addend,
|
||||||
(void *) (destinations[section_index]),
|
(void *) (destinations[section_index]),
|
||||||
sym_name,
|
sym_name,
|
||||||
infoMap[sym_section_index]);
|
infoMap[sym_section_index]));
|
||||||
if (!relocationData) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to allocate RelocationData");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
pluginInfo.addRelocationData(std::move(relocationData));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
class PluginInformationFactory {
|
class PluginInformationFactory {
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<PluginInformation>
|
static std::optional<PluginInformation>
|
||||||
load(const PluginData &pluginData, std::vector<relocation_trampoline_entry_t> &trampolineData, uint8_t trampolineId);
|
load(const PluginData &pluginData, std::vector<relocation_trampoline_entry_t> &trampolineData, uint8_t trampolineId);
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
#include "PluginMetaInformation.h"
|
|
||||||
|
|
||||||
PluginMetaInformation::PluginMetaInformation(const PluginMetaInformation &other) {
|
|
||||||
this->name = other.name;
|
|
||||||
this->author = other.author;
|
|
||||||
this->version = other.version;
|
|
||||||
this->license = other.license;
|
|
||||||
this->buildtimestamp = other.buildtimestamp;
|
|
||||||
this->description = other.description;
|
|
||||||
this->size = other.size;
|
|
||||||
this->storageId = other.storageId;
|
|
||||||
this->wupsversion = other.wupsversion;
|
|
||||||
}
|
|
@ -23,8 +23,6 @@
|
|||||||
|
|
||||||
class PluginMetaInformation {
|
class PluginMetaInformation {
|
||||||
public:
|
public:
|
||||||
PluginMetaInformation(const PluginMetaInformation &other);
|
|
||||||
|
|
||||||
[[nodiscard]] const std::string &getName() const {
|
[[nodiscard]] const std::string &getName() const {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,11 @@
|
|||||||
#include "utils/wiiu_zlib.hpp"
|
#include "utils/wiiu_zlib.hpp"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
std::unique_ptr<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(const PluginData &pluginData, PluginParseErrors &error) {
|
std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(const PluginData &pluginData, PluginParseErrors &error) {
|
||||||
return loadPlugin(pluginData.getBuffer(), error);
|
return loadPlugin(pluginData.getBuffer(), error);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(std::string_view filePath, PluginParseErrors &error) {
|
std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(std::string_view filePath, PluginParseErrors &error) {
|
||||||
std::vector<uint8_t> buffer;
|
std::vector<uint8_t> buffer;
|
||||||
if (FSUtils::LoadFileToMem(filePath, buffer) < 0) {
|
if (FSUtils::LoadFileToMem(filePath, buffer) < 0) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to load file to memory");
|
DEBUG_FUNCTION_LINE_ERR("Failed to load file to memory");
|
||||||
@ -36,7 +36,7 @@ std::unique_ptr<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(
|
|||||||
return loadPlugin(buffer, error);
|
return loadPlugin(buffer, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(std::span<const uint8_t> buffer, PluginParseErrors &error) {
|
std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(std::span<const uint8_t> buffer, PluginParseErrors &error) {
|
||||||
if (buffer.empty()) {
|
if (buffer.empty()) {
|
||||||
error = PLUGIN_PARSE_ERROR_BUFFER_EMPTY;
|
error = PLUGIN_PARSE_ERROR_BUFFER_EMPTY;
|
||||||
DEBUG_FUNCTION_LINE_ERR("Buffer is empty");
|
DEBUG_FUNCTION_LINE_ERR("Buffer is empty");
|
||||||
@ -47,12 +47,12 @@ std::unique_ptr<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(
|
|||||||
if (!reader.load(reinterpret_cast<const char *>(buffer.data()), buffer.size())) {
|
if (!reader.load(reinterpret_cast<const char *>(buffer.data()), buffer.size())) {
|
||||||
error = PLUGIN_PARSE_ERROR_ELFIO_PARSE_FAILED;
|
error = PLUGIN_PARSE_ERROR_ELFIO_PARSE_FAILED;
|
||||||
DEBUG_FUNCTION_LINE_ERR("Can't find or process ELF file");
|
DEBUG_FUNCTION_LINE_ERR("Can't find or process ELF file");
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t pluginSize = 0;
|
size_t pluginSize = 0;
|
||||||
|
|
||||||
auto pluginInfo = std::unique_ptr<PluginMetaInformation>(new PluginMetaInformation);
|
PluginMetaInformation pluginInfo;
|
||||||
|
|
||||||
uint32_t sec_num = reader.sections.size();
|
uint32_t sec_num = reader.sections.size();
|
||||||
|
|
||||||
@ -89,28 +89,28 @@ std::unique_ptr<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(
|
|||||||
std::string value(curEntry + firstFound + 1);
|
std::string value(curEntry + firstFound + 1);
|
||||||
|
|
||||||
if (key == "name") {
|
if (key == "name") {
|
||||||
pluginInfo->setName(value);
|
pluginInfo.setName(value);
|
||||||
} else if (key == "author") {
|
} else if (key == "author") {
|
||||||
pluginInfo->setAuthor(value);
|
pluginInfo.setAuthor(value);
|
||||||
} else if (key == "version") {
|
} else if (key == "version") {
|
||||||
pluginInfo->setVersion(value);
|
pluginInfo.setVersion(value);
|
||||||
} else if (key == "license") {
|
} else if (key == "license") {
|
||||||
pluginInfo->setLicense(value);
|
pluginInfo.setLicense(value);
|
||||||
} else if (key == "buildtimestamp") {
|
} else if (key == "buildtimestamp") {
|
||||||
pluginInfo->setBuildTimestamp(value);
|
pluginInfo.setBuildTimestamp(value);
|
||||||
} else if (key == "description") {
|
} else if (key == "description") {
|
||||||
pluginInfo->setDescription(value);
|
pluginInfo.setDescription(value);
|
||||||
} else if (key == "storage_id") {
|
} else if (key == "storage_id") {
|
||||||
pluginInfo->setStorageId(value);
|
pluginInfo.setStorageId(value);
|
||||||
} else if (key == "wups") {
|
} else if (key == "wups") {
|
||||||
if (value == "0.7.1") {
|
if (value == "0.7.1") {
|
||||||
pluginInfo->setWUPSVersion(0, 7, 1);
|
pluginInfo.setWUPSVersion(0, 7, 1);
|
||||||
} else if (value == "0.8.0") {
|
} else if (value == "0.8.0") {
|
||||||
pluginInfo->setWUPSVersion(0, 8, 0);
|
pluginInfo.setWUPSVersion(0, 8, 0);
|
||||||
} else {
|
} else {
|
||||||
error = PLUGIN_PARSE_ERROR_INCOMPATIBLE_VERSION;
|
error = PLUGIN_PARSE_ERROR_INCOMPATIBLE_VERSION;
|
||||||
DEBUG_FUNCTION_LINE_ERR("Warning: Ignoring plugin - Unsupported WUPS version: %s.", value.c_str());
|
DEBUG_FUNCTION_LINE_ERR("Warning: Ignoring plugin - Unsupported WUPS version: %s.", value.c_str());
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ std::unique_ptr<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginInfo->setSize(pluginSize);
|
pluginInfo.setSize(pluginSize);
|
||||||
|
|
||||||
error = PLUGIN_PARSE_ERROR_NONE;
|
error = PLUGIN_PARSE_ERROR_NONE;
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ enum PluginParseErrors {
|
|||||||
|
|
||||||
class PluginMetaInformationFactory {
|
class PluginMetaInformationFactory {
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<PluginMetaInformation> loadPlugin(const PluginData &pluginData, PluginParseErrors &error);
|
static std::optional<PluginMetaInformation> loadPlugin(const PluginData &pluginData, PluginParseErrors &error);
|
||||||
|
|
||||||
static std::unique_ptr<PluginMetaInformation> loadPlugin(std::string_view filePath, PluginParseErrors &error);
|
static std::optional<PluginMetaInformation> loadPlugin(std::string_view filePath, PluginParseErrors &error);
|
||||||
|
|
||||||
static std::unique_ptr<PluginMetaInformation> loadPlugin(std::span<const uint8_t> buffer, PluginParseErrors &error);
|
static std::optional<PluginMetaInformation> loadPlugin(std::span<const uint8_t> buffer, PluginParseErrors &error);
|
||||||
};
|
};
|
||||||
|
@ -9,8 +9,6 @@ public:
|
|||||||
(static_cast<uint64_t>(minor) << 16) |
|
(static_cast<uint64_t>(minor) << 16) |
|
||||||
static_cast<uint64_t>(revision)) {}
|
static_cast<uint64_t>(revision)) {}
|
||||||
|
|
||||||
WUPSVersion(const WUPSVersion &other) = default;
|
|
||||||
|
|
||||||
static std::optional<WUPSVersion> createFromString(const std::string &versionStr) {
|
static std::optional<WUPSVersion> createFromString(const std::string &versionStr) {
|
||||||
char *end;
|
char *end;
|
||||||
errno = 0; // Initialize errno before calling strtol
|
errno = 0; // Initialize errno before calling strtol
|
||||||
|
@ -72,16 +72,16 @@ void ConfigUtils::displayMenu() {
|
|||||||
renderBasicScreen("Loading configs...");
|
renderBasicScreen("Loading configs...");
|
||||||
|
|
||||||
std::vector<ConfigDisplayItem> configs;
|
std::vector<ConfigDisplayItem> configs;
|
||||||
for (auto &plugin : gLoadedPlugins) {
|
for (const auto &plugin : gLoadedPlugins) {
|
||||||
GeneralConfigInformation info;
|
GeneralConfigInformation info;
|
||||||
info.name = plugin->getMetaInformation().getName();
|
info.name = plugin.getMetaInformation().getName();
|
||||||
info.author = plugin->getMetaInformation().getAuthor();
|
info.author = plugin.getMetaInformation().getAuthor();
|
||||||
info.version = plugin->getMetaInformation().getVersion();
|
info.version = plugin.getMetaInformation().getVersion();
|
||||||
|
|
||||||
std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> config;
|
std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> config;
|
||||||
auto configData = plugin->getConfigData();
|
const auto configData = plugin.getConfigData();
|
||||||
if (configData) {
|
if (configData) {
|
||||||
auto configHandleOpt = configData->createConfig();
|
const auto configHandleOpt = configData->createConfig();
|
||||||
if (configHandleOpt) {
|
if (configHandleOpt) {
|
||||||
WUPSConfigAPIStatus callbackResult = configData->CallMenuOpenendCallback(configHandleOpt.value());
|
WUPSConfigAPIStatus callbackResult = configData->CallMenuOpenendCallback(configHandleOpt.value());
|
||||||
config = WUPSConfigAPIBackend::Intern::PopConfigByHandle(configHandleOpt.value());
|
config = WUPSConfigAPIBackend::Intern::PopConfigByHandle(configHandleOpt.value());
|
||||||
@ -97,13 +97,13 @@ void ConfigUtils::displayMenu() {
|
|||||||
DEBUG_FUNCTION_LINE_ERR("Failed to create config for plugin: \"%s\"", info.name.c_str());
|
DEBUG_FUNCTION_LINE_ERR("Failed to create config for plugin: \"%s\"", info.name.c_str());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (const auto &hook : plugin->getPluginInformation().getHookDataList()) {
|
for (const auto &hook : plugin.getPluginInformation().getHookDataList()) {
|
||||||
if (hook->getType() == WUPS_LOADER_HOOK_GET_CONFIG_DEPRECATED) {
|
if (hook.getType() == WUPS_LOADER_HOOK_GET_CONFIG_DEPRECATED) {
|
||||||
if (hook->getFunctionPointer() == nullptr) {
|
if (hook.getFunctionPointer() == nullptr) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Hook had invalid ptr");
|
DEBUG_FUNCTION_LINE_ERR("Hook had invalid ptr");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto cur_config_handle = ((void *(*) ())((uint32_t *) hook->getFunctionPointer()))();
|
auto cur_config_handle = ((void *(*) ())((uint32_t *) hook.getFunctionPointer()))();
|
||||||
if (cur_config_handle == nullptr) {
|
if (cur_config_handle == nullptr) {
|
||||||
DEBUG_FUNCTION_LINE_WARN("Hook returned empty handle");
|
DEBUG_FUNCTION_LINE_WARN("Hook returned empty handle");
|
||||||
break;
|
break;
|
||||||
@ -183,12 +183,14 @@ void ConfigUtils::displayMenu() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &plugin : gLoadedPlugins) {
|
for (const auto &plugin : gLoadedPlugins) {
|
||||||
auto configData = plugin->getConfigData();
|
const auto configData = plugin.getConfigData();
|
||||||
if (configData) {
|
if (configData) {
|
||||||
configData->CallMenuClosedCallback();
|
if (configData->CallMenuClosedCallback() == WUPSCONFIG_API_RESULT_MISSING_CALLBACK) {
|
||||||
|
DEBUG_FUNCTION_LINE_WARN("CallMenuClosedCallback is missing for %s", plugin.getMetaInformation().getName().c_str());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
CallHook(*plugin, WUPS_LOADER_HOOK_CONFIG_CLOSED_DEPRECATED);
|
CallHook(plugin, WUPS_LOADER_HOOK_CONFIG_CLOSED_DEPRECATED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ extern "C" PluginBackendApiErrorType WUPSGetPluginMetaInformation(WUPSBackendGet
|
|||||||
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<PluginMetaInformation> pluginInfo;
|
std::optional<PluginMetaInformation> pluginInfo;
|
||||||
PluginParseErrors error = PLUGIN_PARSE_ERROR_UNKNOWN;
|
PluginParseErrors error = PLUGIN_PARSE_ERROR_UNKNOWN;
|
||||||
if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_PATH && path != nullptr) {
|
if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_PATH && path != nullptr) {
|
||||||
pluginInfo = PluginMetaInformationFactory::loadPlugin(path, error);
|
pluginInfo = PluginMetaInformationFactory::loadPlugin(path, error);
|
||||||
@ -136,8 +136,8 @@ extern "C" PluginBackendApiErrorType WUPSGetPluginDataForContainerHandles(const
|
|||||||
auto handle = plugin_container_handle_list[i];
|
auto handle = plugin_container_handle_list[i];
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (const auto &curContainer : gLoadedPlugins) {
|
for (const auto &curContainer : gLoadedPlugins) {
|
||||||
if (curContainer->getHandle() == handle) {
|
if (curContainer.getHandle() == handle) {
|
||||||
auto pluginData = curContainer->getPluginDataCopy();
|
auto pluginData = curContainer.getPluginDataCopy();
|
||||||
plugin_data_list[i] = (uint32_t) pluginData->getHandle();
|
plugin_data_list[i] = (uint32_t) pluginData->getHandle();
|
||||||
gLoadedData.insert(std::move(pluginData));
|
gLoadedData.insert(std::move(pluginData));
|
||||||
found = true;
|
found = true;
|
||||||
@ -160,8 +160,8 @@ extern "C" PluginBackendApiErrorType WUPSGetMetaInformation(const wups_backend_p
|
|||||||
auto handle = plugin_container_handle_list[i];
|
auto handle = plugin_container_handle_list[i];
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (const auto &curContainer : gLoadedPlugins) {
|
for (const auto &curContainer : gLoadedPlugins) {
|
||||||
if (curContainer->getHandle() == handle) {
|
if (curContainer.getHandle() == handle) {
|
||||||
const auto &metaInfo = curContainer->getMetaInformation();
|
const auto &metaInfo = curContainer.getMetaInformation();
|
||||||
|
|
||||||
plugin_information_list[i].plugin_information_version = WUPS_BACKEND_PLUGIN_INFORMATION_VERSION;
|
plugin_information_list[i].plugin_information_version = WUPS_BACKEND_PLUGIN_INFORMATION_VERSION;
|
||||||
strncpy(plugin_information_list[i].storageId, metaInfo.getStorageId().c_str(), sizeof(plugin_information_list[i].storageId) - 1);
|
strncpy(plugin_information_list[i].storageId, metaInfo.getStorageId().c_str(), sizeof(plugin_information_list[i].storageId) - 1);
|
||||||
@ -196,7 +196,7 @@ extern "C" PluginBackendApiErrorType WUPSGetLoadedPlugins(wups_backend_plugin_co
|
|||||||
uint32_t counter = 0;
|
uint32_t counter = 0;
|
||||||
for (const auto &plugin : gLoadedPlugins) {
|
for (const auto &plugin : gLoadedPlugins) {
|
||||||
if (counter < buffer_size) {
|
if (counter < buffer_size) {
|
||||||
io_handles[counter] = plugin->getHandle();
|
io_handles[counter] = plugin.getHandle();
|
||||||
counter++;
|
counter++;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@ -245,9 +245,9 @@ extern "C" PluginBackendApiErrorType WUPSGetSectionInformationForPlugin(const wu
|
|||||||
if (handle != 0 && plugin_section_list != nullptr && buffer_size != 0) {
|
if (handle != 0 && plugin_section_list != nullptr && buffer_size != 0) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (const auto &curContainer : gLoadedPlugins) {
|
for (const auto &curContainer : gLoadedPlugins) {
|
||||||
if (curContainer->getHandle() == handle) {
|
if (curContainer.getHandle() == handle) {
|
||||||
found = true;
|
found = true;
|
||||||
const auto §ionInfoList = curContainer->getPluginInformation().getSectionInfoList();
|
const auto §ionInfoList = curContainer.getPluginInformation().getSectionInfoList();
|
||||||
|
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
for (auto const &[key, sectionInfo] : sectionInfoList) {
|
for (auto const &[key, sectionInfo] : sectionInfoList) {
|
||||||
@ -255,9 +255,9 @@ extern "C" PluginBackendApiErrorType WUPSGetSectionInformationForPlugin(const wu
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
plugin_section_list[offset].plugin_section_info_version = WUPS_BACKEND_PLUGIN_SECTION_INFORMATION_VERSION;
|
plugin_section_list[offset].plugin_section_info_version = WUPS_BACKEND_PLUGIN_SECTION_INFORMATION_VERSION;
|
||||||
strncpy(plugin_section_list[offset].name, sectionInfo->getName().c_str(), sizeof(plugin_section_list[offset].name) - 1);
|
strncpy(plugin_section_list[offset].name, sectionInfo.getName().c_str(), sizeof(plugin_section_list[offset].name) - 1);
|
||||||
plugin_section_list[offset].address = (void *) sectionInfo->getAddress();
|
plugin_section_list[offset].address = (void *) sectionInfo.getAddress();
|
||||||
plugin_section_list[offset].size = sectionInfo->getSize();
|
plugin_section_list[offset].size = sectionInfo.getSize();
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
if (out_count != nullptr) {
|
if (out_count != nullptr) {
|
||||||
@ -289,9 +289,9 @@ extern "C" PluginBackendApiErrorType WUPSGetSectionMemoryAddresses(wups_backend_
|
|||||||
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
for (const auto &curContainer : gLoadedPlugins) {
|
for (const auto &curContainer : gLoadedPlugins) {
|
||||||
if (curContainer->getHandle() == handle) {
|
if (curContainer.getHandle() == handle) {
|
||||||
*textAddress = (void *) curContainer->getPluginInformation().getTextMemory().data();
|
*textAddress = (void *) curContainer.getPluginInformation().getTextMemory().data();
|
||||||
*dataAddress = (void *) curContainer->getPluginInformation().getDataMemory().data();
|
*dataAddress = (void *) curContainer.getPluginInformation().getDataMemory().data();
|
||||||
return PLUGIN_BACKEND_API_ERROR_NONE;
|
return PLUGIN_BACKEND_API_ERROR_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user