PM: Added API
This commit is contained in:
parent
3d798def58
commit
bf68b2d4e5
51
libctru/include/3ds/services/pm.h
Normal file
51
libctru/include/3ds/services/pm.h
Normal file
@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
Requires access to "pm:app" service
|
||||
*/
|
||||
|
||||
Result pmInit();
|
||||
Result pmExit();
|
||||
|
||||
/* PM_LaunchTitle()
|
||||
About: Launches a title
|
||||
|
||||
mediatype mediatype of title
|
||||
titleid TitleId of title to launch
|
||||
launch_flags use if you know of any
|
||||
*/
|
||||
Result PM_LaunchTitle(u8 mediatype, u64 titleid);
|
||||
|
||||
/* PM_GetTitleExheaderFlags()
|
||||
About: Writes to a buffer the launch flags (8 bytes) from a title exheader.
|
||||
|
||||
mediatype mediatype of title
|
||||
titleid TitleId of title
|
||||
out ptr to where the flags should be written to
|
||||
*/
|
||||
Result PM_GetTitleExheaderFlags(u8 mediatype, u64 titleid, u8* out);
|
||||
|
||||
/* PM_SetFIRMLaunchParams()
|
||||
About: Sets the FIRM launch params from in
|
||||
|
||||
size size of FIRM launch params
|
||||
in ptr to location of FIRM launch params
|
||||
*/
|
||||
Result PM_SetFIRMLaunchParams(u32 size, u8* in);
|
||||
|
||||
/* PM_GetFIRMLaunchParams()
|
||||
About: Sets the FIRM launch params from in
|
||||
|
||||
size size of buffer to store FIRM launch params
|
||||
out ptr to location to write FIRM launch params
|
||||
*/
|
||||
Result PM_GetFIRMLaunchParams(u32 size, u8* out);
|
||||
|
||||
/* PM_SetFIRMLaunchParams()
|
||||
About: Same as PM_SetFIRMLaunchParams(), but also triggers a FIRM launch
|
||||
|
||||
firm_titleid_low TitleID low of firm title to launch
|
||||
size size of FIRM launch params
|
||||
in ptr to location of FIRM launch params
|
||||
*/
|
||||
Result PM_LaunchFIRMSetParams(u64 firm_titleid_low, u32 size, u8* in);
|
95
libctru/source/services/pm.c
Normal file
95
libctru/source/services/pm.c
Normal file
@ -0,0 +1,95 @@
|
||||
#include <stdlib.h>
|
||||
#include <3ds.h>
|
||||
|
||||
static Handle pmHandle;
|
||||
|
||||
Result pmInit()
|
||||
{
|
||||
return srvGetServiceHandle(&pmHandle, "pm:app");
|
||||
}
|
||||
|
||||
Result pmExit()
|
||||
{
|
||||
return svcCloseHandle(pmHandle);
|
||||
}
|
||||
|
||||
Result PM_LaunchTitle(u8 mediatype, u64 titleid, u32 launch_flags)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = 0x00010140;
|
||||
cmdbuf[1] = titleid & 0xffffffff;
|
||||
cmdbuf[2] = (titleid >> 32) & 0xffffffff;
|
||||
cmdbuf[3] = mediatype;
|
||||
cmdbuf[4] = 0x0;
|
||||
cmdbuf[5] = launch_flags;
|
||||
|
||||
if((ret = svcSendSyncRequest(pmHandle))!=0)return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result PM_GetTitleExheaderFlags(u8 mediatype, u64 titleid, u8* out)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = 0x00080100;
|
||||
cmdbuf[1] = titleid & 0xffffffff;
|
||||
cmdbuf[2] = (titleid >> 32) & 0xffffffff;
|
||||
cmdbuf[3] = mediatype;
|
||||
cmdbuf[4] = 0x0;
|
||||
|
||||
if((ret = svcSendSyncRequest(pmHandle))!=0)return ret;
|
||||
|
||||
memcpy(out, (u8*)(&cmdbuf[2]), 8);
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result PM_SetFIRMLaunchParams(u32 size, u8* in)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = 0x00090042;
|
||||
cmdbuf[1] = size;
|
||||
cmdbuf[2] = (size << 0x4) | 0xa;
|
||||
cmdbuf[3] = (u32)in;
|
||||
|
||||
if((ret = svcSendSyncRequest(pmHandle))!=0)return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result PM_GetFIRMLaunchParams(u32 size, u8* out)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = 0x00070042;
|
||||
cmdbuf[1] = size;
|
||||
cmdbuf[2] = (size << 0x4) | 0xc;
|
||||
cmdbuf[3] = (u32)out;
|
||||
|
||||
if((ret = svcSendSyncRequest(pmHandle))!=0)return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result PM_LaunchFIRMSetParams(u32 firm_titleid_low, u32 size, u8* in)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = 0x00020082;
|
||||
cmdbuf[1] = firm_titleid_low;
|
||||
cmdbuf[2] = size;
|
||||
cmdbuf[3] = (size << 0x4) | 0xa;
|
||||
cmdbuf[4] = (u32)in;
|
||||
|
||||
if((ret = svcSendSyncRequest(pmHandle))!=0)return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
Loading…
Reference in New Issue
Block a user