Upstream changes with GUI, screen glitch fixes and more!

- System version now displays region ID:

U = USA/CAN
E = EUR/AUS
J = JPN
C = CHN
K = KOR
T = TWN

- Minor code clean up + consistency.

- Now displays home menu ID in misc tab.

- WiFi information, SSID and password. Thanks to LiquidFenrir for his WiFi manager's network struct.

- New colours:

- Displays Homemenu ID
- Displays IP address
- Displays brightness

Cyan for misc info.
Purple for NNID.
Green for WiFi slots.

- Fixed buffer overflows thanks to GCC  7.1.0.
This commit is contained in:
Joel 2017-07-16 03:35:22 -04:00
parent b288fd5093
commit f8769ed82d
12 changed files with 285 additions and 139 deletions

View File

@ -4,7 +4,7 @@
#include <3ds.h>
u32 titleCount(FS_MediaType mediaType);
bool detectSD();
bool detectSD(void);
u64 getFreeStorage(FS_SystemMediaType mediaType);
u64 getTotalStorage(FS_SystemMediaType mediaType);
u64 getUsedStorage(FS_SystemMediaType mediaType);

View File

@ -3,6 +3,6 @@
#include <3ds.h>
const char * batteryStatus();
const char * batteryStatus(void);
#endif

View File

@ -3,19 +3,20 @@
#include <3ds.h>
const char * getModel();
const char * getRegion();
const char * getLang();
char * getMacAddress();
char * getScreenType();
u64 getLocalFriendCodeSeed();
const char * getModel(void);
const char * getRegion(void);
const char getFirmRegion(void);
const char * getLang(void);
char * getMacAddress(void);
char * getScreenType(void);
u64 getLocalFriendCodeSeed(void);
char * getSerialNum(void);
u32 getDeviceId(void);
u64 getSoapId(void);
char * getDeviceCert(void);
char * getNNIDInfo(u32 size, u32 blkId);
char * isDebugModeEnabled();
char * isDebugModeEnabled(void);
char * getBrightness(u32 screen);
char * getCardSlotStatus();
char * getCardSlotStatus(void);
#endif

View File

@ -12,6 +12,6 @@
void getSizeString(char *string, uint64_t size);
void utf2ascii(char* dst, u16* src);
char * base64Encode(u8 const * input);
char * base64Encode(u8 const * bytesToEnc, size_t bufLen);
#endif

72
include/wifi.h Normal file
View File

@ -0,0 +1,72 @@
#ifndef WIFI_H
#define WIFI_H
#include <3ds.h>
/*
The things below here were found by LiquidFenrir and his Wifi Manager. (https://github.com/LiquidFenrir/WifiManager)
*/
#define CFG_WIFI_BLKID (u32)0x00080000
#define CFG_WIFI_SLOT_SIZE (u32)0xC00
typedef struct {
bool exists;
bool use;
bool second;
u8 padding1;
char SSID[0x20];
u8 SSID_length;
u8 AP_encryption_type;
u16 padding2;
char password[0x40]; //plaintext, blank for a network set up with WPS
u8 passwordPSK[0x20];
} networkStruct;
typedef struct {
bool exists;
u8 padding1;
u16 checksum; //crc-16 of the next 0x410 bytes, with initval 0: https://github.com/lammertb/libcrc/blob/v2.0/src/crc16.c#L43-L76
//if the network is set "normally", 'use' is 1
//if the network is set by WPS, 'use' is 0
//'second' is 0
//if setting multiple networks with WPS in the same session, only the last set will have this. others will have completely 0x00 except for 'exists'
networkStruct network;
u8 padding2[0x20];
//completely 0x00 if the network was set "normally", otherwise (set by WPS) normal but 'use' and 'second' are 1
networkStruct network_WPS;
u8 padding3[0x20C];
bool auto_obtain_IP; //defaults to 1
bool auto_obtain_DNS; //defaults to 1
u16 padding4;
u8 IP_address[4];
u8 gateway_address[4];
u8 subnet_mask[4];
u8 primary_DNS[4];
u8 secondary_DNS[4];
// if setting multiple networks in the same session, only the last set will have these. others will have completely 0x00
u8 unk1[4];
u8 IP_to_use[4];
u8 MAC_address[6];
u8 channel;
u8 padding5;
bool use_proxy; //defaults to 0
bool basic_authentication; //defaults to 0
u16 port_number; //defaults to 1
char proxy_address[0x30]; //including ending nullbyte
u8 padding6[0x34];
char proxy_username[0x20]; //including ending nullbyte
char proxy_password[0x20]; //including ending nullbyte
u16 padding7;
u16 MTU_value; //defaults to 1400, range [576;1500]
//nothing beyond this point (0x414), but each slot is 0xC00 big...
u8 padding8[0x7EC];
} wifiBlock;
#endif

View File

@ -215,6 +215,7 @@ AccessControlInfo:
- cecd:u
- cfg:nor
- cfg:u
- cfg:i
- cfg:s
- csnd:SND
- dsp::DSP

View File

@ -53,7 +53,7 @@ char * getCID(int type)
else if (type == 1) //NAND
FSUSER_GetNandCid(buf, 0x10);
sprintf(cid, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
snprintf(cid, 33, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
buf[6], buf[7], buf[8], buf[9], buf[10], buf[11],
buf[12], buf[13], buf[14], buf[15]);

View File

@ -1,9 +1,4 @@
#include <3ds.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <malloc.h>
#include <unistd.h>
#include "actu.h"
#include "cfgs.h"
@ -14,6 +9,7 @@
#include "screenshot.h"
#include "system.h"
#include "utils.h"
#include "wifi.h"
#define SDK(a, b, c, d) ((a<<24) | (b<<16) | (c<<8) | d)
@ -33,10 +29,12 @@ void initServices()
aptInit();
hidInit();
actInit(SDK(11, 2, 0, 200), 0x20000);
socInit((u32*)memalign(0x1000, 0x10000), 0x10000);
}
void termServices()
{
socExit();
actExit();
hidExit();
aptExit();
@ -57,25 +55,95 @@ int main(int argc, char *argv[])
{
initServices();
consoleInit(GFX_BOTTOM, NULL);
printf("\x1b[32;1m> Press any key to exit =)\x1b[0m");
//printf("\x1b[31;1m*\x1b[0m Device cert: \x1b[31;1m%s\x1b[0m \n\n", getDeviceCert());
consoleInit(GFX_TOP, NULL);
//=====================================================================//
//------------------------Variable Declaration-------------------------//
//=====================================================================//
char *str_ver = (char *)malloc(sizeof(char) * 255), *str_sysver = (char *)malloc(sizeof(char) * 255);
double wifiPercent, volPercent, _3dSliderPercent;
u32 os_ver = osGetKernelVersion(), firm_ver = osGetKernelVersion(), principalID = 0;
u8 buf[16], batteryPercent, batteryVolt, volume;
unsigned long long transferableID = 0, homemenuID = 0;
u32 os_ver = osGetKernelVersion(), firm_ver = osGetKernelVersion(), ip;
unsigned int principalID = 0, persistentID = 0;
u16 info[0x16];
u8 buf[16], batteryPercent = 0, batteryVolt = 0, volume = 0, mcuFwMajor = 0, mcuFwMinor = 0;
bool isConnected = false;
OS_VersionBin *nver = (OS_VersionBin *)malloc(sizeof(OS_VersionBin)), *cver = (OS_VersionBin *)malloc(sizeof(OS_VersionBin));
char sdFreeSize[16], sdTotalSize[16];
char ctrFreeSize[16], ctrTotalSize[16];
s32 ret;
char sdFreeSize[16], sdTotalSize[16], ctrFreeSize[16], ctrTotalSize[16], name[0x16];
Result ret = 0, wifiRet = 0;
wifiBlock slotData;
consoleInit(GFX_BOTTOM, NULL);
//=====================================================================//
//------------------------------MISC Info (continued)------------------//
//=====================================================================//
printf("\x1b[36;1m*\x1b[0m Brightness: \x1b[36;1m%s\x1b[0m \n", getBrightness(1));
ip = gethostid();
printf("\x1b[36;1m*\x1b[0m IP: \x1b[36;1m%lu.%lu.%lu.%lu\x1b[0m \n\n", ip & 0xFF, (ip>>8)&0xFF, (ip>>16)&0xFF, (ip>>24)&0xFF);
//=====================================================================//
//------------------------------NNID Info------------------------------//
//=====================================================================//
ACTU_GetAccountDataBlock(&principalID, 0x4, 0xC); // First check if principal ID exists then display NNID info.
if (principalID != 0)
{
printf("\x1b[35;1m*\x1b[0m NNID: \x1b[35;1m%s\x1b[0m\n", getNNIDInfo(0x11, 0x8));
ACTU_GetAccountDataBlock(info, 0x16, 0x1B);
utf2ascii(name, info);
printf("\x1b[35;1m*\x1b[0m Mii name: \x1b[35;1m%s\x1b[0m\n", name);
printf("\x1b[35;1m*\x1b[0m Principal ID: \x1b[35;1m%u\x1b[0m\n", principalID);
ACTU_GetAccountDataBlock(&persistentID, 0x4, 0x5);
printf("\x1b[35;1m*\x1b[0m Persistent ID: \x1b[35;1m%u\x1b[0m\n", persistentID);
ACTU_GetAccountDataBlock(&transferableID, 0x8, 0x6);
printf("\x1b[35;1m*\x1b[0m Transferable ID: \x1b[35;1m%llu\x1b[0m\n", transferableID);
printf("\x1b[35;1m*\x1b[0m Country: \x1b[35;1m%s\x1b[0m\n", getNNIDInfo(0x3, 0xB));
printf("\x1b[35;1m*\x1b[0m Time Zone: \x1b[35;1m%s\x1b[0m\n\n", getNNIDInfo(0x41, 0x1E));
}
//=====================================================================//
//------------------------------WIFI Info------------------------------//
//=====================================================================//
wifiRet = CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID + 0, (u8*)&slotData);
if ((!wifiRet) && (slotData.exists))
{
if (slotData.network.use)
printf("\x1b[32;1m*\x1b[0m WiFi Slot 1: \x1b[32;1m%s\x1b[0m (\x1b[32;1m%s\x1b[0m)\n", slotData.network.SSID, slotData.network.password);
else if (slotData.network_WPS.use)
printf("\x1b[32;1m*\x1b[0m WiFi Slot 1: \x1b[32;1m%s\x1b[0m (\x1b[32;1m%s\x1b[0m)\n", slotData.network_WPS.SSID, slotData.network_WPS.password);
}
wifiRet = CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID + 1, (u8*)&slotData);
if ((!wifiRet) && (slotData.exists))
{
if (slotData.network.use)
printf("\x1b[32;1m*\x1b[0m WiFi Slot 2: \x1b[32;1m%s\x1b[0m (\x1b[32;1m%s\x1b[0m)\n", slotData.network.SSID, slotData.network.password);
else if (slotData.network_WPS.use)
printf("\x1b[32;1m*\x1b[0m WiFi Slot 2: \x1b[32;1m%s\x1b[0m (\x1b[32;1m%s\x1b[0m)\n", slotData.network_WPS.SSID, slotData.network_WPS.password);
}
wifiRet = CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID + 2, (u8*)&slotData);
if ((!wifiRet) && (slotData.exists))
{
if (slotData.network.use)
printf("\x1b[32;1m*\x1b[0m WiFi Slot 3: \x1b[32;1m%s\x1b[0m (\x1b[32;1m%s\x1b[0m)\n", slotData.network.SSID, slotData.network.password);
else if (slotData.network_WPS.use)
printf("\x1b[32;1m*\x1b[0m WiFi Slot 3: \x1b[32;1m%s\x1b[0m (\x1b[32;1m%s\x1b[0m)\n", slotData.network_WPS.SSID, slotData.network_WPS.password);
}
printf("\n\x1b[32;1m> Press any key to exit =)\x1b[0m");
consoleInit(GFX_TOP, NULL);
printf("\x1b[1;1H"); //Move the cursor to the top left corner of the screen
printf("\x1b[32;1m3DSident 0.7.6\x1b[0m\n\n");
@ -102,11 +170,12 @@ int main(int argc, char *argv[])
if (ret)
printf("\x1b[33;1m*\x1b[0m System version: \x1b[33;1m0x%08liX\x1b[0m\n\n", ret);
snprintf(str_sysver, 100, "\x1b[33;1m*\x1b[0m System version: \x1b[33;1m%d.%d.%d-%d\x1b[0m\n\n",
snprintf(str_sysver, 100, "\x1b[33;1m*\x1b[0m System version: \x1b[33;1m%d.%d.%d-%d%c\x1b[0m\n\n",
cver->mainver,
cver->minor,
cver->build,
nver->mainver
nver->mainver,
getFirmRegion()
);
if (!ret)
@ -119,9 +188,6 @@ int main(int argc, char *argv[])
printf("\x1b[31;1m*\x1b[0m Model: \x1b[31;1m%s\x1b[0m (\x1b[31;1m%s\x1b[0m) \n\x1b[0m", getModel(), getRegion());
printf("\x1b[31;1m*\x1b[0m Screen type: \x1b[31;1m %s \n\x1b[0m", getScreenType());
printf("\x1b[31;1m*\x1b[0m Language: \x1b[31;1m%s\x1b[0m \n", getLang());
ACTU_GetAccountDataBlock(&principalID, 0x4, 0xC);
printf("\x1b[31;1m*\x1b[0m NNID: \x1b[31;1m%s\x1b[0m (\x1b[31;1m%u\x1b[0m) \n", getNNIDInfo(0x11, 0x8), (unsigned int)principalID);
printf("\x1b[31;1m*\x1b[0m Device ID: \x1b[31;1m%lu \n", getDeviceId());
printf("\x1b[31;1m*\x1b[0m ECS Device ID: \x1b[31;1m%llu \n", getSoapId());
@ -136,74 +202,66 @@ int main(int argc, char *argv[])
buf[12], buf[13], buf[14], buf[15]);
FSUSER_GetNandCid(buf, 0x10);
printf("\x1b[31;1m*\x1b[0m NAND CID: \x1b[31;1m%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\x1b[0m \n\n",
printf("\x1b[31;1m*\x1b[0m NAND CID: \x1b[31;1m%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\x1b[0m \n",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
buf[6], buf[7], buf[8], buf[9], buf[10], buf[11],
buf[12], buf[13], buf[14], buf[15]);
//=====================================================================//
//----------------------------Battery Info-----------------------------//
//=====================================================================//
mcuGetBatteryLevel(&batteryPercent);
printf("\x1b[34;1m*\x1b[0m Battery percentage: \x1b[34;1m%3d%%\x1b[0m (\x1b[34;1m%s\x1b[0m) \n\x1b[0m", batteryPercent, batteryStatus());
mcuGetBatteryVoltage(&batteryVolt);
printf("\x1b[34;1m*\x1b[0m Battery voltage: \x1b[34;1m%d\x1b[0m (\x1b[34;1m%.1f V\x1b[0m)\n", batteryVolt, 5.0 * ((double)batteryVolt / 256.0)); // Estimated volt
u8 mcuFwMajor, mcuFwMinor;
GetMcuFwVerHigh(&mcuFwMajor);
GetMcuFwVerLow(&mcuFwMinor);
printf("\x1b[34;1m*\x1b[0m MCU firmware: \x1b[34;1m%u.%u\x1b[0m\n\n", (mcuFwMajor - 16), mcuFwMinor);
ret = APT_GetAppletInfo(APPID_HOMEMENU, &homemenuID, NULL, NULL, NULL, NULL);
printf("\x1b[31;1m*\x1b[0m Homemenu ID: \x1b[31;1m%016llX\x1b[0m \n\n", homemenuID);
//=====================================================================//
//------------------------------Misc Info------------------------------//
//=====================================================================//
getSizeString(sdFreeSize, getFreeStorage(SYSTEM_MEDIATYPE_SD));
getSizeString(sdTotalSize, getTotalStorage(SYSTEM_MEDIATYPE_SD));
printf("\x1b[32;1m*\x1b[0m SD Size: \x1b[32;1m%s\x1b[0m / \x1b[32;1m%s\x1b[0m \n", sdFreeSize, sdTotalSize);
getSizeString(ctrFreeSize, getFreeStorage(SYSTEM_MEDIATYPE_CTR_NAND));
getSizeString(ctrTotalSize, getTotalStorage(SYSTEM_MEDIATYPE_CTR_NAND));
printf("\x1b[32;1m*\x1b[0m CTR Size: \x1b[32;1m%s\x1b[0m / \x1b[32;1m%s\x1b[0m \n", ctrFreeSize, ctrTotalSize);
printf("\x1b[32;1m*\x1b[0m Installed titles: SD: \x1b[32;1m%lu\x1b[0m (NAND: \x1b[32;1m%lu\x1b[0m)\n", titleCount(MEDIATYPE_SD), titleCount(MEDIATYPE_NAND));
while (aptMainLoop())
{
//=====================================================================//
//----------------------------Battery Info-----------------------------//
//=====================================================================//
printf("\x1b[19;0H"); //Move the cursor to the top left corner of the screen
printf("\x1b[19;0H");
mcuGetBatteryLevel(&batteryPercent);
printf("\x1b[34;1m*\x1b[0m Battery percentage: \x1b[34;1m%3d%%\x1b[0m (\x1b[34;1m%s\x1b[0m) \n\x1b[0m", batteryPercent, batteryStatus());
printf("\x1b[34;1m*\x1b[0m Battery percentage: \x1b[34;1m%3d%%\x1b[0m (\x1b[34;1m%s\x1b[0m) \n", batteryPercent, batteryStatus());
printf("\x1b[20;0H"); //Move the cursor to the top left corner of the screen
printf("\x1b[20;0H");
mcuGetBatteryVoltage(&batteryVolt);
printf("\x1b[34;1m*\x1b[0m Battery voltage: \x1b[34;1m%d\x1b[0m (\x1b[34;1m%.1f V\x1b[0m)\n", batteryVolt, 5.0 * ((double)batteryVolt / 256.0));//,(Estimated: %0.1lf V) estimatedVolt);
printf("\x1b[34;1m*\x1b[0m Battery voltage: \x1b[34;1m%d\x1b[0m (\x1b[34;1m%.1f V\x1b[0m) \n", batteryVolt, 5.0 * ((double)batteryVolt / 256.0));//,(Estimated: %0.1lf V) estimatedVolt);
printf("\x1b[21;0H");
PTMU_GetAdapterState(&isConnected);
printf("\x1b[34;1m*\x1b[0m Adapter state: \x1b[34;1m%s\x1b[0m\n", isConnected? "connected " : "disconnected");
printf("\x1b[22;0H");
GetMcuFwVerHigh(&mcuFwMajor);
GetMcuFwVerLow(&mcuFwMinor);
printf("\x1b[34;1m*\x1b[0m MCU firmware: \x1b[34;1m%u.%u\x1b[0m\n\n", (mcuFwMajor - 16), mcuFwMinor);
//=====================================================================//
//------------------------------Misc Info------------------------------//
//=====================================================================//
printf("\x1b[26;0H"); // Move the cursor
wifiPercent = (osGetWifiStrength() * 33.3333333333);
printf("\x1b[32;1m*\x1b[0m WiFi signal strength: \x1b[32;1m%d\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", osGetWifiStrength(), wifiPercent);
printf("\x1b[24;0H");
getSizeString(sdFreeSize, getFreeStorage(SYSTEM_MEDIATYPE_SD));
getSizeString(sdTotalSize, getTotalStorage(SYSTEM_MEDIATYPE_SD));
printf("\x1b[36;1m*\x1b[0m SD Size: \x1b[36;1m%s\x1b[0m / \x1b[36;1m%s\x1b[0m \n", sdFreeSize, sdTotalSize);
printf("\x1b[27;0H"); //Move the cursor
printf("\x1b[25;0H");
getSizeString(ctrFreeSize, getFreeStorage(SYSTEM_MEDIATYPE_CTR_NAND));
getSizeString(ctrTotalSize, getTotalStorage(SYSTEM_MEDIATYPE_CTR_NAND));
printf("\x1b[36;1m*\x1b[0m CTR Size: \x1b[36;1m%s\x1b[0m / \x1b[36;1m%s\x1b[0m \n", ctrFreeSize, ctrTotalSize);
printf("\x1b[26;0H");
printf("\x1b[36;1m*\x1b[0m Installed titles: SD: \x1b[36;1m%lu\x1b[0m (NAND: \x1b[36;1m%lu\x1b[0m)\n", titleCount(MEDIATYPE_SD), titleCount(MEDIATYPE_NAND));
printf("\x1b[27;0H");
wifiPercent = (osGetWifiStrength() * 33.3333333333);
printf("\x1b[36;1m*\x1b[0m WiFi signal strength: \x1b[36;1m%d\x1b[0m (\x1b[36;1m%.0lf%%\x1b[0m) \n", osGetWifiStrength(), wifiPercent);
printf("\x1b[28;0H");
HIDUSER_GetSoundVolume(&volume);
volPercent = (volume * 1.5873015873);
printf("\x1b[32;1m*\x1b[0m Volume slider state: \x1b[32;1m%d\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", volume, volPercent);
printf("\x1b[36;1m*\x1b[0m Volume slider state: \x1b[36;1m%d\x1b[0m (\x1b[36;1m%.0lf%%\x1b[0m) \n", volume, volPercent);
printf("\x1b[28;0H"); //Move the cursor
printf("\x1b[29;0H");
_3dSliderPercent = (osGet3DSliderState() * 100.0);
printf("\x1b[32;1m*\x1b[0m 3D slider state: \x1b[32;1m%.1lf\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", osGet3DSliderState(), _3dSliderPercent);
printf("\x1b[29;0H"); //Move the cursor
printf("\x1b[32;1m*\x1b[0m Brightness: \x1b[32;1m%s\x1b[0m \n", getBrightness(1));
printf("\x1b[36;1m*\x1b[0m 3D slider state: \x1b[36;1m%.1lf\x1b[0m (\x1b[36;1m%.0lf%%\x1b[0m) \n", osGet3DSliderState(), _3dSliderPercent);
gspWaitForVBlank();
hidScanInput();

View File

@ -9,7 +9,7 @@ u32 titleCount(FS_MediaType mediaType)
return count;
}
bool detectSD()
bool detectSD(void)
{
bool isSD;
FSUSER_IsSdmcDetected(&isSD);

View File

@ -1,7 +1,7 @@
#include "power.h"
#include "screenshot.h"
const char * batteryStatus()
const char * batteryStatus(void)
{
u8 batteryStateBool;
PTMU_GetBatteryChargeState(&batteryStateBool);

View File

@ -4,9 +4,9 @@
#include "system.h"
#include "utils.h"
const char * getModel()
const char * getModel(void)
{
const char *models[] =
const char * models[] =
{
"OLD 3DS - CTR",
"OLD 3DS XL - SPR",
@ -26,9 +26,9 @@ const char * getModel()
return models[6];
}
const char * getRegion()
const char * getRegion(void)
{
const char *regions[] =
const char * regions[] =
{
"JPN",
"USA",
@ -49,9 +49,30 @@ const char * getRegion()
return regions[7];
}
const char * getLang()
const char getFirmRegion(void)
{
const char *languages[] =
u8 canadaOrUsa = 0;
CFGU_GetRegionCanadaUSA(&canadaOrUsa);
if (strncmp(getRegion(), "JPN", 3) == 0)
return 'J';
else if (canadaOrUsa == 1)
return 'U';
else if ((strncmp(getRegion(), "EUR", 3) == 0) || (strncmp(getRegion(), "AUS", 3) == 0))
return 'E';
else if (strncmp(getRegion(), "CHN", 3) == 0)
return 'C';
else if (strncmp(getRegion(), "KOR", 3) == 0)
return 'K';
else if (strncmp(getRegion(), "TWN", 3) == 0)
return 'T';
else
return 'X';
}
const char * getLang(void)
{
const char * languages[] =
{
"Japanese",
"English",
@ -76,9 +97,9 @@ const char * getLang()
return languages[11];
}
char * getMacAddress()
char * getMacAddress(void)
{
u8* macByte = (u8*)0x1FF81060;
u8 * macByte = (u8*)0x1FF81060;
static char macAddress[18];
//sprintf automatically zero-terminates the string
@ -87,7 +108,7 @@ char * getMacAddress()
return macAddress;
}
char * getScreenType()
char * getScreenType(void)
{
bool isNew3DS = 0;
APT_CheckNew3DS(&isNew3DS);
@ -143,7 +164,7 @@ char * getScreenType()
return screenType;
}
u64 getLocalFriendCodeSeed()
u64 getLocalFriendCodeSeed(void)
{
u64 seed = 0;
@ -181,7 +202,7 @@ char * getDeviceCert(void)
{
u8 const cert[0x180];
amNetGetDeviceCert(cert);
return base64Encode(cert);
return base64Encode(cert, 0x180);
}
char * getNNIDInfo(u32 size, u32 blkId)
@ -195,7 +216,7 @@ char * getNNIDInfo(u32 size, u32 blkId)
return str;
}
char * isDebugModeEnabled()
char * isDebugModeEnabled(void)
{
u8 debugMode = 0;
CFG_GetConfig(4, 0x130000, &debugMode);
@ -230,7 +251,7 @@ char * getBrightness(u32 screen)
return "n3DS only";
}
char * getCardSlotStatus()
char * getCardSlotStatus(void)
{
bool isInserted = false;
FS_CardType cardType = 0;

View File

@ -23,57 +23,50 @@ void utf2ascii(char* dst, u16* src)
*dst=0x00;
}
char * base64Encode(u8 const * input)
// Crashes doesn't work. Leavign it here for anyone who's interested.
// Also, this is Rei's function (initially in C++, in working condition) not mine.
static const char * base64_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
char * base64Encode(u8 const * bytesToEnc, size_t bufLen)
{
int len = strlen((const char *)input);
int leftover = len % 3;
char *ret = malloc(((len/3) * 4) + ((leftover)?4:0) + 1);
int n = 0;
int outlen = 0;
uint8_t i = 0;
uint8_t *inp = (uint8_t *) input;
const char *index = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
char * ret = "";
int i = 0, j = 0;
u8 temp[3];
u8 str[4];
if (ret == NULL)
return NULL;
while (bufLen--)
{
temp[i++] = *(bytesToEnc++);
if (i == 3)
{
str[0] = (temp[0] & 0xfc) >> 2;
str[1] = ((temp[0] & 0x03) << 4) + ((temp[1] & 0xf0) >> 4);
str[2] = ((temp[1] & 0x0f) << 2) + ((temp[2] & 0xc0) >> 6);
str[3] = temp[2] & 0x3f;
// Convert each 3 bytes of input to 4 bytes of output.
len -= leftover;
for (n = 0; n < len; n+=3) {
i = inp[n] >> 2;
ret[outlen++] = index[i];
for(i = 0; (i <4) ; i++) ret += base64_chars[str[i]];
i = 0;
}
}
i = (inp[n] & 0x03) << 4;
i |= (inp[n+1] & 0xf0) >> 4;
ret[outlen++] = index[i];
if (i)
{
for(j = i; j < 3; j++) temp[j] = '\0';
i = ((inp[n+1] & 0x0f) << 2);
i |= ((inp[n+2] & 0xc0) >> 6);
ret[outlen++] = index[i];
str[0] = (temp[0] & 0xfc) >> 2;
str[1] = ((temp[0] & 0x03) << 4) + ((temp[1] & 0xf0) >> 4);
str[2] = ((temp[1] & 0x0f) << 2) + ((temp[2] & 0xc0) >> 6);
str[3] = temp[2] & 0x3f;
i = (inp[n+2] & 0x3f);
ret[outlen++] = index[i];
}
for (j = 0; (j < i + 1); j++)
ret += base64_chars[str[j]];
// Handle leftover 1 or 2 bytes.
if (leftover) {
i = (inp[n] >> 2);
ret[outlen++] = index[i];
while((i++ < 3))
ret += '=';
}
i = (inp[n] & 0x03) << 4;
if (leftover == 2) {
i |= (inp[n+1] & 0xf0) >> 4;
ret[outlen++] = index[i];
i = ((inp[n+1] & 0x0f) << 2);
}
ret[outlen++] = index[i];
ret[outlen++] = '=';
if (leftover == 1)
ret[outlen++] = '=';
}
ret[outlen] = '\0';
return ret;
return ret;
}