WUPS 0.6.1 support

This commit is contained in:
Maschell 2021-10-01 17:25:48 +02:00
parent aa90e2478b
commit fe2e7d6fa9
9 changed files with 48 additions and 24 deletions

View File

@ -56,7 +56,7 @@ struct plugin_meta_info_t {
char license[MAXIMUM_PLUGIN_META_FIELD_LENGTH] = ""; char license[MAXIMUM_PLUGIN_META_FIELD_LENGTH] = "";
char buildTimestamp[MAXIMUM_PLUGIN_META_FIELD_LENGTH] = ""; char buildTimestamp[MAXIMUM_PLUGIN_META_FIELD_LENGTH] = "";
char descripion[MAXIMUM_PLUGIN_DESCRIPTION_LENGTH] = ""; char descripion[MAXIMUM_PLUGIN_DESCRIPTION_LENGTH] = "";
char id[MAXIMUM_PLUGIN_META_FIELD_LENGTH] = ""; char storageId[MAXIMUM_PLUGIN_META_FIELD_LENGTH] = "";
uint32_t size{}; uint32_t size{};
}; };

View File

@ -89,7 +89,7 @@ void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t
wups_loader_init_storage_args_t args; wups_loader_init_storage_args_t args;
args.open_storage_ptr = &StorageUtils::OpenStorage; args.open_storage_ptr = &StorageUtils::OpenStorage;
args.close_storage_ptr = &StorageUtils::CloseStorage; args.close_storage_ptr = &StorageUtils::CloseStorage;
args.plugin_id = plugin_data->meta.id; args.plugin_id = plugin_data->meta.storageId;
((void (*)(wups_loader_init_storage_args_t)) ((uint32_t *) func_ptr))(args); ((void (*)(wups_loader_init_storage_args_t)) ((uint32_t *) func_ptr))(args);
} else { } else {
DEBUG_FUNCTION_LINE("######################################"); DEBUG_FUNCTION_LINE("######################################");

View File

@ -55,10 +55,10 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
} }
strncpy(plugin_meta_data->descripion, pluginMetaInfo.getDescription().c_str(), MAXIMUM_PLUGIN_DESCRIPTION_LENGTH - 1); strncpy(plugin_meta_data->descripion, pluginMetaInfo.getDescription().c_str(), MAXIMUM_PLUGIN_DESCRIPTION_LENGTH - 1);
if (pluginMetaInfo.getId().size() >= MAXIMUM_PLUGIN_META_FIELD_LENGTH) { if (pluginMetaInfo.getStorageId().length() >= MAXIMUM_PLUGIN_META_FIELD_LENGTH) {
DEBUG_FUNCTION_LINE("Warning: plugin id will be truncated."); DEBUG_FUNCTION_LINE("Warning: plugin storage id will be truncated.");
} }
strncpy(plugin_meta_data->id, pluginMetaInfo.getId().c_str(), MAXIMUM_PLUGIN_META_FIELD_LENGTH - 1); strncpy(plugin_meta_data->storageId, pluginMetaInfo.getStorageId().c_str(), MAXIMUM_PLUGIN_META_FIELD_LENGTH - 1);
plugin_meta_data->size = pluginMetaInfo.getSize(); plugin_meta_data->size = pluginMetaInfo.getSize();
@ -202,6 +202,7 @@ std::vector<PluginContainer> PluginContainerPersistence::loadPlugins(plugin_info
metaInformation.setDescription(meta->descripion); metaInformation.setDescription(meta->descripion);
metaInformation.setSize(meta->size); metaInformation.setSize(meta->size);
metaInformation.setName(meta->name); metaInformation.setName(meta->name);
metaInformation.setStorageId(meta->storageId);
plugin_data_t *data = &(plugin_data->data); plugin_data_t *data = &(plugin_data->data);
@ -237,6 +238,18 @@ std::vector<PluginContainer> PluginContainerPersistence::loadPlugins(plugin_info
curPluginInformation.addHookData(curHook); curPluginInformation.addHookData(curHook);
} }
bool storageHasId = true;
for(auto const &value : curPluginInformation.getHookDataList()){
if(value.getType() == WUPS_LOADER_HOOK_INIT_STORAGE &&
metaInformation.getStorageId().empty()){
storageHasId = false;
}
}
if(!storageHasId){
DEBUG_FUNCTION_LINE("Plugin is using the storage API but has not set an ID");
continue;
}
/* load function replacement data */ /* load function replacement data */
uint32_t functionReplaceCount = plugin_data->info.number_used_functions; uint32_t functionReplaceCount = plugin_data->info.number_used_functions;

View File

@ -8,5 +8,5 @@ PluginMetaInformation::PluginMetaInformation(const PluginMetaInformation &other)
this->buildtimestamp = other.buildtimestamp; this->buildtimestamp = other.buildtimestamp;
this->description = other.description; this->description = other.description;
this->size = other.size; this->size = other.size;
this->id = other.id; this->storageId = other.storageId;
} }

View File

@ -48,8 +48,8 @@ public:
return this->description; return this->description;
} }
[[nodiscard]] const std::string &getId() const { [[nodiscard]] const std::string &getStorageId() const {
return this->id; return this->storageId;
} }
[[nodiscard]] size_t getSize() const { [[nodiscard]] size_t getSize() const {
@ -87,8 +87,8 @@ private:
this->size = _size; this->size = _size;
} }
void setId(const std::string &_id) { void setStorageId(const std::string &_storageId) {
this->id = _id; this->storageId = _storageId;
} }
std::string name; std::string name;
@ -97,7 +97,7 @@ private:
std::string license; std::string license;
std::string buildtimestamp; std::string buildtimestamp;
std::string description; std::string description;
std::string id; std::string storageId;
size_t size{}; size_t size{};
friend class PluginMetaInformationFactory; friend class PluginMetaInformationFactory;

View File

@ -110,10 +110,10 @@ std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(co
pluginInfo.setBuildTimestamp(value); pluginInfo.setBuildTimestamp(value);
} else if (key == "description") { } else if (key == "description") {
pluginInfo.setDescription(value); pluginInfo.setDescription(value);
} else if (key == "id") { } else if (key == "storage_id") {
pluginInfo.setId(value); pluginInfo.setStorageId(value);
} else if (key == "wups") { } else if (key == "wups") {
if (value != "0.6") { if (value != "0.6.1") {
DEBUG_FUNCTION_LINE("Warning: Ignoring plugin - Unsupported WUPS version: %s.", value.c_str()); DEBUG_FUNCTION_LINE("Warning: Ignoring plugin - Unsupported WUPS version: %s.", value.c_str());
return std::nullopt; return std::nullopt;
} }

View File

@ -146,6 +146,10 @@ void ConfigUtils::displayMenu() {
} }
} }
if(configs.empty()){
return;
}
ConfigDisplayItem *currentConfig = nullptr; ConfigDisplayItem *currentConfig = nullptr;
WUPSConfigCategory *currentCategory = nullptr; WUPSConfigCategory *currentCategory = nullptr;

View File

@ -10,13 +10,14 @@
#include <wums.h> #include <wums.h>
void fillPluginInformation(plugin_information *out, PluginMetaInformation *metaInformation) { void fillPluginInformation(plugin_information *out, PluginMetaInformation *metaInformation) {
out->plugin_information_version = PLUGIN_INFORMATION_VERSION;
strncpy(out->author, metaInformation->getAuthor().c_str(), sizeof(out->author) - 1); strncpy(out->author, metaInformation->getAuthor().c_str(), sizeof(out->author) - 1);
strncpy(out->buildTimestamp, metaInformation->getBuildTimestamp().c_str(), sizeof(out->buildTimestamp) - 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->description, metaInformation->getDescription().c_str(), sizeof(out->description) - 1);
strncpy(out->name, metaInformation->getName().c_str(), sizeof(out->name) - 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->license, metaInformation->getLicense().c_str(), sizeof(out->license) - 1);
strncpy(out->version, metaInformation->getVersion().c_str(), sizeof(out->version) - 1); strncpy(out->version, metaInformation->getVersion().c_str(), sizeof(out->version) - 1);
strncpy(out->id, metaInformation->getId().c_str(), sizeof(out->id) - 1); strncpy(out->storageId, metaInformation->getStorageId().c_str(), sizeof(out->storageId) - 1);
out->size = metaInformation->getSize(); out->size = metaInformation->getSize();
} }
@ -156,13 +157,14 @@ extern "C" PluginBackendApiErrorType WUPSGetMetaInformation(const plugin_contain
auto handle = plugin_container_handle_list[i]; auto handle = plugin_container_handle_list[i];
auto *container = (PluginContainer *) handle; auto *container = (PluginContainer *) handle;
strncpy(plugin_information_list[i].id, container->metaInformation.getId().c_str(), 255); plugin_information_list[i].plugin_information_version = PLUGIN_INFORMATION_VERSION;
strncpy(plugin_information_list[i].author, container->metaInformation.getAuthor().c_str(), 255); strncpy(plugin_information_list[i].storageId, container->metaInformation.getStorageId().c_str(), sizeof(plugin_information_list[i].storageId) - 1);
strncpy(plugin_information_list[i].buildTimestamp, container->metaInformation.getBuildTimestamp().c_str(), 255); strncpy(plugin_information_list[i].author, container->metaInformation.getAuthor().c_str(), sizeof(plugin_information_list[i].author) - 1);
strncpy(plugin_information_list[i].description, container->metaInformation.getDescription().c_str(), 255); strncpy(plugin_information_list[i].buildTimestamp, container->metaInformation.getBuildTimestamp().c_str(), sizeof(plugin_information_list[i].buildTimestamp) - 1);
strncpy(plugin_information_list[i].name, container->metaInformation.getName().c_str(), 255); strncpy(plugin_information_list[i].description, container->metaInformation.getDescription().c_str(), sizeof(plugin_information_list[i].description) - 1);
strncpy(plugin_information_list[i].license, container->metaInformation.getLicense().c_str(), 255); strncpy(plugin_information_list[i].name, container->metaInformation.getName().c_str(), sizeof(plugin_information_list[i].name) - 1);
strncpy(plugin_information_list[i].version, container->metaInformation.getVersion().c_str(), 255); strncpy(plugin_information_list[i].license, container->metaInformation.getLicense().c_str(), sizeof(plugin_information_list[i].license) - 1);
strncpy(plugin_information_list[i].version, container->metaInformation.getVersion().c_str(), sizeof(plugin_information_list[i].version) - 1);
plugin_information_list[i].size = container->metaInformation.getSize(); plugin_information_list[i].size = container->metaInformation.getSize();
} }
} else { } else {
@ -172,7 +174,12 @@ extern "C" PluginBackendApiErrorType WUPSGetMetaInformation(const plugin_contain
return res; return res;
} }
extern "C" PluginBackendApiErrorType WUPSGetLoadedPlugins(plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize) { extern "C" PluginBackendApiErrorType WUPSGetLoadedPlugins(plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize, uint32_t *plugin_information_version) {
DEBUG_FUNCTION_LINE();
if (plugin_information_version == nullptr) {
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
}
*plugin_information_version = PLUGIN_INFORMATION_VERSION;
auto plugins = PluginContainerPersistence::loadPlugins(gPluginInformation); auto plugins = PluginContainerPersistence::loadPlugins(gPluginInformation);
uint32_t counter = 0; uint32_t counter = 0;
for (auto &plugin: plugins) { for (auto &plugin: plugins) {

View File

@ -31,7 +31,7 @@ PluginBackendApiErrorType WUPSGetPluginDataForContainerHandles(const plugin_cont
PluginBackendApiErrorType WUPSGetMetaInformation(const plugin_container_handle *plugin_container_handle_list, plugin_information *plugin_information_list, uint32_t buffer_size); PluginBackendApiErrorType WUPSGetMetaInformation(const plugin_container_handle *plugin_container_handle_list, plugin_information *plugin_information_list, uint32_t buffer_size);
PluginBackendApiErrorType WUPSGetLoadedPlugins(plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize); PluginBackendApiErrorType WUPSGetLoadedPlugins(plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize, uint32_t *plugin_information_version);
#ifdef __cplusplus #ifdef __cplusplus
} }