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)) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to patch functions");
|
||||
OSFatal("Failed to patch functions");
|
||||
OSFatal("WiiUPluginLoaderBackend: Failed to patch functions");
|
||||
}
|
||||
|
||||
return plugins;
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <vector>
|
||||
#include <wums/defines/relocation_defines.h>
|
||||
|
||||
#define VERSION "v0.3.1"
|
||||
#define VERSION "v0.3.2"
|
||||
#define VERSION_FULL VERSION VERSION_EXTRA
|
||||
|
||||
extern StoredBuffer gStoredTVBuffer;
|
||||
|
@ -67,12 +67,12 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector<relocat
|
||||
uint32_t sectionSize = psec->get_size();
|
||||
auto address = (uint32_t) psec->get_address();
|
||||
if ((address >= 0x02000000) && address < 0x10000000) {
|
||||
text_size += sectionSize;
|
||||
text_size += sectionSize + psec->get_addr_align();
|
||||
} else if ((address >= 0x10000000) && address < 0xC0000000) {
|
||||
data_size += sectionSize;
|
||||
data_size += sectionSize + psec->get_addr_align();
|
||||
}
|
||||
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) {
|
||||
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) {
|
||||
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();
|
||||
|
||||
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());
|
||||
OSFatal("WUPSLoader: Tried to overflow buffer");
|
||||
DEBUG_FUNCTION_LINE_ERR("Tried to overflow .data buffer. %08X > %08X", destination + sectionSize, (uint32_t) data_data.data() + data_data.size());
|
||||
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) {
|
||||
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();
|
||||
|
||||
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) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("memset section %s %08X to 0 (%d bytes)", psec->get_name().c_str(), destination, 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++) {
|
||||
if (i < cat->getCategories().size()) {
|
||||
auto item = make_unique_nothrow<ConfigRendererItemCategory>(cat->getCategories()[i].get());
|
||||
if (!item) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to alloc ConfigRendererItemCategory");
|
||||
OSFatal("WiiUPluginBackend::CategoryRenderer::CategoryRenderer() Failed to alloc ConfigRendererItemCategory");
|
||||
}
|
||||
assert(item);
|
||||
mItemRenderer.push_back(std::move(item));
|
||||
} else {
|
||||
auto itemIndex = (int32_t) (i - cat->getCategories().size());
|
||||
if (itemIndex < 0 || itemIndex >= (int32_t) cat->getItems().size()) {
|
||||
DEBUG_FUNCTION_LINE_ERR("unexpected index");
|
||||
OSFatal("WiiUPluginBackend::CategoryRenderer::CategoryRenderer() unexpected index");
|
||||
assert(false);
|
||||
}
|
||||
auto item = make_unique_nothrow<ConfigRendererItem>(cat->getItems()[itemIndex].get());
|
||||
if (!item) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to alloc ConfigRendererItemCategory");
|
||||
OSFatal("WiiUPluginBackend::CategoryRenderer::CategoryRenderer() Failed to alloc ConfigRendererItem");
|
||||
}
|
||||
assert(item);
|
||||
mItemRenderer.push_back(std::move(item));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user