From deab92d48643f25f4bd47bbbabbb0d7f11b7bbae Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 22 May 2018 10:33:45 -0500 Subject: [PATCH] Add some setsysGet* functions (#98) * Add some setsysGet* functions --- nx/include/switch/services/set.h | 36 ++++++ nx/source/services/set.c | 198 +++++++++++++++++++++++++++++++ 2 files changed, 234 insertions(+) diff --git a/nx/include/switch/services/set.h b/nx/include/switch/services/set.h index cd4fc0a0..41ae0b1f 100644 --- a/nx/include/switch/services/set.h +++ b/nx/include/switch/services/set.h @@ -72,3 +72,39 @@ Result setsysGetColorSetId(ColorSetId* out); * @param serial Pointer to output the serial to. (The buffer size needs to be at least 0x19 bytes) */ Result setsysGetSerialNumber(char *serial); + +/** + * @brief Gets the lockscreen status. + * @param out Pointer to output the status to. + */ +Result setsysGetLockScreenFlag(bool *out); + +/** + * @brief Gets the console information upload status. + * @param out Pointer to output the status to. + */ +Result setsysGetConsoleInformationUploadFlag(bool *out); + +/** + * @brief Gets the automatic application download status. + * @param out Pointer to output the status to. + */ +Result setsysGetAutomaticApplicationDownloadFlag(bool *out); + +/** + * @brief Gets the NFC status. + * @param out Pointer to output the status to. + */ +Result setsysGetNfcEnableFlag(bool *out); + +/** + * @brief Gets the wireless LAN status. + * @param out Pointer to output the status to. + */ +Result setsysGetWirelessLanEnableFlag(bool *out); + +/** + * @brief Gets the bluetooth status. + * @param out Pointer to output the status to. + */ +Result setsysGetBluetoothEnableFlag(bool *out); diff --git a/nx/source/services/set.c b/nx/source/services/set.c index b8c4674b..5fb2ff2a 100644 --- a/nx/source/services/set.c +++ b/nx/source/services/set.c @@ -384,3 +384,201 @@ Result setsysGetSerialNumber(char *serial) { return rc; } + +Result setsysGetLockScreenFlag(bool *out) { + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 7; + + Result rc = serviceIpcDispatch(&g_setsysSrv); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + ipcParse(&r); + + struct { + u64 magic; + u64 result; + u8 flag; + } *resp = r.Raw; + + *out = resp->flag; + rc = resp->result; + } + + return rc; +} + +Result setsysGetConsoleInformationUploadFlag(bool *out) { + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 25; + + Result rc = serviceIpcDispatch(&g_setsysSrv); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + ipcParse(&r); + + struct { + u64 magic; + u64 result; + u8 flag; + } *resp = r.Raw; + + *out = resp->flag; + rc = resp->result; + } + + return rc; +} + +Result setsysGetAutomaticApplicationDownloadFlag(bool *out) { + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 27; + + Result rc = serviceIpcDispatch(&g_setsysSrv); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + ipcParse(&r); + + struct { + u64 magic; + u64 result; + u8 flag; + } *resp = r.Raw; + + *out = resp->flag; + rc = resp->result; + } + + return rc; +} + +Result setsysGetNfcEnableFlag(bool *out) { + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 69; + + Result rc = serviceIpcDispatch(&g_setsysSrv); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + ipcParse(&r); + + struct { + u64 magic; + u64 result; + u8 flag; + } *resp = r.Raw; + + *out = resp->flag; + rc = resp->result; + } + + return rc; +} + +Result setsysGetWirelessLanEnableFlag(bool *out) { + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 73; + + Result rc = serviceIpcDispatch(&g_setsysSrv); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + ipcParse(&r); + + struct { + u64 magic; + u64 result; + u8 flag; + } *resp = r.Raw; + + *out = resp->flag; + rc = resp->result; + } + + return rc; +} + +Result setsysGetBluetoothEnableFlag(bool *out) { + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 88; + + Result rc = serviceIpcDispatch(&g_setsysSrv); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + ipcParse(&r); + + struct { + u64 magic; + u64 result; + u8 flag; + } *resp = r.Raw; + + *out = resp->flag; + rc = resp->result; + } + + return rc; +}