Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions libctru/include/3ds/services/apt.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,15 @@ void aptSetMessageCallback(aptMessageCb callback, void* user);
*/
void aptLaunchLibraryApplet(NS_APPID appId, void* buf, size_t bufsize, Handle handle);

/**
* @brief Launches a system applet.
* @param appId ID of the applet to launch.
* @param buf Input/output buffer that contains launch parameters on entry and result data on exit.
* @param bufsize Size of the buffer.
* @param handle Handle to pass to the system applet.
*/
void aptLaunchSystemApplet(NS_APPID appId, void* buf, size_t bufsize, Handle handle);

/// Clears the chainloader state.
void aptClearChainloader(void);

Expand Down
25 changes: 25 additions & 0 deletions libctru/source/services/apt.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,31 @@ void aptLaunchLibraryApplet(NS_APPID appId, void* buf, size_t bufsize, Handle ha
aptSetSleepAllowed(sleep);
}

void aptLaunchSystemApplet(NS_APPID appId, void* buf, size_t bufsize, Handle handle)
{
bool sleep = aptIsSleepAllowed();

aptSetSleepAllowed(false);
aptFlags &= ~FLAG_SPURIOUS; // If we haven't received a spurious wakeup by now, we probably never will (see aptInit)
APT_PrepareToStartSystemApplet(appId);
aptSetSleepAllowed(sleep);

aptCallHook(APTHOOK_ONSUSPEND);

GSPGPU_SaveVramSysArea();
GSPGPU_ReleaseRight();

aptSetSleepAllowed(false);
APT_StartSystemApplet(appId, buf, bufsize, handle);
aptFlags &= ~FLAG_ACTIVE;

aptScreenTransfer(appId, true);

aptWaitForWakeUp(TR_SYSAPPLET);
memcpy(buf, aptParameters, bufsize);
aptSetSleepAllowed(sleep);
}

Result APT_GetLockHandle(u16 flags, Handle* lockHandle)
{
u32 cmdbuf[16];
Expand Down