NS: Added API
This commit is contained in:
parent
b66d047e76
commit
3d798def58
21
libctru/include/3ds/services/ns.h
Normal file
21
libctru/include/3ds/services/ns.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
Requires access to "ns:s" service
|
||||
*/
|
||||
|
||||
Result nsInit();
|
||||
Result nsExit();
|
||||
|
||||
/* NS_LaunchTitle()
|
||||
titleid TitleId of title to launch, if 0, gamecard assumed
|
||||
launch_flags use if you know of any
|
||||
procid ptr to where the process id of the launched title will be written to, leave a NULL, if you don't care
|
||||
*/
|
||||
Result NS_LaunchTitle(u64 titleid, u32 launch_flags, u32 *procid);
|
||||
|
||||
/* NS_RebootToTitle()
|
||||
mediatype mediatype for title
|
||||
titleid TitleId of title to launch
|
||||
*/
|
||||
Result NS_RebootToTitle(u8 mediatype, u64 titleid);
|
50
libctru/source/services/ns.c
Normal file
50
libctru/source/services/ns.c
Normal file
@ -0,0 +1,50 @@
|
||||
#include <stdlib.h>
|
||||
#include <3ds.h>
|
||||
|
||||
static Handle nsHandle;
|
||||
|
||||
Result nsInit()
|
||||
{
|
||||
return srvGetServiceHandle(&nsHandle, "ns:s");
|
||||
}
|
||||
|
||||
Result nsExit()
|
||||
{
|
||||
return svcCloseHandle(nsHandle);
|
||||
}
|
||||
|
||||
Result NS_LaunchTitle(u64 titleid, u32 launch_flags, u32 *procid)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = 0x000200C0;
|
||||
cmdbuf[1] = titleid & 0xffffffff;
|
||||
cmdbuf[2] = (titleid >> 32) & 0xffffffff;
|
||||
cmdbuf[3] = launch_flags;
|
||||
|
||||
if((ret = svcSendSyncRequest(nsHandle))!=0)return ret;
|
||||
|
||||
if(procid != NULL)
|
||||
*procid = cmdbuf[2];
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result NS_RebootToTitle(u8 mediatype, u64 titleid)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = 0x00100180;
|
||||
cmdbuf[1] = 0x1;
|
||||
cmdbuf[2] = titleid & 0xffffffff;
|
||||
cmdbuf[3] = (titleid >> 32) & 0xffffffff;
|
||||
cmdbuf[4] = mediatype;
|
||||
cmdbuf[5] = 0x0; // reserved
|
||||
cmdbuf[6] = 0x0;
|
||||
|
||||
if((ret = svcSendSyncRequest(nsHandle))!=0)return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
Loading…
Reference in New Issue
Block a user