mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-04 10:32:15 +02:00
Added a few misc IPC wrappers
Signed-off-by: Adubbz <Adubbz@users.noreply.github.com>
This commit is contained in:
parent
a5381e43c0
commit
635f0401e8
@ -17,3 +17,9 @@ Result nsInitialize(void);
|
||||
void nsExit(void);
|
||||
|
||||
Result nsGetApplicationControlData(u8 flag, u64 titleID, NsApplicationControlData* buffer, size_t size, size_t* actual_size);
|
||||
|
||||
Result nsvmInitialize(void);
|
||||
void nsvmExit(void);
|
||||
|
||||
Result nsvmNeedsUpdateVulnerability(u8 *out);
|
||||
Result nsvmGetSafeSystemVersion(u16 *out);
|
||||
|
@ -27,3 +27,4 @@ Result pmdmntEnableDebugForApplication(Handle* handle_out);
|
||||
Result pminfoGetTitleId(u64* title_id_out, u64 pid);
|
||||
|
||||
Result pmshellLaunchProcess(u32 launch_flags, u64 titleID, u64 storageID, u64 *pid);
|
||||
Result pmshellTerminateProcessByTitleId(u64 title_id);
|
@ -7,6 +7,8 @@
|
||||
*/
|
||||
#include "../result.h"
|
||||
|
||||
#define SET_MAX_NAME_SIZE 0x30
|
||||
|
||||
typedef enum {
|
||||
ColorSetId_Light=0,
|
||||
ColorSetId_Dark=1
|
||||
@ -67,6 +69,18 @@ void setsysExit(void);
|
||||
/// Gets the current system theme.
|
||||
Result setsysGetColorSetId(ColorSetId* out);
|
||||
|
||||
/**
|
||||
* @brief Gets the size of a settings item value.
|
||||
* @param out Pointer to output the size to.
|
||||
*/
|
||||
Result setsysGetSettingsItemValueSize(const char *name, const char *item_key, u64 *size_out);
|
||||
|
||||
/**
|
||||
* @brief Gets the value of a settings item value.
|
||||
* @param out Pointer to output the value to.
|
||||
*/
|
||||
Result setsysGetSettingsItemValue(const char *name, const char *item_key, u64 *value_out);
|
||||
|
||||
/**
|
||||
* @brief Gets the system's serial number.
|
||||
* @param serial Pointer to output the serial to. (The buffer size needs to be at least 0x19 bytes)
|
||||
@ -108,3 +122,5 @@ Result setsysGetWirelessLanEnableFlag(bool *out);
|
||||
* @param out Pointer to output the status to.
|
||||
*/
|
||||
Result setsysGetBluetoothEnableFlag(bool *out);
|
||||
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
#include "services/sm.h"
|
||||
#include "services/ns.h"
|
||||
|
||||
static Service g_nsAppManSrv, g_nsGetterSrv;
|
||||
static u64 g_nsRefCnt;
|
||||
static Service g_nsAppManSrv, g_nsGetterSrv, g_nsvmSrv;
|
||||
static u64 g_nsRefCnt, g_nsvmRefCnt;
|
||||
|
||||
static Result _nsGetInterface(Service* srv_out, u64 cmd_id);
|
||||
|
||||
@ -116,3 +116,89 @@ Result nsGetApplicationControlData(u8 flag, u64 titleID, NsApplicationControlDat
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result nsvmInitialize(void)
|
||||
{
|
||||
atomicIncrement64(&g_nsvmRefCnt);
|
||||
|
||||
if (serviceIsActive(&g_nsvmSrv))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_AlreadyInitialized);
|
||||
|
||||
return smGetService(&g_nsvmSrv, "ns:vm");
|
||||
}
|
||||
|
||||
void nsvmExit(void)
|
||||
{
|
||||
if (atomicDecrement64(&g_nsvmRefCnt) == 0) {
|
||||
serviceClose(&g_nsvmSrv);
|
||||
}
|
||||
}
|
||||
|
||||
Result nsvmNeedsUpdateVulnerability(u8 *out) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 1200;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_nsvmSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u8 out;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc) && out) *out = resp->out;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result nsvmGetSafeSystemVersion(u16 *out)
|
||||
{
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 1202;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_nsvmSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u16 out;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc) && out) *out = resp->out;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
@ -314,3 +314,36 @@ Result pmshellLaunchProcess(u32 launch_flags, u64 titleID, u64 storageID, u64 *p
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result pmshellTerminateProcessByTitleId(u64 title_id) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u64 title_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 2;
|
||||
raw->title_id = title_id;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_pmshellSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
@ -348,6 +348,76 @@ Result setsysGetColorSetId(ColorSetId* out)
|
||||
|
||||
}
|
||||
|
||||
Result setsysGetSettingsItemValue(const char *name, const char *item_key, u64 *value_out) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
ipcAddSendStatic(&c, name, SET_MAX_NAME_SIZE, 0);
|
||||
ipcAddSendStatic(&c, item_key, SET_MAX_NAME_SIZE, 0);
|
||||
ipcAddRecvBuffer(&c, value_out, sizeof(u64), 0);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 38;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_setsysSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result setsysGetSettingsItemValueSize(const char *name, const char *item_key, u64 *size_out) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
ipcAddSendStatic(&c, name, SET_MAX_NAME_SIZE, 0);
|
||||
ipcAddSendStatic(&c, item_key, SET_MAX_NAME_SIZE, 0);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 37;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_setsysSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u64 size;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc) && size_out) *size_out = resp->size;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result setsysGetSerialNumber(char *serial) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
Loading…
Reference in New Issue
Block a user