Save the current titleId when executing the payload.elf

This commit is contained in:
Maschell 2020-10-19 00:22:25 +02:00
parent 8498757a87
commit 4f208ba8a6

View File

@ -18,6 +18,7 @@
#include <stdint.h>
#include <coreinit/cache.h>
#include <coreinit/dynload.h>
#include <coreinit/title.h>
#include <sysapp/launch.h>
#include <nsysnet/socket.h>
#include <proc_ui/procui.h>
@ -72,11 +73,13 @@ extern "C" int _start(int argc, char **argv) {
WHBLogUdpInit();
int res = 0;
// If we load from our CustomRPXLoader the argv is set with "safe.rpx"
// in this case we don't want to do any ProcUi stuff on error, only on success
bool doProcUI = (argc != 1 || std::string(argv[0]) != "safe.rpx");
uint64_t *cfwLaunchedWithPtr = (uint64_t *) 0x00FFFFF8;
*cfwLaunchedWithPtr = OSGetTitleID();
uint32_t ApplicationMemoryEnd;
asm volatile("lis %0, __CODE_END@h; ori %0, %0, __CODE_END@l" : "=r" (ApplicationMemoryEnd));