Compare commits
11 Commits
19f6ac9c23
...
ea59e95c56
Author | SHA1 | Date |
---|---|---|
Maschell | ea59e95c56 | |
Maschell | 23c8635ca0 | |
Maschell | 67a6533507 | |
Maschell | 747144384a | |
Maschell | e251a62c02 | |
Maschell | 2f137293b9 | |
Maschell | 0a2e837b5b | |
Maschell | 0e10f23074 | |
Maschell | cb07ebd437 | |
Maschell | e40d46599c | |
Maschell | d497441ac2 |
|
@ -42,7 +42,7 @@ IndentPPDirectives: None
|
|||
IndentWidth: 4
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: All
|
||||
NamespaceIndentation: None
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PointerAlignment: Right
|
||||
|
|
|
@ -6,7 +6,7 @@ jobs:
|
|||
clang-format:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./source ./include
|
||||
|
@ -14,7 +14,7 @@ jobs:
|
|||
runs-on: ubuntu-22.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: build lib
|
||||
run: |
|
||||
docker build . -f Dockerfile.buildlocal -t builder
|
||||
|
|
|
@ -3,30 +3,49 @@ on:
|
|||
push:
|
||||
branches:
|
||||
- main
|
||||
- '*-dev'
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
clang-format-lib:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./include ./source
|
||||
build-lib:
|
||||
runs-on: ubuntu-22.04
|
||||
needs: clang-format-lib
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: build binary
|
||||
run: |
|
||||
docker build . -f Dockerfile.buildlocal -t builder
|
||||
docker run --rm -v ${PWD}:/project builder make
|
||||
build-and-push-image:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-lib]
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Extract Docker metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=raw,value={{date 'YYYYMMDD'}}-{{sha}}
|
||||
type=raw,value={{date 'YYYYMMDD'}}
|
||||
type=raw,value=latest
|
||||
type=raw,value={{branch}}-{{date 'YYYYMMDD'}}-{{sha}},enable=${{ github.ref != format('refs/heads/{0}', 'main') }}
|
||||
type=raw,value={{date 'YYYYMMDD'}}-{{sha}},enable={{is_default_branch}}
|
||||
type=raw,value={{date 'YYYYMMDD'}},enable={{is_default_branch}}
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Log into registry ${{ env.REGISTRY }}
|
||||
uses: docker/login-action@v2.1.0
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
FROM ghcr.io/wiiu-env/devkitppc:20230621
|
||||
|
||||
COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20230621 /artifacts $DEVKITPRO
|
||||
FROM ghcr.io/wiiu-env/devkitppc:20240423
|
||||
|
||||
WORKDIR tmp_build
|
||||
COPY . .
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
FROM ghcr.io/wiiu-env/devkitppc:20230621
|
||||
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)
|
||||
|
|
|
@ -25,17 +25,17 @@
|
|||
#include "PluginMetaInformation.h"
|
||||
|
||||
namespace WUPSBackend {
|
||||
class PluginContainer {
|
||||
class PluginContainer {
|
||||
|
||||
public:
|
||||
PluginContainer(std::shared_ptr<PluginData> data, std::shared_ptr<PluginMetaInformation> metaInfo);
|
||||
public:
|
||||
PluginContainer(PluginData data, PluginMetaInformation metaInfo);
|
||||
|
||||
[[nodiscard]] const std::shared_ptr<PluginMetaInformation> &getMetaInformation() const;
|
||||
[[nodiscard]] const PluginMetaInformation &getMetaInformation() const;
|
||||
|
||||
[[nodiscard]] const std::shared_ptr<PluginData> &getPluginData() const;
|
||||
[[nodiscard]] const PluginData &getPluginData() const;
|
||||
|
||||
private:
|
||||
const std::shared_ptr<PluginData> pluginData;
|
||||
const std::shared_ptr<PluginMetaInformation> metaInformation;
|
||||
};
|
||||
private:
|
||||
PluginData pluginData;
|
||||
PluginMetaInformation metaInformation;
|
||||
};
|
||||
} // namespace WUPSBackend
|
|
@ -20,16 +20,22 @@
|
|||
#include <wups_backend/import_defines.h>
|
||||
|
||||
namespace WUPSBackend {
|
||||
class PluginData {
|
||||
class PluginData {
|
||||
|
||||
public:
|
||||
explicit PluginData(uint32_t handle);
|
||||
~PluginData();
|
||||
public:
|
||||
explicit PluginData(uint32_t handle);
|
||||
|
||||
[[nodiscard]] uint32_t getHandle() const {
|
||||
return handle;
|
||||
}
|
||||
PluginData(const PluginData &) = delete;
|
||||
|
||||
uint32_t handle;
|
||||
};
|
||||
PluginData(PluginData &&src) noexcept;
|
||||
|
||||
~PluginData();
|
||||
|
||||
PluginData &operator=(PluginData &&src) noexcept;
|
||||
|
||||
[[nodiscard]] uint32_t getHandle() const;
|
||||
|
||||
private:
|
||||
uint32_t mHandle;
|
||||
};
|
||||
} // namespace WUPSBackend
|
|
@ -22,91 +22,59 @@
|
|||
#include <vector>
|
||||
|
||||
namespace WUPSBackend {
|
||||
class PluginMetaInformation {
|
||||
public:
|
||||
[[nodiscard]] const std::string &getName() const {
|
||||
return name;
|
||||
}
|
||||
class PluginMetaInformation {
|
||||
public:
|
||||
[[nodiscard]] const std::string &getName() const {
|
||||
return name;
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::string &getAuthor() const {
|
||||
return this->author;
|
||||
}
|
||||
[[nodiscard]] const std::string &getAuthor() const {
|
||||
return this->author;
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::string &getVersion() const {
|
||||
return this->version;
|
||||
}
|
||||
[[nodiscard]] const std::string &getVersion() const {
|
||||
return this->version;
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::string &getLicense() const {
|
||||
return this->license;
|
||||
}
|
||||
[[nodiscard]] const std::string &getLicense() const {
|
||||
return this->license;
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::string &getBuildTimestamp() const {
|
||||
return this->buildtimestamp;
|
||||
}
|
||||
[[nodiscard]] const std::string &getBuildTimestamp() const {
|
||||
return this->buildtimestamp;
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::string &getDescription() const {
|
||||
return this->description;
|
||||
}
|
||||
[[nodiscard]] const std::string &getDescription() const {
|
||||
return this->description;
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::string &getStorageId() const {
|
||||
return this->storageId;
|
||||
}
|
||||
[[nodiscard]] const std::string &getStorageId() const {
|
||||
return this->storageId;
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t getSize() const {
|
||||
return this->size;
|
||||
}
|
||||
[[nodiscard]] size_t getSize() const {
|
||||
return this->size;
|
||||
}
|
||||
|
||||
PluginMetaInformation(std::string name,
|
||||
std::string author,
|
||||
std::string version,
|
||||
std::string license,
|
||||
std::string buildtimestamp,
|
||||
std::string description,
|
||||
std::string storageId,
|
||||
size_t size);
|
||||
PluginMetaInformation(std::string_view name,
|
||||
std::string_view author,
|
||||
std::string_view version,
|
||||
std::string_view license,
|
||||
std::string_view buildtimestamp,
|
||||
std::string_view description,
|
||||
std::string_view storageId,
|
||||
size_t size);
|
||||
|
||||
private:
|
||||
PluginMetaInformation() = default;
|
||||
private:
|
||||
PluginMetaInformation() = default;
|
||||
|
||||
void setName(std::string name_) {
|
||||
this->name = std::move(name_);
|
||||
}
|
||||
|
||||
void setAuthor(std::string author_) {
|
||||
this->author = std::move(author_);
|
||||
}
|
||||
|
||||
void setVersion(std::string version_) {
|
||||
this->version = std::move(version_);
|
||||
}
|
||||
|
||||
void setLicense(std::string license_) {
|
||||
this->license = std::move(license_);
|
||||
}
|
||||
|
||||
void setBuildTimestamp(std::string buildtimestamp_) {
|
||||
this->buildtimestamp = std::move(buildtimestamp_);
|
||||
}
|
||||
|
||||
void setDescription(std::string description_) {
|
||||
this->description = std::move(description_);
|
||||
}
|
||||
|
||||
void setStorageId(std::string storageId_) {
|
||||
this->storageId = std::move(storageId_);
|
||||
}
|
||||
|
||||
void setSize(size_t size_) {
|
||||
this->size = size_;
|
||||
}
|
||||
|
||||
std::string name;
|
||||
std::string author;
|
||||
std::string version;
|
||||
std::string license;
|
||||
std::string buildtimestamp;
|
||||
std::string description;
|
||||
std::string storageId;
|
||||
size_t size{};
|
||||
};
|
||||
std::string name;
|
||||
std::string author;
|
||||
std::string version;
|
||||
std::string license;
|
||||
std::string buildtimestamp;
|
||||
std::string description;
|
||||
std::string storageId;
|
||||
size_t size{};
|
||||
};
|
||||
} // namespace WUPSBackend
|
|
@ -21,18 +21,22 @@
|
|||
#include <optional>
|
||||
|
||||
namespace WUPSBackend {
|
||||
class PluginUtils {
|
||||
public:
|
||||
static std::optional<std::unique_ptr<PluginMetaInformation>> getMetaInformationForBuffer(char *buffer, size_t size);
|
||||
|
||||
static std::optional<std::unique_ptr<PluginMetaInformation>> getMetaInformationForPath(const std::string &path);
|
||||
const char *GetStatusStr(PluginBackendApiErrorType err);
|
||||
|
||||
static std::vector<std::unique_ptr<PluginContainer>> getLoadedPlugins(uint32_t maxSize);
|
||||
namespace PluginUtils {
|
||||
|
||||
static std::optional<std::unique_ptr<PluginContainer>> getPluginForPath(const std::string &path);
|
||||
std::optional<PluginMetaInformation> getMetaInformationForBuffer(char *buffer, size_t size, PluginBackendApiErrorType &err, PluginBackendPluginParseError &parseErr);
|
||||
|
||||
static std::optional<std::unique_ptr<PluginContainer>> getPluginForBuffer(char *buffer, size_t size);
|
||||
std::optional<PluginMetaInformation> getMetaInformationForPath(const std::string &path, PluginBackendApiErrorType &err, PluginBackendPluginParseError &parseErr);
|
||||
|
||||
static int32_t LoadAndLinkOnRestart(const std::vector<std::unique_ptr<PluginContainer>> &plugins);
|
||||
};
|
||||
std::vector<PluginContainer> getLoadedPlugins(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, PluginBackendPluginParseError &parseErr);
|
||||
|
||||
PluginBackendApiErrorType LoadAndLinkOnRestart(const std::vector<PluginContainer> &plugins);
|
||||
|
||||
} // namespace PluginUtils
|
||||
} // namespace WUPSBackend
|
|
@ -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,29 +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_LoadPluginAsData(GetPluginInformationInputType inputType, const char *path, char *buffer, size_t size, plugin_data_handle *out);
|
||||
PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByPath(wups_backend_plugin_data_handle *output, const char *path);
|
||||
|
||||
PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByPath(plugin_data_handle *output, const char *path);
|
||||
PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByBuffer(wups_backend_plugin_data_handle *output, char *buffer, size_t size);
|
||||
|
||||
PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByBuffer(plugin_data_handle *output, char *buffer, size_t size);
|
||||
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByPath(wups_backend_plugin_information *output, const char *path, PluginBackendPluginParseError *errOut);
|
||||
|
||||
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformation(GetPluginInformationInputType inputType, const char *path, char *buffer, size_t size, plugin_information *output);
|
||||
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByBuffer(wups_backend_plugin_information *output, char *buffer, size_t size, PluginBackendPluginParseError *errOut);
|
||||
|
||||
PluginBackendApiErrorType WUPSBackend_WUPSGetPluginMetaInformationByPath(plugin_information *output, const char *path);
|
||||
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_GetPluginMetaInformationByBuffer(plugin_information *output, char *buffer, size_t 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_GetPluginDataForContainerHandles(const plugin_container_handle *plugin_container_handle_list, const 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_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
|
||||
}
|
||||
|
|
|
@ -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 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,
|
||||
|
@ -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;
|
||||
|
|
|
@ -3,15 +3,14 @@
|
|||
|
||||
using namespace WUPSBackend;
|
||||
|
||||
|
||||
PluginContainer::PluginContainer(std::shared_ptr<PluginData> data, std::shared_ptr<PluginMetaInformation> metaInfo) : pluginData(std::move(data)),
|
||||
metaInformation(std::move(metaInfo)) {
|
||||
PluginContainer::PluginContainer(PluginData data, PluginMetaInformation metaInfo) : pluginData(std::move(data)),
|
||||
metaInformation(std::move(metaInfo)) {
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::shared_ptr<PluginMetaInformation> &PluginContainer::getMetaInformation() const {
|
||||
[[nodiscard]] const PluginMetaInformation &PluginContainer::getMetaInformation() const {
|
||||
return this->metaInformation;
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::shared_ptr<PluginData> &PluginContainer::getPluginData() const {
|
||||
[[nodiscard]] const PluginData &PluginContainer::getPluginData() const {
|
||||
return pluginData;
|
||||
}
|
||||
|
|
|
@ -16,20 +16,36 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "wups_backend/PluginData.h"
|
||||
#include "imports.h"
|
||||
#include "logger.h"
|
||||
#include "wups_backend/api.h"
|
||||
#include <coreinit/debug.h>
|
||||
|
||||
using namespace WUPSBackend;
|
||||
|
||||
PluginData::PluginData(uint32_t handle) {
|
||||
this->handle = handle;
|
||||
this->mHandle = handle;
|
||||
}
|
||||
|
||||
PluginData::PluginData(PluginData &&src) noexcept : mHandle(src.mHandle) {
|
||||
src.mHandle = {};
|
||||
}
|
||||
|
||||
PluginData::~PluginData() {
|
||||
if (handle != 0) {
|
||||
if (WUPSDeletePluginData(&handle, 1) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
if (mHandle != 0) {
|
||||
if (WUPSBackend_DeletePluginData(&mHandle, 1) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to delete plugin data");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PluginData &PluginData::operator=(PluginData &&src) noexcept {
|
||||
if (this != &src) {
|
||||
this->mHandle = src.mHandle;
|
||||
src.mHandle = {};
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
uint32_t PluginData::getHandle() const {
|
||||
return mHandle;
|
||||
}
|
||||
|
|
|
@ -22,20 +22,20 @@
|
|||
|
||||
using namespace WUPSBackend;
|
||||
|
||||
PluginMetaInformation::PluginMetaInformation(std::string name,
|
||||
std::string author,
|
||||
std::string version,
|
||||
std::string license,
|
||||
std::string buildtimestamp,
|
||||
std::string description,
|
||||
std::string storageId,
|
||||
PluginMetaInformation::PluginMetaInformation(std::string_view name,
|
||||
std::string_view author,
|
||||
std::string_view version,
|
||||
std::string_view license,
|
||||
std::string_view buildtimestamp,
|
||||
std::string_view description,
|
||||
std::string_view storageId,
|
||||
size_t size) {
|
||||
this->name = std::move(name);
|
||||
this->author = std::move(author);
|
||||
this->name = name;
|
||||
this->author = author;
|
||||
this->size = size;
|
||||
this->buildtimestamp = std::move(buildtimestamp);
|
||||
this->description = std::move(description);
|
||||
this->license = std::move(license);
|
||||
this->version = std::move(version);
|
||||
this->storageId = std::move(storageId);
|
||||
this->buildtimestamp = buildtimestamp;
|
||||
this->description = description;
|
||||
this->license = license;
|
||||
this->version = version;
|
||||
this->storageId = storageId;
|
||||
}
|
||||
|
|
|
@ -16,116 +16,98 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "wups_backend/PluginUtils.h"
|
||||
#include "imports.h"
|
||||
#include "logger.h"
|
||||
#include "utils.h"
|
||||
#include "wups_backend/api.h"
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
using namespace WUPSBackend;
|
||||
namespace WUPSBackend {
|
||||
|
||||
std::optional<std::unique_ptr<PluginMetaInformation>> getMetaInformation(const plugin_information &info) {
|
||||
if (info.plugin_information_version != PLUGIN_INFORMATION_VERSION) {
|
||||
const char *GetStatusStr(PluginBackendApiErrorType status) {
|
||||
return WUPSBackend_GetStatusStr(status);
|
||||
}
|
||||
|
||||
namespace PluginUtils {
|
||||
static std::optional<PluginMetaInformation> getMetaInformation(const wups_backend_plugin_information &info, PluginBackendApiErrorType &err) {
|
||||
if (info.plugin_information_version != WUPS_BACKEND_PLUGIN_INFORMATION_VERSION) {
|
||||
err = PLUGIN_BACKEND_API_ERROR_UNSUPPORTED_VERSION;
|
||||
DEBUG_FUNCTION_LINE_ERR("Version mismatch");
|
||||
return {};
|
||||
}
|
||||
auto res = make_unique_nothrow<PluginMetaInformation>(info.name,
|
||||
info.author,
|
||||
info.version,
|
||||
info.license,
|
||||
info.buildTimestamp,
|
||||
info.description,
|
||||
info.storageId,
|
||||
info.size);
|
||||
if (!res) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Not enough memory");
|
||||
return {};
|
||||
}
|
||||
return res;
|
||||
return PluginMetaInformation(info.name,
|
||||
info.author,
|
||||
info.version,
|
||||
info.license,
|
||||
info.buildTimestamp,
|
||||
info.description,
|
||||
info.storageId,
|
||||
info.size);
|
||||
}
|
||||
|
||||
std::optional<std::unique_ptr<PluginMetaInformation>> PluginUtils::getMetaInformationForBuffer(char *buffer, size_t size) {
|
||||
plugin_information info = {};
|
||||
if (WUPSGetPluginMetaInformationByBuffer(&info, buffer, size) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
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, &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);
|
||||
return getMetaInformation(info, err);
|
||||
}
|
||||
|
||||
std::optional<std::unique_ptr<PluginMetaInformation>> PluginUtils::getMetaInformationForPath(const std::string &path) {
|
||||
plugin_information info = {};
|
||||
if (WUPSGetPluginMetaInformationByPath(&info, path.c_str()) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
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(), &parseErr)) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to load meta infos for %s", path.c_str());
|
||||
return {};
|
||||
}
|
||||
|
||||
return getMetaInformation(info);
|
||||
return getMetaInformation(info, err);
|
||||
}
|
||||
|
||||
std::optional<std::unique_ptr<PluginContainer>> PluginUtils::getPluginForPath(const std::string &path) {
|
||||
auto metaInfoOpt = PluginUtils::getMetaInformationForPath(path);
|
||||
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 {};
|
||||
}
|
||||
|
||||
plugin_data_handle dataHandle;
|
||||
if (WUPSLoadPluginAsDataByPath(&dataHandle, path.c_str()) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
wups_backend_plugin_data_handle dataHandle;
|
||||
if ((err = WUPSBackend_LoadPluginAsDataByPath(&dataHandle, path.c_str())) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
DEBUG_FUNCTION_LINE_ERR("WUPSLoadPluginAsDataByPath failed for path %s", path.c_str());
|
||||
return {};
|
||||
}
|
||||
|
||||
auto pluginData = make_shared_nothrow<PluginData>(dataHandle);
|
||||
if (!pluginData) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to allocate PluginData");
|
||||
return {};
|
||||
}
|
||||
|
||||
auto pluginContainer = make_unique_nothrow<PluginContainer>(std::move(pluginData), std::move(metaInfoOpt.value()));
|
||||
if (!pluginContainer) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to allocate PluginContainer");
|
||||
return {};
|
||||
}
|
||||
|
||||
return pluginContainer;
|
||||
return PluginContainer(PluginData(dataHandle), std::move(metaInfoOpt.value()));
|
||||
}
|
||||
|
||||
std::optional<std::unique_ptr<PluginContainer>> PluginUtils::getPluginForBuffer(char *buffer, size_t size) {
|
||||
auto metaInfoOpt = PluginUtils::getMetaInformationForBuffer(buffer, size);
|
||||
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 {};
|
||||
}
|
||||
|
||||
plugin_data_handle dataHandle;
|
||||
if (WUPSLoadPluginAsDataByBuffer(&dataHandle, buffer, size) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
wups_backend_plugin_data_handle dataHandle;
|
||||
if ((err = WUPSBackend_LoadPluginAsDataByBuffer(&dataHandle, buffer, size)) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
DEBUG_FUNCTION_LINE_ERR("WUPSLoadPluginAsDataByBuffer failed for buffer %08X (%d bytes)", buffer, size);
|
||||
return {};
|
||||
}
|
||||
|
||||
auto pluginData = make_shared_nothrow<PluginData>(dataHandle);
|
||||
if (!pluginData) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to allocate PluginData");
|
||||
return {};
|
||||
}
|
||||
|
||||
auto pluginContainer = make_unique_nothrow<PluginContainer>(std::move(pluginData), std::move(metaInfoOpt.value()));
|
||||
if (!pluginContainer) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to allocate PluginContainer");
|
||||
return {};
|
||||
}
|
||||
|
||||
return pluginContainer;
|
||||
return PluginContainer(PluginData(dataHandle), std::move(metaInfoOpt.value()));
|
||||
}
|
||||
|
||||
std::vector<PluginContainer> getLoadedPlugins(PluginBackendApiErrorType &err) {
|
||||
std::vector<PluginContainer> result;
|
||||
|
||||
std::vector<std::unique_ptr<PluginContainer>> PluginUtils::getLoadedPlugins(uint32_t maxSize) {
|
||||
std::vector<std::unique_ptr<PluginContainer>> result;
|
||||
PluginBackendApiErrorType err2;
|
||||
uint32_t maxSize;
|
||||
if ((err2 = WUPSBackend_GetNumberOfLoadedPlugins(&maxSize)) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
DEBUG_FUNCTION_LINE_WARN("Failed to get number of loaded plugins: %s", WUPSBackend_GetStatusStr(err2));
|
||||
maxSize = 120;
|
||||
}
|
||||
|
||||
auto handles = make_unique_nothrow<plugin_container_handle[]>(maxSize);
|
||||
auto handles = make_unique_nothrow<wups_backend_plugin_container_handle[]>(maxSize);
|
||||
if (!handles) {
|
||||
err = PLUGIN_BACKEND_API_ERROR_FAILED_ALLOC;
|
||||
DEBUG_FUNCTION_LINE_ERR("Not enough memory");
|
||||
return result;
|
||||
}
|
||||
|
@ -136,87 +118,76 @@ std::vector<std::unique_ptr<PluginContainer>> PluginUtils::getLoadedPlugins(uint
|
|||
}
|
||||
|
||||
uint32_t plugin_information_version = 0;
|
||||
|
||||
if (WUPSGetLoadedPlugins(handles.get(), maxSize, &realSize, &plugin_information_version) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
if ((err = WUPSBackend_GetLoadedPlugins(handles.get(), maxSize, &realSize, &plugin_information_version)) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
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) {
|
||||
err = PLUGIN_BACKEND_API_ERROR_UNSUPPORTED_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) {
|
||||
err = PLUGIN_BACKEND_API_ERROR_FAILED_ALLOC;
|
||||
DEBUG_FUNCTION_LINE_ERR("Not enough memory");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (WUPSGetPluginDataForContainerHandles(handles.get(), dataHandles.get(), realSize) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
if ((err = WUPSBackend_GetPluginDataForContainerHandles(handles.get(), dataHandles.get(), realSize)) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to get plugin data");
|
||||
return result;
|
||||
}
|
||||
|
||||
auto information = make_unique_nothrow<plugin_information[]>(realSize);
|
||||
auto information = make_unique_nothrow<wups_backend_plugin_information[]>(realSize);
|
||||
if (!information) {
|
||||
err = PLUGIN_BACKEND_API_ERROR_FAILED_ALLOC;
|
||||
DEBUG_FUNCTION_LINE_ERR("Not enough memory");
|
||||
return result;
|
||||
}
|
||||
if (WUPSGetMetaInformation(handles.get(), information.get(), realSize) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
if ((err = WUPSBackend_GetMetaInformation(handles.get(), information.get(), realSize)) != PLUGIN_BACKEND_API_ERROR_NONE) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to get meta information for handles");
|
||||
return result;
|
||||
}
|
||||
|
||||
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) {
|
||||
err = PLUGIN_BACKEND_API_ERROR_UNSUPPORTED_VERSION;
|
||||
DEBUG_FUNCTION_LINE_ERR("Skip, wrong struct version.");
|
||||
continue;
|
||||
return {};
|
||||
}
|
||||
auto metaInfo = make_shared_nothrow<PluginMetaInformation>(information[i].name,
|
||||
information[i].author,
|
||||
information[i].version,
|
||||
information[i].license,
|
||||
information[i].buildTimestamp,
|
||||
information[i].description,
|
||||
information[i].storageId,
|
||||
information[i].size);
|
||||
|
||||
if (!metaInfo) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Skip, failed to allocate MetaInformation");
|
||||
continue;
|
||||
}
|
||||
|
||||
auto pluginData = std::make_shared<PluginData>((uint32_t) dataHandles[i]);
|
||||
if (!pluginData) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Skip, failed to allocate PluginData");
|
||||
continue;
|
||||
}
|
||||
|
||||
auto pluginContainer = make_unique_nothrow<PluginContainer>(std::move(pluginData), std::move(metaInfo));
|
||||
if (!pluginContainer) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Skip, failed to allocate PluginContainer");
|
||||
continue;
|
||||
}
|
||||
|
||||
result.push_back(std::move(pluginContainer));
|
||||
result.emplace_back(PluginData(dataHandles[i]), PluginMetaInformation(information[i].name,
|
||||
information[i].author,
|
||||
information[i].version,
|
||||
information[i].license,
|
||||
information[i].buildTimestamp,
|
||||
information[i].description,
|
||||
information[i].storageId,
|
||||
information[i].size));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t PluginUtils::LoadAndLinkOnRestart(const std::vector<std::unique_ptr<PluginContainer>> &plugins) {
|
||||
PluginBackendApiErrorType LoadAndLinkOnRestart(const std::vector<PluginContainer> &plugins) {
|
||||
uint32_t dataSize = plugins.size();
|
||||
plugin_data_handle handles[dataSize];
|
||||
auto handles = make_unique_nothrow<wups_backend_plugin_data_handle[]>(dataSize);
|
||||
if (!handles) {
|
||||
return PLUGIN_BACKEND_API_ERROR_FAILED_ALLOC;
|
||||
}
|
||||
int i = 0;
|
||||
for (auto &plugin : plugins) {
|
||||
plugin_data_handle handle = plugin->getPluginData()->getHandle();
|
||||
for (const auto &plugin : plugins) {
|
||||
const auto &handle = plugin.getPluginData().getHandle();
|
||||
if (handle == 0) {
|
||||
dataSize--;
|
||||
return PLUGIN_BACKEND_API_INVALID_HANDLE;
|
||||
} else {
|
||||
handles[i] = handle;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return WUPSLoadAndLinkByDataHandle(handles, dataSize);
|
||||
return WUPSBackend_LoadAndLinkByDataHandle(handles.get(), dataSize);
|
||||
}
|
||||
} // namespace PluginUtils
|
||||
} // namespace WUPSBackend
|
103
source/api.cpp
103
source/api.cpp
|
@ -9,16 +9,23 @@ 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 (*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;
|
||||
|
@ -118,7 +135,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 +180,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;
|
||||
}
|
||||
|
@ -178,46 +195,78 @@ PluginBackendApiErrorType WUPSBackend_GetSectionMemoryAddresses(plugin_container
|
|||
return reinterpret_cast<decltype(&WUPSBackend_GetSectionMemoryAddresses)>(sWUPSGetSectionMemoryAddresses)(handle, textAddress, dataAddress);
|
||||
}
|
||||
|
||||
PluginBackendApiErrorType WUPSBackend_LoadAndLinkByDataHandle(const plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size) {
|
||||
#define PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED() \
|
||||
do { \
|
||||
if (sWUPSAPIVersion == WUPS_BACKEND_MODULE_API_VERSION_ERROR) { DEBUG_FUNCTION_LINE_WARN("libwupsbackend is not initialized, please make sure to call WUPSBackend_InitLibrary"); } \
|
||||
} while (0)
|
||||
|
||||
|
||||
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_LoadPluginAsData(GetPluginInformationInputType inputType, const char *path, char *buffer, size_t size, plugin_data_handle *out) {
|
||||
return WUPSLoadPluginAsData(inputType, path, buffer, size, out);
|
||||
}
|
||||
|
||||
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_GetPluginMetaInformation(GetPluginInformationInputType inputType, const char *path, char *buffer, size_t size, plugin_information *output) {
|
||||
return WUPSGetPluginMetaInformation(inputType, path, buffer, size, output);
|
||||
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_WUPSGetPluginMetaInformationByPath(plugin_information *output, const char *path) {
|
||||
return WUPSGetPluginMetaInformationByPath(output, path);
|
||||
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_GetPluginMetaInformationByBuffer(plugin_information *output, char *buffer, size_t size) {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -23,27 +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 WUPSLoadPluginAsData(GetPluginInformationInputType inputType, const char *path, char *buffer, size_t size, plugin_data_handle *out);
|
||||
extern PluginBackendApiErrorType WUPSLoadPluginAsDataByPath(wups_backend_plugin_data_handle *output, const char *path);
|
||||
|
||||
extern PluginBackendApiErrorType WUPSLoadPluginAsDataByPath(plugin_data_handle *output, const char *path);
|
||||
extern PluginBackendApiErrorType WUPSLoadPluginAsDataByBuffer(wups_backend_plugin_data_handle *output, char *buffer, size_t size);
|
||||
|
||||
extern PluginBackendApiErrorType WUPSLoadPluginAsDataByBuffer(plugin_data_handle *output, char *buffer, size_t size);
|
||||
extern PluginBackendApiErrorType WUPSGetPluginMetaInformationByPath(wups_backend_plugin_information *output, const char *path);
|
||||
|
||||
extern PluginBackendApiErrorType WUPSGetPluginMetaInformation(GetPluginInformationInputType inputType, const char *path, char *buffer, size_t size, plugin_information *output);
|
||||
extern PluginBackendApiErrorType WUPSGetPluginMetaInformationByBuffer(wups_backend_plugin_information *output, char *buffer, size_t size);
|
||||
|
||||
extern PluginBackendApiErrorType WUPSGetPluginMetaInformationByPath(plugin_information *output, const char *path);
|
||||
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 WUPSGetPluginMetaInformationByBuffer(plugin_information *output, char *buffer, size_t 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 WUPSGetPluginDataForContainerHandles(const plugin_container_handle *plugin_container_handle_list, const 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 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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue