From 8854ff3f906acc45383b67ef2cdb3f8e2d4cf0b1 Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 7 Jun 2024 13:55:59 +0200 Subject: [PATCH] Prevent loading homebre when currently no account is loaded --- src/utils/TcpReceiver.cpp | 13 +++++++++++++ src/utils/TcpReceiver.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/utils/TcpReceiver.cpp b/src/utils/TcpReceiver.cpp index 99c7fbc..918d6a5 100644 --- a/src/utils/TcpReceiver.cpp +++ b/src/utils/TcpReceiver.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -123,6 +124,9 @@ void TcpReceiver::executeThread() { case LAUNCH_FAILED: NotificationModule_AddErrorNotification("Wiiload plugin: Failed to launch homebrew. Launching will be aborted."); break; + case NO_ACTIVE_ACCOUNT: + NotificationModule_AddErrorNotification("Wiiload plugin: Failed to launch homebrew. No active account loaded."); + break; } if (result == SUCCESS) { @@ -233,6 +237,15 @@ TcpReceiver::eLoadResults TcpReceiver::loadBinary(void *data, uint32_t fileSize) if (error != SUCCESS) { return error; } + + nn::act::Initialize(); + bool accountLoaded = nn::act::IsSlotOccupied(nn::act::GetSlotNo()); + nn::act::Finalize(); + + if (!accountLoaded) { + return NO_ACTIVE_ACCOUNT; + } + RPXLoaderStatus launchRes; if ((launchRes = RPXLoader_LaunchHomebrew(loadedPath.c_str())) != RPX_LOADER_RESULT_SUCCESS) { DEBUG_FUNCTION_LINE_ERR("Failed to start %s %s", loadedPath.c_str(), RPXLoader_GetStatusStr(launchRes)); diff --git a/src/utils/TcpReceiver.h b/src/utils/TcpReceiver.h index b8653b2..a1c5b5d 100644 --- a/src/utils/TcpReceiver.h +++ b/src/utils/TcpReceiver.h @@ -18,6 +18,7 @@ public: NOT_ENOUGH_MEMORY = -6, RECV_ERROR = -7, LAUNCH_FAILED = -8, + NO_ACTIVE_ACCOUNT = -9, }; explicit TcpReceiver(int32_t port);