-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathns.c
111 lines (72 loc) · 2.6 KB
/
ns.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include <3ds.h>
#include "ns.h"
Handle nsHandle = 0;
Result NS_LaunchApplicationFIRM(u64 tid, u32 flags)
{
Result ret = 0;
if(!nsHandle) srvGetServiceHandle(&nsHandle, "ns:s");
printf("NS_LaunchApplicationFIRM %08X %llx\n", (unsigned int)nsHandle, (long long unsigned int)tid);
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x000500C0;
cmdbuf[1] = tid & 0xFFFFFFFF;
cmdbuf[2] = (tid >> 32) & 0xFFFFFFFF;
cmdbuf[3] = flags;
if((ret = svcSendSyncRequest(nsHandle))!=0) return ret;
printf("%08X\n", (unsigned int)cmdbuf[1]);
return (Result)cmdbuf[1];
}
Result _NS_LaunchTitle(u64 tid, u32 flags)
{
Result ret = 0;
if(!nsHandle) srvGetServiceHandle(&nsHandle, "ns:s");
printf("_NS_LaunchTitle %08X %llx\n", (unsigned int)nsHandle, (long long unsigned int)tid);
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x000200C0;
cmdbuf[1] = tid & 0xFFFFFFFF;
cmdbuf[2] = (tid >> 32) & 0xFFFFFFFF;
cmdbuf[3] = flags;
if((ret = svcSendSyncRequest(nsHandle))!=0) return ret;
printf("%08X\n", (unsigned int)cmdbuf[1]);
return (Result)cmdbuf[1];
}
Result NS_LaunchFIRM(u64 tid)
{
Result ret = 0;
if(!nsHandle) srvGetServiceHandle(&nsHandle, "ns:s");
printf("NS_LaunchFIRM %08X %llx\n", (unsigned int)nsHandle, (long long unsigned int)tid);
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x000100C0;
cmdbuf[1] = tid & 0xFFFFFFFF;
cmdbuf[2] = (tid >> 32) & 0xFFFFFFFF;
cmdbuf[3] = 0;
if((ret = svcSendSyncRequest(nsHandle))!=0) return ret;
printf("%08X\n", (unsigned int)cmdbuf[1]);
return (Result)cmdbuf[1];
}
Result NS_TerminateProcess(u32 pid)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x00040040;
cmdbuf[1] = pid;
if(!nsHandle) srvGetServiceHandle(&nsHandle, "ns:s");
printf("NS_TerminateProcess %08X %08x ", (unsigned int)nsHandle, (unsigned int)pid);
if((ret = svcSendSyncRequest(nsHandle))!=0) return ret;
printf("%08X\n", (unsigned int)cmdbuf[1]);
return (Result)cmdbuf[1];
}
Result NS_TerminateTitle(u64 tid, u64 timeout)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x00110100;
cmdbuf[1] = tid & 0xFFFFFFFF;
cmdbuf[2] = (tid >> 32) & 0xFFFFFFFF;
cmdbuf[3] = timeout & 0xFFFFFFFF;
cmdbuf[4] = (timeout >> 32) & 0xFFFFFFFF;
if(!nsHandle) srvGetServiceHandle(&nsHandle, "ns:s");
printf("NS_TerminateTitle %08X %llx ", (unsigned int)nsHandle, (long long unsigned int)tid);
if((ret = svcSendSyncRequest(nsHandle))!=0) return ret;
printf("%08X\n", (unsigned int)cmdbuf[1]);
return (Result)cmdbuf[1];
}