mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-22 04:39:17 +01:00
Small fixes to the .wps loading, return nullptr instead of OSFatal, add asserts instead of OSFatal
This commit is contained in:
parent
6855564c28
commit
43a18b56d7
@ -42,7 +42,7 @@ PluginManagement::loadPlugins(const std::set<std::shared_ptr<PluginData>> &plugi
|
|||||||
|
|
||||||
if (!PluginManagement::DoFunctionPatches(plugins)) {
|
if (!PluginManagement::DoFunctionPatches(plugins)) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to patch functions");
|
DEBUG_FUNCTION_LINE_ERR("Failed to patch functions");
|
||||||
OSFatal("Failed to patch functions");
|
OSFatal("WiiUPluginLoaderBackend: Failed to patch functions");
|
||||||
}
|
}
|
||||||
|
|
||||||
return plugins;
|
return plugins;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <wums/defines/relocation_defines.h>
|
#include <wums/defines/relocation_defines.h>
|
||||||
|
|
||||||
#define VERSION "v0.3.1"
|
#define VERSION "v0.3.2"
|
||||||
#define VERSION_FULL VERSION VERSION_EXTRA
|
#define VERSION_FULL VERSION VERSION_EXTRA
|
||||||
|
|
||||||
extern StoredBuffer gStoredTVBuffer;
|
extern StoredBuffer gStoredTVBuffer;
|
||||||
|
@ -67,12 +67,12 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
|
|||||||
uint32_t sectionSize = psec->get_size();
|
uint32_t sectionSize = psec->get_size();
|
||||||
auto address = (uint32_t) psec->get_address();
|
auto address = (uint32_t) psec->get_address();
|
||||||
if ((address >= 0x02000000) && address < 0x10000000) {
|
if ((address >= 0x02000000) && address < 0x10000000) {
|
||||||
text_size += sectionSize;
|
text_size += sectionSize + psec->get_addr_align();
|
||||||
} else if ((address >= 0x10000000) && address < 0xC0000000) {
|
} else if ((address >= 0x10000000) && address < 0xC0000000) {
|
||||||
data_size += sectionSize;
|
data_size += sectionSize + psec->get_addr_align();
|
||||||
}
|
}
|
||||||
if (psec->get_name().starts_with(".wups.")) {
|
if (psec->get_name().starts_with(".wups.")) {
|
||||||
data_size += sectionSize;
|
data_size += sectionSize + psec->get_addr_align();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,7 +107,10 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
|
|||||||
|
|
||||||
if (destination + sectionSize > (uint32_t) text_data.data() + text_size) {
|
if (destination + sectionSize > (uint32_t) text_data.data() + text_size) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Tried to overflow .text buffer. %08X > %08X", destination + sectionSize, (uint32_t) text_data.data() + text_data.size());
|
DEBUG_FUNCTION_LINE_ERR("Tried to overflow .text buffer. %08X > %08X", destination + sectionSize, (uint32_t) text_data.data() + text_data.size());
|
||||||
OSFatal("WUPSLoader: Tried to overflow buffer");
|
return std::nullopt;
|
||||||
|
} else if (destination < (uint32_t) text_data.data()) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Tried to underflow .text buffer. %08X < %08X", destination, (uint32_t) text_data.data());
|
||||||
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
} else if ((address >= 0x10000000) && address < 0xC0000000) {
|
} else if ((address >= 0x10000000) && address < 0xC0000000) {
|
||||||
destination += (uint32_t) data_data.data();
|
destination += (uint32_t) data_data.data();
|
||||||
@ -115,8 +118,11 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
|
|||||||
destinations[psec->get_index()] = (uint8_t *) data_data.data();
|
destinations[psec->get_index()] = (uint8_t *) data_data.data();
|
||||||
|
|
||||||
if (destination + sectionSize > (uint32_t) data_data.data() + data_data.size()) {
|
if (destination + sectionSize > (uint32_t) data_data.data() + data_data.size()) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Tried to overflow .data buffer. %08X > %08X", destination + sectionSize, (uint32_t) text_data.data() + text_data.size());
|
DEBUG_FUNCTION_LINE_ERR("Tried to overflow .data buffer. %08X > %08X", destination + sectionSize, (uint32_t) data_data.data() + data_data.size());
|
||||||
OSFatal("WUPSLoader: Tried to overflow buffer");
|
return std::nullopt;
|
||||||
|
} else if (destination < (uint32_t) data_data.data()) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Tried to underflow .data buffer. %08X < %08X", destination, (uint32_t) text_data.data());
|
||||||
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
} else if (address >= 0xC0000000) {
|
} else if (address >= 0xC0000000) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Loading section from 0xC0000000 is NOT supported");
|
DEBUG_FUNCTION_LINE_ERR("Loading section from 0xC0000000 is NOT supported");
|
||||||
@ -128,6 +134,12 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
|
|||||||
|
|
||||||
const char *p = psec->get_data();
|
const char *p = psec->get_data();
|
||||||
|
|
||||||
|
uint32_t address_align = psec->get_addr_align();
|
||||||
|
if ((destination & (address_align - 1)) != 0) {
|
||||||
|
DEBUG_FUNCTION_LINE_WARN("Address not aligned: %08X %08X", destination, address_align);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
if (psec->get_type() == SHT_NOBITS) {
|
if (psec->get_type() == SHT_NOBITS) {
|
||||||
DEBUG_FUNCTION_LINE_VERBOSE("memset section %s %08X to 0 (%d bytes)", psec->get_name().c_str(), destination, sectionSize);
|
DEBUG_FUNCTION_LINE_VERBOSE("memset section %s %08X to 0 (%d bytes)", psec->get_name().c_str(), destination, sectionSize);
|
||||||
memset((void *) destination, 0, sectionSize);
|
memset((void *) destination, 0, sectionSize);
|
||||||
|
@ -11,22 +11,15 @@ CategoryRenderer::CategoryRenderer(const GeneralConfigInformation *info, const W
|
|||||||
for (uint32_t i = 0; i < cat->getCategories().size() + cat->getItems().size(); i++) {
|
for (uint32_t i = 0; i < cat->getCategories().size() + cat->getItems().size(); i++) {
|
||||||
if (i < cat->getCategories().size()) {
|
if (i < cat->getCategories().size()) {
|
||||||
auto item = make_unique_nothrow<ConfigRendererItemCategory>(cat->getCategories()[i].get());
|
auto item = make_unique_nothrow<ConfigRendererItemCategory>(cat->getCategories()[i].get());
|
||||||
if (!item) {
|
assert(item);
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to alloc ConfigRendererItemCategory");
|
|
||||||
OSFatal("WiiUPluginBackend::CategoryRenderer::CategoryRenderer() Failed to alloc ConfigRendererItemCategory");
|
|
||||||
}
|
|
||||||
mItemRenderer.push_back(std::move(item));
|
mItemRenderer.push_back(std::move(item));
|
||||||
} else {
|
} else {
|
||||||
auto itemIndex = (int32_t) (i - cat->getCategories().size());
|
auto itemIndex = (int32_t) (i - cat->getCategories().size());
|
||||||
if (itemIndex < 0 || itemIndex >= (int32_t) cat->getItems().size()) {
|
if (itemIndex < 0 || itemIndex >= (int32_t) cat->getItems().size()) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("unexpected index");
|
assert(false);
|
||||||
OSFatal("WiiUPluginBackend::CategoryRenderer::CategoryRenderer() unexpected index");
|
|
||||||
}
|
}
|
||||||
auto item = make_unique_nothrow<ConfigRendererItem>(cat->getItems()[itemIndex].get());
|
auto item = make_unique_nothrow<ConfigRendererItem>(cat->getItems()[itemIndex].get());
|
||||||
if (!item) {
|
assert(item);
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to alloc ConfigRendererItemCategory");
|
|
||||||
OSFatal("WiiUPluginBackend::CategoryRenderer::CategoryRenderer() Failed to alloc ConfigRendererItem");
|
|
||||||
}
|
|
||||||
mItemRenderer.push_back(std::move(item));
|
mItemRenderer.push_back(std::move(item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user