2019-03-29 00:32:45 +01:00
|
|
|
#include <3ds.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "launch.h"
|
2019-03-30 15:36:49 +01:00
|
|
|
#include "info.h"
|
2019-03-29 00:32:45 +01:00
|
|
|
#include "util.h"
|
2020-05-10 03:58:21 +02:00
|
|
|
#include "manager.h"
|
2019-03-29 00:32:45 +01:00
|
|
|
|
|
|
|
void pmDbgHandleCommands(void *ctx)
|
|
|
|
{
|
|
|
|
(void)ctx;
|
|
|
|
u32 *cmdbuf = getThreadCommandBuffer();
|
|
|
|
u32 cmdhdr = cmdbuf[0];
|
|
|
|
|
|
|
|
FS_ProgramInfo programInfo;
|
2019-03-30 15:36:49 +01:00
|
|
|
u64 titleId;
|
2020-05-10 03:58:21 +02:00
|
|
|
Handle debug;
|
2019-03-31 16:12:31 +02:00
|
|
|
u32 pid;
|
2020-05-10 03:58:21 +02:00
|
|
|
u32 launchFlags;
|
2019-03-30 15:36:49 +01:00
|
|
|
|
2019-03-29 00:32:45 +01:00
|
|
|
switch (cmdhdr >> 16) {
|
|
|
|
case 1:
|
|
|
|
debug = 0;
|
|
|
|
memcpy(&programInfo, cmdbuf + 1, sizeof(FS_ProgramInfo));
|
|
|
|
cmdbuf[1] = LaunchAppDebug(&debug, &programInfo, cmdbuf[5]);
|
|
|
|
cmdbuf[0] = IPC_MakeHeader(1, 1, 2);
|
|
|
|
cmdbuf[2] = IPC_Desc_MoveHandles(1);
|
|
|
|
cmdbuf[3] = debug;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
memcpy(&programInfo, cmdbuf + 1, sizeof(FS_ProgramInfo));
|
|
|
|
cmdbuf[1] = LaunchApp(&programInfo, cmdbuf[5]);
|
|
|
|
cmdbuf[0] = IPC_MakeHeader(2, 1, 0);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
debug = 0;
|
|
|
|
cmdbuf[1] = RunQueuedProcess(&debug);
|
|
|
|
cmdbuf[0] = IPC_MakeHeader(3, 1, 2);
|
|
|
|
cmdbuf[2] = IPC_Desc_MoveHandles(1);
|
|
|
|
cmdbuf[3] = debug;
|
|
|
|
break;
|
2019-03-30 15:36:49 +01:00
|
|
|
|
|
|
|
// Custom
|
|
|
|
case 0x100:
|
2020-05-10 03:58:21 +02:00
|
|
|
cmdbuf[1] = GetCurrentAppInfo(&programInfo, &pid, &launchFlags);
|
|
|
|
cmdbuf[0] = IPC_MakeHeader(0x100, 7, 0);
|
|
|
|
memcpy(cmdbuf + 2, &programInfo, sizeof(FS_ProgramInfo));
|
|
|
|
cmdbuf[6] = pid;
|
|
|
|
cmdbuf[7] = launchFlags;
|
2019-03-30 15:36:49 +01:00
|
|
|
break;
|
|
|
|
case 0x101:
|
2019-06-14 01:32:50 +02:00
|
|
|
cmdbuf[1] = DebugNextApplicationByForce(cmdbuf[1] != 0);
|
2019-03-30 15:36:49 +01:00
|
|
|
cmdbuf[0] = IPC_MakeHeader(0x101, 1, 0);
|
|
|
|
break;
|
|
|
|
case 0x102:
|
|
|
|
debug = 0;
|
|
|
|
memcpy(&programInfo, cmdbuf + 1, sizeof(FS_ProgramInfo));
|
|
|
|
cmdbuf[1] = LaunchTitleDebug(&debug, &programInfo, cmdbuf[5]);
|
|
|
|
cmdbuf[0] = IPC_MakeHeader(0x102, 1, 2);
|
|
|
|
cmdbuf[2] = IPC_Desc_MoveHandles(1);
|
|
|
|
cmdbuf[3] = debug;
|
|
|
|
break;
|
2020-05-10 03:58:21 +02:00
|
|
|
case 0x103:
|
|
|
|
memcpy(&titleId, cmdbuf + 1, 8);
|
|
|
|
cmdbuf[1] = PrepareToChainloadHomebrew(titleId);
|
|
|
|
cmdbuf[0] = IPC_MakeHeader(0x103, 1, 0);
|
|
|
|
break;
|
2019-03-29 00:32:45 +01:00
|
|
|
default:
|
|
|
|
cmdbuf[0] = IPC_MakeHeader(0, 1, 0);
|
|
|
|
cmdbuf[1] = 0xD900182F;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|