Only check for config menu if the plugin is linked and loaded

This commit is contained in:
Maschell 2024-08-04 15:41:10 +02:00
parent b34fa84bed
commit 9e0932cb38

View File

@ -84,38 +84,41 @@ void ConfigUtils::displayMenu() {
info.pluginData = plugin.getPluginDataCopy(); info.pluginData = plugin.getPluginDataCopy();
std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> config; std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> config;
if (const auto configData = plugin.getConfigData()) {
if (const auto configHandleOpt = configData->createConfig()) { if (plugin.isLinkedAndLoaded()) {
WUPSConfigAPIStatus callbackResult = configData->CallMenuOpenedCallback(configHandleOpt.value()); if (const auto configData = plugin.getConfigData()) {
config = WUPSConfigAPIBackend::Intern::PopConfigByHandle(configHandleOpt.value()); if (const auto configHandleOpt = configData->createConfig()) {
if (!config) { WUPSConfigAPIStatus callbackResult = configData->CallMenuOpenedCallback(configHandleOpt.value());
DEBUG_FUNCTION_LINE_ERR("Failed to get config for handle: %08X", configHandleOpt.value().handle); config = WUPSConfigAPIBackend::Intern::PopConfigByHandle(configHandleOpt.value());
} else if (callbackResult != WUPSCONFIG_API_RESULT_SUCCESS) { if (!config) {
DEBUG_FUNCTION_LINE_ERR("Callback failed for %s: %s", info.name.c_str(), WUPSConfigAPI_GetStatusStr(callbackResult)); DEBUG_FUNCTION_LINE_ERR("Failed to get config for handle: %08X", configHandleOpt.value().handle);
config.reset(); } else if (callbackResult != WUPSCONFIG_API_RESULT_SUCCESS) {
DEBUG_FUNCTION_LINE_ERR("Callback failed for %s: %s", info.name.c_str(), WUPSConfigAPI_GetStatusStr(callbackResult));
config.reset();
} else {
info.name = config->getName();
}
} else { } else {
info.name = config->getName(); DEBUG_FUNCTION_LINE_ERR("Failed to create config for plugin: \"%s\"", info.name.c_str());
} }
} else { } else {
DEBUG_FUNCTION_LINE_ERR("Failed to create config for plugin: \"%s\"", info.name.c_str()); for (const auto &hook : plugin.getPluginLinkInformation().getHookDataList()) {
} if (hook.getType() == WUPS_LOADER_HOOK_GET_CONFIG_DEPRECATED) {
} else { if (hook.getFunctionPointer() == nullptr) {
for (const auto &hook : plugin.getPluginLinkInformation().getHookDataList()) { DEBUG_FUNCTION_LINE_ERR("Hook had invalid ptr");
if (hook.getType() == WUPS_LOADER_HOOK_GET_CONFIG_DEPRECATED) { break;
if (hook.getFunctionPointer() == nullptr) { }
DEBUG_FUNCTION_LINE_ERR("Hook had invalid ptr"); auto cur_config_handle = ((void *(*) ())((uint32_t *) hook.getFunctionPointer()))();
if (cur_config_handle == nullptr) {
DEBUG_FUNCTION_LINE_WARN("Hook returned empty handle");
break;
}
config = WUPSConfigAPIBackend::Intern::PopConfigByHandle(WUPSConfigHandle(cur_config_handle));
if (!config) {
DEBUG_FUNCTION_LINE_ERR("Failed to find config for handle: %08X", cur_config_handle);
}
break; break;
} }
auto cur_config_handle = reinterpret_cast<void *(*) ()>(static_cast<uint32_t *>(hook.getFunctionPointer()))();
if (cur_config_handle == nullptr) {
DEBUG_FUNCTION_LINE_WARN("Hook returned empty handle");
break;
}
config = WUPSConfigAPIBackend::Intern::PopConfigByHandle(WUPSConfigHandle(cur_config_handle));
if (!config) {
DEBUG_FUNCTION_LINE_ERR("Failed to find config for handle: %08X", cur_config_handle);
}
break;
} }
} }
} }