Implement setsys(Get/Set)DeviceNickname.

Thanks to @shchmue & @thog for tips on the send/recv buffers!
This commit is contained in:
The Dax 2019-06-03 18:28:32 -04:00
parent 8cf419802a
commit fd858d5923
2 changed files with 78 additions and 0 deletions

View File

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

View File

@ -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;
}