From d3f8b192f34be982808830637431b459f40f53fe Mon Sep 17 00:00:00 2001 From: Joel16 Date: Sun, 17 Sep 2017 01:16:14 -0500 Subject: [PATCH] Merge upstream changes from GUI --- include/kernel.h | 23 +++++++++++++++++++ include/system.h | 19 ++++++++++++++++ source/kernel.c | 3 +-- source/system.c | 59 ++++++++++++++++++++++++++++++++++++------------ 4 files changed, 87 insertions(+), 17 deletions(-) diff --git a/include/kernel.h b/include/kernel.h index 3a41c33..7394ab9 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -3,6 +3,29 @@ #include <3ds.h> +enum +{ + KERNEL_VERSIONREVISION = 0x1FF80001, + KERNEL_VERSIONMINOR = 0x1FF80002, + KERNEL_VERSIONMAJOR = 0x1FF80003, + UPDATEFLAG = 0x1FF80004, + NSTID = 0x1FF80008, + SYSCOREVER = 0x1FF80010, + ENVINFO = 0x1FF80014, + UNITINFO = 0x1FF80014, + PREV_FIRM = 0x1FF80016, + KERNEL_CTRSDKVERSION = 0x1FF80018, + APPMEMTYPE = 0x1FF80030, + APPMEMALLOC = 0x1FF80040, + SYSMEMALLOC = 0x1FF80044, + BASEMEMALLOC = 0x1FF80048, + FIRM_VERSIONREVISION = 0x1FF80061, + FIRM_VERSIONMINOR = 0x1FF80062, + FIRM_VERSIONMAJOR = 0x1FF80063, + FIRM_SYSCOREVER = 0x1FF80064, + FIRM_CTRSDKVERSION = 0x1FF80068, +}; + char * getVersion(int version); char * getSdmcCid(void); char * getNandCid(void); diff --git a/include/system.h b/include/system.h index 366852e..a7414e5 100644 --- a/include/system.h +++ b/include/system.h @@ -3,11 +3,30 @@ #include <3ds.h> +enum +{ + DATETIME = 0x1FF81000, + RUNNING_HW = 0x1FF81004, + MCU_HW_INFO = 0x1FF81005, + DATETIME_0 = 0x1FF81020, + DATETIME_1 = 0x1FF81040, + WIFI_MACADDR = 0x1FF81060, + WIFI_LINKLEVEL = 0x1FF81066, + _3D_SLIDERSTATE = 0x1FF81080, + _3D_LEDSTATE = 0x1FF81084, + BATTERY_LEDSTATE = 0x1FF81085, + MENUTID = 0x1FF810A0, + ACTIVEMENUTID = 0x1FF810A8, + HEADSET_CONNECTED = 0x1FF810C0 +}; + const char * getModel(void); const char * getRegion(void); const char getFirmRegion(void); const char * getLang(void); char * getMacAddress(void); +char * getRunningHW(void); +char * isDebugUnit(void); char * getScreenType(void); u64 getLocalFriendCodeSeed(void); u8 * getSerialNumber(void); diff --git a/source/kernel.c b/source/kernel.c index 39950fb..534c033 100644 --- a/source/kernel.c +++ b/source/kernel.c @@ -26,9 +26,8 @@ char * getVersion(int version) memset(nver, 0, sizeof(OS_VersionBin)); memset(cver, 0, sizeof(OS_VersionBin)); - ret = osGetSystemVersionData(nver, cver); - if (ret) + if (R_FAILED(ret = osGetSystemVersionData(nver, cver))) snprintf(str_sysver, 100, "0x%08liX", ret); else snprintf(str_sysver, 100, "%d.%d.%d-%d%c", diff --git a/source/system.c b/source/system.c index 7387bf4..3d9e723 100644 --- a/source/system.c +++ b/source/system.c @@ -117,7 +117,7 @@ const char * getLang(void) char * getMacAddress(void) { - u8 * macByte = (u8 *)0x1FF81060; + u8 * macByte = (u8 *)WIFI_MACADDR; static char macAddress[18]; snprintf(macAddress, 18, "%02X:%02X:%02X:%02X:%02X:%02X", *macByte, *(macByte + 1), *(macByte + 2), *(macByte + 3), *(macByte + 4), *(macByte + 5)); @@ -125,10 +125,39 @@ char * getMacAddress(void) return macAddress; } +char * getRunningHW(void) +{ + u8 * data = (u8 *)RUNNING_HW; + static char runningHW[0x9]; + + switch (*data) + { + case 1: + snprintf(runningHW, 0x7, "Retail"); + break; + case 2: + snprintf(runningHW, 0x9, "Devboard"); + break; + case 3: + snprintf(runningHW, 0x9, "Debugger"); + break; + case 4: + snprintf(runningHW, 0x8, "Capture"); + break; + } + + return runningHW; +} + +char * isDebugUnit(void) +{ + return *(char *)0x1FF80015 ? "(Debug Unit)" : ""; +} + char * getScreenType(void) { - static char uScreenType[20]; - static char dScreenType[20]; + static char upperScreen[20]; + static char lowerScreen[20]; static char screenType[32]; @@ -144,31 +173,31 @@ char * getScreenType(void) switch ((screens >> 4) & 0xF) { - case 1: // 0x01 = JDI => IPS - sprintf(uScreenType, "Upper: IPS"); + case 0x01: // 0x01 = JDI => IPS + sprintf(upperScreen, "Upper: IPS"); break; - case 0xC: // 0x0C = SHARP => TN - sprintf(uScreenType, "Upper: TN"); + case 0x0C: // 0x0C = SHARP => TN + sprintf(upperScreen, "Upper: TN"); break; default: - sprintf(uScreenType, "Upper: Unknown"); + sprintf(upperScreen, "Upper: Unknown"); break; } switch (screens & 0xF) { - case 1: // 0x01 = JDI => IPS - sprintf(dScreenType, " | Lower: IPS"); + case 0x01: // 0x01 = JDI => IPS + sprintf(lowerScreen, " | Lower: IPS"); break; - case 0xC: // 0x0C = SHARP => TN - sprintf(dScreenType, " | Lower: TN"); + case 0x0C: // 0x0C = SHARP => TN + sprintf(lowerScreen, " | Lower: TN"); break; default: - sprintf(dScreenType, " | Lower: Unknown"); + sprintf(lowerScreen, " | Lower: Unknown"); break; } - strcpy(screenType, uScreenType); - strcat(screenType, dScreenType); + strcpy(screenType, upperScreen); + strcat(screenType, lowerScreen); } else sprintf(screenType, "Upper: TN | Lower: TN");