My Project
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
ns.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <3ds.h>
3 
4 static Handle nsHandle;
5 
7 {
8  return srvGetServiceHandle(&nsHandle, "ns:s");
9 }
10 
12 {
13  return svcCloseHandle(nsHandle);
14 }
15 
16 Result NS_LaunchTitle(u64 titleid, u32 launch_flags, u32 *procid)
17 {
18  Result ret = 0;
19  u32 *cmdbuf = getThreadCommandBuffer();
20 
21  cmdbuf[0] = 0x000200C0;
22  cmdbuf[1] = titleid & 0xffffffff;
23  cmdbuf[2] = (titleid >> 32) & 0xffffffff;
24  cmdbuf[3] = launch_flags;
25 
26  if((ret = svcSendSyncRequest(nsHandle))!=0)return ret;
27 
28  if(procid != NULL)
29  *procid = cmdbuf[2];
30 
31  return (Result)cmdbuf[1];
32 }
33 
34 Result NS_RebootToTitle(u8 mediatype, u64 titleid)
35 {
36  Result ret = 0;
37  u32 *cmdbuf = getThreadCommandBuffer();
38 
39  cmdbuf[0] = 0x00100180;
40  cmdbuf[1] = 0x1;
41  cmdbuf[2] = titleid & 0xffffffff;
42  cmdbuf[3] = (titleid >> 32) & 0xffffffff;
43  cmdbuf[4] = mediatype;
44  cmdbuf[5] = 0x0; // reserved
45  cmdbuf[6] = 0x0;
46 
47  if((ret = svcSendSyncRequest(nsHandle))!=0)return ret;
48 
49  return (Result)cmdbuf[1];
50 }
s32 Result
Definition: types.h:42
s32 svcCloseHandle(Handle handle)
Result NS_RebootToTitle(u8 mediatype, u64 titleid)
Definition: ns.c:34
Result srvGetServiceHandle(Handle *out, const char *name)
Definition: srv.c:109
u32 Handle
Definition: types.h:41
u32 * getThreadCommandBuffer(void)
uint8_t u8
Definition: types.h:21
uint64_t u64
Definition: types.h:24
Result NS_LaunchTitle(u64 titleid, u32 launch_flags, u32 *procid)
Definition: ns.c:16
uint32_t u32
Definition: types.h:23
Result nsExit()
Definition: ns.c:11
Result nsInit()
Definition: ns.c:6
s32 svcSendSyncRequest(Handle session)