From 2075261f1e571594fd692589b6d8a112f49beb14 Mon Sep 17 00:00:00 2001 From: Joel16 Date: Fri, 18 May 2018 18:56:00 -0500 Subject: [PATCH] Add setGetSerialNumber --- nx/include/switch/services/set.h | 3 +++ nx/source/services/set.c | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/nx/include/switch/services/set.h b/nx/include/switch/services/set.h index 57ffeeff..c77e3e5d 100644 --- a/nx/include/switch/services/set.h +++ b/nx/include/switch/services/set.h @@ -66,3 +66,6 @@ void setsysExit(void); /// Gets the current system theme. Result setsysGetColorSetId(ColorSetId* out); + +/// Gets the serial number. +Result setGetSerialNumber(char *serial); diff --git a/nx/source/services/set.c b/nx/source/services/set.c index ae66fad0..9e815bb0 100644 --- a/nx/source/services/set.c +++ b/nx/source/services/set.c @@ -346,3 +346,38 @@ Result setsysGetColorSetId(ColorSetId* out) return rc; } + +Result setGetSerialNumber(char *serial) { + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 68; + + Result rc = serviceIpcDispatch(&g_setsysSrv); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + ipcParse(&r); + + struct { + u64 magic; + u64 result; + char serial[0x18]; + } *resp = r.Raw; + + rc = resp->result; + + if (R_SUCCEEDED(rc) && serial) + memcpy(serial, resp->serial, 0x18); + } + + return rc; +}