mirror of
https://github.com/wiiu-env/WUMSLoader.git
synced 2025-02-05 03:26:21 +01:00
Allow early init of the Module System, check EnvrionmentLoader version
This commit is contained in:
parent
40bec5454c
commit
40420432e2
@ -1,4 +1,5 @@
|
|||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
#include "../wumsloader/src/globals.h"
|
||||||
#include "ElfUtils.h"
|
#include "ElfUtils.h"
|
||||||
#include "wumsloader_elf.h"
|
#include "wumsloader_elf.h"
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
@ -20,6 +21,9 @@ void SetupWUMSLoader() {
|
|||||||
KernelWriteU32(repl_addr, 0x48000003 | entryPoint);
|
KernelWriteU32(repl_addr, 0x48000003 | entryPoint);
|
||||||
DCFlushRange((void *) repl_addr, 4);
|
DCFlushRange((void *) repl_addr, 4);
|
||||||
ICInvalidateRange((void *) (repl_addr), 4);
|
ICInvalidateRange((void *) (repl_addr), 4);
|
||||||
|
|
||||||
|
// We call the mainhook (wumloader) once with a MAGIC number to set up the WUMS Modules but not actually call the original main function
|
||||||
|
((int (*)(int, char **))(entryPoint))(WUMS_LOADER_SETUP_MAGIC_WORD, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KernelWriteU32(uint32_t addr, uint32_t value) {
|
void KernelWriteU32(uint32_t addr, uint32_t value) {
|
||||||
|
@ -12,6 +12,11 @@ int main(int argc, char **argv) {
|
|||||||
if (argc >= 1) {
|
if (argc >= 1) {
|
||||||
basePath = argv[0];
|
basePath = argv[0];
|
||||||
}
|
}
|
||||||
|
if (argc < 4 || std::string_view("EnvironmentLoader") != argv[1] || (uint32_t) argv[2] < 2 || (uint32_t) argv[3] == 0) {
|
||||||
|
OSFatal("WUMSLoader: Failed to parse arguments, make sure to use the latest environment loader.\n See https://wiiu.hacks.guide/ for more information.");
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(MEMORY_REGION_USABLE_MEM_REGION_END_VALUE_PTR, &argv[3], sizeof(uint32_t));
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Warray-bounds"
|
#pragma GCC diagnostic ignored "-Warray-bounds"
|
||||||
|
@ -70,7 +70,7 @@ MAKEFLAGS += --no-print-directory
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# any extra libraries we wish to link with the project
|
# any extra libraries we wish to link with the project
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
LIBS := -lwums -lwut -lz
|
LIBS := -lwut -lz
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# list of directories containing libraries, this must be the top level containing
|
||||||
|
@ -53,6 +53,10 @@ extern "C" int _start(int argc, char **argv) {
|
|||||||
:);
|
:);
|
||||||
|
|
||||||
OSCheckActiveThreads();
|
OSCheckActiveThreads();
|
||||||
|
if (argc == WUMS_LOADER_SETUP_MAGIC_WORD) {
|
||||||
|
DEBUG_FUNCTION_LINE("Skip calling the real main function because we just want to setup WUMS");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return ((int (*)(int, char **))(*(unsigned int *) 0x1005E040))(argc, argv);
|
return ((int (*)(int, char **))(*(unsigned int *) 0x1005E040))(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,9 +20,15 @@ extern std::vector<void *> gAllocatedAddresses;
|
|||||||
#define CUSTOM_RPX_LOADER_RETURN_CODE 0x00009000 // We have to skip the first 0x00009000 bytes because it's still used
|
#define CUSTOM_RPX_LOADER_RETURN_CODE 0x00009000 // We have to skip the first 0x00009000 bytes because it's still used
|
||||||
#define RELOCATOR_SIZE 0x52000 // Maximum size of the wumsloader, needs to match the one defined in link.ld
|
#define RELOCATOR_SIZE 0x52000 // Maximum size of the wumsloader, needs to match the one defined in link.ld
|
||||||
#define ENVIRONMENT_PATH_LENGTH 0x100 // Length of the EnvironmentPath.
|
#define ENVIRONMENT_PATH_LENGTH 0x100 // Length of the EnvironmentPath.
|
||||||
|
#define MEMORY_REGION_USABLE_MEM_REGION_END_LENGTH 0x04 // sizeof(uint32_t)
|
||||||
|
|
||||||
#define MEMORY_REGION_ENVIRONMENT_STRING_ADRR (MEMORY_REGION_START + CUSTOM_RPX_LOADER_RETURN_CODE + RELOCATOR_SIZE)
|
#define MEMORY_REGION_ENVIRONMENT_STRING_ADRR (MEMORY_REGION_START + CUSTOM_RPX_LOADER_RETURN_CODE + RELOCATOR_SIZE)
|
||||||
#define MEMORY_REGION_USABLE_HEAP_START (MEMORY_REGION_ENVIRONMENT_STRING_ADRR + ENVIRONMENT_PATH_LENGTH)
|
#define MEMORY_REGION_USABLE_MEM_REGION_END_VALUE_PTR ((uint32_t *) (MEMORY_REGION_ENVIRONMENT_STRING_ADRR + ENVIRONMENT_PATH_LENGTH))
|
||||||
#define MEMORY_REGION_USABLE_HEAP_END (0x00FFF000) // We need to leave space for the BAT hook
|
#define MEMORY_REGION_USABLE_MEM_REGION_END_VALUE (*MEMORY_REGION_USABLE_MEM_REGION_END_VALUE_PTR)
|
||||||
|
|
||||||
|
#define MEMORY_REGION_USABLE_HEAP_START ((uint32_t) MEMORY_REGION_USABLE_MEM_REGION_END_VALUE_PTR + MEMORY_REGION_USABLE_MEM_REGION_END_LENGTH)
|
||||||
|
#define MEMORY_REGION_USABLE_HEAP_END MEMORY_REGION_USABLE_MEM_REGION_END_VALUE
|
||||||
|
|
||||||
#define ENVRIONMENT_STRING ((char *) MEMORY_REGION_ENVIRONMENT_STRING_ADRR)
|
#define ENVRIONMENT_STRING ((char *) MEMORY_REGION_ENVIRONMENT_STRING_ADRR)
|
||||||
|
|
||||||
|
#define WUMS_LOADER_SETUP_MAGIC_WORD 0x13371337
|
||||||
|
@ -38,6 +38,8 @@ IMPORT(__KernelGetInfo);
|
|||||||
IMPORT(OSCheckActiveThreads);
|
IMPORT(OSCheckActiveThreads);
|
||||||
IMPORT(OSGetCurrentThread);
|
IMPORT(OSGetCurrentThread);
|
||||||
IMPORT(OSSetThreadCleanupCallback);
|
IMPORT(OSSetThreadCleanupCallback);
|
||||||
|
IMPORT(OSIsDebuggerPresent);
|
||||||
|
IMPORT(__os_snprintf);
|
||||||
|
|
||||||
IMPORT(FSTimeToCalendarTime);
|
IMPORT(FSTimeToCalendarTime);
|
||||||
IMPORT(FSInit);
|
IMPORT(FSInit);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user