Rename structs to add wups_backend

This commit is contained in:
Maschell 2024-03-23 08:11:02 +01:00
parent cb07ebd437
commit 0e10f23074
5 changed files with 59 additions and 59 deletions

View File

@ -12,7 +12,7 @@ PluginBackendApiErrorType WUPSBackend_DeInitLibrary();
const char *WUPSBackend_GetStatusStr(PluginBackendApiErrorType status);
PluginBackendApiErrorType WUPSBackend_GetSectionInformationForPlugin(plugin_container_handle handle, plugin_section_info *plugin_section_list, uint32_t buffer_size, uint32_t *out_count);
PluginBackendApiErrorType WUPSBackend_GetSectionInformationForPlugin(wups_backend_plugin_container_handle handle, wups_backend_plugin_section_info *plugin_section_list, uint32_t buffer_size, uint32_t *out_count);
PluginBackendApiErrorType WUPSBackend_GetApiVersion(WUPSBackendAPIVersion *outVersion);
@ -20,25 +20,25 @@ PluginBackendApiErrorType WUPSBackend_GetNumberOfLoadedPlugins(uint32_t *out_cou
PluginBackendApiErrorType WUPSBackend_WillReloadPluginsOnNextLaunch(bool *out);
PluginBackendApiErrorType WUPSBackend_GetSectionMemoryAddresses(plugin_container_handle handle, void **textAddress, void **dataAddress);
PluginBackendApiErrorType WUPSBackend_GetSectionMemoryAddresses(wups_backend_plugin_container_handle handle, void **textAddress, void **dataAddress);
PluginBackendApiErrorType WUPSBackend_LoadAndLinkByDataHandle(const plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size);
PluginBackendApiErrorType WUPSBackend_LoadAndLinkByDataHandle(const wups_backend_plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size);
PluginBackendApiErrorType WUPSBackend_DeletePluginData(const plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size);
PluginBackendApiErrorType WUPSBackend_DeletePluginData(const wups_backend_plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size);
PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByPath(plugin_data_handle *output, const char *path);
PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByPath(wups_backend_plugin_data_handle *output, const char *path);
PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByBuffer(plugin_data_handle *output, char *buffer, size_t size);
PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByBuffer(wups_backend_plugin_data_handle *output, char *buffer, size_t size);
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByPath(plugin_information *output, const char *path);
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByPath(wups_backend_plugin_information *output, const char *path);
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByBuffer(plugin_information *output, char *buffer, size_t size);
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByBuffer(wups_backend_plugin_information *output, char *buffer, size_t size);
PluginBackendApiErrorType WUPSBackend_GetPluginDataForContainerHandles(const plugin_container_handle *plugin_container_handle_list, const plugin_data_handle *plugin_data_list, uint32_t buffer_size);
PluginBackendApiErrorType WUPSBackend_GetPluginDataForContainerHandles(const wups_backend_plugin_container_handle *plugin_container_handle_list, const wups_backend_plugin_data_handle *plugin_data_list, uint32_t buffer_size);
PluginBackendApiErrorType WUPSBackend_GetMetaInformation(const plugin_container_handle *plugin_container_handle_list, plugin_information *plugin_information_list, uint32_t buffer_size);
PluginBackendApiErrorType WUPSBackend_GetMetaInformation(const wups_backend_plugin_container_handle *plugin_container_handle_list, wups_backend_plugin_information *plugin_information_list, uint32_t buffer_size);
PluginBackendApiErrorType WUPSBackend_GetLoadedPlugins(const plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize, uint32_t *plugin_information_version);
PluginBackendApiErrorType WUPSBackend_GetLoadedPlugins(const wups_backend_plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize, uint32_t *plugin_information_version);
#ifdef __cplusplus
}

View File

@ -20,22 +20,22 @@
#include <stddef.h>
#include <stdint.h>
typedef enum GetPluginInformationInputType {
typedef enum WUPSBackendGetPluginInformationInputType {
PLUGIN_INFORMATION_INPUT_TYPE_PATH = 0,
PLUGIN_INFORMATION_INPUT_TYPE_BUFFER = 1,
} GetPluginInformationInputType;
} WUPSBackendGetPluginInformationInputType;
typedef uint32_t plugin_container_handle;
typedef uint32_t plugin_data_handle;
typedef uint32_t wups_backend_plugin_container_handle;
typedef uint32_t wups_backend_plugin_data_handle;
typedef uint32_t WUPSBackendAPIVersion;
#define WUPS_BACKEND_MODULE_API_VERSION 0x00000002
#define WUPS_BACKEND_MODULE_API_VERSION_ERROR 0xFFFFFFFF
#define PLUGIN_INFORMATION_VERSION 0x00000002
#define WUPS_BACKEND_PLUGIN_INFORMATION_VERSION 0x00000002
/* plugin_information message */
typedef struct plugin_information {
typedef struct wups_backend_plugin_information {
uint32_t plugin_information_version;
char name[256];
char author[256];
@ -45,16 +45,16 @@ typedef struct plugin_information {
char version[256];
char storageId[256];
size_t size;
} plugin_information;
} wups_backend_plugin_information;
#define PLUGIN_SECTION_INFORMATION_VERSION 0x00000001
#define WUPS_BACKEND_PLUGIN_SECTION_INFORMATION_VERSION 0x00000001
typedef struct plugin_section_info {
typedef struct wups_backend_plugin_section_info {
uint32_t plugin_section_info_version;
char name[32];
void *address;
uint32_t size;
} plugin_section_info;
} wups_backend_plugin_section_info;
typedef enum PluginBackendApiErrorType {
PLUGIN_BACKEND_API_ERROR_NONE = 0,

View File

@ -24,8 +24,8 @@
using namespace WUPSBackend;
std::optional<std::unique_ptr<PluginMetaInformation>> getMetaInformation(const plugin_information &info) {
if (info.plugin_information_version != PLUGIN_INFORMATION_VERSION) {
std::optional<std::unique_ptr<PluginMetaInformation>> getMetaInformation(const wups_backend_plugin_information &info) {
if (info.plugin_information_version != WUPS_BACKEND_PLUGIN_INFORMATION_VERSION) {
DEBUG_FUNCTION_LINE_ERR("Version mismatch");
return {};
}
@ -45,7 +45,7 @@ std::optional<std::unique_ptr<PluginMetaInformation>> getMetaInformation(const p
}
std::optional<std::unique_ptr<PluginMetaInformation>> PluginUtils::getMetaInformationForBuffer(char *buffer, size_t size) {
plugin_information info = {};
wups_backend_plugin_information info;
if (WUPSGetPluginMetaInformationByBuffer(&info, buffer, size) != PLUGIN_BACKEND_API_ERROR_NONE) {
DEBUG_FUNCTION_LINE_ERR("Failed to load meta infos for buffer %08X with size %08X", buffer, size);
return {};
@ -55,7 +55,7 @@ std::optional<std::unique_ptr<PluginMetaInformation>> PluginUtils::getMetaInform
}
std::optional<std::unique_ptr<PluginMetaInformation>> PluginUtils::getMetaInformationForPath(const std::string &path) {
plugin_information info = {};
wups_backend_plugin_information info = {};
if (WUPSGetPluginMetaInformationByPath(&info, path.c_str()) != PLUGIN_BACKEND_API_ERROR_NONE) {
DEBUG_FUNCTION_LINE_ERR("Failed to load meta infos for %s", path.c_str());
return {};
@ -71,7 +71,7 @@ std::optional<std::unique_ptr<PluginContainer>> PluginUtils::getPluginForPath(co
return {};
}
plugin_data_handle dataHandle;
wups_backend_plugin_data_handle dataHandle;
if (WUPSLoadPluginAsDataByPath(&dataHandle, path.c_str()) != PLUGIN_BACKEND_API_ERROR_NONE) {
DEBUG_FUNCTION_LINE_ERR("WUPSLoadPluginAsDataByPath failed for path %s", path.c_str());
return {};
@ -99,7 +99,7 @@ std::optional<std::unique_ptr<PluginContainer>> PluginUtils::getPluginForBuffer(
return {};
}
plugin_data_handle dataHandle;
wups_backend_plugin_data_handle dataHandle;
if (WUPSLoadPluginAsDataByBuffer(&dataHandle, buffer, size) != PLUGIN_BACKEND_API_ERROR_NONE) {
DEBUG_FUNCTION_LINE_ERR("WUPSLoadPluginAsDataByBuffer failed for buffer %08X (%d bytes)", buffer, size);
return {};
@ -124,7 +124,7 @@ std::optional<std::unique_ptr<PluginContainer>> PluginUtils::getPluginForBuffer(
std::vector<std::unique_ptr<PluginContainer>> PluginUtils::getLoadedPlugins(uint32_t maxSize) {
std::vector<std::unique_ptr<PluginContainer>> result;
auto handles = make_unique_nothrow<plugin_container_handle[]>(maxSize);
auto handles = make_unique_nothrow<wups_backend_plugin_container_handle[]>(maxSize);
if (!handles) {
DEBUG_FUNCTION_LINE_ERR("Not enough memory");
return result;
@ -141,12 +141,12 @@ std::vector<std::unique_ptr<PluginContainer>> PluginUtils::getLoadedPlugins(uint
DEBUG_FUNCTION_LINE_ERR("WUPSGetLoadedPlugins: Failed");
return result;
}
if (realSize == 0 || plugin_information_version != PLUGIN_INFORMATION_VERSION) {
if (realSize == 0 || plugin_information_version != WUPS_BACKEND_PLUGIN_INFORMATION_VERSION) {
DEBUG_FUNCTION_LINE_ERR("realSize is 0 or version mismatch");
return result;
}
auto dataHandles = make_unique_nothrow<plugin_data_handle[]>(realSize);
auto dataHandles = make_unique_nothrow<wups_backend_plugin_data_handle[]>(realSize);
if (!dataHandles) {
DEBUG_FUNCTION_LINE_ERR("Not enough memory");
return result;
@ -157,7 +157,7 @@ std::vector<std::unique_ptr<PluginContainer>> PluginUtils::getLoadedPlugins(uint
return result;
}
auto information = make_unique_nothrow<plugin_information[]>(realSize);
auto information = make_unique_nothrow<wups_backend_plugin_information[]>(realSize);
if (!information) {
DEBUG_FUNCTION_LINE_ERR("Not enough memory");
return result;
@ -168,7 +168,7 @@ std::vector<std::unique_ptr<PluginContainer>> PluginUtils::getLoadedPlugins(uint
}
for (uint32_t i = 0; i < realSize; i++) {
if (information[i].plugin_information_version != PLUGIN_INFORMATION_VERSION) {
if (information[i].plugin_information_version != WUPS_BACKEND_PLUGIN_INFORMATION_VERSION) {
DEBUG_FUNCTION_LINE_ERR("Skip, wrong struct version.");
continue;
}
@ -206,10 +206,10 @@ std::vector<std::unique_ptr<PluginContainer>> PluginUtils::getLoadedPlugins(uint
int32_t PluginUtils::LoadAndLinkOnRestart(const std::vector<std::unique_ptr<PluginContainer>> &plugins) {
uint32_t dataSize = plugins.size();
plugin_data_handle handles[dataSize];
wups_backend_plugin_data_handle handles[dataSize];
int i = 0;
for (auto &plugin : plugins) {
plugin_data_handle handle = plugin->getPluginData()->getHandle();
const wups_backend_plugin_data_handle &handle = plugin->getPluginData()->getHandle();
if (handle == 0) {
dataSize--;
} else {

View File

@ -9,14 +9,14 @@ static OSDynLoad_Module sModuleHandle = nullptr;
static PluginBackendApiErrorType (*sWUPSGetAPIVersion)(WUPSBackendAPIVersion *) = nullptr;
static PluginBackendApiErrorType (*sWUPSGetSectionInformationForPlugin)(
plugin_container_handle handle,
plugin_section_info *plugin_section_list,
wups_backend_plugin_container_handle handle,
wups_backend_plugin_section_info *plugin_section_list,
uint32_t buffer_size,
uint32_t *out_count) = nullptr;
static PluginBackendApiErrorType (*sWUPSGetNumberOfLoadedPlugins)(uint32_t *out) = nullptr;
static PluginBackendApiErrorType (*sWUPSWillReloadPluginsOnNextLaunch)(bool *out) = nullptr;
static PluginBackendApiErrorType (*sWUPSGetSectionMemoryAddresses)(plugin_container_handle handle,
static PluginBackendApiErrorType (*sWUPSGetSectionMemoryAddresses)(wups_backend_plugin_container_handle handle,
void **textAddress,
void **dataAddress) = nullptr;
@ -118,7 +118,7 @@ PluginBackendApiErrorType WUPSBackend_GetApiVersion(WUPSBackendAPIVersion *outVe
return reinterpret_cast<decltype(&WUPSBackend_GetApiVersion)>(sWUPSGetAPIVersion)(outVersion);
}
PluginBackendApiErrorType WUPSBackend_GetSectionInformationForPlugin(plugin_container_handle handle, plugin_section_info *plugin_section_list, uint32_t buffer_size, uint32_t *out_count) {
PluginBackendApiErrorType WUPSBackend_GetSectionInformationForPlugin(wups_backend_plugin_container_handle handle, wups_backend_plugin_section_info *plugin_section_list, uint32_t buffer_size, uint32_t *out_count) {
if (sWUPSAPIVersion == WUPS_BACKEND_MODULE_API_VERSION_ERROR) {
return PLUGIN_BACKEND_API_ERROR_LIB_UNINITIALIZED;
}
@ -163,7 +163,7 @@ PluginBackendApiErrorType WUPSBackend_WillReloadPluginsOnNextLaunch(bool *out) {
return reinterpret_cast<decltype(&WUPSBackend_WillReloadPluginsOnNextLaunch)>(sWUPSWillReloadPluginsOnNextLaunch)(out);
}
PluginBackendApiErrorType WUPSBackend_GetSectionMemoryAddresses(plugin_container_handle handle, void **textAddress, void **dataAddress) {
PluginBackendApiErrorType WUPSBackend_GetSectionMemoryAddresses(wups_backend_plugin_container_handle handle, void **textAddress, void **dataAddress) {
if (sWUPSAPIVersion == WUPS_BACKEND_MODULE_API_VERSION_ERROR) {
return PLUGIN_BACKEND_API_ERROR_LIB_UNINITIALIZED;
}
@ -184,47 +184,47 @@ PluginBackendApiErrorType WUPSBackend_GetSectionMemoryAddresses(plugin_container
} while (0)
PluginBackendApiErrorType WUPSBackend_LoadAndLinkByDataHandle(const plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size) {
PluginBackendApiErrorType WUPSBackend_LoadAndLinkByDataHandle(const wups_backend_plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size) {
PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED();
return WUPSLoadAndLinkByDataHandle(plugin_data_handle_list, plugin_data_handle_list_size);
}
PluginBackendApiErrorType WUPSBackend_DeletePluginData(const plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size) {
PluginBackendApiErrorType WUPSBackend_DeletePluginData(const wups_backend_plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size) {
PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED();
return WUPSDeletePluginData(plugin_data_handle_list, plugin_data_handle_list_size);
}
PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByPath(plugin_data_handle *output, const char *path) {
PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByPath(wups_backend_plugin_data_handle *output, const char *path) {
PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED();
return WUPSLoadPluginAsDataByPath(output, path);
}
PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByBuffer(plugin_data_handle *output, char *buffer, size_t size) {
PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByBuffer(wups_backend_plugin_data_handle *output, char *buffer, size_t size) {
PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED();
return WUPSLoadPluginAsDataByBuffer(output, buffer, size);
}
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByPath(plugin_information *output, const char *path) {
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByPath(wups_backend_plugin_information *output, const char *path) {
PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED();
return WUPSGetPluginMetaInformationByPath(output, path);
}
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByBuffer(plugin_information *output, char *buffer, size_t size) {
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByBuffer(wups_backend_plugin_information *output, char *buffer, size_t size) {
PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED();
return WUPSGetPluginMetaInformationByBuffer(output, buffer, size);
}
PluginBackendApiErrorType WUPSBackend_GetPluginDataForContainerHandles(const plugin_container_handle *plugin_container_handle_list, const plugin_data_handle *plugin_data_list, uint32_t buffer_size) {
PluginBackendApiErrorType WUPSBackend_GetPluginDataForContainerHandles(const wups_backend_plugin_container_handle *plugin_container_handle_list, const wups_backend_plugin_data_handle *plugin_data_list, uint32_t buffer_size) {
PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED();
return WUPSGetPluginDataForContainerHandles(plugin_container_handle_list, plugin_data_list, buffer_size);
}
PluginBackendApiErrorType WUPSBackend_GetMetaInformation(const plugin_container_handle *plugin_container_handle_list, plugin_information *plugin_information_list, uint32_t buffer_size) {
PluginBackendApiErrorType WUPSBackend_GetMetaInformation(const wups_backend_plugin_container_handle *plugin_container_handle_list, wups_backend_plugin_information *plugin_information_list, uint32_t buffer_size) {
PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED();
return WUPSGetMetaInformation(plugin_container_handle_list, plugin_information_list, buffer_size);
}
PluginBackendApiErrorType WUPSBackend_GetLoadedPlugins(const plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize, uint32_t *plugin_information_version) {
PluginBackendApiErrorType WUPSBackend_GetLoadedPlugins(const wups_backend_plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize, uint32_t *plugin_information_version) {
PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED();
return WUPSGetLoadedPlugins(io_handles, buffer_size, outSize, plugin_information_version);
}

View File

@ -23,23 +23,23 @@
extern "C" {
#endif
extern PluginBackendApiErrorType WUPSLoadAndLinkByDataHandle(const plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size);
extern PluginBackendApiErrorType WUPSLoadAndLinkByDataHandle(const wups_backend_plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size);
extern PluginBackendApiErrorType WUPSDeletePluginData(const plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size);
extern PluginBackendApiErrorType WUPSDeletePluginData(const wups_backend_plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size);
extern PluginBackendApiErrorType WUPSLoadPluginAsDataByPath(plugin_data_handle *output, const char *path);
extern PluginBackendApiErrorType WUPSLoadPluginAsDataByPath(wups_backend_plugin_data_handle *output, const char *path);
extern PluginBackendApiErrorType WUPSLoadPluginAsDataByBuffer(plugin_data_handle *output, char *buffer, size_t size);
extern PluginBackendApiErrorType WUPSLoadPluginAsDataByBuffer(wups_backend_plugin_data_handle *output, char *buffer, size_t size);
extern PluginBackendApiErrorType WUPSGetPluginMetaInformationByPath(plugin_information *output, const char *path);
extern PluginBackendApiErrorType WUPSGetPluginMetaInformationByPath(wups_backend_plugin_information *output, const char *path);
extern PluginBackendApiErrorType WUPSGetPluginMetaInformationByBuffer(plugin_information *output, char *buffer, size_t size);
extern PluginBackendApiErrorType WUPSGetPluginMetaInformationByBuffer(wups_backend_plugin_information *output, char *buffer, size_t size);
extern PluginBackendApiErrorType WUPSGetPluginDataForContainerHandles(const plugin_container_handle *plugin_container_handle_list, const plugin_data_handle *plugin_data_list, uint32_t buffer_size);
extern PluginBackendApiErrorType WUPSGetPluginDataForContainerHandles(const wups_backend_plugin_container_handle *plugin_container_handle_list, const wups_backend_plugin_data_handle *plugin_data_list, uint32_t buffer_size);
extern PluginBackendApiErrorType WUPSGetMetaInformation(const plugin_container_handle *plugin_container_handle_list, plugin_information *plugin_information_list, uint32_t buffer_size);
extern PluginBackendApiErrorType WUPSGetMetaInformation(const wups_backend_plugin_container_handle *plugin_container_handle_list, wups_backend_plugin_information *plugin_information_list, uint32_t buffer_size);
extern PluginBackendApiErrorType WUPSGetLoadedPlugins(const plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize, uint32_t *plugin_information_version);
extern PluginBackendApiErrorType WUPSGetLoadedPlugins(const wups_backend_plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize, uint32_t *plugin_information_version);
#ifdef __cplusplus
}