Skip to content

Commit

Permalink
Prevent loading homebre when currently no account is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Maschell committed Jun 7, 2024
1 parent 2b28fd3 commit ca3d657
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/utils/TcpReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <coreinit/dynload.h>
#include <coreinit/title.h>
#include <cstring>
#include <nn/act.h>
#include <notifications/notifications.h>
#include <rpxloader/rpxloader.h>
#include <sysapp/launch.h>
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions src/utils/TcpReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class TcpReceiver : public CThread {
NOT_ENOUGH_MEMORY = -6,
RECV_ERROR = -7,
LAUNCH_FAILED = -8,
NO_ACTIVE_ACCOUNT = -9,
};

explicit TcpReceiver(int32_t port);
Expand Down

0 comments on commit ca3d657

Please sign in to comment.