2019-03-30 18:12:54 +01:00
|
|
|
// License for this file: ctrulib's license
|
2020-04-25 14:26:21 +02:00
|
|
|
// Copyright AuroraWright, TuxSH 2019-2020
|
2019-03-30 18:12:54 +01:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <3ds/types.h>
|
|
|
|
#include <3ds/result.h>
|
|
|
|
#include <3ds/svc.h>
|
|
|
|
#include <3ds/srv.h>
|
|
|
|
#include <3ds/synchronization.h>
|
|
|
|
#include <3ds/services/pmdbg.h>
|
|
|
|
#include <3ds/ipc.h>
|
|
|
|
|
2020-05-10 03:58:21 +02:00
|
|
|
Result PMDBG_GetCurrentAppInfo(FS_ProgramInfo *outProgramInfo, u32 *outPid, u32 *outLaunchFlags)
|
2019-03-30 18:12:54 +01:00
|
|
|
{
|
|
|
|
Result ret = 0;
|
|
|
|
u32 *cmdbuf = getThreadCommandBuffer();
|
|
|
|
cmdbuf[0] = IPC_MakeHeader(0x100, 0, 0);
|
|
|
|
if(R_FAILED(ret = svcSendSyncRequest(*pmDbgGetSessionHandle()))) return ret;
|
|
|
|
|
2020-05-10 03:58:21 +02:00
|
|
|
memcpy(outProgramInfo, cmdbuf + 2, sizeof(FS_ProgramInfo));
|
|
|
|
*outPid = cmdbuf[6];
|
|
|
|
*outLaunchFlags = cmdbuf[7];
|
2019-03-30 18:12:54 +01:00
|
|
|
return cmdbuf[1];
|
|
|
|
}
|
|
|
|
|
2019-06-14 01:32:50 +02:00
|
|
|
Result PMDBG_DebugNextApplicationByForce(bool debug)
|
2019-03-30 18:12:54 +01:00
|
|
|
{
|
|
|
|
Result ret = 0;
|
|
|
|
u32 *cmdbuf = getThreadCommandBuffer();
|
2019-06-14 01:32:50 +02:00
|
|
|
cmdbuf[0] = IPC_MakeHeader(0x101, 1, 0);
|
|
|
|
cmdbuf[1] = (u32)debug;
|
2019-03-30 18:12:54 +01:00
|
|
|
|
|
|
|
if(R_FAILED(ret = svcSendSyncRequest(*pmDbgGetSessionHandle()))) return ret;
|
|
|
|
return cmdbuf[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
Result PMDBG_LaunchTitleDebug(Handle *outDebug, const FS_ProgramInfo *programInfo, u32 launchFlags)
|
|
|
|
{
|
|
|
|
Result ret = 0;
|
|
|
|
u32 *cmdbuf = getThreadCommandBuffer();
|
|
|
|
|
|
|
|
cmdbuf[0] = IPC_MakeHeader(0x102, 5, 0);
|
|
|
|
memcpy(&cmdbuf[1], programInfo, sizeof(FS_ProgramInfo));
|
|
|
|
cmdbuf[5] = launchFlags;
|
|
|
|
|
|
|
|
if(R_FAILED(ret = svcSendSyncRequest(*pmDbgGetSessionHandle()))) return ret;
|
|
|
|
|
|
|
|
*outDebug = cmdbuf[3];
|
|
|
|
return (Result)cmdbuf[1];
|
|
|
|
}
|
2020-05-10 03:58:21 +02:00
|
|
|
|
|
|
|
Result PMDBG_PrepareToChainloadHomebrew(u64 titleId)
|
|
|
|
{
|
|
|
|
Result ret = 0;
|
|
|
|
u32 *cmdbuf = getThreadCommandBuffer();
|
|
|
|
|
|
|
|
cmdbuf[0] = IPC_MakeHeader(0x103, 2, 0);
|
|
|
|
memcpy(&cmdbuf[1], &titleId, 8);
|
|
|
|
|
|
|
|
if(R_FAILED(ret = svcSendSyncRequest(*pmDbgGetSessionHandle()))) return ret;
|
|
|
|
|
|
|
|
return (Result)cmdbuf[1];
|
|
|
|
}
|