mirror of
https://github.com/wiiu-env/libwupsbackend.git
synced 2024-11-13 05:25:07 +01:00
Add support for API 3
This commit is contained in:
parent
67a6533507
commit
23c8635ca0
@ -1,6 +1,4 @@
|
||||
FROM ghcr.io/wiiu-env/devkitppc:20231112
|
||||
|
||||
COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:0.8.0-dev-20240302-3b5cc2f /artifacts $DEVKITPRO
|
||||
FROM ghcr.io/wiiu-env/devkitppc:20240423
|
||||
|
||||
WORKDIR tmp_build
|
||||
COPY . .
|
||||
|
@ -1,3 +1,3 @@
|
||||
FROM ghcr.io/wiiu-env/devkitppc:20231112
|
||||
FROM ghcr.io/wiiu-env/devkitppc:20240423
|
||||
|
||||
WORKDIR project
|
2
Makefile
2
Makefile
@ -13,7 +13,7 @@ include $(DEVKITPRO)/wut/share/wut_rules
|
||||
WUPS_ROOT := $(DEVKITPRO)/wups
|
||||
|
||||
export VER_MAJOR := 1
|
||||
export VER_MINOR := 2
|
||||
export VER_MINOR := 3
|
||||
export VER_PATCH := 0
|
||||
|
||||
VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
|
||||
|
@ -26,15 +26,15 @@ const char *GetStatusStr(PluginBackendApiErrorType err);
|
||||
|
||||
namespace PluginUtils {
|
||||
|
||||
std::optional<PluginMetaInformation> getMetaInformationForBuffer(char *buffer, size_t size, PluginBackendApiErrorType &err);
|
||||
std::optional<PluginMetaInformation> getMetaInformationForBuffer(char *buffer, size_t size, PluginBackendApiErrorType &err, PluginBackendPluginParseError &parseErr);
|
||||
|
||||
std::optional<PluginMetaInformation> getMetaInformationForPath(const std::string &path, PluginBackendApiErrorType &err);
|
||||
std::optional<PluginMetaInformation> getMetaInformationForPath(const std::string &path, PluginBackendApiErrorType &err, PluginBackendPluginParseError &parseErr);
|
||||
|
||||
std::vector<PluginContainer> getLoadedPlugins(PluginBackendApiErrorType &err);
|
||||
|
||||
std::optional<PluginContainer> getPluginForPath(const std::string &path, PluginBackendApiErrorType &err);
|
||||
std::optional<PluginContainer> getPluginForPath(const std::string &path, PluginBackendApiErrorType &err, PluginBackendPluginParseError &parseErr);
|
||||
|
||||
std::optional<PluginContainer> getPluginForBuffer(char *buffer, size_t size, PluginBackendApiErrorType &err);
|
||||
std::optional<PluginContainer> getPluginForBuffer(char *buffer, size_t size, PluginBackendApiErrorType &err, PluginBackendPluginParseError &parseErr);
|
||||
|
||||
PluginBackendApiErrorType LoadAndLinkOnRestart(const std::vector<PluginContainer> &plugins);
|
||||
|
||||
|
@ -30,9 +30,9 @@ PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByPath(wups_backend_plugin
|
||||
|
||||
PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByBuffer(wups_backend_plugin_data_handle *output, char *buffer, size_t size);
|
||||
|
||||
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByPath(wups_backend_plugin_information *output, const char *path);
|
||||
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByPath(wups_backend_plugin_information *output, const char *path, PluginBackendPluginParseError *errOut);
|
||||
|
||||
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByBuffer(wups_backend_plugin_information *output, char *buffer, size_t size);
|
||||
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByBuffer(wups_backend_plugin_information *output, char *buffer, size_t size, PluginBackendPluginParseError *errOut);
|
||||
|
||||
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);
|
||||
|
||||
|
@ -69,3 +69,9 @@ typedef enum PluginBackendApiErrorType {
|
||||
PLUGIN_BACKEND_API_ERROR_LIB_UNINITIALIZED = 0xFFFFFFF7,
|
||||
PLUGIN_BACKEND_API_ERROR_UNSUPPORTED_COMMAND = 0xFFFFFFF6,
|
||||
} PluginBackendApiErrorType;
|
||||
|
||||
typedef enum PluginBackendPluginParseError {
|
||||
PLUGIN_BACKEND_PLUGIN_PARSE_ERROR_NONE = 0,
|
||||
PLUGIN_BACKEND_PLUGIN_PARSE_ERROR_UNKNOWN = -1,
|
||||
PLUGIN_BACKEND_PLUGIN_PARSE_ERROR_INCOMPATIBLE_VERSION = -2,
|
||||
} PluginBackendPluginParseError;
|
||||
|
@ -45,26 +45,26 @@ static std::optional<PluginMetaInformation> getMetaInformation(const wups_backen
|
||||
info.size);
|
||||
}
|
||||
|
||||
std::optional<PluginMetaInformation> getMetaInformationForBuffer(char *buffer, size_t size, PluginBackendApiErrorType &err) {
|
||||
std::optional<PluginMetaInformation> getMetaInformationForBuffer(char *buffer, size_t size, PluginBackendApiErrorType &err, PluginBackendPluginParseError &parseErr) {
|
||||
wups_backend_plugin_information info = {};
|
||||
if ((err = WUPSBackend_GetPluginMetaInformationByBuffer(&info, buffer, size)) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
if ((err = WUPSBackend_GetPluginMetaInformationByBuffer(&info, buffer, size, &parseErr)) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to load meta infos for buffer %08X with size %08X", buffer, size);
|
||||
return {};
|
||||
}
|
||||
return getMetaInformation(info, err);
|
||||
}
|
||||
|
||||
std::optional<PluginMetaInformation> getMetaInformationForPath(const std::string &path, PluginBackendApiErrorType &err) {
|
||||
std::optional<PluginMetaInformation> getMetaInformationForPath(const std::string &path, PluginBackendApiErrorType &err, PluginBackendPluginParseError &parseErr) {
|
||||
wups_backend_plugin_information info = {};
|
||||
if ((err = WUPSBackend_GetPluginMetaInformationByPath(&info, path.c_str())) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
if ((err = WUPSBackend_GetPluginMetaInformationByPath(&info, path.c_str(), &parseErr)) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to load meta infos for %s", path.c_str());
|
||||
return {};
|
||||
}
|
||||
return getMetaInformation(info, err);
|
||||
}
|
||||
|
||||
std::optional<PluginContainer> getPluginForPath(const std::string &path, PluginBackendApiErrorType &err) {
|
||||
auto metaInfoOpt = getMetaInformationForPath(path, err);
|
||||
std::optional<PluginContainer> getPluginForPath(const std::string &path, PluginBackendApiErrorType &err, PluginBackendPluginParseError &parseErr) {
|
||||
auto metaInfoOpt = getMetaInformationForPath(path, err, parseErr);
|
||||
if (!metaInfoOpt) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to get MetaInformation for path %s", path.c_str());
|
||||
return {};
|
||||
@ -79,8 +79,8 @@ std::optional<PluginContainer> getPluginForPath(const std::string &path, PluginB
|
||||
return PluginContainer(PluginData(dataHandle), std::move(metaInfoOpt.value()));
|
||||
}
|
||||
|
||||
std::optional<PluginContainer> getPluginForBuffer(char *buffer, size_t size, PluginBackendApiErrorType &err) {
|
||||
auto metaInfoOpt = getMetaInformationForBuffer(buffer, size, err);
|
||||
std::optional<PluginContainer> getPluginForBuffer(char *buffer, size_t size, PluginBackendApiErrorType &err, PluginBackendPluginParseError &parseErr) {
|
||||
auto metaInfoOpt = getMetaInformationForBuffer(buffer, size, err, parseErr);
|
||||
if (!metaInfoOpt) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to get MetaInformation for buffer %08X (%d bytes)", buffer, size);
|
||||
return {};
|
||||
|
@ -14,11 +14,18 @@ static PluginBackendApiErrorType (*sWUPSGetSectionInformationForPlugin)(
|
||||
uint32_t buffer_size,
|
||||
uint32_t *out_count) = nullptr;
|
||||
|
||||
static PluginBackendApiErrorType (*sWUPSGetNumberOfLoadedPlugins)(uint32_t *out) = nullptr;
|
||||
static PluginBackendApiErrorType (*sWUPSWillReloadPluginsOnNextLaunch)(bool *out) = nullptr;
|
||||
static PluginBackendApiErrorType (*sWUPSGetNumberOfLoadedPlugins)(uint32_t *out) = nullptr;
|
||||
static PluginBackendApiErrorType (*sWUPSWillReloadPluginsOnNextLaunch)(bool *out) = nullptr;
|
||||
static PluginBackendApiErrorType (*sWUPSGetSectionMemoryAddresses)(wups_backend_plugin_container_handle handle,
|
||||
void **textAddress,
|
||||
void **dataAddress) = nullptr;
|
||||
void **dataAddress) = nullptr;
|
||||
static PluginBackendApiErrorType (*sWUPSGetPluginMetaInformationByPathEx)(wups_backend_plugin_information *output,
|
||||
const char *path,
|
||||
PluginBackendPluginParseError *err) = nullptr;
|
||||
static PluginBackendApiErrorType (*sWUPSGetPluginMetaInformationByBufferEx)(wups_backend_plugin_information *output,
|
||||
char *buffer,
|
||||
size_t size,
|
||||
PluginBackendPluginParseError *err) = nullptr;
|
||||
|
||||
static bool sLibInitDone = false;
|
||||
|
||||
@ -81,6 +88,16 @@ PluginBackendApiErrorType WUPSBackend_InitLibrary() {
|
||||
sWUPSGetSectionMemoryAddresses = nullptr;
|
||||
}
|
||||
|
||||
if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "WUPSGetPluginMetaInformationByPathEx", (void **) &sWUPSGetPluginMetaInformationByPathEx) != OS_DYNLOAD_OK) {
|
||||
DEBUG_FUNCTION_LINE_WARN("FindExport WUPSGetPluginMetaInformationByPathEx failed.");
|
||||
sWUPSGetPluginMetaInformationByPathEx = nullptr;
|
||||
}
|
||||
|
||||
if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "WUPSGetPluginMetaInformationByBufferEx", (void **) &sWUPSGetPluginMetaInformationByBufferEx) != OS_DYNLOAD_OK) {
|
||||
DEBUG_FUNCTION_LINE_WARN("FindExport WUPSGetPluginMetaInformationByBufferEx failed.");
|
||||
sWUPSGetPluginMetaInformationByBufferEx = nullptr;
|
||||
}
|
||||
|
||||
auto res = WUPSBackend_GetApiVersion(&sWUPSAPIVersion);
|
||||
if (res != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
sWUPSAPIVersion = WUPS_BACKEND_MODULE_API_VERSION_ERROR;
|
||||
@ -204,14 +221,39 @@ PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByBuffer(wups_backend_plug
|
||||
return WUPSLoadPluginAsDataByBuffer(output, buffer, size);
|
||||
}
|
||||
|
||||
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_GetPluginMetaInformationByPath(wups_backend_plugin_information *output, const char *path, PluginBackendPluginParseError *err) {
|
||||
if (sWUPSAPIVersion == WUPS_BACKEND_MODULE_API_VERSION_ERROR || sWUPSGetPluginMetaInformationByPathEx == nullptr || sWUPSAPIVersion < 3) {
|
||||
PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED();
|
||||
auto res = WUPSGetPluginMetaInformationByPath(output, path);
|
||||
if (err) {
|
||||
*err = res == PLUGIN_BACKEND_API_ERROR_NONE ? PLUGIN_BACKEND_PLUGIN_PARSE_ERROR_NONE : PLUGIN_BACKEND_PLUGIN_PARSE_ERROR_UNKNOWN;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
if (output == nullptr || path == nullptr) {
|
||||
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
return reinterpret_cast<decltype(&WUPSBackend_GetPluginMetaInformationByPath)>(sWUPSGetPluginMetaInformationByPathEx)(output, path, err);
|
||||
}
|
||||
|
||||
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_GetPluginMetaInformationByBuffer(wups_backend_plugin_information *output, char *buffer, size_t size, PluginBackendPluginParseError *err) {
|
||||
if (sWUPSAPIVersion == WUPS_BACKEND_MODULE_API_VERSION_ERROR || sWUPSGetPluginMetaInformationByBufferEx == nullptr || sWUPSAPIVersion < 3) {
|
||||
PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED();
|
||||
|
||||
auto res = WUPSGetPluginMetaInformationByBuffer(output, buffer, size);
|
||||
if (err) {
|
||||
*err = res == PLUGIN_BACKEND_API_ERROR_NONE ? PLUGIN_BACKEND_PLUGIN_PARSE_ERROR_NONE : PLUGIN_BACKEND_PLUGIN_PARSE_ERROR_UNKNOWN;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
if (output == nullptr || buffer == nullptr || size == 0) {
|
||||
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
return reinterpret_cast<decltype(&WUPSBackend_GetPluginMetaInformationByBuffer)>(sWUPSGetPluginMetaInformationByBufferEx)(output, buffer, size, err);
|
||||
}
|
||||
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user