NS: Added API

This commit is contained in:
idunoe 2014-10-27 13:17:34 +08:00
parent b66d047e76
commit 3d798def58
2 changed files with 71 additions and 0 deletions

View 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);

View 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];
}