Remove unnecessary std::unique_ptr usages

This commit is contained in:
Maschell 2024-03-24 07:40:58 +01:00
parent b8647b94fc
commit 7d07f6525b
21 changed files with 244 additions and 229 deletions

View File

@ -12,9 +12,9 @@
#include <memory.h>
#include <memory>
std::vector<std::unique_ptr<PluginContainer>>
std::vector<PluginContainer>
PluginManagement::loadPlugins(const std::set<std::shared_ptr<PluginData>> &pluginDataList, std::vector<relocation_trampoline_entry_t> &trampolineData) {
std::vector<std::unique_ptr<PluginContainer>> plugins;
std::vector<PluginContainer> plugins;
uint32_t trampolineID = 0;
for (const auto &pluginData : pluginDataList) {
@ -29,13 +29,7 @@ PluginManagement::loadPlugins(const std::set<std::shared_ptr<PluginData>> &plugi
DisplayErrorNotificationMessage(errMsg, 15.0f);
continue;
}
std::string nameCpy = metaInfo->getName();
auto container = make_unique_nothrow<PluginContainer>(std::move(metaInfo), std::move(info), pluginData);
if (!container) {
DEBUG_FUNCTION_LINE_ERR("Failed to create PluginContainer, skipping %s", nameCpy.c_str());
continue;
}
plugins.push_back(std::move(container));
plugins.emplace_back(std::move(*metaInfo), std::move(*info), pluginData);
} else {
auto errMsg = string_format("Failed to load plugin: %s", pluginData->getSource().c_str());
if (error == PLUGIN_PARSE_ERROR_INCOMPATIBLE_VERSION) {
@ -54,13 +48,13 @@ PluginManagement::loadPlugins(const std::set<std::shared_ptr<PluginData>> &plugi
return plugins;
}
bool PluginManagement::doRelocation(const std::vector<std::unique_ptr<RelocationData>> &relocData,
bool PluginManagement::doRelocation(const std::vector<RelocationData> &relocData,
std::vector<relocation_trampoline_entry_t> &trampData,
uint32_t trampolineID,
std::map<std::string, OSDynLoad_Module> &usedRPls) {
for (auto const &cur : relocData) {
uint32_t functionAddress = 0;
auto &functionName = cur->getName();
auto &functionName = cur.getName();
if (functionName == "MEMAllocFromDefaultHeap") {
OSDynLoad_Module rplHandle;
@ -77,8 +71,8 @@ bool PluginManagement::doRelocation(const std::vector<std::unique_ptr<Relocation
}
if (functionAddress == 0) {
auto rplName = cur->getImportRPLInformation().getRPLName();
int32_t isData = cur->getImportRPLInformation().isData();
auto rplName = cur.getImportRPLInformation().getRPLName();
int32_t isData = cur.getImportRPLInformation().isData();
OSDynLoad_Module rplHandle = nullptr;
if (!usedRPls.contains(rplName)) {
@ -106,7 +100,7 @@ bool PluginManagement::doRelocation(const std::vector<std::unique_ptr<Relocation
//DEBUG_FUNCTION_LINE("Found export for %s %s", rplName.c_str(), functionName.c_str());
}
if (!ElfUtils::elfLinkOne(cur->getType(), cur->getOffset(), cur->getAddend(), (uint32_t) cur->getDestination(), functionAddress, trampData, RELOC_TYPE_IMPORT, trampolineID)) {
if (!ElfUtils::elfLinkOne(cur.getType(), cur.getOffset(), cur.getAddend(), (uint32_t) cur.getDestination(), functionAddress, trampData, RELOC_TYPE_IMPORT, trampolineID)) {
DEBUG_FUNCTION_LINE_ERR("elfLinkOne failed");
return false;
}
@ -127,7 +121,7 @@ bool PluginManagement::doRelocation(const std::vector<std::unique_ptr<Relocation
return true;
}
bool PluginManagement::doRelocations(const std::vector<std::unique_ptr<PluginContainer>> &plugins,
bool PluginManagement::doRelocations(const std::vector<PluginContainer> &plugins,
std::vector<relocation_trampoline_entry_t> &trampData,
std::map<std::string, OSDynLoad_Module> &usedRPls) {
for (auto &cur : trampData) {
@ -143,10 +137,10 @@ bool PluginManagement::doRelocations(const std::vector<std::unique_ptr<PluginCon
OSDynLoad_SetAllocator(CustomDynLoadAlloc, CustomDynLoadFree);
for (const auto &pluginContainer : plugins) {
DEBUG_FUNCTION_LINE_VERBOSE("Doing relocations for plugin: %s", pluginContainer->getMetaInformation().getName().c_str());
if (!PluginManagement::doRelocation(pluginContainer->getPluginInformation().getRelocationDataList(),
DEBUG_FUNCTION_LINE_VERBOSE("Doing relocations for plugin: %s", pluginContainer.getMetaInformation().getName().c_str());
if (!PluginManagement::doRelocation(pluginContainer.getPluginInformation().getRelocationDataList(),
trampData,
pluginContainer->getPluginInformation().getTrampolineId(),
pluginContainer.getPluginInformation().getTrampolineId(),
usedRPls)) {
return false;
}
@ -157,10 +151,10 @@ bool PluginManagement::doRelocations(const std::vector<std::unique_ptr<PluginCon
return true;
}
bool PluginManagement::RestoreFunctionPatches(const std::vector<std::unique_ptr<PluginContainer>> &plugins) {
for (const auto &cur : std::ranges::reverse_view(plugins)) {
for (const auto &curFunction : std::ranges::reverse_view(cur->getPluginInformation().getFunctionDataList())) {
if (!curFunction->RemovePatch()) {
bool PluginManagement::RestoreFunctionPatches(std::vector<PluginContainer> &plugins) {
for (auto &cur : std::ranges::reverse_view(plugins)) {
for (auto &curFunction : std::ranges::reverse_view(cur.getPluginInformation().getFunctionDataList())) {
if (!curFunction.RemovePatch()) {
return false;
}
}
@ -168,11 +162,11 @@ bool PluginManagement::RestoreFunctionPatches(const std::vector<std::unique_ptr<
return true;
}
bool PluginManagement::DoFunctionPatches(const std::vector<std::unique_ptr<PluginContainer>> &plugins) {
for (const auto &cur : plugins) {
for (const auto &curFunction : cur->getPluginInformation().getFunctionDataList()) {
if (!curFunction->AddPatch()) {
DEBUG_FUNCTION_LINE_ERR("Failed to add function patch for: plugin %s", cur->getMetaInformation().getName().c_str());
bool PluginManagement::DoFunctionPatches(std::vector<PluginContainer> &plugins) {
for (auto &cur : plugins) {
for (auto &curFunction : cur.getPluginInformation().getFunctionDataList()) {
if (!curFunction.AddPatch()) {
DEBUG_FUNCTION_LINE_ERR("Failed to add function patch for: plugin %s", cur.getMetaInformation().getName().c_str());
return false;
}
}
@ -180,7 +174,7 @@ bool PluginManagement::DoFunctionPatches(const std::vector<std::unique_ptr<Plugi
return true;
}
void PluginManagement::callInitHooks(const std::vector<std::unique_ptr<PluginContainer>> &plugins) {
void PluginManagement::callInitHooks(const std::vector<PluginContainer> &plugins) {
CallHook(plugins, WUPS_LOADER_HOOK_INIT_CONFIG);
CallHook(plugins, WUPS_LOADER_HOOK_INIT_STORAGE_DEPRECATED);
CallHook(plugins, WUPS_LOADER_HOOK_INIT_STORAGE);

View File

@ -9,22 +9,22 @@
class PluginManagement {
public:
static std::vector<std::unique_ptr<PluginContainer>> loadPlugins(
static std::vector<PluginContainer> loadPlugins(
const std::set<std::shared_ptr<PluginData>> &pluginDataList,
std::vector<relocation_trampoline_entry_t> &trampolineData);
static void callInitHooks(const std::vector<std::unique_ptr<PluginContainer>> &plugins);
static void callInitHooks(const std::vector<PluginContainer> &plugins);
static bool doRelocations(const std::vector<std::unique_ptr<PluginContainer>> &plugins,
static bool doRelocations(const std::vector<PluginContainer> &plugins,
std::vector<relocation_trampoline_entry_t> &trampData,
std::map<std::string, OSDynLoad_Module> &usedRPls);
static bool doRelocation(const std::vector<std::unique_ptr<RelocationData>> &relocData,
static bool doRelocation(const std::vector<RelocationData> &relocData,
std::vector<relocation_trampoline_entry_t> &trampData,
uint32_t trampolineID,
std::map<std::string, OSDynLoad_Module> &usedRPls);
static bool DoFunctionPatches(const std::vector<std::unique_ptr<PluginContainer>> &plugins);
static bool DoFunctionPatches(std::vector<PluginContainer> &plugins);
static bool RestoreFunctionPatches(const std::vector<std::unique_ptr<PluginContainer>> &plugins);
static bool RestoreFunctionPatches(std::vector<PluginContainer> &plugins);
};

View File

@ -140,7 +140,7 @@ namespace WUPSConfigAPIBackend {
return WUPSCONFIG_API_RESULT_INVALID_ARGUMENT;
}
for (auto &cur : gLoadedPlugins) {
if (cur->getHandle() == pluginIdentifier) {
if (cur.getHandle() == pluginIdentifier) {
if (options.version != 1) {
return WUPSCONFIG_API_RESULT_UNSUPPORTED_VERSION;
}
@ -149,7 +149,7 @@ namespace WUPSConfigAPIBackend {
DEBUG_FUNCTION_LINE_WARN("Failed to create config data for %08X", pluginIdentifier);
return WUPSCONFIG_API_RESULT_UNSUPPORTED_VERSION;
}
cur->setConfigData(configDat.value());
cur.setConfigData(configDat.value());
return WUPSCONFIG_API_RESULT_SUCCESS;
}
}

View File

@ -3,7 +3,7 @@
StoredBuffer gStoredTVBuffer = {};
StoredBuffer gStoredDRCBuffer = {};
std::vector<std::unique_ptr<PluginContainer>> gLoadedPlugins;
std::vector<PluginContainer> gLoadedPlugins;
std::vector<relocation_trampoline_entry_t> gTrampData;
std::set<std::shared_ptr<PluginData>> gLoadedData;

View File

@ -17,7 +17,7 @@ extern StoredBuffer gStoredDRCBuffer;
#define TRAMP_DATA_SIZE 1024
extern std::vector<relocation_trampoline_entry_t> gTrampData;
extern std::vector<std::unique_ptr<PluginContainer>> gLoadedPlugins;
extern std::vector<PluginContainer> gLoadedPlugins;
extern std::set<std::shared_ptr<PluginData>> gLoadedData;
extern std::set<std::shared_ptr<PluginData>> gLoadOnNextLaunch;

View File

@ -35,18 +35,18 @@ static const char **hook_names = (const char *[]){
"WUPS_LOADER_HOOK_INIT_STORAGE",
"WUPS_LOADER_HOOK_INIT_CONFIG"};
void CallHook(const std::vector<std::unique_ptr<PluginContainer>> &plugins, wups_loader_hook_type_t hook_type) {
void CallHook(const std::vector<PluginContainer> &plugins, wups_loader_hook_type_t hook_type) {
DEBUG_FUNCTION_LINE_VERBOSE("Calling hook of type %s [%d]", hook_names[hook_type], hook_type);
for (const auto &plugin : plugins) {
CallHook(*plugin, hook_type);
CallHook(plugin, hook_type);
}
}
void CallHook(const PluginContainer &plugin, wups_loader_hook_type_t hook_type) {
for (const auto &hook : plugin.getPluginInformation().getHookDataList()) {
if (hook->getType() == hook_type) {
DEBUG_FUNCTION_LINE_VERBOSE("Calling hook of type %s for plugin %s [%d]", hook_names[hook->getType()], plugin.getMetaInformation().getName().c_str(), hook_type);
void *func_ptr = hook->getFunctionPointer();
if (hook.getType() == hook_type) {
DEBUG_FUNCTION_LINE_VERBOSE("Calling hook of type %s for plugin %s [%d]", hook_names[hook.getType()], plugin.getMetaInformation().getName().c_str(), hook_type);
void *func_ptr = hook.getFunctionPointer();
if (func_ptr != nullptr) {
switch (hook_type) {
case WUPS_LOADER_HOOK_INIT_WUT_MALLOC:

View File

@ -5,6 +5,6 @@
#include <vector>
#include <wups/hooks.h>
void CallHook(const std::vector<std::unique_ptr<PluginContainer>> &plugins, wups_loader_hook_type_t hook_type);
void CallHook(const std::vector<PluginContainer> &plugins, wups_loader_hook_type_t hook_type);
void CallHook(const PluginContainer &plugin, wups_loader_hook_type_t hook_type);

View File

@ -67,7 +67,7 @@ WUMS_APPLICATION_ENDS() {
deinitLogging();
}
void CheckCleanupCallbackUsage(const std::vector<std::unique_ptr<PluginContainer>> &plugins);
void CheckCleanupCallbackUsage(const std::vector<PluginContainer> &plugins);
WUMS_APPLICATION_STARTS() {
uint32_t upid = OSGetUPID();
@ -132,9 +132,9 @@ WUMS_APPLICATION_STARTS() {
PluginManagement::RestoreFunctionPatches(gLoadedPlugins);
for (auto &plugin : gLoadedPlugins) {
WUPSStorageError err = plugin->CloseStorage();
WUPSStorageError err = plugin.CloseStorage();
if (err != WUPS_STORAGE_ERROR_SUCCESS) {
DEBUG_FUNCTION_LINE_ERR("Failed to close storage for plugin: %s", plugin->getMetaInformation().getName().c_str());
DEBUG_FUNCTION_LINE_ERR("Failed to close storage for plugin: %s", plugin.getMetaInformation().getName().c_str());
}
}
@ -174,9 +174,9 @@ WUMS_APPLICATION_STARTS() {
if (initNeeded) {
for (auto &plugin : gLoadedPlugins) {
WUPSStorageError err = plugin->OpenStorage();
WUPSStorageError err = plugin.OpenStorage();
if (err != WUPS_STORAGE_ERROR_SUCCESS) {
DEBUG_FUNCTION_LINE_ERR("Failed to open storage for plugin: %s. (%s)", plugin->getMetaInformation().getName().c_str(), WUPSStorageAPI_GetStatusStr(err));
DEBUG_FUNCTION_LINE_ERR("Failed to open storage for plugin: %s. (%s)", plugin.getMetaInformation().getName().c_str(), WUPSStorageAPI_GetStatusStr(err));
}
}
PluginManagement::callInitHooks(gLoadedPlugins);
@ -186,16 +186,16 @@ WUMS_APPLICATION_STARTS() {
}
}
void CheckCleanupCallbackUsage(const std::vector<std::unique_ptr<PluginContainer>> &plugins) {
void CheckCleanupCallbackUsage(const std::vector<PluginContainer> &plugins) {
auto *curThread = OSGetCurrentThread();
for (const auto &cur : plugins) {
auto textSection = cur->getPluginInformation().getSectionInfo(".text");
auto textSection = cur.getPluginInformation().getSectionInfo(".text");
if (!textSection) {
continue;
}
uint32_t startAddress = textSection->getAddress();
uint32_t endAddress = textSection->getAddress() + textSection->getSize();
auto *pluginName = cur->getMetaInformation().getName().c_str();
auto *pluginName = cur.getMetaInformation().getName().c_str();
{
__OSLockScheduler(curThread);
int state = OSDisableInterrupts();

View File

@ -121,7 +121,7 @@ DECL_FUNCTION(uint32_t, SC17_FindClosestSymbol,
char *moduleNameBuffer,
uint32_t moduleNameBufferLength) {
for (const auto &plugin : gLoadedPlugins) {
auto sectionInfo = plugin->getPluginInformation().getSectionInfo(".text");
const auto sectionInfo = plugin.getPluginInformation().getSectionInfo(".text");
if (!sectionInfo) {
continue;
}
@ -130,8 +130,8 @@ DECL_FUNCTION(uint32_t, SC17_FindClosestSymbol,
continue;
}
strncpy(moduleNameBuffer, plugin->getMetaInformation().getName().c_str(), moduleNameBufferLength - 1);
auto functionSymbolData = plugin->getPluginInformation().getNearestFunctionSymbolData(addr);
strncpy(moduleNameBuffer, plugin.getMetaInformation().getName().c_str(), moduleNameBufferLength - 1);
auto functionSymbolData = plugin.getPluginInformation().getNearestFunctionSymbolData(addr);
if (functionSymbolData) {
strncpy(symbolNameBuffer, functionSymbolData->getName().c_str(), moduleNameBufferLength - 1);
if (outDistance) {
@ -154,7 +154,7 @@ DECL_FUNCTION(uint32_t, SC17_FindClosestSymbol,
DECL_FUNCTION(uint32_t, KiGetAppSymbolName, uint32_t addr, char *buffer, int32_t bufSize) {
for (const auto &plugin : gLoadedPlugins) {
auto sectionInfo = plugin->getPluginInformation().getSectionInfo(".text");
const auto sectionInfo = plugin.getPluginInformation().getSectionInfo(".text");
if (!sectionInfo) {
continue;
}
@ -163,14 +163,14 @@ DECL_FUNCTION(uint32_t, KiGetAppSymbolName, uint32_t addr, char *buffer, int32_t
continue;
}
auto pluginNameLen = strlen(plugin->getMetaInformation().getName().c_str());
auto pluginNameLen = strlen(plugin.getMetaInformation().getName().c_str());
int32_t spaceLeftInBuffer = (int32_t) bufSize - (int32_t) pluginNameLen - 1;
if (spaceLeftInBuffer < 0) {
spaceLeftInBuffer = 0;
}
strncpy(buffer, plugin->getMetaInformation().getName().c_str(), bufSize - 1);
strncpy(buffer, plugin.getMetaInformation().getName().c_str(), bufSize - 1);
auto functionSymbolData = plugin->getPluginInformation().getNearestFunctionSymbolData(addr);
const auto functionSymbolData = plugin.getPluginInformation().getNearestFunctionSymbolData(addr);
if (functionSymbolData) {
buffer[pluginNameLen] = '|';
buffer[pluginNameLen + 1] = '\0';

View File

@ -14,7 +14,7 @@ public:
mClosedCallback(closedCallback) {
}
std::optional<WUPSConfigHandle> createConfig() {
[[nodiscard]] std::optional<WUPSConfigHandle> createConfig() const{
WUPSConfigHandle handle;
if (WUPSConfigAPIBackend::Intern::CreateConfig(mName.c_str(), &handle) == WUPSCONFIG_API_RESULT_SUCCESS) {
return handle;
@ -22,7 +22,7 @@ public:
return std::nullopt;
}
WUPSConfigAPIStatus CallMenuOpenendCallback(WUPSConfigHandle config) {
[[nodiscard]] WUPSConfigAPIStatus CallMenuOpenendCallback(WUPSConfigHandle config) const {
if (mOpenedCallback == nullptr) {
return WUPSCONFIG_API_RESULT_MISSING_CALLBACK;
}
@ -32,7 +32,7 @@ public:
return WUPSCONFIG_API_RESULT_SUCCESS;
}
WUPSConfigAPIStatus CallMenuClosedCallback() {
[[nodiscard]] WUPSConfigAPIStatus CallMenuClosedCallback() const {
if (mClosedCallback == nullptr) {
return WUPSCONFIG_API_RESULT_MISSING_CALLBACK;
}

View File

@ -28,18 +28,49 @@
class PluginContainer {
public:
PluginContainer(std::unique_ptr<PluginMetaInformation> metaInformation, std::unique_ptr<PluginInformation> pluginInformation, std::shared_ptr<PluginData> pluginData)
PluginContainer(PluginMetaInformation metaInformation, PluginInformation pluginInformation, std::shared_ptr<PluginData> pluginData)
: mMetaInformation(std::move(metaInformation)),
mPluginInformation(std::move(pluginInformation)),
mPluginData(std::move(pluginData)) {
}
PluginContainer(const PluginContainer &) = delete;
PluginContainer(PluginContainer &&src) : mMetaInformation(std::move(src.mMetaInformation)),
mPluginInformation(std::move(src.mPluginInformation)),
mPluginData(std::move(src.mPluginData)),
mPluginConfigData(std::move(src.mPluginConfigData)),
storageRootItem(src.storageRootItem)
{
src.storageRootItem = {};
}
PluginContainer &operator=(PluginContainer &&src) {
if (this != &src) {
this->mMetaInformation = src.mMetaInformation;
this->mPluginInformation = std::move(src.mPluginInformation);
this->mPluginData = std::move(src.mPluginData);
this->mPluginConfigData = std::move(src.mPluginConfigData);
this->storageRootItem = src.storageRootItem;
storageRootItem = nullptr;
}
return *this;
}
[[nodiscard]] const PluginMetaInformation &getMetaInformation() const {
return *this->mMetaInformation;
return this->mMetaInformation;
}
[[nodiscard]] const PluginInformation &getPluginInformation() const {
return *this->mPluginInformation;
return this->mPluginInformation;
}
[[nodiscard]] PluginInformation &getPluginInformation() {
return this->mPluginInformation;
}
[[nodiscard]] std::shared_ptr<PluginData> getPluginDataCopy() const {
@ -88,9 +119,9 @@ public:
}
private:
const std::unique_ptr<PluginMetaInformation> mMetaInformation;
const std::unique_ptr<PluginInformation> mPluginInformation;
const std::shared_ptr<PluginData> mPluginData;
PluginMetaInformation mMetaInformation;
PluginInformation mPluginInformation;
std::shared_ptr<PluginData> mPluginData;
std::optional<PluginConfigData> mPluginConfigData;
wups_storage_root_item storageRootItem = nullptr;

View File

@ -34,53 +34,89 @@
#include <vector>
struct FunctionSymbolDataComparator {
bool operator()(const std::unique_ptr<FunctionSymbolData> &lhs,
const std::unique_ptr<FunctionSymbolData> &rhs) const {
return *lhs < *rhs;
bool operator()(const FunctionSymbolData &lhs,
const FunctionSymbolData &rhs) const {
return lhs < rhs;
}
};
class PluginInformation {
public:
void addHookData(std::unique_ptr<HookData> hook_data) {
mHookDataList.push_back(std::move(hook_data));
PluginInformation(const PluginInformation &) = delete;
PluginInformation(PluginInformation &&src) : mHookDataList(std::move(src.mHookDataList)),
mFunctionDataList(std::move(src.mFunctionDataList)),
mRelocationDataList(std::move(src.mRelocationDataList)),
mSymbolDataList(std::move(src.mSymbolDataList)),
mSectionInfoList(std::move(src.mSectionInfoList)),
mTrampolineId(src.mTrampolineId),
mAllocatedTextMemoryAddress(std::move(src.mAllocatedTextMemoryAddress)),
mAllocatedDataMemoryAddress(std::move(src.mAllocatedDataMemoryAddress))
{
src.mTrampolineId = {};
}
[[nodiscard]] const std::vector<std::unique_ptr<HookData>> &getHookDataList() const {
PluginInformation &operator=(PluginInformation &&src) {
if (this != &src) {
this->mHookDataList = std::move(src.mHookDataList);
this->mFunctionDataList = std::move(src.mFunctionDataList);
this->mRelocationDataList = std::move(src.mRelocationDataList);
this->mSymbolDataList = std::move(src.mSymbolDataList);
this->mSectionInfoList = std::move(src.mSectionInfoList);
this->mTrampolineId = src.mTrampolineId;
this->mAllocatedTextMemoryAddress = std::move(src.mAllocatedTextMemoryAddress);
this->mAllocatedDataMemoryAddress = std::move(src.mAllocatedDataMemoryAddress);
src.mTrampolineId = {};
}
return *this;
}
void addHookData(HookData hook_data) {
mHookDataList.push_back(hook_data);
}
[[nodiscard]] const std::vector<HookData> &getHookDataList() const {
return mHookDataList;
}
void addFunctionData(std::unique_ptr<FunctionData> function_data) {
void addFunctionData(FunctionData function_data) {
mFunctionDataList.push_back(std::move(function_data));
}
[[nodiscard]] const std::vector<std::unique_ptr<FunctionData>> &getFunctionDataList() const {
[[nodiscard]] const std::vector<FunctionData> &getFunctionDataList() const {
return mFunctionDataList;
}
void addRelocationData(std::unique_ptr<RelocationData> relocation_data) {
[[nodiscard]] std::vector<FunctionData> &getFunctionDataList() {
return mFunctionDataList;
}
void addRelocationData(RelocationData relocation_data) {
mRelocationDataList.push_back(std::move(relocation_data));
}
[[nodiscard]] const std::vector<std::unique_ptr<RelocationData>> &getRelocationDataList() const {
[[nodiscard]] const std::vector<RelocationData> &getRelocationDataList() const {
return mRelocationDataList;
}
void addFunctionSymbolData(std::unique_ptr<FunctionSymbolData> symbol_data) {
mSymbolDataList.insert(std::move(symbol_data));
void addFunctionSymbolData(const FunctionSymbolData &symbol_data) {
mSymbolDataList.insert(symbol_data);
}
void addSectionInfo(std::unique_ptr<SectionInfo> sectionInfo) {
mSectionInfoList[sectionInfo->getName()] = std::move(sectionInfo);
void addSectionInfo(const SectionInfo &sectionInfo) {
mSectionInfoList.insert(std::pair(sectionInfo.getName(), sectionInfo));
}
[[nodiscard]] const std::map<std::string, std::unique_ptr<SectionInfo>> &getSectionInfoList() const {
[[nodiscard]] const std::map<std::string, SectionInfo> &getSectionInfoList() const {
return mSectionInfoList;
}
[[nodiscard]] std::optional<SectionInfo> getSectionInfo(const std::string &sectionName) const {
if (getSectionInfoList().contains(sectionName)) {
return *mSectionInfoList.at(sectionName);
return mSectionInfoList.at(sectionName);
}
return std::nullopt;
}
@ -93,16 +129,16 @@ public:
return mTrampolineId;
}
[[nodiscard]] FunctionSymbolData *getNearestFunctionSymbolData(uint32_t address) const {
FunctionSymbolData *result = nullptr;
[[nodiscard]] const FunctionSymbolData *getNearestFunctionSymbolData(uint32_t address) const {
const FunctionSymbolData *result = nullptr;
bool foundHit = false;
for (auto &cur : mSymbolDataList) {
if (foundHit && address < (uint32_t) cur->getAddress()) {
if (foundHit && address < (uint32_t) cur.getAddress()) {
break;
}
if (address >= (uint32_t) cur->getAddress()) {
result = cur.get();
if (address >= (uint32_t) cur.getAddress()) {
result = &cur;
foundHit = true;
}
}
@ -122,11 +158,14 @@ public:
}
private:
std::vector<std::unique_ptr<HookData>> mHookDataList;
std::vector<std::unique_ptr<FunctionData>> mFunctionDataList;
std::vector<std::unique_ptr<RelocationData>> mRelocationDataList;
std::set<std::unique_ptr<FunctionSymbolData>, FunctionSymbolDataComparator> mSymbolDataList;
std::map<std::string, std::unique_ptr<SectionInfo>> mSectionInfoList;
PluginInformation(){
}
std::vector<HookData> mHookDataList;
std::vector<FunctionData> mFunctionDataList;
std::vector<RelocationData> mRelocationDataList;
std::set<FunctionSymbolData, FunctionSymbolDataComparator> mSymbolDataList;
std::map<std::string, SectionInfo> mSectionInfoList;
uint8_t mTrampolineId = 0;

View File

@ -17,7 +17,6 @@
#include "PluginInformationFactory.h"
#include "../utils/ElfUtils.h"
#include "../utils/utils.h"
#include "utils/HeapMemoryFixedSize.h"
#include "utils/wiiu_zlib.hpp"
#include <coreinit/cache.h>
@ -28,32 +27,28 @@
using namespace ELFIO;
std::unique_ptr<PluginInformation>
std::optional<PluginInformation>
PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocation_trampoline_entry_t> &trampolineData, uint8_t trampolineId) {
auto buffer = pluginData.getBuffer();
if (buffer.empty()) {
DEBUG_FUNCTION_LINE_ERR("Buffer was empty");
return nullptr;
return std::nullopt;
}
elfio reader(new wiiu_zlib);
if (!reader.load(reinterpret_cast<const char *>(buffer.data()), buffer.size())) {
DEBUG_FUNCTION_LINE_ERR("Can't process PluginData in elfio");
return nullptr;
return std::nullopt;
}
auto pluginInfo = make_unique_nothrow<PluginInformation>();
if (!pluginInfo) {
DEBUG_FUNCTION_LINE_ERR("Failed to allocate PluginInformation");
return nullptr;
}
PluginInformation pluginInfo;
uint32_t sec_num = reader.sections.size();
auto destinationsData = make_unique_nothrow<uint8_t *[]>(sec_num);
if (!destinationsData) {
DEBUG_FUNCTION_LINE_ERR("Failed alloc memory for destinations array");
return nullptr;
return std::nullopt;
}
std::span<uint8_t *> destinations(destinationsData.get(), sec_num);
@ -85,13 +80,13 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
HeapMemoryFixedSize text_data(text_size);
if (!text_data) {
DEBUG_FUNCTION_LINE_ERR("Failed to alloc memory for the .text section (%d bytes)", text_size);
return nullptr;
return std::nullopt;
}
HeapMemoryFixedSize data_data(data_size);
if (!data_data) {
DEBUG_FUNCTION_LINE_ERR("Failed to alloc memory for the .data section (%d bytes)", data_size);
return nullptr;
return std::nullopt;
}
for (uint32_t i = 0; i < sec_num; ++i) {
@ -125,10 +120,10 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
}
} else if (address >= 0xC0000000) {
DEBUG_FUNCTION_LINE_ERR("Loading section from 0xC0000000 is NOT supported");
return nullptr;
return std::nullopt;
} else {
DEBUG_FUNCTION_LINE_ERR("Unhandled case");
return nullptr;
return std::nullopt;
}
const char *p = psec->get_data();
@ -140,14 +135,7 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
DEBUG_FUNCTION_LINE_VERBOSE("Copy section %s %08X -> %08X (%d bytes)", psec->get_name().c_str(), p, destination, sectionSize);
memcpy((void *) destination, p, sectionSize);
}
auto sectionInfo = make_unique_nothrow<SectionInfo>(psec->get_name(), destination, sectionSize);
if (!sectionInfo) {
DEBUG_FUNCTION_LINE_ERR("Failed to allocat SectionInfo");
return nullptr;
}
pluginInfo->addSectionInfo(std::move(sectionInfo));
pluginInfo.addSectionInfo(SectionInfo(psec->get_name(), destination, sectionSize));
DEBUG_FUNCTION_LINE_VERBOSE("Saved %s section info. Location: %08X size: %08X", psec->get_name().c_str(), destination, sectionSize);
totalSize += sectionSize;
@ -164,14 +152,14 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
if (!linkSection(reader, psec->get_index(), (uint32_t) destinations[psec->get_index()], (uint32_t) text_data.data(), (uint32_t) data_data.data(), trampolineData,
trampolineId)) {
DEBUG_FUNCTION_LINE_ERR("linkSection failed");
return nullptr;
return std::nullopt;
}
}
}
if (!PluginInformationFactory::addImportRelocationData(*pluginInfo, reader, destinations)) {
if (!PluginInformationFactory::addImportRelocationData(pluginInfo, reader, destinations)) {
DEBUG_FUNCTION_LINE_ERR("addImportRelocationData failed");
return nullptr;
return std::nullopt;
}
DCFlushRange((void *) text_data.data(), text_data.size());
@ -179,9 +167,9 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
DCFlushRange((void *) data_data.data(), data_data.size());
ICInvalidateRange((void *) data_data.data(), data_data.size());
pluginInfo->setTrampolineId(trampolineId);
pluginInfo.setTrampolineId(trampolineId);
auto secInfo = pluginInfo->getSectionInfo(".wups.hooks");
auto secInfo = pluginInfo.getSectionInfo(".wups.hooks");
if (secInfo && secInfo->getSize() > 0) {
size_t entries_count = secInfo->getSize() / sizeof(wups_loader_hook_t);
auto *entries = (wups_loader_hook_t *) secInfo->getAddress();
@ -189,17 +177,12 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
for (size_t j = 0; j < entries_count; j++) {
wups_loader_hook_t *hook = &entries[j];
DEBUG_FUNCTION_LINE_VERBOSE("Saving hook of plugin Type: %08X, target: %08X", hook->type, (void *) hook->target);
auto hookData = make_unique_nothrow<HookData>((void *) hook->target, hook->type);
if (!hookData) {
DEBUG_FUNCTION_LINE_ERR("Failed to allocate HookData");
return nullptr;
}
pluginInfo->addHookData(std::move(hookData));
pluginInfo.addHookData(HookData((void *) hook->target, hook->type));
}
}
}
secInfo = pluginInfo->getSectionInfo(".wups.load");
secInfo = pluginInfo.getSectionInfo(".wups.load");
if (secInfo && secInfo->getSize() > 0) {
size_t entries_count = secInfo->getSize() / sizeof(wups_loader_entry_t);
auto *entries = (wups_loader_entry_t *) secInfo->getAddress();
@ -210,19 +193,13 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
cur_function->_function.name /*,mPluginData->getPluginInformation()->getName().c_str()*/,
cur_function->_function.physical_address, cur_function->_function.virtual_address, cur_function->_function.library, cur_function->_function.target,
(void *) cur_function->_function.call_addr);
auto functionData = make_unique_nothrow<FunctionData>((void *) cur_function->_function.physical_address,
(void *) cur_function->_function.virtual_address,
cur_function->_function.name,
(function_replacement_library_type_t) cur_function->_function.library,
(void *) cur_function->_function.target,
(void *) cur_function->_function.call_addr,
(FunctionPatcherTargetProcess) cur_function->_function.targetProcess);
if (!functionData) {
DEBUG_FUNCTION_LINE_ERR("Failed to allocate FunctionData");
return nullptr;
}
pluginInfo->addFunctionData(std::move(functionData));
pluginInfo.addFunctionData(FunctionData((void *) cur_function->_function.physical_address,
(void *) cur_function->_function.virtual_address,
cur_function->_function.name,
(function_replacement_library_type_t) cur_function->_function.library,
(void *) cur_function->_function.target,
(void *) cur_function->_function.call_addr,
(FunctionPatcherTargetProcess) cur_function->_function.targetProcess));
}
}
}
@ -248,18 +225,13 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
if (type == STT_FUNC) { // We only care about functions.
auto sectionVal = reader.sections[section];
auto offsetVal = value - sectionVal->get_address();
auto sectionInfo = pluginInfo->getSectionInfo(sectionVal->get_name());
auto sectionInfo = pluginInfo.getSectionInfo(sectionVal->get_name());
if (!sectionInfo) {
continue;
}
auto finalAddress = offsetVal + sectionInfo->getAddress();
auto functionSymbolData = make_unique_nothrow<FunctionSymbolData>(name, (void *) finalAddress, (uint32_t) size);
if (!functionSymbolData) {
DEBUG_FUNCTION_LINE_ERR("Failed to allocate FunctionSymbolData");
return nullptr;
}
pluginInfo->addFunctionSymbolData(std::move(functionSymbolData));
auto finalAddress = offsetVal + sectionInfo->getAddress();
pluginInfo.addFunctionSymbolData(FunctionSymbolData(name, (void *) finalAddress, (uint32_t) size));
}
}
}
@ -270,13 +242,13 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
if (totalSize > text_size + data_size) {
DEBUG_FUNCTION_LINE_ERR("We didn't allocate enough memory!!");
return nullptr;
return std::nullopt;
}
// Save the addresses for the allocated memory. This way we can free it again :)
pluginInfo->mAllocatedDataMemoryAddress = std::move(data_data);
pluginInfo->mAllocatedTextMemoryAddress = std::move(text_data);
pluginInfo.mAllocatedDataMemoryAddress = std::move(data_data);
pluginInfo.mAllocatedTextMemoryAddress = std::move(text_data);
return pluginInfo;
}
@ -340,18 +312,12 @@ bool PluginInformationFactory::addImportRelocationData(PluginInformation &plugin
return false;
}
auto relocationData = make_unique_nothrow<RelocationData>(type,
offset - 0x02000000,
addend,
(void *) (destinations[section_index]),
sym_name,
infoMap[sym_section_index]);
if (!relocationData) {
DEBUG_FUNCTION_LINE_ERR("Failed to allocate RelocationData");
return false;
}
pluginInfo.addRelocationData(std::move(relocationData));
pluginInfo.addRelocationData(RelocationData(type,
offset - 0x02000000,
addend,
(void *) (destinations[section_index]),
sym_name,
infoMap[sym_section_index]));
}
}
}

View File

@ -29,7 +29,7 @@
class PluginInformationFactory {
public:
static std::unique_ptr<PluginInformation>
static std::optional<PluginInformation>
load(const PluginData &pluginData, std::vector<relocation_trampoline_entry_t> &trampolineData, uint8_t trampolineId);
static bool

View File

@ -1,13 +0,0 @@
#include "PluginMetaInformation.h"
PluginMetaInformation::PluginMetaInformation(const PluginMetaInformation &other) {
this->name = other.name;
this->author = other.author;
this->version = other.version;
this->license = other.license;
this->buildtimestamp = other.buildtimestamp;
this->description = other.description;
this->size = other.size;
this->storageId = other.storageId;
this->wupsversion = other.wupsversion;
}

View File

@ -23,8 +23,6 @@
class PluginMetaInformation {
public:
PluginMetaInformation(const PluginMetaInformation &other);
[[nodiscard]] const std::string &getName() const {
return name;
}

View File

@ -22,11 +22,11 @@
#include "utils/wiiu_zlib.hpp"
#include <memory>
std::unique_ptr<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(const PluginData &pluginData, PluginParseErrors &error) {
std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(const PluginData &pluginData, PluginParseErrors &error) {
return loadPlugin(pluginData.getBuffer(), error);
}
std::unique_ptr<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(std::string_view filePath, PluginParseErrors &error) {
std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(std::string_view filePath, PluginParseErrors &error) {
std::vector<uint8_t> buffer;
if (FSUtils::LoadFileToMem(filePath, buffer) < 0) {
DEBUG_FUNCTION_LINE_ERR("Failed to load file to memory");
@ -36,7 +36,7 @@ std::unique_ptr<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(
return loadPlugin(buffer, error);
}
std::unique_ptr<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(std::span<const uint8_t> buffer, PluginParseErrors &error) {
std::optional<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(std::span<const uint8_t> buffer, PluginParseErrors &error) {
if (buffer.empty()) {
error = PLUGIN_PARSE_ERROR_BUFFER_EMPTY;
DEBUG_FUNCTION_LINE_ERR("Buffer is empty");
@ -47,12 +47,12 @@ std::unique_ptr<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(
if (!reader.load(reinterpret_cast<const char *>(buffer.data()), buffer.size())) {
error = PLUGIN_PARSE_ERROR_ELFIO_PARSE_FAILED;
DEBUG_FUNCTION_LINE_ERR("Can't find or process ELF file");
return nullptr;
return {};
}
size_t pluginSize = 0;
auto pluginInfo = std::unique_ptr<PluginMetaInformation>(new PluginMetaInformation);
PluginMetaInformation pluginInfo;
uint32_t sec_num = reader.sections.size();
@ -89,28 +89,28 @@ std::unique_ptr<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(
std::string value(curEntry + firstFound + 1);
if (key == "name") {
pluginInfo->setName(value);
pluginInfo.setName(value);
} else if (key == "author") {
pluginInfo->setAuthor(value);
pluginInfo.setAuthor(value);
} else if (key == "version") {
pluginInfo->setVersion(value);
pluginInfo.setVersion(value);
} else if (key == "license") {
pluginInfo->setLicense(value);
pluginInfo.setLicense(value);
} else if (key == "buildtimestamp") {
pluginInfo->setBuildTimestamp(value);
pluginInfo.setBuildTimestamp(value);
} else if (key == "description") {
pluginInfo->setDescription(value);
pluginInfo.setDescription(value);
} else if (key == "storage_id") {
pluginInfo->setStorageId(value);
pluginInfo.setStorageId(value);
} else if (key == "wups") {
if (value == "0.7.1") {
pluginInfo->setWUPSVersion(0, 7, 1);
pluginInfo.setWUPSVersion(0, 7, 1);
} else if (value == "0.8.0") {
pluginInfo->setWUPSVersion(0, 8, 0);
pluginInfo.setWUPSVersion(0, 8, 0);
} else {
error = PLUGIN_PARSE_ERROR_INCOMPATIBLE_VERSION;
DEBUG_FUNCTION_LINE_ERR("Warning: Ignoring plugin - Unsupported WUPS version: %s.", value.c_str());
return nullptr;
return {};
}
}
}
@ -119,7 +119,7 @@ std::unique_ptr<PluginMetaInformation> PluginMetaInformationFactory::loadPlugin(
}
}
pluginInfo->setSize(pluginSize);
pluginInfo.setSize(pluginSize);
error = PLUGIN_PARSE_ERROR_NONE;

View File

@ -36,9 +36,9 @@ enum PluginParseErrors {
class PluginMetaInformationFactory {
public:
static std::unique_ptr<PluginMetaInformation> loadPlugin(const PluginData &pluginData, PluginParseErrors &error);
static std::optional<PluginMetaInformation> loadPlugin(const PluginData &pluginData, PluginParseErrors &error);
static std::unique_ptr<PluginMetaInformation> loadPlugin(std::string_view filePath, PluginParseErrors &error);
static std::optional<PluginMetaInformation> loadPlugin(std::string_view filePath, PluginParseErrors &error);
static std::unique_ptr<PluginMetaInformation> loadPlugin(std::span<const uint8_t> buffer, PluginParseErrors &error);
static std::optional<PluginMetaInformation> loadPlugin(std::span<const uint8_t> buffer, PluginParseErrors &error);
};

View File

@ -9,8 +9,6 @@ public:
(static_cast<uint64_t>(minor) << 16) |
static_cast<uint64_t>(revision)) {}
WUPSVersion(const WUPSVersion &other) = default;
static std::optional<WUPSVersion> createFromString(const std::string &versionStr) {
char *end;
errno = 0; // Initialize errno before calling strtol

View File

@ -72,16 +72,16 @@ void ConfigUtils::displayMenu() {
renderBasicScreen("Loading configs...");
std::vector<ConfigDisplayItem> configs;
for (auto &plugin : gLoadedPlugins) {
for (const auto &plugin : gLoadedPlugins) {
GeneralConfigInformation info;
info.name = plugin->getMetaInformation().getName();
info.author = plugin->getMetaInformation().getAuthor();
info.version = plugin->getMetaInformation().getVersion();
info.name = plugin.getMetaInformation().getName();
info.author = plugin.getMetaInformation().getAuthor();
info.version = plugin.getMetaInformation().getVersion();
std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> config;
auto configData = plugin->getConfigData();
const auto configData = plugin.getConfigData();
if (configData) {
auto configHandleOpt = configData->createConfig();
const auto configHandleOpt = configData->createConfig();
if (configHandleOpt) {
WUPSConfigAPIStatus callbackResult = configData->CallMenuOpenendCallback(configHandleOpt.value());
config = WUPSConfigAPIBackend::Intern::PopConfigByHandle(configHandleOpt.value());
@ -97,13 +97,13 @@ void ConfigUtils::displayMenu() {
DEBUG_FUNCTION_LINE_ERR("Failed to create config for plugin: \"%s\"", info.name.c_str());
}
} else {
for (const auto &hook : plugin->getPluginInformation().getHookDataList()) {
if (hook->getType() == WUPS_LOADER_HOOK_GET_CONFIG_DEPRECATED) {
if (hook->getFunctionPointer() == nullptr) {
for (const auto &hook : plugin.getPluginInformation().getHookDataList()) {
if (hook.getType() == WUPS_LOADER_HOOK_GET_CONFIG_DEPRECATED) {
if (hook.getFunctionPointer() == nullptr) {
DEBUG_FUNCTION_LINE_ERR("Hook had invalid ptr");
break;
}
auto cur_config_handle = ((void *(*) ())((uint32_t *) hook->getFunctionPointer()))();
auto cur_config_handle = ((void *(*) ())((uint32_t *) hook.getFunctionPointer()))();
if (cur_config_handle == nullptr) {
DEBUG_FUNCTION_LINE_WARN("Hook returned empty handle");
break;
@ -183,12 +183,14 @@ void ConfigUtils::displayMenu() {
}
}
for (auto &plugin : gLoadedPlugins) {
auto configData = plugin->getConfigData();
for (const auto &plugin : gLoadedPlugins) {
const auto configData = plugin.getConfigData();
if (configData) {
configData->CallMenuClosedCallback();
if (configData->CallMenuClosedCallback() == WUPSCONFIG_API_RESULT_MISSING_CALLBACK) {
DEBUG_FUNCTION_LINE_WARN("CallMenuClosedCallback is missing for %s", plugin.getMetaInformation().getName().c_str());
}
} else {
CallHook(*plugin, WUPS_LOADER_HOOK_CONFIG_CLOSED_DEPRECATED);
CallHook(plugin, WUPS_LOADER_HOOK_CONFIG_CLOSED_DEPRECATED);
}
}

View File

@ -97,7 +97,7 @@ extern "C" PluginBackendApiErrorType WUPSGetPluginMetaInformation(WUPSBackendGet
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
}
std::unique_ptr<PluginMetaInformation> pluginInfo;
std::optional<PluginMetaInformation> pluginInfo;
PluginParseErrors error = PLUGIN_PARSE_ERROR_UNKNOWN;
if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_PATH && path != nullptr) {
pluginInfo = PluginMetaInformationFactory::loadPlugin(path, error);
@ -136,8 +136,8 @@ extern "C" PluginBackendApiErrorType WUPSGetPluginDataForContainerHandles(const
auto handle = plugin_container_handle_list[i];
bool found = false;
for (const auto &curContainer : gLoadedPlugins) {
if (curContainer->getHandle() == handle) {
auto pluginData = curContainer->getPluginDataCopy();
if (curContainer.getHandle() == handle) {
auto pluginData = curContainer.getPluginDataCopy();
plugin_data_list[i] = (uint32_t) pluginData->getHandle();
gLoadedData.insert(std::move(pluginData));
found = true;
@ -160,8 +160,8 @@ extern "C" PluginBackendApiErrorType WUPSGetMetaInformation(const wups_backend_p
auto handle = plugin_container_handle_list[i];
bool found = false;
for (const auto &curContainer : gLoadedPlugins) {
if (curContainer->getHandle() == handle) {
const auto &metaInfo = curContainer->getMetaInformation();
if (curContainer.getHandle() == handle) {
const auto &metaInfo = curContainer.getMetaInformation();
plugin_information_list[i].plugin_information_version = WUPS_BACKEND_PLUGIN_INFORMATION_VERSION;
strncpy(plugin_information_list[i].storageId, metaInfo.getStorageId().c_str(), sizeof(plugin_information_list[i].storageId) - 1);
@ -196,7 +196,7 @@ extern "C" PluginBackendApiErrorType WUPSGetLoadedPlugins(wups_backend_plugin_co
uint32_t counter = 0;
for (const auto &plugin : gLoadedPlugins) {
if (counter < buffer_size) {
io_handles[counter] = plugin->getHandle();
io_handles[counter] = plugin.getHandle();
counter++;
} else {
break;
@ -245,9 +245,9 @@ extern "C" PluginBackendApiErrorType WUPSGetSectionInformationForPlugin(const wu
if (handle != 0 && plugin_section_list != nullptr && buffer_size != 0) {
bool found = false;
for (const auto &curContainer : gLoadedPlugins) {
if (curContainer->getHandle() == handle) {
if (curContainer.getHandle() == handle) {
found = true;
const auto &sectionInfoList = curContainer->getPluginInformation().getSectionInfoList();
const auto &sectionInfoList = curContainer.getPluginInformation().getSectionInfoList();
uint32_t offset = 0;
for (auto const &[key, sectionInfo] : sectionInfoList) {
@ -255,9 +255,9 @@ extern "C" PluginBackendApiErrorType WUPSGetSectionInformationForPlugin(const wu
break;
}
plugin_section_list[offset].plugin_section_info_version = WUPS_BACKEND_PLUGIN_SECTION_INFORMATION_VERSION;
strncpy(plugin_section_list[offset].name, sectionInfo->getName().c_str(), sizeof(plugin_section_list[offset].name) - 1);
plugin_section_list[offset].address = (void *) sectionInfo->getAddress();
plugin_section_list[offset].size = sectionInfo->getSize();
strncpy(plugin_section_list[offset].name, sectionInfo.getName().c_str(), sizeof(plugin_section_list[offset].name) - 1);
plugin_section_list[offset].address = (void *) sectionInfo.getAddress();
plugin_section_list[offset].size = sectionInfo.getSize();
offset++;
}
if (out_count != nullptr) {
@ -289,9 +289,9 @@ extern "C" PluginBackendApiErrorType WUPSGetSectionMemoryAddresses(wups_backend_
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
}
for (const auto &curContainer : gLoadedPlugins) {
if (curContainer->getHandle() == handle) {
*textAddress = (void *) curContainer->getPluginInformation().getTextMemory().data();
*dataAddress = (void *) curContainer->getPluginInformation().getDataMemory().data();
if (curContainer.getHandle() == handle) {
*textAddress = (void *) curContainer.getPluginInformation().getTextMemory().data();
*dataAddress = (void *) curContainer.getPluginInformation().getDataMemory().data();
return PLUGIN_BACKEND_API_ERROR_NONE;
}
}