2022-02-04 16:25:44 +01:00
|
|
|
#include "../PluginManagement.h"
|
|
|
|
#include "../globals.h"
|
2020-12-26 14:17:50 +01:00
|
|
|
#include "../plugin/PluginDataFactory.h"
|
2022-02-04 16:25:44 +01:00
|
|
|
#include "../plugin/PluginMetaInformationFactory.h"
|
2022-05-14 14:00:20 +02:00
|
|
|
#include "utils.h"
|
2020-05-17 21:08:13 +02:00
|
|
|
#include <wums.h>
|
2024-03-23 08:01:04 +01:00
|
|
|
#include <wups_backend/import_defines.h>
|
2020-05-17 21:08:13 +02:00
|
|
|
|
2024-03-23 08:01:04 +01:00
|
|
|
static void fillPluginInformation(wups_backend_plugin_information *out, const PluginMetaInformation &metaInformation) {
|
|
|
|
out->plugin_information_version = WUPS_BACKEND_PLUGIN_INFORMATION_VERSION;
|
2023-11-04 15:32:45 +01:00
|
|
|
strncpy(out->author, metaInformation.getAuthor().c_str(), sizeof(out->author) - 1);
|
|
|
|
strncpy(out->buildTimestamp, metaInformation.getBuildTimestamp().c_str(), sizeof(out->buildTimestamp) - 1);
|
|
|
|
strncpy(out->description, metaInformation.getDescription().c_str(), sizeof(out->description) - 1);
|
|
|
|
strncpy(out->name, metaInformation.getName().c_str(), sizeof(out->name) - 1);
|
|
|
|
strncpy(out->license, metaInformation.getLicense().c_str(), sizeof(out->license) - 1);
|
|
|
|
strncpy(out->version, metaInformation.getVersion().c_str(), sizeof(out->version) - 1);
|
|
|
|
strncpy(out->storageId, metaInformation.getStorageId().c_str(), sizeof(out->storageId) - 1);
|
|
|
|
out->size = metaInformation.getSize();
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
|
2024-03-23 08:01:04 +01:00
|
|
|
extern "C" PluginBackendApiErrorType WUPSLoadAndLinkByDataHandle(const wups_backend_plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size) {
|
2022-05-14 14:00:20 +02:00
|
|
|
if (plugin_data_handle_list == nullptr || plugin_data_handle_list_size == 0) {
|
2021-04-07 00:23:23 +02:00
|
|
|
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
2023-11-04 15:32:45 +01:00
|
|
|
|
2022-05-14 14:00:20 +02:00
|
|
|
std::lock_guard<std::mutex> lock(gLoadedDataMutex);
|
|
|
|
for (uint32_t i = 0; i < plugin_data_handle_list_size; i++) {
|
|
|
|
auto handle = plugin_data_handle_list[i];
|
|
|
|
bool found = false;
|
|
|
|
|
2023-11-04 15:32:45 +01:00
|
|
|
for (const auto &pluginData : gLoadedData) {
|
2022-05-14 14:00:20 +02:00
|
|
|
if (pluginData->getHandle() == handle) {
|
2023-11-04 15:32:45 +01:00
|
|
|
gLoadOnNextLaunch.insert(pluginData);
|
2022-05-14 14:00:20 +02:00
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-11-04 15:32:45 +01:00
|
|
|
|
2022-05-14 14:00:20 +02:00
|
|
|
if (!found) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to get plugin data for handle %08X. Skipping it.", handle);
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
}
|
2022-05-14 14:00:20 +02:00
|
|
|
|
2021-04-07 00:23:23 +02:00
|
|
|
return PLUGIN_BACKEND_API_ERROR_NONE;
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
|
2024-03-23 08:01:04 +01:00
|
|
|
extern "C" PluginBackendApiErrorType WUPSDeletePluginData(const wups_backend_plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size) {
|
2020-12-26 14:17:50 +01:00
|
|
|
if (plugin_data_handle_list != nullptr && plugin_data_handle_list_size != 0) {
|
2024-03-30 12:06:47 +01:00
|
|
|
std::lock_guard lock(gLoadedDataMutex);
|
2023-11-04 15:32:45 +01:00
|
|
|
for (auto &handle : std::span(plugin_data_handle_list, plugin_data_handle_list_size)) {
|
2024-03-30 12:06:47 +01:00
|
|
|
if (!remove_first_if(gLoadedData, [&handle](auto &cur) { return cur->getHandle() == handle; })) {
|
2022-05-14 14:00:20 +02:00
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to delete plugin data by handle %08X", handle);
|
|
|
|
}
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
}
|
2021-04-07 00:23:23 +02:00
|
|
|
return PLUGIN_BACKEND_API_ERROR_NONE;
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
|
2024-03-23 08:01:04 +01:00
|
|
|
extern "C" PluginBackendApiErrorType WUPSLoadPluginAsData(WUPSBackendGetPluginInformationInputType inputType, const char *path, char *buffer, size_t size, wups_backend_plugin_data_handle *out) {
|
2022-05-14 14:00:20 +02:00
|
|
|
if (out == nullptr) {
|
|
|
|
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2023-11-04 15:32:45 +01:00
|
|
|
std::unique_ptr<PluginData> pluginData;
|
2021-01-10 13:17:47 +01:00
|
|
|
if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_PATH && path != nullptr) {
|
2022-05-14 14:00:20 +02:00
|
|
|
pluginData = PluginDataFactory::load(path);
|
2021-01-10 13:17:47 +01:00
|
|
|
} else if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_BUFFER && buffer != nullptr && size > 0) {
|
2023-11-04 15:32:45 +01:00
|
|
|
pluginData = make_unique_nothrow<PluginData>(std::span((uint8_t *) buffer, size), "<UNKNOWN>");
|
2020-05-17 21:08:13 +02:00
|
|
|
} else {
|
2021-04-07 00:23:23 +02:00
|
|
|
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!pluginData) {
|
2022-04-22 22:55:53 +02:00
|
|
|
DEBUG_FUNCTION_LINE_ERR("PLUGIN_BACKEND_API_ERROR_FAILED_ALLOC");
|
2021-04-07 00:23:23 +02:00
|
|
|
return PLUGIN_BACKEND_API_ERROR_FAILED_ALLOC;
|
2023-11-04 15:32:45 +01:00
|
|
|
} else {
|
|
|
|
*out = pluginData->getHandle();
|
2024-03-23 21:16:27 +01:00
|
|
|
{
|
|
|
|
std::lock_guard lockLoadedData(gLoadedDataMutex);
|
|
|
|
gLoadedData.insert(std::move(pluginData));
|
|
|
|
}
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
|
2021-04-07 00:23:23 +02:00
|
|
|
return PLUGIN_BACKEND_API_ERROR_NONE;
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
|
2024-03-23 08:01:04 +01:00
|
|
|
extern "C" PluginBackendApiErrorType WUPSLoadPluginAsDataByPath(wups_backend_plugin_data_handle *output, const char *path) {
|
2020-12-26 14:17:50 +01:00
|
|
|
return WUPSLoadPluginAsData(PLUGIN_INFORMATION_INPUT_TYPE_PATH, path, nullptr, 0, output);
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
|
2024-03-23 08:01:04 +01:00
|
|
|
extern "C" PluginBackendApiErrorType WUPSLoadPluginAsDataByBuffer(wups_backend_plugin_data_handle *output, char *buffer, size_t size) {
|
2020-12-26 14:17:50 +01:00
|
|
|
return WUPSLoadPluginAsData(PLUGIN_INFORMATION_INPUT_TYPE_BUFFER, nullptr, buffer, size, output);
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
|
2024-03-23 08:01:04 +01:00
|
|
|
extern "C" PluginBackendApiErrorType WUPSGetPluginMetaInformation(WUPSBackendGetPluginInformationInputType inputType, const char *path, char *buffer, size_t size, wups_backend_plugin_information *output) {
|
2023-11-04 15:32:45 +01:00
|
|
|
if (output == nullptr) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
|
|
|
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2024-03-24 07:40:58 +01:00
|
|
|
std::optional<PluginMetaInformation> pluginInfo;
|
2023-08-16 10:18:02 +02:00
|
|
|
PluginParseErrors error = PLUGIN_PARSE_ERROR_UNKNOWN;
|
2020-12-26 14:17:50 +01:00
|
|
|
if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_PATH && path != nullptr) {
|
2023-11-04 15:32:45 +01:00
|
|
|
pluginInfo = PluginMetaInformationFactory::loadPlugin(path, error);
|
2020-12-26 14:17:50 +01:00
|
|
|
} else if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_BUFFER && buffer != nullptr && size > 0) {
|
2023-11-04 15:32:45 +01:00
|
|
|
pluginInfo = PluginMetaInformationFactory::loadPlugin(std::span<uint8_t const>((uint8_t *) buffer, size), error);
|
2020-05-17 21:08:13 +02:00
|
|
|
} else {
|
2022-04-22 22:55:53 +02:00
|
|
|
DEBUG_FUNCTION_LINE_ERR("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
2021-04-07 00:23:23 +02:00
|
|
|
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!pluginInfo) {
|
2022-04-22 22:55:53 +02:00
|
|
|
DEBUG_FUNCTION_LINE_ERR("PLUGIN_BACKEND_API_ERROR_FILE_NOT_FOUND");
|
2021-04-07 00:23:23 +02:00
|
|
|
return PLUGIN_BACKEND_API_ERROR_FILE_NOT_FOUND;
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
2023-11-04 15:32:45 +01:00
|
|
|
fillPluginInformation(output, *pluginInfo);
|
2020-05-17 21:08:13 +02:00
|
|
|
|
2021-04-07 00:23:23 +02:00
|
|
|
return PLUGIN_BACKEND_API_ERROR_NONE;
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
|
2024-03-23 08:01:04 +01:00
|
|
|
extern "C" PluginBackendApiErrorType WUPSGetPluginMetaInformationByPath(wups_backend_plugin_information *output, const char *path) {
|
2020-12-26 14:17:50 +01:00
|
|
|
return WUPSGetPluginMetaInformation(PLUGIN_INFORMATION_INPUT_TYPE_PATH, path, nullptr, 0, output);
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
|
2024-03-23 08:01:04 +01:00
|
|
|
extern "C" PluginBackendApiErrorType WUPSGetPluginMetaInformationByBuffer(wups_backend_plugin_information *output, char *buffer, size_t size) {
|
2020-12-26 14:17:50 +01:00
|
|
|
return WUPSGetPluginMetaInformation(PLUGIN_INFORMATION_INPUT_TYPE_BUFFER, nullptr, buffer, size, output);
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
|
2024-03-23 08:01:04 +01:00
|
|
|
extern "C" PluginBackendApiErrorType WUPSGetPluginDataForContainerHandles(const wups_backend_plugin_container_handle *plugin_container_handle_list, wups_backend_plugin_data_handle *plugin_data_list, uint32_t buffer_size) {
|
2021-04-07 00:23:23 +02:00
|
|
|
PluginBackendApiErrorType res = PLUGIN_BACKEND_API_ERROR_NONE;
|
2022-05-14 14:00:20 +02:00
|
|
|
if (plugin_container_handle_list == nullptr || buffer_size == 0) {
|
|
|
|
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::lock_guard<std::mutex> lock(gLoadedDataMutex);
|
2023-11-04 15:32:45 +01:00
|
|
|
for (uint32_t i = 0; i < buffer_size; i++) {
|
2022-05-14 14:00:20 +02:00
|
|
|
auto handle = plugin_container_handle_list[i];
|
|
|
|
bool found = false;
|
2023-11-04 15:32:45 +01:00
|
|
|
for (const auto &curContainer : gLoadedPlugins) {
|
2024-03-24 07:40:58 +01:00
|
|
|
if (curContainer.getHandle() == handle) {
|
|
|
|
auto pluginData = curContainer.getPluginDataCopy();
|
2022-05-14 14:00:20 +02:00
|
|
|
plugin_data_list[i] = (uint32_t) pluginData->getHandle();
|
2023-11-04 15:32:45 +01:00
|
|
|
gLoadedData.insert(std::move(pluginData));
|
2022-05-14 14:00:20 +02:00
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to get container for handle %08X", handle);
|
2023-11-04 15:32:45 +01:00
|
|
|
return PLUGIN_BACKEND_API_INVALID_HANDLE;
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
}
|
2022-05-14 14:00:20 +02:00
|
|
|
|
2020-05-17 21:08:13 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2024-03-23 08:01:04 +01:00
|
|
|
extern "C" PluginBackendApiErrorType WUPSGetMetaInformation(const wups_backend_plugin_container_handle *plugin_container_handle_list, wups_backend_plugin_information *plugin_information_list, uint32_t buffer_size) {
|
2021-04-07 00:23:23 +02:00
|
|
|
PluginBackendApiErrorType res = PLUGIN_BACKEND_API_ERROR_NONE;
|
2020-12-26 14:17:50 +01:00
|
|
|
if (plugin_container_handle_list != nullptr && buffer_size != 0) {
|
2020-05-17 21:08:13 +02:00
|
|
|
for (uint32_t i = 0; i < buffer_size; i++) {
|
2022-05-14 14:00:20 +02:00
|
|
|
auto handle = plugin_container_handle_list[i];
|
|
|
|
bool found = false;
|
2023-11-04 15:32:45 +01:00
|
|
|
for (const auto &curContainer : gLoadedPlugins) {
|
2024-03-24 07:40:58 +01:00
|
|
|
if (curContainer.getHandle() == handle) {
|
|
|
|
const auto &metaInfo = curContainer.getMetaInformation();
|
2022-05-14 14:00:20 +02:00
|
|
|
|
2024-03-23 08:01:04 +01:00
|
|
|
plugin_information_list[i].plugin_information_version = WUPS_BACKEND_PLUGIN_INFORMATION_VERSION;
|
2023-11-04 15:32:45 +01:00
|
|
|
strncpy(plugin_information_list[i].storageId, metaInfo.getStorageId().c_str(), sizeof(plugin_information_list[i].storageId) - 1);
|
|
|
|
strncpy(plugin_information_list[i].author, metaInfo.getAuthor().c_str(), sizeof(plugin_information_list[i].author) - 1);
|
|
|
|
strncpy(plugin_information_list[i].buildTimestamp, metaInfo.getBuildTimestamp().c_str(), sizeof(plugin_information_list[i].buildTimestamp) - 1);
|
|
|
|
strncpy(plugin_information_list[i].description, metaInfo.getDescription().c_str(), sizeof(plugin_information_list[i].description) - 1);
|
|
|
|
strncpy(plugin_information_list[i].name, metaInfo.getName().c_str(), sizeof(plugin_information_list[i].name) - 1);
|
|
|
|
strncpy(plugin_information_list[i].license, metaInfo.getLicense().c_str(), sizeof(plugin_information_list[i].license) - 1);
|
|
|
|
strncpy(plugin_information_list[i].version, metaInfo.getVersion().c_str(), sizeof(plugin_information_list[i].version) - 1);
|
|
|
|
plugin_information_list[i].size = metaInfo.getSize();
|
2022-05-14 14:00:20 +02:00
|
|
|
found = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("FAILED TO FIND CONTAINER FOR HANDLE %08X", handle);
|
|
|
|
}
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
} else {
|
2022-04-22 22:55:53 +02:00
|
|
|
DEBUG_FUNCTION_LINE_ERR("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
2021-04-07 00:23:23 +02:00
|
|
|
res = PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2024-03-23 08:01:04 +01:00
|
|
|
extern "C" PluginBackendApiErrorType WUPSGetLoadedPlugins(wups_backend_plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize, uint32_t *plugin_information_version) {
|
2021-10-01 17:25:48 +02:00
|
|
|
if (plugin_information_version == nullptr) {
|
|
|
|
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
|
|
|
}
|
2024-03-23 08:01:04 +01:00
|
|
|
*plugin_information_version = WUPS_BACKEND_PLUGIN_INFORMATION_VERSION;
|
2022-02-04 16:25:44 +01:00
|
|
|
uint32_t counter = 0;
|
2023-11-04 15:32:45 +01:00
|
|
|
for (const auto &plugin : gLoadedPlugins) {
|
2020-05-17 21:08:13 +02:00
|
|
|
if (counter < buffer_size) {
|
2024-03-24 07:40:58 +01:00
|
|
|
io_handles[counter] = plugin.getHandle();
|
2020-05-17 21:08:13 +02:00
|
|
|
counter++;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-12-26 14:17:50 +01:00
|
|
|
if (outSize != nullptr) {
|
2020-05-17 21:08:13 +02:00
|
|
|
*outSize = counter;
|
|
|
|
}
|
2021-04-07 00:23:23 +02:00
|
|
|
return PLUGIN_BACKEND_API_ERROR_NONE;
|
2020-05-17 21:08:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSLoadPluginAsDataByPath);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSLoadPluginAsDataByBuffer);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSLoadPluginAsData);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSLoadAndLinkByDataHandle);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSDeletePluginData);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSGetPluginMetaInformation);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSGetPluginMetaInformationByPath);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSGetPluginMetaInformationByBuffer);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSGetMetaInformation);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSGetLoadedPlugins);
|
2023-02-17 17:30:28 +01:00
|
|
|
WUMS_EXPORT_FUNCTION(WUPSGetPluginDataForContainerHandles);
|
|
|
|
|
|
|
|
// API 2.0
|
|
|
|
extern "C" PluginBackendApiErrorType WUPSGetAPIVersion(WUPSBackendAPIVersion *outVersion) {
|
|
|
|
if (outVersion == nullptr) {
|
|
|
|
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
*outVersion = 2;
|
|
|
|
return PLUGIN_BACKEND_API_ERROR_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" PluginBackendApiErrorType WUPSGetNumberOfLoadedPlugins(uint32_t *outCount) {
|
|
|
|
if (outCount == nullptr) {
|
|
|
|
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
*outCount = gLoadedPlugins.size();
|
|
|
|
return PLUGIN_BACKEND_API_ERROR_NONE;
|
|
|
|
}
|
|
|
|
|
2024-03-23 08:01:04 +01:00
|
|
|
extern "C" PluginBackendApiErrorType WUPSGetSectionInformationForPlugin(const wups_backend_plugin_container_handle handle, wups_backend_plugin_section_info *plugin_section_list, uint32_t buffer_size, uint32_t *out_count) {
|
2023-02-17 17:30:28 +01:00
|
|
|
PluginBackendApiErrorType res = PLUGIN_BACKEND_API_ERROR_NONE;
|
|
|
|
if (out_count != nullptr) {
|
|
|
|
*out_count = 0;
|
|
|
|
}
|
|
|
|
if (handle != 0 && plugin_section_list != nullptr && buffer_size != 0) {
|
|
|
|
bool found = false;
|
2023-11-04 15:32:45 +01:00
|
|
|
for (const auto &curContainer : gLoadedPlugins) {
|
2024-03-24 07:40:58 +01:00
|
|
|
if (curContainer.getHandle() == handle) {
|
2023-11-04 15:32:45 +01:00
|
|
|
found = true;
|
2024-03-24 07:40:58 +01:00
|
|
|
const auto §ionInfoList = curContainer.getPluginInformation().getSectionInfoList();
|
2023-02-17 17:30:28 +01:00
|
|
|
|
|
|
|
uint32_t offset = 0;
|
|
|
|
for (auto const &[key, sectionInfo] : sectionInfoList) {
|
|
|
|
if (offset >= buffer_size) {
|
|
|
|
break;
|
|
|
|
}
|
2024-03-23 08:01:04 +01:00
|
|
|
plugin_section_list[offset].plugin_section_info_version = WUPS_BACKEND_PLUGIN_SECTION_INFORMATION_VERSION;
|
2024-03-24 07:40:58 +01:00
|
|
|
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].size = sectionInfo.getSize();
|
2023-02-17 17:30:28 +01:00
|
|
|
offset++;
|
|
|
|
}
|
|
|
|
if (out_count != nullptr) {
|
|
|
|
*out_count = offset;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
res = PLUGIN_BACKEND_API_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
res = PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" PluginBackendApiErrorType WUPSWillReloadPluginsOnNextLaunch(bool *out) {
|
|
|
|
if (out == nullptr) {
|
|
|
|
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
std::lock_guard<std::mutex> lock(gLoadedDataMutex);
|
|
|
|
*out = !gLoadOnNextLaunch.empty();
|
|
|
|
return PLUGIN_BACKEND_API_ERROR_NONE;
|
|
|
|
}
|
|
|
|
|
2024-03-23 08:01:04 +01:00
|
|
|
extern "C" PluginBackendApiErrorType WUPSGetSectionMemoryAddresses(wups_backend_plugin_container_handle handle, void **textAddress, void **dataAddress) {
|
2023-02-17 17:30:28 +01:00
|
|
|
if (handle == 0 || textAddress == nullptr || dataAddress == nullptr) {
|
|
|
|
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
|
|
|
}
|
2023-11-04 15:32:45 +01:00
|
|
|
for (const auto &curContainer : gLoadedPlugins) {
|
2024-03-24 07:40:58 +01:00
|
|
|
if (curContainer.getHandle() == handle) {
|
|
|
|
*textAddress = (void *) curContainer.getPluginInformation().getTextMemory().data();
|
|
|
|
*dataAddress = (void *) curContainer.getPluginInformation().getDataMemory().data();
|
2023-02-17 17:30:28 +01:00
|
|
|
return PLUGIN_BACKEND_API_ERROR_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PLUGIN_BACKEND_API_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSGetAPIVersion);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSGetNumberOfLoadedPlugins);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSGetSectionInformationForPlugin);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSWillReloadPluginsOnNextLaunch);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSGetSectionMemoryAddresses);
|