mirror of
https://github.com/wiiu-env/WUMSLoader.git
synced 2024-11-23 16:29:16 +01:00
Fix support for loading multiple modules
This commit is contained in:
parent
b9064883a2
commit
fa68c980af
@ -87,7 +87,8 @@ int main(int argc, char **argv) {
|
||||
for (int i = 0; i < setupModules.GetFilecount(); i++) {
|
||||
memset((void *) gModuleData, 0, sizeof(module_information_t));
|
||||
DEBUG_FUNCTION_LINE("Trying to run %s", setupModules.GetFilepath(i));
|
||||
std::optional<ModuleData> moduleData = ModuleDataFactory::load(setupModules.GetFilepath(i), 0x00900000, 0x01000000 - textSectionStart, gModuleData->trampolines, DYN_LINK_TRAMPOLIN_LIST_LENGTH);
|
||||
uint32_t destination_address = 0x00900000;
|
||||
std::optional<ModuleData> moduleData = ModuleDataFactory::load(setupModules.GetFilepath(i), &destination_address, 0x01000000 - textSectionStart, gModuleData->trampolines, DYN_LINK_TRAMPOLIN_LIST_LENGTH);
|
||||
if (!moduleData) {
|
||||
DEBUG_FUNCTION_LINE("Failed to load %s", setupModules.GetFilepath(i));
|
||||
continue;
|
||||
@ -116,11 +117,11 @@ int main(int argc, char **argv) {
|
||||
|
||||
DirList modules("fs:/vol/external01/wiiu/modules", ".wms", DirList::Files, 1);
|
||||
modules.SortList();
|
||||
|
||||
uint32_t destination_address = 0x00900000;
|
||||
for (int i = 0; i < modules.GetFilecount(); i++) {
|
||||
DEBUG_FUNCTION_LINE("Loading module %s", modules.GetFilepath(i));
|
||||
|
||||
std::optional<ModuleData> moduleData = ModuleDataFactory::load(modules.GetFilepath(i), 0x00900000, 0x01000000 - textSectionStart, gModuleData->trampolines, DYN_LINK_TRAMPOLIN_LIST_LENGTH);
|
||||
std::optional<ModuleData> moduleData = ModuleDataFactory::load(modules.GetFilepath(i), &destination_address, 0x01000000 - textSectionStart, gModuleData->trampolines, DYN_LINK_TRAMPOLIN_LIST_LENGTH);
|
||||
|
||||
if (moduleData) {
|
||||
DEBUG_FUNCTION_LINE("Successfully loaded %s", modules.GetFilepath(i));
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
using namespace ELFIO;
|
||||
|
||||
std::optional<ModuleData> ModuleDataFactory::load(std::string path, uint32_t destination_address, uint32_t maximum_size, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length) {
|
||||
std::optional<ModuleData> ModuleDataFactory::load(std::string path, uint32_t* destination_address_ptr, uint32_t maximum_size, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length) {
|
||||
elfio reader;
|
||||
ModuleData moduleData;
|
||||
|
||||
@ -43,7 +43,7 @@ std::optional<ModuleData> ModuleDataFactory::load(std::string path, uint32_t des
|
||||
|
||||
uint8_t **destinations = (uint8_t **) malloc(sizeof(uint8_t *) * sec_num);
|
||||
|
||||
uint32_t baseOffset = destination_address;
|
||||
uint32_t baseOffset = *destination_address_ptr;
|
||||
|
||||
uint32_t offset_text = baseOffset;
|
||||
uint32_t offset_data = offset_text;
|
||||
@ -181,18 +181,20 @@ std::optional<ModuleData> ModuleDataFactory::load(std::string path, uint32_t des
|
||||
}
|
||||
}
|
||||
|
||||
DCFlushRange((void*)destination_address, totalSize);
|
||||
ICInvalidateRange((void*)destination_address, totalSize);
|
||||
DCFlushRange((void*)*destination_address_ptr, totalSize);
|
||||
ICInvalidateRange((void*)*destination_address_ptr, totalSize);
|
||||
|
||||
free(destinations);
|
||||
|
||||
moduleData.setEntrypoint(entrypoint);
|
||||
moduleData.setStartAddress(destination_address);
|
||||
moduleData.setStartAddress(*destination_address_ptr);
|
||||
moduleData.setEndAddress(endAddress);
|
||||
DEBUG_FUNCTION_LINE("Saved entrypoint as %08X", entrypoint);
|
||||
DEBUG_FUNCTION_LINE("Saved startAddress as %08X", destination_address);
|
||||
DEBUG_FUNCTION_LINE("Saved startAddress as %08X", *destination_address_ptr);
|
||||
DEBUG_FUNCTION_LINE("Saved endAddress as %08X", endAddress);
|
||||
|
||||
*destination_address_ptr = (*destination_address_ptr + totalSize + 0x100) & 0xFFFFFF00;
|
||||
|
||||
return moduleData;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
class ModuleDataFactory {
|
||||
public:
|
||||
static std::optional<ModuleData> load(std::string path, uint32_t destination_address, uint32_t maximum_size, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length);
|
||||
static std::optional<ModuleData> load(std::string path, uint32_t* destination_address_ptr, uint32_t maximum_size, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length);
|
||||
|
||||
static bool linkSection(ELFIO::elfio &reader, uint32_t section_index, uint32_t destination, uint32_t base_text, uint32_t base_data, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user