diff --git a/nx/include/switch/services/set.h b/nx/include/switch/services/set.h index 1f8b41ee..6c862982 100644 --- a/nx/include/switch/services/set.h +++ b/nx/include/switch/services/set.h @@ -175,3 +175,15 @@ Result setsysBindFatalDirtyFlagEvent(Event *out); * @param flags_1 Pointer to populate with second 64 flags. */ Result setsysGetFatalDirtyFlags(u64 *flags_0, u64 *flags_1); + +/** + * @brief Gets the system's nickname. + * @param buffer Pointer to output the nickname to. (The buffer size needs to be at least 0x80 bytes) + */ +Result setsysGetDeviceNickname(char* buffer); + +/** + * @brief Sets the system's nickname. + * @param buffer Pointer to read the nickname from. + */ +Result setsysSetDeviceNickname(char* buffer); diff --git a/nx/source/services/set.c b/nx/source/services/set.c index 0772dac5..8f78cd04 100644 --- a/nx/source/services/set.c +++ b/nx/source/services/set.c @@ -686,3 +686,69 @@ Result setsysGetFatalDirtyFlags(u64 *flags_0, u64 *flags_1) { return rc; } + +Result setsysGetDeviceNickname(char* buffer) { + IpcCommand c; + ipcInitialize(&c); + + ipcAddRecvBuffer(&c, buffer, 0x80, BufferType_Normal); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 77; + + 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 setsysSetDeviceNickname(char* buffer) { + IpcCommand c; + ipcInitialize(&c); + + ipcAddSendBuffer(&c, buffer, 0x80, BufferType_Normal); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 78; + + 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; +}