next: Reimplement 3DSident in C++

This commit is contained in:
Joel16 2024-09-20 10:50:21 -04:00
parent c665eebce9
commit 7b951f3170
104 changed files with 1902 additions and 3600 deletions

236
Makefile Normal file → Executable file
View File

@ -1,7 +1,235 @@
SUBDIRS = console gui
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
all:
@for dir in $(SUBDIRS); do $(MAKE) -C $$dir; done
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
# GRAPHICS is a list of directories containing graphics files
# GFXBUILD is the directory where converted graphics files will be placed
# If set to $(BUILD), it will statically link in the converted
# files as if they were data files.
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
GRAPHICS := res/drawable
#GFXBUILD := $(BUILD)
#ICON := res/drawable/icon.png
ROMFS := romfs
GFXBUILD := $(ROMFS)/res/drawable
VERSION_MAJOR := 0
VERSION_MINOR := 9
VERSION_MICRO := 0
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-ffunction-sections \
-DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_MICRO=$(VERSION_MICRO) \
$(ARCH)
CFLAGS += $(INCLUDE) -D__3DS__
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++20
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lcitro2d -lcitro3d -lctru -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
GFXFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.t3s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
ifeq ($(GFXBUILD),$(BUILD))
#---------------------------------------------------------------------------------
export T3XFILES := $(GFXFILES:.t3s=.t3x)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export ROMFS_T3XFILES := $(patsubst %.t3s, $(GFXBUILD)/%.t3x, $(GFXFILES))
export T3XHFILES := $(patsubst %.t3s, $(BUILD)/%.h, $(GFXFILES))
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(addsuffix .o,$(T3XFILES))
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
export HFILES := $(PICAFILES:.v.pica=_shbin.h) $(SHLISTFILES:.shlist=_shbin.h) \
$(addsuffix .h,$(subst .,_,$(BINFILES))) \
$(GFXFILES:.t3s=.h)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
export _3DSXDEPS := $(if $(NO_SMDH),,$(OUTPUT).smdh)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
endif
.PHONY: all clean
#---------------------------------------------------------------------------------
all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
$(BUILD):
@mkdir -p $@
ifneq ($(GFXBUILD),$(BUILD))
$(GFXBUILD):
@mkdir -p $@
endif
ifneq ($(DEPSDIR),$(BUILD))
$(DEPSDIR):
@mkdir -p $@
endif
#---------------------------------------------------------------------------------
clean:
@for dir in $(SUBDIRS); do $(MAKE) clean -C $$dir; done
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf $(GFXBUILD)
#---------------------------------------------------------------------------------
$(GFXBUILD)/%.t3x $(BUILD)/%.h : %.t3s
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@tex3ds -i $< -H $(BUILD)/$*.h -d $(DEPSDIR)/$*.d -o $(GFXBUILD)/$*.t3x
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).3dsx : $(OUTPUT).elf $(_3DSXDEPS)
$(OFILES_SOURCES) : $(HFILES)
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
.PRECIOUS : %.t3x %.shbin
#---------------------------------------------------------------------------------
%.t3x.o %_t3x.h : %.t3x
#---------------------------------------------------------------------------------
$(SILENTMSG) $(notdir $<)
$(bin2o)
#---------------------------------------------------------------------------------
%.shbin.o %_shbin.h : %.shbin
#---------------------------------------------------------------------------------
$(SILENTMSG) $(notdir $<)
$(bin2o)
-include $(DEPSDIR)/*.d
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -20,7 +20,8 @@ ctr_vercheck was originally created by wolfvak - It was initially intended to be
- Battery charging status.
- AC Adapter connection status.
- Battery percentage (actual battery percentage using mcu::HWC).
- Displays battery voltage (estimated) and unknown format.
- Displays battery voltage (estimated).
- Displays battery temperature.
- Displays MCU firmware.
- SD detection.
- Displays SD free and total storage capacity.
@ -44,3 +45,7 @@ ctr_vercheck was originally created by wolfvak - It was initially intended to be
- Displays home menu ID.
- Displays Wifi slot info (SSID, password and MAC address).
- Displays original/NAND local friend code seed.
# Credits:
- **Preetisketch** for the logo/banner.
- **devkitPro maintainers and contributors** for libctru, citro2d, devkitARM, and other packages used by this project.

View File

@ -1,41 +0,0 @@
#include <stdio.h>
#include <string.h>
#include "fs.h"
#include "utils.h"
Result FS_OpenArchive(FS_Archive *archive, FS_ArchiveID archiveID)
{
Result ret = 0;
if (R_FAILED(ret = FSUSER_OpenArchive(archive, archiveID, fsMakePath(PATH_EMPTY, ""))))
return ret;
return 0;
}
Result FS_CloseArchive(FS_Archive archive)
{
Result ret = 0;
if (R_FAILED(ret = FSUSER_CloseArchive(archive)))
return ret;
return 0;
}
bool FS_FileExists(FS_Archive archive, const char *path)
{
Handle handle;
u16 path_u16[strlen(path) + 1];
Utils_U8_To_U16(path_u16, path, strlen(path) + 1);
if (R_FAILED(FSUSER_OpenFile(&handle, archive, fsMakePath(PATH_UTF16, path_u16), FS_OPEN_READ, 0)))
return false;
if (R_FAILED(FSFILE_Close(handle)))
return false;
return true;
}

View File

@ -1,12 +0,0 @@
#ifndef _3DSIDENT_FS_H_
#define _3DSIDENT_FS_H_
#include <3ds.h>
FS_Archive archive;
Result FS_OpenArchive(FS_Archive *archive, FS_ArchiveID archiveID);
Result FS_CloseArchive(FS_Archive archive);
bool FS_FileExists(FS_Archive archive, const char *path);
#endif

View File

@ -1,88 +0,0 @@
#include <stdio.h>
#include "hardware.h"
#include "utils.h"
#define REG_LCD_TOP_SCREEN (u32)0x202200
#define REG_LCD_BOTTOM_SCREEN (u32)0x202A00
char *Hardware_GetAudioJackStatus(void)
{
bool audio_jack = false;
static char status[0xD];
if (R_SUCCEEDED(DSP_GetHeadphoneStatus(&audio_jack)))
{
snprintf(status, 0xD, audio_jack? "inserted" : "not inserted");
return status;
}
return NULL;
}
char *Hardware_GetCardSlotStatus(void)
{
bool isInserted = false;
FS_CardType cardType = 0;
static char card[0x14];
if (R_SUCCEEDED(FSUSER_CardSlotIsInserted(&isInserted)))
{
if (isInserted)
{
FSUSER_GetCardType(&cardType);
snprintf(card, 0x14, "inserted %s", cardType? "(TWL)" : "(CTR)");
return card;
}
else
{
snprintf(card, 0x14, "not inserted");
return card;
}
}
return NULL;
}
char *Hardware_DetectSD(void)
{
bool detect = false;
static char status[0xD];
if (R_SUCCEEDED(FSUSER_IsSdmcDetected(&detect)))
{
snprintf(status, 0xD, detect? "detected" : "not detected");
return status;
}
return NULL;
}
char *Hardware_GetBrightness(u32 screen)
{
u32 brightness = 0;
static char level[5];
Result ret = 0;
if (R_SUCCEEDED(ret = gspInit()))
{
if (screen == GSPLCD_SCREEN_TOP)
{
if (R_SUCCEEDED(ret = GSPGPU_ReadHWRegs(REG_LCD_TOP_SCREEN + 0x40, &brightness, 4)))
gspExit();
}
else if (screen = GSPLCD_SCREEN_BOTTOM)
{
if (R_SUCCEEDED(ret = GSPGPU_ReadHWRegs(REG_LCD_BOTTOM_SCREEN + 0x40, &brightness, 4)))
gspExit();
}
else
gspExit();
}
snprintf(level, 0x4, "%lu", R_FAILED(ret)? 0 : brightness);
return level;
}

View File

@ -1,11 +0,0 @@
#ifndef _3DSIDENT_HARDWARE_H_
#define _3DSIDENT_HARDWARE_H_
#include <3ds.h>
char *Hardware_GetAudioJackStatus(void);
char *Hardware_GetCardSlotStatus(void);
char *Hardware_DetectSD(void);
char *Hardware_GetBrightness(u32 screen);
#endif

View File

@ -1,143 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fs.h"
#include "kernel.h"
#include "system.h"
#include "utils.h"
char *Kernel_GetInitalVersion(void)
{
static char initialVer[0xB];
FS_OpenArchive(&archive, ARCHIVE_NAND_TWL_FS);
Handle handle;
if (R_FAILED(FSUSER_OpenFileDirectly(&handle, ARCHIVE_NAND_TWL_FS, fsMakePath(PATH_EMPTY, ""), fsMakePath(PATH_ASCII, "/sys/log/product.log"), FS_OPEN_READ, 0)))
return NULL;
u64 size64 = 0;
u32 size = 0;
if (R_FAILED(FSFILE_GetSize(handle, &size64)))
return NULL;
size = (u32)size64;
char *buf = (char *)malloc(size + 1);
u32 bytesread = 0;
if (R_FAILED(FSFILE_Read(handle, &bytesread, 0, (u32 *)buf, size)))
return NULL;
buf[size] = '\0';
// New 3DS/2DS only
strcpy(initialVer, Utils_ExtractBetween(buf, "cup:", " preInstall:"));
if (strlen(initialVer) == 0)
strcpy(initialVer, Utils_ExtractBetween(buf, "cup:", ","));
strcat(initialVer, "-");
strcat(initialVer, Utils_ExtractBetween(buf, "nup:", " cup:"));
if (R_FAILED(FSFILE_Close(handle)))
return NULL;
free(buf);
FS_CloseArchive(archive);
return initialVer;
}
char *Kernel_GetVersion(int version)
{
char *str_kernel = (char *)malloc(sizeof(char) * 255), *str_ver = (char *)malloc(sizeof(char) * 255), *str_sysver = (char *)malloc(sizeof(char) * 255);
u32 os_ver = osGetKernelVersion(), firm_ver = osGetKernelVersion();
OS_VersionBin *nver = (OS_VersionBin *)malloc(sizeof(OS_VersionBin)), *cver = (OS_VersionBin *)malloc(sizeof(OS_VersionBin));
s32 ret;
snprintf(str_kernel, 255, "%lu.%lu-%lu",
GET_VERSION_MAJOR(os_ver),
GET_VERSION_MINOR(os_ver),
GET_VERSION_REVISION(os_ver)
);
snprintf(str_ver, 255, "%lu.%lu-%lu",
GET_VERSION_MAJOR(firm_ver),
GET_VERSION_MINOR(firm_ver),
GET_VERSION_REVISION(firm_ver)
);
memset(nver, 0, sizeof(OS_VersionBin));
memset(cver, 0, sizeof(OS_VersionBin));
if (R_FAILED(ret = osGetSystemVersionData(nver, cver)))
snprintf(str_sysver, 100, "0x%08liX", ret);
else
snprintf(str_sysver, 100, "%d.%d.%d-%d%c",
cver->mainver,
cver->minor,
cver->build,
nver->mainver,
System_GetFirmRegion()
);
if (version == 0)
return str_kernel;
else if (version == 1)
return str_ver;
else if (version == 2)
return Kernel_GetInitalVersion();
else
return str_sysver;
}
char *Kernel_GetSDMCCID(void)
{
u8 buf[16];
static char cid[33];
if (R_SUCCEEDED(FSUSER_GetSdmcCid(buf, 0x10)))
{
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]);
return cid;
}
return NULL;
}
char *Kernel_GetNANDCID(void)
{
u8 buf[16];
static char cid[33];
if (R_SUCCEEDED(FSUSER_GetNandCid(buf, 0x10)))
{
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]);
return cid;
}
return NULL;
}
u32 Kernel_GetDeviceId(void) // Same as PS_GetDeviceId
{
u32 id = 0;
if (R_SUCCEEDED(AM_GetDeviceId(&id)))
return id;
return 0;
}

View File

@ -1,12 +0,0 @@
#ifndef _3DSIDENT_KERNEL_H_
#define _3DSIDENT_KERNEL_H_
#include <3ds.h>
char *Kernel_GetInitalVersion(void);
char *Kernel_GetVersion(int version);
char *Kernel_GetSDMCCID(void);
char *Kernel_GetNANDCID(void);
u32 Kernel_GetDeviceId(void);
#endif

View File

@ -1,33 +0,0 @@
#include "am.h"
#include "misc.h"
#include "utils.h"
u32 Misc_TitleCount(FS_MediaType mediaType)
{
u32 count = 0;
if (R_SUCCEEDED(AM_GetTitleCount(mediaType, &count)))
return count;
return 0;
}
u32 Misc_TicketCount(void)
{
u32 count = 0;
if (R_SUCCEEDED(AM_GetTicketCount(&count)))
return count;
return 0;
}
char *Misc_GetDeviceCert(void)
{
u8 const cert[0x180];
if (R_SUCCEEDED(amNetGetDeviceCert(cert)))
return Utils_Base64Encode(cert, 0x180);
return NULL;
}

View File

@ -1,10 +0,0 @@
#ifndef _3DSIDENT_MISC_H_
#define _3DSIDENT_MISC_H_
#include <3ds.h>
u32 Misc_TitleCount(FS_MediaType mediaType);
u32 Misc_TicketCount(void);
char *Misc_GetDeviceCert(void);
#endif

View File

@ -1,31 +0,0 @@
#include "storage.h"
u64 Storage_GetFreeStorage(FS_SystemMediaType mediaType)
{
FS_ArchiveResource resource = {0};
if (R_SUCCEEDED(FSUSER_GetArchiveResource(&resource, mediaType)))
return (((u64) resource.freeClusters * (u64) resource.clusterSize));
return 0;
}
u64 Storage_GetTotalStorage(FS_SystemMediaType mediaType)
{
FS_ArchiveResource resource = {0};
if (R_SUCCEEDED(FSUSER_GetArchiveResource(&resource, mediaType)))
return (((u64) resource.totalClusters * (u64) resource.clusterSize));
return 0;
}
u64 Storage_GetUsedStorage(FS_SystemMediaType mediaType)
{
FS_ArchiveResource resource = {0};
if (R_SUCCEEDED(FSUSER_GetArchiveResource(&resource, mediaType)))
return ((((u64) resource.totalClusters * (u64) resource.clusterSize)) - (((u64) resource.freeClusters * (u64) resource.clusterSize)));
return 0;
}

View File

@ -1,10 +0,0 @@
#ifndef _3DSIDENT_STORAGE_H_
#define _3DSIDENT_STORAGE_H_
#include <3ds.h>
u64 Storage_GetFreeStorage(FS_SystemMediaType mediaType);
u64 Storage_GetTotalStorage(FS_SystemMediaType mediaType);
u64 Storage_GetUsedStorage(FS_SystemMediaType mediaType);
#endif

View File

@ -1,277 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fs.h"
#include "system.h"
#include "utils.h"
const char *System_GetModel(void)
{
const char *models[] =
{
"OLD 3DS - CTR",
"OLD 3DS XL - SPR",
"NEW 3DS - KTR",
"OLD 2DS - FTR",
"NEW 3DS XL - RED",
"NEW 2DS XL - JAN",
"Unknown"
};
u8 model = 0;
if (R_SUCCEEDED(CFGU_GetSystemModel(&model)))
{
if (model < 6)
return models[model];
}
return models[6];
}
const char *System_GetRegion(void)
{
const char *regions[] =
{
"JPN",
"USA",
"EUR",
"AUS",
"CHN",
"KOR",
"TWN",
"Unknown"
};
CFG_Region region = 0;
if (R_SUCCEEDED(CFGU_SecureInfoGetRegion(&region)))
{
if (region < 7)
return regions[region];
}
return regions[7];
}
const char System_GetFirmRegion(void)
{
if (strncmp(System_GetRegion(), "JPN", 3) == 0)
return 'J';
else if (strncmp(System_GetRegion(), "USA", 3) == 0)
return 'U';
else if ((strncmp(System_GetRegion(), "EUR", 3) == 0) || (strncmp(System_GetRegion(), "AUS", 3) == 0))
return 'E';
else if (strncmp(System_GetRegion(), "CHN", 3) == 0)
return 'C';
else if (strncmp(System_GetRegion(), "KOR", 3) == 0)
return 'K';
else if (strncmp(System_GetRegion(), "TWN", 3) == 0)
return 'T';
return 0;
}
bool System_IsCoppacsSupported()
{
u8 IsCoppacs = 0;
if (R_SUCCEEDED(CFGU_GetRegionCanadaUSA(&IsCoppacs)))
{
if (IsCoppacs)
return true;
}
return false;
}
const char *System_GetLang(void)
{
const char *languages[] =
{
"Japanese",
"English",
"French",
"German",
"Italian",
"Spanish",
"Simplified Chinese",
"Korean",
"Dutch",
"Portugese",
"Russian",
"Traditional Chinese",
"Unknown"
};
CFG_Language language;
if (R_SUCCEEDED(CFGU_GetSystemLanguage(&language)))
{
if (language < 12)
return languages[language];
}
return languages[12];
}
char *System_GetMacAddress(void)
{
u8 *macByte = (u8 *)WIFI_MACADDR;
static char macAddress[0x12];
snprintf(macAddress, 0x12, "%02X:%02X:%02X:%02X:%02X:%02X", *macByte, *(macByte + 0x1), *(macByte + 0x2), *(macByte + 0x3), *(macByte + 0x4), *(macByte + 0x5));
return macAddress;
}
const char *System_GetRunningHW(void)
{
const char *runningHW[] =
{
"Retail",
"Devboard",
"Debugger",
"Capture"
};
return runningHW[(*(u8 *)RUNNING_HW) - 0x1];
}
char *System_IsDebugUnit(void)
{
return *(u8 *)UNITINFO ? "" : "(Debug Unit)";
}
char *System_GetScreenType(void)
{
static char upperScreen[20];
static char lowerScreen[20];
static char screenType[32];
if (Utils_IsN3DS())
{
u8 screens = 0;
if(R_SUCCEEDED(gspLcdInit()))
{
if (R_SUCCEEDED(GSPLCD_GetVendors(&screens)))
gspLcdExit();
}
switch ((screens >> 4) & 0xF)
{
case 0x01: // 0x01 = JDI => IPS
sprintf(upperScreen, "Upper: IPS");
break;
case 0x0C: // 0x0C = SHARP => TN
sprintf(upperScreen, "Upper: TN");
break;
default:
sprintf(upperScreen, "Upper: Unknown");
break;
}
switch (screens & 0xF)
{
case 0x01: // 0x01 = JDI => IPS
sprintf(lowerScreen, " | Lower: IPS");
break;
case 0x0C: // 0x0C = SHARP => TN
sprintf(lowerScreen, " | Lower: TN");
break;
default:
sprintf(lowerScreen, " | Lower: Unknown");
break;
}
strcpy(screenType, upperScreen);
strcat(screenType, lowerScreen);
}
else
sprintf(screenType, "Upper: TN | Lower: TN");
return screenType;
}
u64 System_GetLocalFriendCodeSeed(void)
{
u64 seed = 0;
if (R_SUCCEEDED(CFGI_GetLocalFriendCodeSeed(&seed)))
return seed;
return 0;
}
char *System_GetNANDLocalFriendCodeSeed(void)
{
FS_Archive nandArchive;
Handle handle;
u32 bytesread = 0;
char *buf = (char *)malloc(6);
static char out[0xB];
FS_OpenArchive(&nandArchive, ARCHIVE_NAND_CTR_FS);
if (FS_FileExists(nandArchive, "/rw/sys/LocalFriendCodeSeed_B"))
{
if (R_FAILED(FSUSER_OpenFile(&handle, nandArchive, fsMakePath(PATH_ASCII, "/rw/sys/LocalFriendCodeSeed_B"), FS_OPEN_READ, 0)))
{
FS_CloseArchive(nandArchive);
return NULL;
}
}
else if (FS_FileExists(nandArchive, "/rw/sys/LocalFriendCodeSeed_A"))
{
if (R_FAILED(FSUSER_OpenFile(&handle, nandArchive, fsMakePath(PATH_ASCII, "/rw/sys/LocalFriendCodeSeed_A"), FS_OPEN_READ, 0)))
{
FS_CloseArchive(nandArchive);
return NULL;
}
}
else
{
FS_CloseArchive(nandArchive);
return NULL;
}
if (R_FAILED(FSFILE_Read(handle, &bytesread, 0x108, (u32 *)buf, 6)))
{
FS_CloseArchive(nandArchive);
return NULL;
}
if (R_FAILED(FSFILE_Close(handle)))
{
FS_CloseArchive(nandArchive);
return NULL;
}
buf[6] = '\0';
FS_CloseArchive(nandArchive);
snprintf(out, 0xB, "%02X%02X%02X%02X%02X", buf[0x4], buf[0x3], buf[0x2], buf[0x1], buf[0x0]);
return out;
}
u8 *System_GetSerialNumber(void)
{
static u8 serial[0xF];
if (R_SUCCEEDED(CFGI_SecureInfoGetSerialNumber(serial)))
return serial;
return NULL;
}
u64 System_GetSoapId(void)
{
u32 id = 0;
if (R_SUCCEEDED(AM_GetDeviceId(&id)))
return (id | (((u64) 4) << 32));
return 0;
}

View File

@ -1,61 +0,0 @@
#ifndef _3DSIDENT_SYSTEM_H_
#define _3DSIDENT_SYSTEM_H_
#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,
};
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 *System_GetModel(void);
const char *System_GetRegion(void);
const char System_GetFirmRegion(void);
bool System_IsCoppacsSupported();
const char *System_GetLang(void);
char *System_GetMacAddress(void);
const char *System_GetRunningHW(void);
char *System_IsDebugUnit(void);
char *System_GetScreenType(void);
u64 System_GetLocalFriendCodeSeed(void);
char *System_GetNANDLocalFriendCodeSeed(void);
u8 *System_GetSerialNumber(void);
u64 System_GetSoapId(void);
#endif

View File

@ -1,126 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "utils.h"
void Utils_GetSizeString(char *string, uint64_t size) //Thanks TheOfficialFloW
{
double double_size = (double)size;
int i = 0;
static char *units[] = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
while (double_size >= 1024.0f)
{
double_size /= 1024.0f;
i++;
}
sprintf(string, "%.*f %s", (i == 0) ? 0 : 2, double_size, units[i]);
}
bool Utils_IsN3DS(void)
{
bool isNew3DS = false;
if (R_SUCCEEDED(APT_CheckNew3DS(&isNew3DS)))
return isNew3DS;
return false;
}
void Utils_U16_To_U8(char *buf, const u16 *input, size_t bufsize)
{
ssize_t units = utf16_to_utf8((u8 *)buf, input, bufsize);
if (units < 0)
units = 0;
buf[units] = 0;
}
void Utils_U8_To_U16(u16 *buf, const char *input, size_t bufsize)
{
ssize_t units = utf8_to_utf16(buf, (const uint8_t*)input, bufsize);
if (units < 0)
units = 0;
buf[units] = 0;
}
char *Utils_ExtractBetween(const char *string, const char *str1, const char *str2)
{
const char *i1 = strstr(string, str1);
if (i1 != NULL)
{
const size_t pl1 = strlen(str1);
const char *i2 = strstr(i1 + pl1, str2);
if (str2 != NULL)
{
/* Found both markers, extract text. */
const size_t mlen = i2 - (i1 + pl1);
char *ret = malloc(mlen + 1);
if (ret != NULL)
{
memcpy(ret, i1 + pl1, mlen);
ret[mlen] = '\0';
return ret;
}
}
}
return "";
}
// 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 *Utils_Base64Encode(u8 const *bytesToEnc, size_t bufLen)
{
char *ret = "";
int i = 0, j = 0;
u8 temp[3];
u8 str[4];
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;
for(i = 0; (i <4) ; i++) ret += base64_chars[str[i]];
i = 0;
}
}
if (i)
{
for(j = i; j < 3; j++) temp[j] = '\0';
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;
for (j = 0; (j < i + 1); j++)
ret += base64_chars[str[j]];
while((i++ < 3))
ret += '=';
}
return ret;
}

View File

@ -1,13 +0,0 @@
#ifndef _3DSIDENT_UTILS_H_
#define _3DSIDENT_UTILS_H_
#include <3ds.h>
void Utils_GetSizeString(char *string, uint64_t size);
bool Utils_IsN3DS(void);
void Utils_U16_To_U8(char *buf, const u16 *input, size_t bufsize);
void Utils_U8_To_U16(u16 *buf, const char *input, size_t bufsize);
char *Utils_ExtractBetween(const char *string, const char *str1, const char *str2);
char *Utils_Base64Encode(u8 const *bytesToEnc, size_t bufLen);
#endif

View File

@ -1,26 +0,0 @@
#include "ac.h"
#include "utils.h"
#include "wifi.h"
const char *WiFi_GetSecurityMode(void)
{
u8 securityMode = 0;
if (R_FAILED(ACI_GetSecurityMode(&securityMode)))
securityMode = 8;
const char *securityString[] =
{
"Not secured",
"WEP 40-bit",
"WEP 104-bit",
"WEP 128-bit",
"WPA TKIP",
"WPA2 TKIP",
"WPA AES",
"WPA2 AES",
"Unknown"
};
return securityString[securityMode];
}

View File

@ -1,70 +0,0 @@
#ifndef _3DSIDENT_WIFI_H_
#define _3DSIDENT_WIFI_H_
#include <3ds.h>
/*
Wifi Slot Structure constructed using the info provided here https://www.3dbrew.org/wiki/Config_Savegame#WiFi_Slot_Structure
*/
#define CFG_WIFI_BLKID (u32) 0x00080000 // Configuration blocks BlkID for WiFi configuration slots
#define CFG_WIFI_SLOT_SIZE (u32) 0xC00 // Blk size 0xC
typedef struct
{
bool set; // Was the network was set or not?
bool use; // Use this network strucutre to connect?
bool isFirst; // If this structure is the first (0) or the second (1) in the larger WiFi slot structure?
u8 padding1;
char SSID[0x20]; // SSID of the network, without a trailing nullbyte.
u8 SSID_length; // Length of the SSID.
u8 AP_crypto_key_type;
u16 padding2;
char passphrase[0x40]; // Plaintext of the passphrase of the network, without a trailing nullbyte.
u8 PBKDF2_passphrase[0x20]; // PBKDF2 of the passphrase and SSID (http://jorisvr.nl/wpapsk.html).
} networkStructure; // This is apparently used twice in the actual wifi slot structure (?) // 0xAC
typedef struct
{
bool set; // Was the network was set or not?
u16 checksum; // CRC-16 checksum of the next 0x410 bytes.
networkStructure network; // First network structure. Only set if the network was set "normally", or was the last to be set using WPS during the session. Size 0x88
u8 padding1[0x20];
networkStructure network_WPS; // Second network structure. Only set if the network was set using WPS, otherwise 0-filled.
u8 padding2[0x20C];
bool auto_obtain_ip_addr; // Automatically get the IP address (use DHCP) or not, defaults to 1.
bool auto_obtain_DNS; // Automatically get the DNS or not, defaults to 1
u16 padding3;
u8 ip_addr[0x4]; // IP address, to use if (auto_obtain_ip_addr) is false.
u8 gateway_addr[0x4]; // IP address of the gateway, to use if (auto_obtain_ip_addr) is false.
u8 subnet_mask[0x4]; // Subnetwork mask, to use if (auto_obtain_ip_addr) is false.
u8 primary_DNS[0x4]; // IP address of the primary DNS , to use if (auto_obtain_ip_addr) is false.
u8 secondary_DNS[0x4]; // IP address of the secondary DNS, to use if (auto_obtain_ip_addr) is false.
u8 lastSet[0x4]; // Always 0x01050000 ? Only set if the network was the last to be set during the session.
u8 ip_to_use[0x4]; // IP address to use. Only set if the network was the last to be set during the session.
u8 mac_addr[0x6]; // MAC address of the AP. Only set if the network was the last to be set during the session.
u8 channel; // Channel. Only set if the network was the last to be set during the session.
u8 padding4; // Only set if the network was the last to be set during the session.
bool use_proxy; // Use a proxy or not, defaults to 0.
bool basic_authentication; // Use a basic authentication for the proxy, defaults to 0.
u16 port_number; // Port to use for the proxy, defaults to 1.
char proxy_addr[0x30]; // URL/address of the proxy, including a trailing nullbyte.
u8 padding5[0x34];
char proxy_username[0x20]; // Username to use for basic authentication, including a trailing nullbyte.
char proxy_password[0x20]; // Password to use for basic authentication, including a trailing nullbyte.
u16 padding6;
u16 MTU_value; // MTU value, defaults to 1400 and ranges between 576 and 1500, inclusive.
u8 padding8[0x7EC];
} wifiSlotStructure;
const char *WiFi_GetSecurityMode(void);
#endif

View File

@ -1,17 +0,0 @@
Copyright (c) 2016 Wolfvak
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgement in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.

View File

@ -1,300 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
# GRAPHICS is a list of directories containing graphics files
# GFXBUILD is the directory where converted graphics files will be placed
# If set to $(BUILD), it will statically link in the converted
# files as if they were data files.
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := 3DSident
BUILD := build
SOURCES := source ../common ../services
DATA := data
INCLUDES := ../common ../services
GRAPHICS := res/drawable
ROMFS := romfs
GFXBUILD := $(ROMFS)/res/drawable
APP_TITLE := 3DSident
APP_DESCRIPTION := Identity tool for the Nintendo 3DS.
APP_AUTHOR := Joel16
VERSION_MAJOR := 0
VERSION_MINOR := 8
VERSION_MICRO := 0
ICON := res/icon.png
# CIA
BANNER_AUDIO := res/banner.wav
BANNER_IMAGE := res/banner.png
RSF_PATH := res/app.rsf
LOGO := res/logo.lz11
UNIQUE_ID := 0x16000
PRODUCT_CODE := CTR-C-3DSI
ICON_FLAGS := nosavebackups,visible
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Werror -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
-DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_MICRO=$(VERSION_MICRO) \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lctru -lm -lz
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
GFXFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.t3s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
ifeq ($(GFXBUILD),$(BUILD))
#---------------------------------------------------------------------------------
export T3XFILES := $(GFXFILES:.t3s=.t3x)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export ROMFS_T3XFILES := $(patsubst %.t3s, $(GFXBUILD)/%.t3x, $(GFXFILES))
export T3XHFILES := $(patsubst %.t3s, $(BUILD)/%.h, $(GFXFILES))
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(addsuffix .o,$(T3XFILES))
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
export HFILES := $(PICAFILES:.v.pica=_shbin.h) $(SHLISTFILES:.shlist=_shbin.h) \
$(addsuffix .h,$(subst .,_,$(BINFILES))) \
$(GFXFILES:.t3s=.h)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
export _3DSXDEPS := $(if $(NO_SMDH),,$(OUTPUT).smdh)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
endif
.PHONY: all clean
#---------------------------------------------------------------------------------
MAKEROM ?= makerom
MAKEROM_ARGS := -elf "$(OUTPUT).elf" -rsf "$(RSF_PATH)" -banner "$(BUILD)/banner.bnr" -icon "$(BUILD)/icon.icn" -DAPP_TITLE="$(APP_TITLE)" -DAPP_PRODUCT_CODE="$(PRODUCT_CODE)" -DAPP_UNIQUE_ID="$(UNIQUE_ID)"
MAKEROM_ARGS += -major $(VERSION_MAJOR) -minor $(VERSION_MINOR) -micro $(VERSION_MICRO)
ifneq ($(strip $(LOGO)),)
MAKEROM_ARGS += -logo "$(LOGO)"
endif
ifneq ($(strip $(ROMFS)),)
MAKEROM_ARGS += -DAPP_ROMFS="$(ROMFS)"
endif
BANNERTOOL ?= bannertool
ifeq ($(suffix $(BANNER_IMAGE)),.cgfx)
BANNER_IMAGE_ARG := -ci
else
BANNER_IMAGE_ARG := -i
endif
ifeq ($(suffix $(BANNER_AUDIO)),.cwav)
BANNER_AUDIO_ARG := -ca
else
BANNER_AUDIO_ARG := -a
endif
#---------------------------------------------------------------------------------
all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
@$(BANNERTOOL) makebanner $(BANNER_IMAGE_ARG) "$(BANNER_IMAGE)" $(BANNER_AUDIO_ARG) "$(BANNER_AUDIO)" -o "$(BUILD)/banner.bnr"
@$(BANNERTOOL) makesmdh -s "$(APP_TITLE)" -l "$(APP_DESCRIPTION)" -p "$(APP_AUTHOR)" -i "$(APP_ICON)" -f "$(ICON_FLAGS)" -o "$(BUILD)/icon.icn"
$(MAKEROM) -f cia -o "$(OUTPUT).cia" -target t -exefslogo $(MAKEROM_ARGS)
$(BUILD):
@mkdir -p $@
ifneq ($(GFXBUILD),$(BUILD))
$(GFXBUILD):
@mkdir -p $@
endif
ifneq ($(DEPSDIR),$(BUILD))
$(DEPSDIR):
@mkdir -p $@
endif
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(TARGET).cia $(TARGET).smdh $(TARGET).elf $(GFXBUILD)
#---------------------------------------------------------------------------------
$(GFXBUILD)/%.t3x $(BUILD)/%.h : %.t3s
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@tex3ds -i $< -H $(BUILD)/$*.h -d $(DEPSDIR)/$*.d -o $(GFXBUILD)/$*.t3x
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).3dsx : $(OUTPUT).elf $(_3DSXDEPS)
$(OFILES_SOURCES) : $(HFILES)
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
.PRECIOUS : %.t3x
#---------------------------------------------------------------------------------
%.t3x.o %_t3x.h : %.t3x
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $*.shbin)
$(eval DEPSFILE := $(DEPSDIR)/$*.shbin.d)
echo "$(CURBIN).o: $< $1" > $(DEPSFILE)
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $*.shbin.o
endef
%.shbin.o %_shbin.h : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o %_shbin.h : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o %_shbin.h : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)$(file)))
#---------------------------------------------------------------------------------
%.t3x %.h : %.t3s
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@tex3ds -i $< -H $*.h -d $*.d -o $*.t3x
-include $(DEPSDIR)/*.d
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,47 +0,0 @@
# 3DSident [![Github latest downloads](https://img.shields.io/github/downloads/joel16/3DSident/total.svg)](https://github.com/joel16/3DSident/releases/latest)
![3DSident Banner](http://i.imgur.com/HPWNgmz.png)
ctr_vercheck was originally created by wolfvak - It was initially intended to be a small application for the Nintendo 3DS to check your current FIRM and OS version only. I decided to fork this project, and added additional device info similar to PSPident, hence the name 3DSident.
# Features:
- Current kernel, FIRM and system version detection.
- Display initial system version. (GUI exclusive)
- Model detection with code name and hardware info (Retail/Devboard/Debugger/Capture unit)
- Displays screen type (TN/IPS).
- Displays region.
- Displays language.
- Displays MAC address.
- Displays serial.
- Displays SDMC and NAND CID
- Displays NNID username, principal ID, persistent ID, transferable base ID, country and timezone.
- Displays Mii's name.
- Displays device ID.
- Displays soap ID.
- Battery charging status.
- AC Adapter connection status.
- Battery percentage (actual battery percentage using mcu::HWC).
- Displays battery voltage (estimated) and unknown format.
- Displays MCU firmware.
- SD detection.
- Displays SD free and total storage capacity.
- Displays CTR free and total storage capacity.
- Displays TWL free and total storage capacity. (GUI exclusive)
- Displays TWL photo free and total storage capacity. (GUI exclusive)
- Displays number of titles installed on SD and NAND.
- Displays number of tickets installed. (GUI exclusive)
- Displays volume slider state and percentage.
- Displays 3D slider state and percentage.
- Displays Wifi signal strength.
- Displays IP address.
- Displays current brightness.
- Display auto-brightness status. (GUI exclusive)
- Display power saving mode. (GUI exclusive)
- Display sound output mode. (GUI exclusive)
- Displays if the console is a debug unit. (GUI exclusive)
- Displays headphone/audio jack status. (GUI exclusive)
- Card slot status and inserted card type (CTR/NAND). (GUI exclusive)
- Displays parental control pin, email address and secret answer. (GUI exclusive)
- Displays home menu ID.
- Displays Wifi slot info (SSID, password and MAC address).
- Using L + R triggers a screenshot in the GUI version.

Binary file not shown.

View File

@ -1,299 +0,0 @@
#include <malloc.h>
#include <stdio.h>
#include <3ds.h>
#include "ac.h"
#include "actu.h"
#include "hardware.h"
#include "kernel.h"
#include "misc.h"
#include "storage.h"
#include "system.h"
#include "utils.h"
#include "wifi.h"
#define ANY_KEY (KEY_TOUCH | KEY_A | KEY_B | KEY_X | KEY_Y | KEY_START | KEY_R | \
KEY_UP | KEY_CPAD_DOWN | KEY_LEFT | KEY_RIGHT | KEY_ZL | KEY_ZR | \
KEY_CSTICK_UP | KEY_CSTICK_DOWN | KEY_CSTICK_LEFT | KEY_CSTICK_RIGHT)
static u32 cpu_time_limit = 0;
void Init_Services(void)
{
gfxInitDefault();
aciInit();
// Check if user is running from *hax.
//if (envIsHomebrew() && (R_FAILED(actInit())))
// isHomebrew = envIsHomebrew();
actInit();
amAppInit();
amInit();
cfguInit();
dspInit();
mcuHwcInit();
ptmuInit();
socInit((u32*)memalign(0x1000, 0x10000), 0x10000);
if (Utils_IsN3DS())
osSetSpeedupEnable(true);
APT_GetAppCpuTimeLimit(&cpu_time_limit);
APT_SetAppCpuTimeLimit(30);
}
void Term_Services(void)
{
if (cpu_time_limit != UINT32_MAX)
APT_SetAppCpuTimeLimit(cpu_time_limit);
if (Utils_IsN3DS())
osSetSpeedupEnable(false);
socExit();
ptmuExit();
mcuHwcExit();
dspExit();
cfguExit();
amExit();
actExit();
acExit();
aciExit();
gfxExit();
}
int main(int argc, char *argv[])
{
Init_Services();
//=====================================================================//
//------------------------Variable Declaration-------------------------//
//=====================================================================//
Result ret = 0;
double wifiPercent = 0, volPercent = 0, _3dSliderPercent = 0;
u32 ip = 0;
unsigned int principalID = 0;
u8 battery_percent = 0, battery_status = 0, battery_volt = 0, volume = 0, fw_ver_high = 0, fw_ver_low = 0;
bool is_connected = false;
char sdFreeSize[16], sdTotalSize[16], ctrFreeSize[16], ctrTotalSize[16], country[0x3], name[0x16], nnid[0x11], timeZone[0x41];
AccountDataBlock accountDataBlock;
bool displayInfo = true; // By default nothing is hidden.
char ssid[0x20], passphrase[0x40];
wifiSlotStructure slotData;
hidScanInput();
u32 kHeld = hidKeysHeld();
if (kHeld & KEY_SELECT)
displayInfo = false; // Holding select on boot hides user specific details.
consoleInit(GFX_BOTTOM, NULL);
//=====================================================================//
//------------------------------MISC Info (continued)------------------//
//=====================================================================//
Utils_GetSizeString(sdFreeSize, Storage_GetFreeStorage(SYSTEM_MEDIATYPE_SD));
Utils_GetSizeString(sdTotalSize, Storage_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);
Utils_GetSizeString(ctrFreeSize, Storage_GetFreeStorage(SYSTEM_MEDIATYPE_CTR_NAND));
Utils_GetSizeString(ctrTotalSize, Storage_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[36;1m*\x1b[0m Installed titles: SD: \x1b[36;1m%lu\x1b[0m (NAND: \x1b[36;1m%lu\x1b[0m)\n", Misc_TitleCount(MEDIATYPE_SD), Misc_TitleCount(MEDIATYPE_NAND));
char hostname[128];
ret = gethostname(hostname, sizeof(hostname));
if (displayInfo)
printf("\x1b[36;1m*\x1b[0m IP: \x1b[36;1m%s\x1b[0m \n\n", hostname);
else
printf("\x1b[36;1m*\x1b[0m IP: \x1b[36;1m%s\x1b[0m \n\n", NULL);
//=====================================================================//
//------------------------------NNID Info------------------------------//
//=====================================================================//
ACTU_GetAccountDataBlock(&principalID, 0x4, 0xC); // First check if principal ID exists then display NNID info.
ACTU_GetAccountDataBlock((u8*)&accountDataBlock, 0xA0, 0x11);
if (principalID != 0)
{
if (R_SUCCEEDED(ACTU_GetAccountDataBlock(nnid, 0x11, 0x8)))
printf("\x1b[35;1m*\x1b[0m NNID: \x1b[35;1m%s\x1b[0m\n", displayInfo? nnid : NULL);
printf("\x1b[35;1m*\x1b[0m Principal ID: \x1b[35;1m%u\x1b[0m\n", displayInfo? principalID : 0);
printf("\x1b[35;1m*\x1b[0m Persistent ID: \x1b[35;1m%u\x1b[0m\n", displayInfo? (unsigned int)accountDataBlock.persistentID : 0);
printf("\x1b[35;1m*\x1b[0m Transferable ID: \x1b[35;1m%llu\x1b[0m\n", displayInfo? accountDataBlock.transferableID : 0);
if (R_SUCCEEDED(ACTU_GetAccountDataBlock(country, 0x3, 0xB)))
printf("\x1b[35;1m*\x1b[0m Country: \x1b[35;1m%s\x1b[0m\n", displayInfo? country : NULL);
if (R_SUCCEEDED(ACTU_GetAccountDataBlock(timeZone, 0x41, 0x1E)))
printf("\x1b[35;1m*\x1b[0m Time Zone: \x1b[35;1m%s\x1b[0m\n\n", displayInfo? timeZone : NULL);
}
//=====================================================================//
//------------------------------WIFI Info------------------------------//
//=====================================================================//
if (R_SUCCEEDED(ACI_LoadWiFiSlot(0)))
{
if (R_SUCCEEDED(ACI_GetSSID(ssid)))
printf("\x1b[32;1m*\x1b[0m WiFi 1 SSID: \x1b[32;1m%s\x1b[0m\n", ssid);
if (R_SUCCEEDED(ACI_GetPassphrase(passphrase)))
printf("\x1b[32;1m*\x1b[0m WiFi 1 pass: \x1b[32;1m%s\x1b[0m\n", displayInfo? passphrase : NULL);
printf("\x1b[32;1m*\x1b[0m WiFi 1 security: \x1b[32;1m%s\x1b[0m\n", displayInfo? WiFi_GetSecurityMode() : NULL);
if ((R_SUCCEEDED(CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID, (u8*)&slotData))) && (slotData.set))
{
if (displayInfo)
printf("\x1b[32;1m*\x1b[0m WiFi 1 mac: \x1b[32;1m%02X:%02X:%02X:%02X:%02X:%02X\x1b[0m\n\n", slotData.mac_addr[0], slotData.mac_addr[1], slotData.mac_addr[2],
slotData.mac_addr[3], slotData.mac_addr[4], slotData.mac_addr[5]);
else
printf("\x1b[32;1m*\x1b[0m WiFi 1 mac: \x1b[32;1m%s\x1b[0m\n\n", NULL);
}
}
if (R_SUCCEEDED(ACI_LoadWiFiSlot(1)))
{
if (R_SUCCEEDED(ACI_GetSSID(ssid)))
printf("\x1b[32;1m*\x1b[0m WiFi 2 SSID: \x1b[32;1m%s\x1b[0m\n", ssid);
if (R_SUCCEEDED(ACI_GetPassphrase(passphrase)))
printf("\x1b[32;1m*\x1b[0m WiFi 2 pass: \x1b[32;1m%s\x1b[0m\n", displayInfo? passphrase : NULL);
printf("\x1b[32;1m*\x1b[0m WiFi 2 security: \x1b[32;1m%s\x1b[0m\n", displayInfo? WiFi_GetSecurityMode() : NULL);
if ((R_SUCCEEDED(CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID + 1, (u8*)&slotData))) && (slotData.set))
{
if (displayInfo)
printf("\x1b[32;1m*\x1b[0m WiFi 2 mac: \x1b[32;1m%02X:%02X:%02X:%02X:%02X:%02X\x1b[0m\n\n", slotData.mac_addr[0], slotData.mac_addr[1], slotData.mac_addr[2],
slotData.mac_addr[3], slotData.mac_addr[4], slotData.mac_addr[5]);
else
printf("\x1b[32;1m*\x1b[0m WiFi 2 mac: \x1b[32;1m%s\x1b[0m\n\n", NULL);
}
}
if (R_SUCCEEDED(ACI_LoadWiFiSlot(2)))
{
if (R_SUCCEEDED(ACI_GetSSID(ssid)))
printf("\x1b[32;1m*\x1b[0m WiFi 3 SSID: \x1b[32;1m%s\x1b[0m\n", ssid);
if (R_SUCCEEDED(ACI_GetPassphrase(passphrase)))
printf("\x1b[32;1m*\x1b[0m WiFi 3 pass: \x1b[32;1m%s\x1b[0m\n", displayInfo? passphrase : NULL);
printf("\x1b[32;1m*\x1b[0m WiFi 3 security: \x1b[32;1m%s\x1b[0m\n", displayInfo? WiFi_GetSecurityMode() : NULL);
if ((R_SUCCEEDED(CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID + 2, (u8*)&slotData))) && (slotData.set))
{
if (displayInfo)
printf("\x1b[32;1m*\x1b[0m WiFi 3 mac: \x1b[32;1m%02X:%02X:%02X:%02X:%02X:%02X\x1b[0m\n\n", slotData.mac_addr[0], slotData.mac_addr[1], slotData.mac_addr[2],
slotData.mac_addr[3], slotData.mac_addr[4], slotData.mac_addr[5]);
else
printf("\x1b[32;1m*\x1b[0m WiFi 3 mac: \x1b[32;1m%s\x1b[0m\n\n", NULL);
}
}
printf("\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 v%d.%d.%d\x1b[0m\n\n", VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO);
//=====================================================================//
//------------------------------Firm Info------------------------------//
//=====================================================================//
printf("\x1b[33;1m*\x1b[0m Kernel version: \x1b[33;1m%s\n", Kernel_GetVersion(0));
printf("\x1b[33;1m*\x1b[0m Firm version: \x1b[33;1m%s\n", Kernel_GetVersion(1));
printf("\x1b[33;1m*\x1b[0m System version: \x1b[33;1m%s\n", Kernel_GetVersion(3));
printf("\x1b[33;1m*\x1b[0m Initial System version: \x1b[33;1m%s\n\n", Kernel_GetVersion(2));
//=====================================================================//
//-----------------------------System Info-----------------------------//
//=====================================================================//
printf("\x1b[31;1m*\x1b[0m Model: \x1b[31;1m%s\x1b[0m (\x1b[31;1m%s\x1b[0m - \x1b[31;1m%s\x1b[0m) \n\x1b[0m", System_GetModel(), System_GetRunningHW(), System_GetRegion());
printf("\x1b[31;1m*\x1b[0m Screen type: \x1b[31;1m %s \n\x1b[0m", System_GetScreenType());
printf("\x1b[31;1m*\x1b[0m Language: \x1b[31;1m%s\x1b[0m \n", System_GetLang());
printf("\x1b[31;1m*\x1b[0m Device ID: \x1b[31;1m%lu \n", displayInfo? Kernel_GetDeviceId() : 0);
printf("\x1b[31;1m*\x1b[0m ECS Device ID: \x1b[31;1m%llu \n", displayInfo? System_GetSoapId() : 0);
printf("\x1b[31;1m*\x1b[0m Original Local friend code seed: \x1b[31;1m%010llX\x1b[0m \n", displayInfo? System_GetLocalFriendCodeSeed() : 0);
printf("\x1b[31;1m*\x1b[0m NAND Local friend code seed: \x1b[31;1m%s\x1b[0m \n", displayInfo? System_GetNANDLocalFriendCodeSeed() : NULL);
printf("\x1b[31;1m*\x1b[0m MAC Address: \x1b[31;1m%s\x1b[0m \n", displayInfo? System_GetMacAddress() : 0);
printf("\x1b[31;1m*\x1b[0m Serial number: \x1b[31;1m%s\x1b[0m \n", displayInfo? System_GetSerialNumber() : 0);
printf("\x1b[31;1m*\x1b[0m SDMC CID: \x1b[31;1m%s\x1b[0m \n", displayInfo? Kernel_GetSDMCCID() : 0);
printf("\x1b[31;1m*\x1b[0m NAND CID: \x1b[31;1m%s\x1b[0m \n\n", displayInfo? Kernel_GetNANDCID() : 0);
while (aptMainLoop())
{
//=====================================================================//
//----------------------------Battery Info-----------------------------//
//=====================================================================//
printf("\x1b[20;0H");
if (R_SUCCEEDED(MCUHWC_GetBatteryLevel(&battery_percent)))
printf("\x1b[34;1m*\x1b[0m Battery percentage: \x1b[34;1m%3d%%\x1b[0m ", battery_percent);
if (R_SUCCEEDED(PTMU_GetBatteryChargeState(&battery_status)))
printf("(\x1b[34;1m%s\x1b[0m) \n\n", battery_status? "charging" : "not charging");
printf("\x1b[21;0H");
if (R_SUCCEEDED(MCUHWC_GetBatteryVoltage(&battery_volt)))
printf("\x1b[34;1m*\x1b[0m Battery voltage: \x1b[34;1m%d\x1b[0m (\x1b[34;1m%.1f V\x1b[0m) \n", battery_volt, 5.0 * ((double)battery_volt / 256.0));//,(Estimated: %0.1lf V) estimatedVolt);
printf("\x1b[22;0H");
if (R_SUCCEEDED(PTMU_GetAdapterState(&is_connected)))
printf("\x1b[34;1m*\x1b[0m Adapter state: \x1b[34;1m%s\x1b[0m\n", is_connected? "connected " : "disconnected");
printf("\x1b[23;0H");
if ((R_SUCCEEDED(MCUHWC_GetFwVerHigh(&fw_ver_high))) && (R_SUCCEEDED(MCUHWC_GetFwVerLow(&fw_ver_low))))
printf("\x1b[34;1m*\x1b[0m MCU firmware: \x1b[34;1m%u.%u\x1b[0m\n\n", (fw_ver_high - 0x10), fw_ver_low);
//=====================================================================//
//------------------------------Misc Info------------------------------//
//=====================================================================//
printf("\x1b[25;0H");
printf("\x1b[36;1m*\x1b[0m Brightness level: \x1b[36;1m%s\x1b[0m \n", Hardware_GetBrightness(GSPLCD_SCREEN_TOP));
printf("\x1b[26;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[27;0H");
if (R_SUCCEEDED(HIDUSER_GetSoundVolume(&volume)))
{
volPercent = (volume * 1.5873015873);
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");
_3dSliderPercent = (osGet3DSliderState() * 100.0);
printf("\x1b[36;1m*\x1b[0m 3D slider state: \x1b[36;1m%.1lf\x1b[0m (\x1b[36;1m%.0lf%%\x1b[0m) \n", osGet3DSliderState(), _3dSliderPercent);
printf("\x1b[29;0H");
printf("\x1b[36;1m*\x1b[0m Card slot status: \x1b[36;1m%s\x1b[0m \n", Hardware_GetCardSlotStatus());
gspWaitForVBlank();
hidScanInput();
if (hidKeysDown() & ANY_KEY)
break;
gfxFlushBuffers();
gfxSwapBuffers();
}
Term_Services();
return 0;
}

View File

@ -1,17 +0,0 @@
Copyright (c) 2016 Wolfvak
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgement in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.

View File

@ -1,300 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
# GRAPHICS is a list of directories containing graphics files
# GFXBUILD is the directory where converted graphics files will be placed
# If set to $(BUILD), it will statically link in the converted
# files as if they were data files.
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := 3DSident-GUI
BUILD := build
SOURCES := source ../common ../services
DATA := data
INCLUDES := include ../common ../services
GRAPHICS := res/drawable
ROMFS := romfs
GFXBUILD := $(ROMFS)/res/drawable
APP_TITLE := 3DSident-GUI
APP_DESCRIPTION := Identity tool for the Nintendo 3DS.
APP_AUTHOR := Joel16
VERSION_MAJOR := 0
VERSION_MINOR := 8
VERSION_MICRO := 0
ICON := res/drawable/icon.png
# CIA
BANNER_AUDIO := res/banner.wav
BANNER_IMAGE := res/banner.png
RSF_PATH := res/app.rsf
LOGO := res/logo.lz11
UNIQUE_ID := 0x16100
PRODUCT_CODE := CTR-G-3DSI
ICON_FLAGS := nosavebackups,visible
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Werror -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
-DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_MICRO=$(VERSION_MICRO) \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lcitro2d -lcitro3d -lctru -lm -lz
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
GFXFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.t3s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
ifeq ($(GFXBUILD),$(BUILD))
#---------------------------------------------------------------------------------
export T3XFILES := $(GFXFILES:.t3s=.t3x)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export ROMFS_T3XFILES := $(patsubst %.t3s, $(GFXBUILD)/%.t3x, $(GFXFILES))
export T3XHFILES := $(patsubst %.t3s, $(BUILD)/%.h, $(GFXFILES))
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(addsuffix .o,$(T3XFILES))
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
export HFILES := $(PICAFILES:.v.pica=_shbin.h) $(SHLISTFILES:.shlist=_shbin.h) \
$(addsuffix .h,$(subst .,_,$(BINFILES))) \
$(GFXFILES:.t3s=.h)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
export _3DSXDEPS := $(if $(NO_SMDH),,$(OUTPUT).smdh)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
endif
.PHONY: all clean
#---------------------------------------------------------------------------------
MAKEROM ?= makerom
MAKEROM_ARGS := -elf "$(OUTPUT).elf" -rsf "$(RSF_PATH)" -banner "$(BUILD)/banner.bnr" -icon "$(BUILD)/icon.icn" -DAPP_TITLE="$(APP_TITLE)" -DAPP_PRODUCT_CODE="$(PRODUCT_CODE)" -DAPP_UNIQUE_ID="$(UNIQUE_ID)"
MAKEROM_ARGS += -major $(VERSION_MAJOR) -minor $(VERSION_MINOR) -micro $(VERSION_MICRO)
ifneq ($(strip $(LOGO)),)
MAKEROM_ARGS += -logo "$(LOGO)"
endif
ifneq ($(strip $(ROMFS)),)
MAKEROM_ARGS += -DAPP_ROMFS="$(ROMFS)"
endif
BANNERTOOL ?= bannertool
ifeq ($(suffix $(BANNER_IMAGE)),.cgfx)
BANNER_IMAGE_ARG := -ci
else
BANNER_IMAGE_ARG := -i
endif
ifeq ($(suffix $(BANNER_AUDIO)),.cwav)
BANNER_AUDIO_ARG := -ca
else
BANNER_AUDIO_ARG := -a
endif
#---------------------------------------------------------------------------------
all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
@$(BANNERTOOL) makebanner $(BANNER_IMAGE_ARG) "$(BANNER_IMAGE)" $(BANNER_AUDIO_ARG) "$(BANNER_AUDIO)" -o "$(BUILD)/banner.bnr"
@$(BANNERTOOL) makesmdh -s "$(APP_TITLE)" -l "$(APP_DESCRIPTION)" -p "$(APP_AUTHOR)" -i "$(APP_ICON)" -f "$(ICON_FLAGS)" -o "$(BUILD)/icon.icn"
$(MAKEROM) -f cia -o "$(TARGET).cia" -target t -exefslogo $(MAKEROM_ARGS)
$(BUILD):
@mkdir -p $@
ifneq ($(GFXBUILD),$(BUILD))
$(GFXBUILD):
@mkdir -p $@
endif
ifneq ($(DEPSDIR),$(BUILD))
$(DEPSDIR):
@mkdir -p $@
endif
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(TARGET).cia $(TARGET).smdh $(TARGET).elf $(GFXBUILD)
#---------------------------------------------------------------------------------
$(GFXBUILD)/%.t3x $(BUILD)/%.h : %.t3s
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@tex3ds -i $< -H $(BUILD)/$*.h -d $(DEPSDIR)/$*.d -o $(GFXBUILD)/$*.t3x
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).3dsx : $(OUTPUT).elf $(_3DSXDEPS)
$(OFILES_SOURCES) : $(HFILES)
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
.PRECIOUS : %.t3x
#---------------------------------------------------------------------------------
%.t3x.o %_t3x.h : %.t3x
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $*.shbin)
$(eval DEPSFILE := $(DEPSDIR)/$*.shbin.d)
echo "$(CURBIN).o: $< $1" > $(DEPSFILE)
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $*.shbin.o
endef
%.shbin.o %_shbin.h : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o %_shbin.h : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o %_shbin.h : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)$(file)))
#---------------------------------------------------------------------------------
%.t3x %.h : %.t3s
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@tex3ds -i $< -H $*.h -d $*.d -o $*.t3x
-include $(DEPSDIR)/*.d
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,47 +0,0 @@
# 3DSident [![Github latest downloads](https://img.shields.io/github/downloads/joel16/3DSident/total.svg)](https://github.com/joel16/3DSident/releases/latest)
![3DSident Banner](http://i.imgur.com/HPWNgmz.png)
ctr_vercheck was originally created by wolfvak - It was initially intended to be a small application for the Nintendo 3DS to check your current FIRM and OS version only. I decided to fork this project, and added additional device info similar to PSPident, hence the name 3DSident.
# Features:
- Current kernel, FIRM and system version detection.
- Display initial system version. (GUI exclusive)
- Model detection with code name and hardware info (Retail/Devboard/Debugger/Capture unit)
- Displays screen type (TN/IPS).
- Displays region.
- Displays language.
- Displays MAC address.
- Displays serial.
- Displays SDMC and NAND CID
- Displays NNID username, principal ID, persistent ID, transferable base ID, country and timezone.
- Displays Mii's name.
- Displays device ID.
- Displays soap ID.
- Battery charging status.
- AC Adapter connection status.
- Battery percentage (actual battery percentage using mcu::HWC).
- Displays battery voltage (estimated) and unknown format.
- Displays MCU firmware.
- SD detection.
- Displays SD free and total storage capacity.
- Displays CTR free and total storage capacity.
- Displays TWL free and total storage capacity. (GUI exclusive)
- Displays TWL photo free and total storage capacity. (GUI exclusive)
- Displays number of titles installed on SD and NAND.
- Displays number of tickets installed. (GUI exclusive)
- Displays volume slider state and percentage.
- Displays 3D slider state and percentage.
- Displays Wifi signal strength.
- Displays IP address.
- Displays current brightness.
- Display auto-brightness status. (GUI exclusive)
- Display power saving mode. (GUI exclusive)
- Display sound output mode. (GUI exclusive)
- Displays if the console is a debug unit. (GUI exclusive)
- Displays headphone/audio jack status. (GUI exclusive)
- Card slot status and inserted card type (CTR/NAND). (GUI exclusive)
- Displays parental control pin, email address and secret answer. (GUI exclusive)
- Displays home menu ID.
- Displays Wifi slot info (SSID, password and MAC address).
- Using L + R triggers a screenshot in the GUI version.

View File

@ -1,31 +0,0 @@
#ifndef _3DSIDENT_C2D_HELPER_H_
#define _3DSIDENT_C2D_HELPER_H_
#include <citro2d.h>
#define BACKGROUND_COLOUR C2D_Color32(242, 241, 240, 255)
#define STATUS_BAR_COLOUR C2D_Color32(69, 67, 62, 255)
#define MENU_BAR_COLOUR C2D_Color32(255, 255, 255, 255)
#define ITEM_COLOUR C2D_Color32(0, 0, 0, 255)
#define ITEM_SELECTED_COLOUR MENU_BAR_COLOUR
#define MENU_SELECTOR_COLOUR C2D_Color32(239, 118, 69, 255)
#define MENU_INFO_TITLE_COLOUR C2D_Color32(144, 137, 129, 255)
#define MENU_INFO_DESC_COLOUR C2D_Color32(51, 51, 51, 255)
C3D_RenderTarget *RENDER_TOP, *RENDER_BOTTOM;
C2D_TextBuf staticBuf, dynamicBuf, sizeBuf;
typedef u32 Colour;
void Draw_EndFrame(void);
void Draw_Text(float x, float y, float size, Colour colour, const char *text);
void Draw_Textf(float x, float y, float size, Colour colour, const char* text, ...);
void Draw_GetTextSize(float size, float *width, float *height, const char *text);
float Draw_GetTextWidth(float size, const char *text);
float Draw_GetTextHeight(float size, const char *text);
bool Draw_Rect(float x, float y, float w, float h, Colour colour);
bool Draw_Image(C2D_Image image, float x, float y);
bool Draw_ImageScale(C2D_Image image, float x, float y, float scaleX, float scaleY);
bool Draw_Image_Blend(C2D_Image image, float x, float y, Colour colour);
#endif

View File

@ -1,10 +0,0 @@
#ifndef _3DSIDENT_COMMON_H_
#define _3DSIDENT_COMMON_H_
#include <setjmp.h>
#define wait(msec) svcSleepThread(10000000 * (s64)msec)
jmp_buf exitJmp;
#endif

View File

@ -1,18 +0,0 @@
#ifndef _3DSIDENT_CONFIG_H_
#define _3DSIDENT_CONFIG_H_
#include <3ds.h>
const wchar_t *Config_GetUsername(void);
char *Config_GetBirthday(void);
char *Config_GetEulaVersion(void);
char *Config_GetSoundOutputMode(void);
char *Config_GetParentalPin(void);
char *Config_GetParentalEmail(void);
char *Config_GetParentalSecretAnswer(void);
bool Config_IsDebugModeEnabled(void);
bool Config_IsUpdatesEnabled(void);
bool Config_IsPowerSaveEnabled(void);
bool Config_IsAutoBrightnessEnabled(void);
#endif

View File

@ -1,8 +0,0 @@
#ifndef _3DSIDENT_MENU_CONTROL_H_
#define _3DSIDENT_MENU_CONTROL_H_
extern bool MENU_STATE_CONTROLS;
void Menu_Controls(void);
#endif

View File

@ -1,6 +0,0 @@
#ifndef _3DSIDENT_MENUS_H_
#define _3DSIDENT_MENUS_H_
void Menu_Main(void);
#endif

View File

@ -1,12 +0,0 @@
#ifndef _3DSIDENT_TEXTURES_H_
#define _3DSIDENT_TEXTURES_H_
#include <citro2d.h>
C2D_Image banner, drive_icon;
C2D_Image btn_A, btn_B, btn_X, btn_Y, btn_Start_Select, btn_L, btn_R, btn_ZL, btn_ZR, btn_Dpad, btn_Cpad, btn_Cstick, btn_home, cursor, volumeIcon;
void Textures_Load(void);
void Textures_Free(void);
#endif

View File

@ -1,286 +0,0 @@
BasicInfo:
Title : $(APP_TITLE)
ProductCode : $(APP_PRODUCT_CODE)
Logo : Homebrew
RomFs:
RootPath: $(APP_ROMFS)
TitleInfo:
Category : Application
UniqueId : $(APP_UNIQUE_ID)
Option:
UseOnSD : true # true if App is to be installed to SD
FreeProductCode : true # Removes limitations on ProductCode
MediaFootPadding : false # If true CCI files are created with padding
EnableCrypt : false # Enables encryption for NCCH and CIA
EnableCompress : true # Compresses where applicable (currently only exefs:/.code)
AccessControlInfo:
CoreVersion : 2
# Exheader Format Version
DescVersion : 2
# Minimum Required Kernel Version (below is for 4.5.0)
ReleaseKernelMajor : "02"
ReleaseKernelMinor : "33"
# ExtData
UseExtSaveData : false # enables ExtData
#ExtSaveDataId : 0x300 # only set this when the ID is different to the UniqueId
# FS:USER Archive Access Permissions
# Uncomment as required
FileSystemAccess:
- CategorySystemApplication
- CategoryHardwareCheck
- CategoryFileSystemTool
- Debug
- TwlCardBackup
- TwlNandData
- Boss
- DirectSdmc
- Core
- CtrNandRo
- CtrNandRw
- CtrNandRoWrite
- CategorySystemSettings
- CardBoard
- ExportImportIvs
- DirectSdmcWrite
- SwitchCleanup
- SaveDataMove
- Shop
- Shell
- CategoryHomeMenu
- SeedDB
IoAccessControl:
- FsMountNand
- FsMountNandRoWrite
- FsMountTwln
- FsMountWnand
- FsMountCardSpi
- UseSdif3
- CreateSeed
- UseCardSpi
# Process Settings
MemoryType : Application # Application/System/Base
SystemMode : 64MB # 64MB(Default)/96MB/80MB/72MB/32MB
IdealProcessor : 0
AffinityMask : 1
Priority : 16
MaxCpu : 0x9E # Default
HandleTableSize : 0x200
DisableDebug : false
EnableForceDebug : false
CanWriteSharedPage : true
CanUsePrivilegedPriority : false
CanUseNonAlphabetAndNumber : true
PermitMainFunctionArgument : true
CanShareDeviceMemory : true
RunnableOnSleep : false
SpecialMemoryArrange : true
# New3DS Exclusive Process Settings
SystemModeExt : Legacy # Legacy(Default)/124MB/178MB Legacy:Use Old3DS SystemMode
CpuSpeed : 804MHz # 268MHz(Default)/804MHz
EnableL2Cache : true # false(default)/true
CanAccessCore2 : true
# Virtual Address Mappings
IORegisterMapping:
- 1ff00000-1ff7ffff # DSP memory
MemoryMapping:
- 1f000000-1f5fffff:r # VRAM
# Accessible SVCs, <Name>:<ID>
SystemCallAccess:
ControlMemory: 1
QueryMemory: 2
ExitProcess: 3
GetProcessAffinityMask: 4
SetProcessAffinityMask: 5
GetProcessIdealProcessor: 6
SetProcessIdealProcessor: 7
CreateThread: 8
ExitThread: 9
SleepThread: 10
GetThreadPriority: 11
SetThreadPriority: 12
GetThreadAffinityMask: 13
SetThreadAffinityMask: 14
GetThreadIdealProcessor: 15
SetThreadIdealProcessor: 16
GetCurrentProcessorNumber: 17
Run: 18
CreateMutex: 19
ReleaseMutex: 20
CreateSemaphore: 21
ReleaseSemaphore: 22
CreateEvent: 23
SignalEvent: 24
ClearEvent: 25
CreateTimer: 26
SetTimer: 27
CancelTimer: 28
ClearTimer: 29
CreateMemoryBlock: 30
MapMemoryBlock: 31
UnmapMemoryBlock: 32
CreateAddressArbiter: 33
ArbitrateAddress: 34
CloseHandle: 35
WaitSynchronization1: 36
WaitSynchronizationN: 37
SignalAndWait: 38
DuplicateHandle: 39
GetSystemTick: 40
GetHandleInfo: 41
GetSystemInfo: 42
GetProcessInfo: 43
GetThreadInfo: 44
ConnectToPort: 45
SendSyncRequest1: 46
SendSyncRequest2: 47
SendSyncRequest3: 48
SendSyncRequest4: 49
SendSyncRequest: 50
OpenProcess: 51
OpenThread: 52
GetProcessId: 53
GetProcessIdOfThread: 54
GetThreadId: 55
GetResourceLimit: 56
GetResourceLimitLimitValues: 57
GetResourceLimitCurrentValues: 58
GetThreadContext: 59
Break: 60
OutputDebugString: 61
ControlPerformanceCounter: 62
CreatePort: 71
CreateSessionToPort: 72
CreateSession: 73
AcceptSession: 74
ReplyAndReceive1: 75
ReplyAndReceive2: 76
ReplyAndReceive3: 77
ReplyAndReceive4: 78
ReplyAndReceive: 79
BindInterrupt: 80
UnbindInterrupt: 81
InvalidateProcessDataCache: 82
StoreProcessDataCache: 83
FlushProcessDataCache: 84
StartInterProcessDma: 85
StopDma: 86
GetDmaState: 87
RestartDma: 88
DebugActiveProcess: 96
BreakDebugProcess: 97
TerminateDebugProcess: 98
GetProcessDebugEvent: 99
ContinueDebugEvent: 100
GetProcessList: 101
GetThreadList: 102
GetDebugThreadContext: 103
SetDebugThreadContext: 104
QueryDebugProcessMemory: 105
ReadProcessMemory: 106
WriteProcessMemory: 107
SetHardwareBreakPoint: 108
GetDebugThreadParam: 109
ControlProcessMemory: 112
MapProcessMemory: 113
UnmapProcessMemory: 114
CreateCodeSet: 115
CreateProcess: 117
TerminateProcess: 118
SetProcessResourceLimits: 119
CreateResourceLimit: 120
SetResourceLimitValues: 121
AddCodeSegment: 122
Backdoor: 123
KernelSetState: 124
QueryProcessMemory: 125
# Service List
# Maximum 34 services (32 if firmware is prior to 9.6.0)
ServiceAccessControl:
- APT:U
- ac:u
- am:net
- boss:U
- cam:u
- cecd:u
- cfg:nor
- cfg:u
- csnd:SND
- dsp::DSP
- frd:u
- fs:USER
- gsp::Gpu
- gsp::Lcd
- hid:USER
- http:C
- ir:rst
- ir:u
- ir:USER
- mic:u
- mcu::HWC
- ndm:u
- news:s
- nwm::EXT
- nwm::UDS
- ptm:sysm
- ptm:u
- pxi:dev
- soc:U
- ssl:C
- y2r:u
SystemControlInfo:
SaveDataSize: 0KB # Change if the app uses savedata
RemasterVersion: $(APP_VERSION_MAJOR)
StackSize: 0x40000
# Modules that run services listed above should be included below
# Maximum 48 dependencies
# <module name>:<module titleid>
Dependency:
ac: 0x0004013000002402
#act: 0x0004013000003802
am: 0x0004013000001502
boss: 0x0004013000003402
camera: 0x0004013000001602
cecd: 0x0004013000002602
cfg: 0x0004013000001702
codec: 0x0004013000001802
csnd: 0x0004013000002702
dlp: 0x0004013000002802
dsp: 0x0004013000001a02
friends: 0x0004013000003202
gpio: 0x0004013000001b02
gsp: 0x0004013000001c02
hid: 0x0004013000001d02
http: 0x0004013000002902
i2c: 0x0004013000001e02
ir: 0x0004013000003302
mcu: 0x0004013000001f02
mic: 0x0004013000002002
ndm: 0x0004013000002b02
news: 0x0004013000003502
#nfc: 0x0004013000004002
nim: 0x0004013000002c02
nwm: 0x0004013000002d02
pdn: 0x0004013000002102
ps: 0x0004013000003102
ptm: 0x0004013000002202
#qtm: 0x0004013020004202
ro: 0x0004013000003702
socket: 0x0004013000002e02
spi: 0x0004013000002302
ssl: 0x0004013000002f02

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -1,18 +0,0 @@
--atlas -f rgba8888 -z auto
A.png
B.png
C_stick.png
Circle_pad.png
cursor.png
D_pad.png
drive.png
Home.png
icon.png
L.png
R.png
Start_select.png
volume.png
X.png
Y.png
ZL.png
ZR.png

View File

@ -1,72 +0,0 @@
#include <stdarg.h>
#include "common.h"
#include "C2D_helper.h"
void Draw_EndFrame(void)
{
C2D_TextBufClear(dynamicBuf);
C2D_TextBufClear(sizeBuf);
C3D_FrameEnd(0);
}
void Draw_Text(float x, float y, float size, Colour colour, const char *text)
{
C2D_Text c2d_text;
C2D_TextParse(&c2d_text, dynamicBuf, text);
C2D_TextOptimize(&c2d_text);
C2D_DrawText(&c2d_text, C2D_WithColor, x, y, 0.5f, size, size, colour);
}
void Draw_Textf(float x, float y, float size, Colour colour, const char* text, ...)
{
char buffer[256];
va_list args;
va_start(args, text);
vsnprintf(buffer, 256, text, args);
Draw_Text(x, y, size, colour, buffer);
va_end(args);
}
void Draw_GetTextSize(float size, float *width, float *height, const char *text)
{
C2D_Text c2d_text;
C2D_TextParse(&c2d_text, sizeBuf, text);
C2D_TextGetDimensions(&c2d_text, size, size, width, height);
}
float Draw_GetTextWidth(float size, const char *text)
{
float width = 0;
Draw_GetTextSize(size, &width, NULL, text);
return width;
}
float Draw_GetTextHeight(float size, const char *text)
{
float height = 0;
Draw_GetTextSize(size, NULL, &height, text);
return height;
}
bool Draw_Rect(float x, float y, float w, float h, Colour colour)
{
return C2D_DrawRectSolid(x, y, 0.5f, w, h, colour);
}
bool Draw_Image(C2D_Image image, float x, float y)
{
return C2D_DrawImageAt(image, x, y, 0.5f, NULL, 1.0f, 1.0f);
}
bool Draw_ImageScale(C2D_Image image, float x, float y, float scaleX, float scaleY)
{
return C2D_DrawImageAt(image, x, y, 0.5f, NULL, scaleX, scaleY);
}
bool Draw_Image_Blend(C2D_Image image, float x, float y, Colour colour)
{
C2D_ImageTint tint;
C2D_PlainImageTint(&tint, colour, 0.50f);
return C2D_DrawImageAt(image, x, y, 0.5f, &tint, 1.0f, 1.0f);
}

View File

@ -1,181 +0,0 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "config.h"
#include "utils.h"
struct Birthday
{
s8 month; // birthday month (1 - 12)
s8 day; // birthday day (1 - 31)
};
const wchar_t *Config_GetUsername(void)
{
u8 data[0x1C];
static wchar_t userName[0x13];
if (R_SUCCEEDED(CFGU_GetConfigInfoBlk2(0x1C, 0x000A0000, data)))
{
for (int i = 0; i < 0x13; i++)
userName[i] = (wchar_t)((u16 *)data)[i];
return userName;
}
return NULL;
}
char *Config_GetBirthday(void)
{
u8 data[0x2];
static char date[0xA];
struct Birthday birthday;
if (R_SUCCEEDED(CFGU_GetConfigInfoBlk2(0x2, 0x000A0001, data)))
{
birthday.month = data[0x01];
birthday.day = data[0x00];
snprintf(date, 0xA, "%02d/%02d", birthday.day, birthday.month);
return date;
}
return NULL;
}
char *Config_GetEulaVersion(void)
{
u8 data[0x4];
static char version[0x6];
if (R_SUCCEEDED(CFGU_GetConfigInfoBlk2(0x4, 0x000D0000, data)))
{
snprintf(version, 0x6, "%1X.%02X", data[0x1], data[0x0]);
return version;
}
return NULL;
}
char *Config_GetSoundOutputMode(void)
{
u8 data[0x1];
static char *mode[] =
{
"mono",
"stereo",
"surround"
};
if (R_SUCCEEDED(CFGU_GetConfigInfoBlk2(0x1, 0x00070001, data)))
return mode[data[0x0]];
return NULL;
}
char *Config_GetParentalPin(void)
{
u8 data[0x94];
static char parentalPin[0x5];
if (R_SUCCEEDED(CFG_GetConfigInfoBlk8(0x94, 0x00100001, data)))
{
snprintf(parentalPin, 0x5, "%u%u%u%u", (data[0xD] - 0x30), (data[0xE] - 0x30), (data[0xF] - 0x30), (data[0x10] - 0x30));
return parentalPin;
}
return NULL;
}
char *Config_GetParentalEmail(void)
{
u8 data[0x200];
static char email[0x200];
if (R_SUCCEEDED(CFGU_GetConfigInfoBlk2(0x200, 0x000C0002, data)))
{
snprintf(email, 0x200, "%s", (data + 1));
return email;
}
return NULL;
}
char *Config_GetParentalSecretAnswer(void)
{
u8 data[0x94]; // block 0x00100001 is of size 0x94
static char out[0x21];
if (R_SUCCEEDED(CFG_GetConfigInfoBlk8(0x94, 0x00100001, data)))
{
Utils_U16_To_U8(out, (u16 *)(data + 0x10), 0x21); // 0x21 cause the secret answer can only be 32 characters long.
return out + 1;
}
return NULL;
}
bool Config_IsDebugModeEnabled(void)
{
u8 data[0x4];
if (R_SUCCEEDED(CFGU_GetConfigInfoBlk2(0x4, 0x00130000, data)))
{
if ((data[0x0] + data[0x1] + data[0x2] + data[0x3]) == 0x100)
return true;
}
return false;
}
bool Config_IsUpdatesEnabled(void)
{
u8 data[0x4];
bool isEnabled = false;
if (R_SUCCEEDED(CFG_GetConfigInfoBlk8(0x4, 0x000F0005, data)))
{
isEnabled = data[0] & 0xFF;
return isEnabled;
}
return false;
}
/*
u8 data[0x2];
data[0x0] -> u8 ABL_powersave_enable
data[0x1] -> u8 brightness_level
*/
bool Config_IsPowerSaveEnabled(void)
{
u8 data[0x2];
bool isEnabled = false;
if (R_SUCCEEDED(CFG_GetConfigInfoBlk8(0x2, 0x00050001, data)))
{
isEnabled = data[0] & 0xFF;
return isEnabled;
}
return false;
}
bool Config_IsAutoBrightnessEnabled(void)
{
u8 data[0x8];
bool isEnabled = false;
if (R_SUCCEEDED(CFG_GetConfigInfoBlk8(0x8, 0x00050009, data)))
{
isEnabled = data[0x4] & 0xFF;
return isEnabled;
}
return false;
}

View File

@ -1,88 +0,0 @@
#include <3ds.h>
#include <malloc.h>
#include "ac.h"
#include "actu.h"
#include "C2D_helper.h"
#include "common.h"
#include "menus.h"
#include "sprites.h"
#include "textures.h"
#include "utils.h"
static u32 cpu_time_limit = 0;
static void Init_Services(void)
{
aciInit();
actInit();
amAppInit();
amInit();
cfguInit();
dspInit();
mcuHwcInit();
ptmuInit();
socInit((u32*)memalign(0x1000, 0x10000), 0x10000);
romfsInit();
gfxInitDefault();
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
C2D_Init(C2D_DEFAULT_MAX_OBJECTS);
C2D_Prepare();
if (Utils_IsN3DS())
osSetSpeedupEnable(true);
APT_GetAppCpuTimeLimit(&cpu_time_limit);
APT_SetAppCpuTimeLimit(30);
staticBuf = C2D_TextBufNew(4096);
dynamicBuf = C2D_TextBufNew(4096);
sizeBuf = C2D_TextBufNew(4096);
RENDER_TOP = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
RENDER_BOTTOM = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
Textures_Load();
}
static void Term_Services(void)
{
Textures_Free();
C2D_TextBufDelete(sizeBuf);
C2D_TextBufDelete(dynamicBuf);
C2D_TextBufDelete(staticBuf);
if (cpu_time_limit != UINT32_MAX)
APT_SetAppCpuTimeLimit(cpu_time_limit);
if (Utils_IsN3DS())
osSetSpeedupEnable(false);
socExit();
ptmuExit();
mcuHwcExit();
dspExit();
cfguExit();
amExit();
actExit();
acExit();
aciExit();
}
int main(int argc, char **argv)
{
Init_Services();
if (setjmp(exitJmp))
{
Term_Services();
return 0;
}
Menu_Main();
Term_Services();
return 0;
}

View File

@ -1,158 +0,0 @@
#include <3ds.h>
#include "C2D_helper.h"
#include "menu_control.h"
#include "textures.h"
bool MENU_STATE_CONTROLS = false;
void Menu_Controls(void)
{
circlePosition cPad, cStick;
touchPosition touch;
u16 touch_x = 0, touch_y = 0;
u8 volume;
int i = 0;
while (MENU_STATE_CONTROLS)
{
hidScanInput();
hidCircleRead(&cPad);
hidCstickRead(&cStick);
u32 kDown = hidKeysDown();
u32 kHeld = hidKeysHeld();
HIDUSER_GetSoundVolume(&volume);
if (((kHeld & KEY_START) && (kDown & KEY_SELECT)) || ((kHeld & KEY_SELECT) && (kDown & KEY_START)))
MENU_STATE_CONTROLS = false;
if (kHeld & KEY_TOUCH)
{
hidTouchRead(&touch);
touch_x = touch.px;
touch_y = touch.py;
}
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
C2D_TargetClear(RENDER_TOP, C2D_Color32(60, 61, 63, 255));
C2D_TargetClear(RENDER_BOTTOM, C2D_Color32(94, 39, 80, 255));
C2D_SceneBegin(RENDER_TOP);
Draw_Rect(75, 30, 250, 210, C2D_Color32(97, 101, 104, 255));
Draw_Rect(85, 40, 230, 175, C2D_Color32(242, 241, 239, 255));
Draw_Rect(85, 40, 230, 15, C2D_Color32(66, 65, 61, 255));
Draw_Textf(90, 40, 0.45f, C2D_Color32(230, 232, 214, 255), "3DSident Button Test");
Draw_Textf(90, 56, 0.45f, C2D_Color32(77, 76, 74, 255), "Circle pad: %04d, %04d", cPad.dx, cPad.dy);
Draw_Textf(90, 70, 0.45f, C2D_Color32(77, 76, 74, 255), "C stick: %04d, %04d", cStick.dx, cStick.dy);
Draw_Textf(90, 84, 0.45f, C2D_Color32(77, 76, 74, 255), "Touch position: %03d, %03d", touch.px, touch.py);
Draw_Textf(90, 84, 0.45f, C2D_Color32(77, 76, 74, 255), "Touch position: %03d, %03d", touch.px, touch.py);
Draw_Image(volumeIcon, 90, 98);
double volPercent = (volume * 1.5873015873);
Draw_Rect(115, 104, 190, 5, C2D_Color32(219, 219, 219, 255));
Draw_Rect(115, 104, ((volPercent / 100) * 190), 5, C2D_Color32(241, 122, 74, 255));
Draw_Textf(90, 118, 0.45f, C2D_Color32(77, 76, 74, 255), "3D");
double _3dSliderPercent = (osGet3DSliderState() * 100.0);
Draw_Rect(115, 122, 190, 5, C2D_Color32(219, 219, 219, 255));
Draw_Rect(115, 122, ((_3dSliderPercent / 100) * 190), 5, C2D_Color32(241, 122, 74, 255));
Draw_Textf(90, 138, 0.45f, C2D_Color32(77, 76, 74, 255), "Press START + SELECT to return.");
Draw_Image(btn_home, 180, 215);
if (kHeld & KEY_L)
Draw_Image_Blend(btn_L, 0, 0, MENU_SELECTOR_COLOUR);
else
Draw_Image(btn_L, 0, 0);
if (kHeld & KEY_R)
Draw_Image_Blend(btn_R, 345, 0, MENU_SELECTOR_COLOUR);
else
Draw_Image(btn_R, 345, 0);
if (kHeld & KEY_ZL)
Draw_Image_Blend(btn_ZL, 60, 0, MENU_SELECTOR_COLOUR);
else
Draw_Image(btn_ZL, 60, 0);
if (kHeld & KEY_ZR)
Draw_Image_Blend(btn_ZR, 300, 0, MENU_SELECTOR_COLOUR);
else
Draw_Image(btn_ZR, 300, 0);
if (kHeld & KEY_A)
Draw_Image_Blend(btn_A, 370, 80, MENU_SELECTOR_COLOUR);
else
Draw_Image(btn_A, 370, 80);
if (kHeld & KEY_B)
Draw_Image_Blend(btn_B, 350, 100, MENU_SELECTOR_COLOUR);
else
Draw_Image(btn_B, 350, 100);
if (kHeld & KEY_X)
Draw_Image_Blend(btn_X, 350, 60, MENU_SELECTOR_COLOUR);
else
Draw_Image(btn_X, 350, 60);
if (kHeld & KEY_Y)
Draw_Image_Blend(btn_Y, 330, 80, MENU_SELECTOR_COLOUR);
else
Draw_Image(btn_Y, 330, 80);
if (kHeld & KEY_START)
Draw_Image_Blend(btn_Start_Select, 330, 140, MENU_SELECTOR_COLOUR);
else
Draw_Image(btn_Start_Select, 330, 140);
if (kHeld & KEY_SELECT)
Draw_Image_Blend(btn_Start_Select, 330, 165, MENU_SELECTOR_COLOUR);
else
Draw_Image(btn_Start_Select, 330, 165);
if (kHeld & KEY_CPAD_LEFT)
Draw_Image_Blend(btn_Cpad, 3, 55, MENU_SELECTOR_COLOUR);
else if (kHeld & KEY_CPAD_RIGHT)
Draw_Image_Blend(btn_Cpad, 13, 55, MENU_SELECTOR_COLOUR);
else if (kHeld & KEY_CPAD_UP)
Draw_Image_Blend(btn_Cpad, 8, 50, MENU_SELECTOR_COLOUR);
else if (kHeld & KEY_CPAD_DOWN)
Draw_Image_Blend(btn_Cpad, 8, 60, MENU_SELECTOR_COLOUR);
else
Draw_Image(btn_Cpad, 8, 55);
if (kHeld & KEY_DLEFT)
Draw_Image_Blend(btn_Dpad, 0, 110, MENU_SELECTOR_COLOUR);
else if (kHeld & KEY_DRIGHT)
Draw_Image_Blend(btn_Dpad, 10, 110, MENU_SELECTOR_COLOUR);
else if (kHeld & KEY_DUP)
Draw_Image_Blend(btn_Dpad, 5, 105, MENU_SELECTOR_COLOUR);
else if (kHeld & KEY_DDOWN)
Draw_Image_Blend(btn_Dpad, 5, 115, MENU_SELECTOR_COLOUR);
else
Draw_Image(btn_Dpad, 5, 110);
if (kHeld & KEY_CSTICK_LEFT)
Draw_Image_Blend(btn_Cstick, 325, 35, MENU_SELECTOR_COLOUR);
else if (kHeld & KEY_CSTICK_RIGHT)
Draw_Image_Blend(btn_Cstick, 335, 35, MENU_SELECTOR_COLOUR);
else if (kHeld & KEY_CSTICK_UP)
Draw_Image_Blend(btn_Cstick, 330, 30, MENU_SELECTOR_COLOUR);
else if (kHeld & KEY_CSTICK_DOWN)
Draw_Image_Blend(btn_Cstick, 330, 40, MENU_SELECTOR_COLOUR);
else
Draw_Image(btn_Cstick, 330, 35);
C2D_SceneBegin(RENDER_BOTTOM);
Draw_Image(cursor, touch_x, touch_y);
Draw_EndFrame();
}
}

View File

@ -1,464 +0,0 @@
#include <stdarg.h>
#include <stdlib.h>
#include <3ds.h>
#include "ac.h"
#include "actu.h"
#include "C2D_helper.h"
#include "common.h"
#include "config.h"
#include "hardware.h"
#include "kernel.h"
#include "menu_control.h"
#include "misc.h"
#include "storage.h"
#include "system.h"
#include "textures.h"
#include "utils.h"
#include "wifi.h"
#define DISTANCE_Y 20
#define MENU_Y_DIST 18
#define MAX_ITEMS 9
static bool display_info = false;
static int item_height = 0;
static char kernel_version[100], system_version[100], firm_version[100], initial_version[0xB], nand_lfcs[0xB];
static u32 sd_titles = 0, nand_titles = 0, tickets = 0;
static void Menu_DrawItem(int x, int y, float size, char *item_title, const char* text, ...)
{
float title_width = 0.0f;
Draw_GetTextSize(size, &title_width, NULL, item_title);
Draw_Text(x, y, size, MENU_INFO_TITLE_COLOUR, item_title);
char buffer[256];
va_list args;
va_start(args, text);
vsnprintf(buffer, 256, text, args);
Draw_Text(x + title_width + 5, y, size, MENU_INFO_DESC_COLOUR, buffer);
va_end(args);
}
static void Menu_Kernel(void)
{
Menu_DrawItem(15, 102, 0.5f, "Kernel version:", kernel_version);
Menu_DrawItem(15, 120, 0.5f, "FIRM version:", firm_version);
Menu_DrawItem(15, 136, 0.5f, "System version:", system_version);
Menu_DrawItem(15, 156, 0.5f, "Initial system version:", initial_version);
Menu_DrawItem(15, 174, 0.5f, "SDMC CID:", display_info? Kernel_GetSDMCCID() : NULL);
Menu_DrawItem(15, 192, 0.5f, "NAND CID:", display_info? Kernel_GetNANDCID() : NULL);
Menu_DrawItem(15, 210, 0.5f, "Device ID:", "%lu", display_info? Kernel_GetDeviceId() : 0);
}
static void Menu_System(void)
{
Menu_DrawItem(15, 102, 0.5f, "Model:", "%s (%s - %s)", System_GetModel(), System_GetRunningHW(), System_GetRegion());
Menu_DrawItem(15, 120, 0.5f, "Language:", System_GetLang());
Menu_DrawItem(15, 138, 0.5f, "ECS Device ID:", "%llu", display_info? System_GetSoapId() : 0);
Menu_DrawItem(15, 156, 0.5f, "Original local friend code seed:", "%010llX", display_info? System_GetLocalFriendCodeSeed() : 0);
Menu_DrawItem(15, 174, 0.5f, "NAND local friend code seed:", "%s", display_info? nand_lfcs : NULL);
Menu_DrawItem(15, 192, 0.5f, "MAC Address:", display_info? System_GetMacAddress() : NULL);
Menu_DrawItem(15, 210, 0.5f, "Serial number:", display_info? System_GetSerialNumber() : NULL);
}
static void Menu_Battery(void)
{
Result ret = 0;
u8 battery_percent = 0, battery_status = 0, battery_volt = 0, fw_ver_high = 0, fw_ver_low = 0;
bool is_connected = false;
ret = MCUHWC_GetBatteryLevel(&battery_percent);
Menu_DrawItem(15, 102, 0.5f, "Battery percentage:", "%3d%%", R_FAILED(ret)? 0 : (battery_percent));
ret = PTMU_GetBatteryChargeState(&battery_status);
Menu_DrawItem(15, 120, 0.5f, "Battery status:", R_FAILED(ret)? NULL : (battery_status? "charging" : "not charging"));
if (R_FAILED(ret = MCUHWC_GetBatteryVoltage(&battery_volt)))
Menu_DrawItem(15, 136, 0.5f, "Battery voltage:", "%d (%.1f V)", 0, 0);
else
Menu_DrawItem(15, 136, 0.5f, "Battery voltage:", "%d (%.1f V)", battery_volt, 5.0 * ((double)battery_volt / 256.0));
ret = PTMU_GetAdapterState(&is_connected);
Menu_DrawItem(15, 156, 0.5f, "Adapter state:", R_FAILED(ret)? NULL : (is_connected? "connected" : "disconnected"));
if ((R_SUCCEEDED(MCUHWC_GetFwVerHigh(&fw_ver_high))) && (R_SUCCEEDED(MCUHWC_GetFwVerLow(&fw_ver_low))))
Menu_DrawItem(15, 174, 0.5f, "MCU firmware:", "%u.%u", (fw_ver_high - 0x10), fw_ver_low);
else
Menu_DrawItem(15, 174, 0.5f, "MCU firmware:", "0.0");
Menu_DrawItem(15, 192, 0.5f, "Power-saving mode:", Config_IsPowerSaveEnabled()? "enabled" : "disabled");
}
static void Menu_NNID(void)
{
Result ret = 0;
AccountDataBlock accountDataBlock;
Result accountDataBlockRet = ACTU_GetAccountDataBlock((u8*)&accountDataBlock, 0xA0, 0x11);
u32 principalID = 0;
char country[0x3], name[0x16], nnid[0x11], timeZone[0x41];
ret = ACTU_GetAccountDataBlock(nnid, 0x11, 0x8);
Menu_DrawItem(15, 102, 0.5f, "NNID:", R_FAILED(ret)? NULL : (display_info? nnid : NULL));
ret = ACTU_GetAccountDataBlock(&principalID, 0x4, 0xC);
Menu_DrawItem(15, 120, 0.5f, "Principal ID:", "%u", R_FAILED(ret)? 0 : (display_info? principalID : 0));
Menu_DrawItem(15, 136, 0.5f, "Persistent ID:", "%u", R_FAILED(accountDataBlockRet)? 0 : (display_info? accountDataBlock.persistentID : 0));
Menu_DrawItem(15, 156, 0.5f, "Transferable ID Base:", "%llu", R_FAILED(accountDataBlockRet)? 0 : (display_info? accountDataBlock.transferableID : 0));
ret = ACTU_GetAccountDataBlock(country, 0x3, 0xB);
Menu_DrawItem(15, 174, 0.5f, "Country:", R_FAILED(ret)? NULL : (display_info? country : NULL));
ret = ACTU_GetAccountDataBlock(timeZone, 0x41, 0x1E);
Menu_DrawItem(15, 192, 0.5f, "Time Zone:", R_FAILED(ret)? NULL : (display_info? timeZone : NULL));
}
static void Menu_Config(void)
{
char username[0x14];
wcstombs(username, Config_GetUsername(), sizeof(username));
Menu_DrawItem(15, 102, 0.5f, "Username: ", username);
Menu_DrawItem(15, 120, 0.5f, "Birthday:", display_info? Config_GetBirthday() : NULL);
Menu_DrawItem(15, 136, 0.5f, "EULA version:", Config_GetEulaVersion());
Menu_DrawItem(15, 156, 0.5f, "Parental control pin:", display_info? Config_GetParentalPin() : NULL);
Menu_DrawItem(15, 174, 0.5f, "Parental control e-mail:", display_info? Config_GetParentalEmail() : NULL);
Menu_DrawItem(15, 192, 0.5f, "Parental control answer:", display_info? Config_GetParentalSecretAnswer() : NULL);
}
static void Menu_Hardware(void)
{
Result ret = 0;
Menu_DrawItem(15, 102, 0.5f, "Screen type:", System_GetScreenType());
Menu_DrawItem(15, 120, 0.5f, "Headphone status:", Hardware_GetAudioJackStatus());
Menu_DrawItem(15, 136, 0.5f, "Card slot status:", Hardware_GetCardSlotStatus());
Menu_DrawItem(15, 156, 0.5f, "SDMC status:", Hardware_DetectSD());
Menu_DrawItem(15, 174, 0.5f, "Sound output:", Config_GetSoundOutputMode());
if (Utils_IsN3DS())
{
Menu_DrawItem(15, 192, 0.5f, "Brightness level:", "%s (auto-brightness mode %s)", Hardware_GetBrightness(GSPLCD_SCREEN_TOP),
Config_IsAutoBrightnessEnabled()? "enabled" : "disabled");
}
else
Menu_DrawItem(15, 192, 0.5f, "Brightness level:", Hardware_GetBrightness(GSPLCD_SCREEN_TOP));
}
static void Menu_Misc(void)
{
Result ret = 0;
Menu_DrawItem(15, 102, 0.5f, "Installed titles:", "SD: %lu (NAND: %lu)", sd_titles, nand_titles);
Menu_DrawItem(15, 120, 0.5f, "Installed tickets:", "%lu", tickets);
u64 homemenuID = 0;
ret = APT_GetAppletInfo(APPID_HOMEMENU, &homemenuID, NULL, NULL, NULL, NULL);
Menu_DrawItem(15, 136, 0.5f, "Homemenu ID:", "%016llX", (R_FAILED(ret))? ret : homemenuID);
double wifi_signal_percent = (osGetWifiStrength() * 33.3333333333);
Menu_DrawItem(15, 156, 0.5f, "WiFi signal strength:", "%d (%.0lf%%)", osGetWifiStrength(), wifi_signal_percent);
char hostname[128];
ret = gethostname(hostname, sizeof(hostname));
if (display_info)
Menu_DrawItem(15, 174, 0.5f, "IP:", hostname);
else
Menu_DrawItem(15, 174, 0.5f, "IP:", NULL);
}
static void Menu_WiFi(void)
{
char ssid[0x20], passphrase[0x40];
wifiSlotStructure slotData;
Draw_Rect(0, 19, 400, 221, BACKGROUND_COLOUR);
if (R_SUCCEEDED(ACI_LoadWiFiSlot(0)))
{
Draw_Rect(15, 27, 370, 70, MENU_INFO_TITLE_COLOUR);
Draw_Rect(16, 28, 368, 68, MENU_BAR_COLOUR);
Draw_Text(20, 30, 0.45f, MENU_INFO_DESC_COLOUR, "WiFi Slot 1:");
if (R_SUCCEEDED(ACI_GetSSID(ssid)))
Menu_DrawItem(20, 46, 0.45f, "SSID:", "%s", ssid);
if (R_SUCCEEDED(ACI_GetPassphrase(passphrase)))
Menu_DrawItem(20, 62, 0.45f, "Pass:", "%s (%s)", display_info? passphrase : NULL, WiFi_GetSecurityMode());
if ((R_SUCCEEDED(CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID, (u8*)&slotData))) && (slotData.set))
{
if (display_info)
Menu_DrawItem(20, 78, 0.45f, "Mac address:", "%02X:%02X:%02X:%02X:%02X:%02X", slotData.mac_addr[0], slotData.mac_addr[1], slotData.mac_addr[2],
slotData.mac_addr[3], slotData.mac_addr[4], slotData.mac_addr[5]);
else
Menu_DrawItem(20, 78, 0.45f, "Mac address:", NULL);
}
}
if (R_SUCCEEDED(ACI_LoadWiFiSlot(1)))
{
Draw_Rect(15, 95, 370, 70, MENU_INFO_TITLE_COLOUR);
Draw_Rect(16, 96, 368, 68, MENU_BAR_COLOUR);
Draw_Text(20, 98, 0.45f, MENU_INFO_DESC_COLOUR, "WiFi Slot 2:");
if (R_SUCCEEDED(ACI_GetSSID(ssid)))
Menu_DrawItem(20, 114, 0.45f, "SSID:", "%s", ssid);
if (R_SUCCEEDED(ACI_GetPassphrase(passphrase)))
Menu_DrawItem(20, 130, 0.45f, "Pass:", "%s (%s)", display_info? passphrase : NULL, WiFi_GetSecurityMode());
if ((R_SUCCEEDED(CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID + 1, (u8*)&slotData))) && (slotData.set))
{
if (display_info)
Menu_DrawItem(20, 146, 0.45f, "Mac address:", "%02X:%02X:%02X:%02X:%02X:%02X", slotData.mac_addr[0], slotData.mac_addr[1], slotData.mac_addr[2],
slotData.mac_addr[3], slotData.mac_addr[4], slotData.mac_addr[5]);
else
Menu_DrawItem(20, 146, 0.45f, "Mac address:", NULL);
}
}
if (R_SUCCEEDED(ACI_LoadWiFiSlot(2)))
{
Draw_Rect(15, 163, 370, 70, MENU_INFO_TITLE_COLOUR);
Draw_Rect(16, 164, 368, 68, MENU_BAR_COLOUR);
Draw_Text(20, 166, 0.45f, MENU_INFO_DESC_COLOUR, "WiFi Slot 3:");
if (R_SUCCEEDED(ACI_GetSSID(ssid)))
Menu_DrawItem(20, 182, 0.45f, "SSID:", "%s", ssid);
if (R_SUCCEEDED(ACI_GetPassphrase(passphrase)))
Menu_DrawItem(20, 198, 0.45f, "Pass:", "%s (%s)", display_info? passphrase : NULL, WiFi_GetSecurityMode());
if ((R_SUCCEEDED(CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID + 2, (u8*)&slotData))) && (slotData.set))
{
if (display_info)
Menu_DrawItem(20, 214, 0.45f, "Mac address:", "%02X:%02X:%02X:%02X:%02X:%02X", slotData.mac_addr[0], slotData.mac_addr[1], slotData.mac_addr[2],
slotData.mac_addr[3], slotData.mac_addr[4], slotData.mac_addr[5]);
else
Menu_DrawItem(20, 214, 0.45f, "Mac address:", NULL);
}
}
}
static void Menu_Storage(void)
{
u64 sdUsed = 0, sdTotal = 0, ctrUsed = 0, ctrTotal = 0, twlUsed = 0, twlTotal = 0, twlpUsed = 0, twlpTotal = 0;
char sdFreeSize[16], sdUsedSize[16], sdTotalSize[16];
char ctrFreeSize[16], ctrUsedSize[16], ctrTotalSize[16];
char twlFreeSize[16], twlUsedSize[16], twlTotalSize[16];
char twlpFreeSize[16], twlpUsedSize[16], twlpTotalSize[16];
Utils_GetSizeString(sdFreeSize, Storage_GetFreeStorage(SYSTEM_MEDIATYPE_SD));
Utils_GetSizeString(sdUsedSize, Storage_GetUsedStorage(SYSTEM_MEDIATYPE_SD));
Utils_GetSizeString(sdTotalSize, Storage_GetTotalStorage(SYSTEM_MEDIATYPE_SD));
Utils_GetSizeString(ctrFreeSize, Storage_GetFreeStorage(SYSTEM_MEDIATYPE_CTR_NAND));
Utils_GetSizeString(ctrUsedSize, Storage_GetUsedStorage(SYSTEM_MEDIATYPE_CTR_NAND));
Utils_GetSizeString(ctrTotalSize, Storage_GetTotalStorage(SYSTEM_MEDIATYPE_CTR_NAND));
Utils_GetSizeString(twlFreeSize, Storage_GetFreeStorage(SYSTEM_MEDIATYPE_TWL_NAND));
Utils_GetSizeString(twlUsedSize, Storage_GetUsedStorage(SYSTEM_MEDIATYPE_TWL_NAND));
Utils_GetSizeString(twlTotalSize, Storage_GetTotalStorage(SYSTEM_MEDIATYPE_TWL_NAND));
Utils_GetSizeString(twlpFreeSize, Storage_GetFreeStorage(SYSTEM_MEDIATYPE_TWL_PHOTO));
Utils_GetSizeString(twlpUsedSize, Storage_GetUsedStorage(SYSTEM_MEDIATYPE_TWL_PHOTO));
Utils_GetSizeString(twlpTotalSize, Storage_GetTotalStorage(SYSTEM_MEDIATYPE_TWL_PHOTO));
Draw_Rect(0, 20, 400, 220, BACKGROUND_COLOUR);
sdUsed = Storage_GetUsedStorage(SYSTEM_MEDIATYPE_SD);
sdTotal = Storage_GetTotalStorage(SYSTEM_MEDIATYPE_SD);
Draw_Rect(20, 105, 60, 10, MENU_INFO_TITLE_COLOUR);
Draw_Rect(21, 106, 58, 8, BACKGROUND_COLOUR);
Draw_Rect(21, 106, (((double)sdUsed / (double)sdTotal) * 58.00), 8, MENU_SELECTOR_COLOUR);
Draw_Text(85, 50, 0.45f, MENU_INFO_DESC_COLOUR, "SD:");
Menu_DrawItem(85, 71, 0.45f, "Free:", sdFreeSize);
Menu_DrawItem(85, 87, 0.45f, "Used:", sdUsedSize);
Menu_DrawItem(85, 103, 0.45f, "Total:", sdTotalSize);
Draw_Image(drive_icon, 20, 40);
ctrUsed = Storage_GetUsedStorage(SYSTEM_MEDIATYPE_CTR_NAND);
ctrTotal = Storage_GetTotalStorage(SYSTEM_MEDIATYPE_CTR_NAND);
Draw_Rect(220, 105, 60, 10, MENU_INFO_TITLE_COLOUR);
Draw_Rect(221, 106, 58, 8, BACKGROUND_COLOUR);
Draw_Rect(221, 106, (((double)ctrUsed / (double)ctrTotal) * 58.00), 8, MENU_SELECTOR_COLOUR);
Draw_Text(285, 50, 0.45f, MENU_INFO_DESC_COLOUR, "CTR Nand:");
Menu_DrawItem(285, 71, 0.45f, "Free:", ctrFreeSize);
Menu_DrawItem(285, 87, 0.45f, "Used:", ctrUsedSize);
Menu_DrawItem(285, 103, 0.45f, "Total:", ctrTotalSize);
Draw_Image(drive_icon, 220, 40);
twlUsed = Storage_GetUsedStorage(SYSTEM_MEDIATYPE_TWL_NAND);
twlTotal = Storage_GetTotalStorage(SYSTEM_MEDIATYPE_TWL_NAND);
Draw_Rect(20, 200, 60, 10, MENU_INFO_TITLE_COLOUR);
Draw_Rect(21, 201, 58, 8, BACKGROUND_COLOUR);
Draw_Rect(21, 201, (((double)twlUsed / (double)twlTotal) * 58.00), 8, MENU_SELECTOR_COLOUR);
Draw_Text(85, 145, 0.45f, MENU_INFO_DESC_COLOUR, "TWL Nand:");
Menu_DrawItem(85, 166, 0.45f, "Free:", twlFreeSize);
Menu_DrawItem(85, 182, 0.45f, "Used:", twlUsedSize);
Menu_DrawItem(85, 198, 0.45f, "Total:", twlTotalSize);
Draw_Image(drive_icon, 20, 135);
twlpUsed = Storage_GetUsedStorage(SYSTEM_MEDIATYPE_TWL_PHOTO);
twlpTotal = Storage_GetTotalStorage(SYSTEM_MEDIATYPE_TWL_PHOTO);
Draw_Rect(220, 200, 60, 10, MENU_INFO_TITLE_COLOUR);
Draw_Rect(221, 201, 58, 8, BACKGROUND_COLOUR);
Draw_Rect(221, 201, (((double)twlpUsed / (double)twlpTotal) * 58.00), 8, MENU_SELECTOR_COLOUR);
Draw_Text(285, 145, 0.45f, MENU_INFO_DESC_COLOUR, "TWL Photo:");
Menu_DrawItem(285, 166, 0.45f, "Free:", twlpFreeSize);
Menu_DrawItem(285, 182, 0.45f, "Used:", twlpUsedSize);
Menu_DrawItem(285, 198, 0.45f, "Total:", twlpTotalSize);
Draw_Image(drive_icon, 220, 135);
}
static int touchButton(touchPosition *touch, int selection)
{
if (touch->px >= 16 && touch->px <= 304 && touch->py >= 16 && touch->py <= 35)
selection = 0;
else if (touch->px >= 16 && touch->px <= 304 && touch->py >= 36 && touch->py <= 55)
selection = 1;
else if (touch->px >= 16 && touch->px <= 304 && touch->py >= 56 && touch->py <= 75)
selection = 2;
else if (touch->px >= 16 && touch->px <= 304 && touch->py >= 76 && touch->py <= 95)
selection = 3;
else if (touch->px >= 16 && touch->px <= 304 && touch->py >= 96 && touch->py <= 115)
selection = 4;
else if (touch->px >= 16 && touch->px <= 304 && touch->py >= 116 && touch->py <= 135)
selection = 5;
else if (touch->px >= 16 && touch->px <= 304 && touch->py >= 136 && touch->py <= 155)
selection = 6;
else if (touch->px >= 16 && touch->px <= 304 && touch->py >= 156 && touch->py <= 175)
selection = 7;
else if (touch->px >= 16 && touch->px <= 304 && touch->py >= 176 && touch->py <= 195)
selection = 8;
else if (touch->px >= 16 && touch->px <= 304 && touch->py >= 196 && touch->py <= 215)
selection = 9;
return selection;
}
void Menu_Main(void)
{
int selection = 0;
display_info = true;
touchPosition touch;
strcpy(kernel_version, Kernel_GetVersion(0));
strcpy(firm_version, Kernel_GetVersion(1));
strcpy(initial_version, Kernel_GetVersion(2));
strcpy(system_version, Kernel_GetVersion(3));
strcpy(nand_lfcs, System_GetNANDLocalFriendCodeSeed());
sd_titles = Misc_TitleCount(MEDIATYPE_SD);
nand_titles = Misc_TitleCount(MEDIATYPE_NAND);
tickets = Misc_TicketCount();
float instr_width = 0.0f, instr_width2 = 0.0f, instr_height = 0.0f;
Draw_GetTextSize(0.5f, &instr_width, &instr_height, "Press select to hide user-specific info.");
Draw_GetTextSize(0.5f, &instr_width2, NULL, "Press START + SELECT to use button tester.");
while (aptMainLoop())
{
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
C2D_TargetClear(RENDER_TOP, BACKGROUND_COLOUR);
C2D_TargetClear(RENDER_BOTTOM, BACKGROUND_COLOUR);
C2D_SceneBegin(RENDER_TOP);
Draw_Rect(0, 0, 400, 20, STATUS_BAR_COLOUR);
Draw_Textf(5, (20 - Draw_GetTextHeight(0.5f, "3DSident v0.0.0"))/2, 0.5f, BACKGROUND_COLOUR, "3DSident v%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO);
Draw_Image(banner, (400 - banner.subtex->width) / 2, ((82 - banner.subtex->height) / 2) + 20);
switch(selection)
{
case 0:
Menu_Kernel();
break;
case 1:
Menu_System();
break;
case 2:
Menu_Battery();
break;
case 3:
Menu_NNID();
break;
case 4:
Menu_Config();
break;
case 5:
Menu_Hardware();
break;
case 6:
Menu_WiFi();
break;
case 7:
Menu_Storage();
break;
case 8:
Menu_Misc();
break;
case 9:
Draw_Text((400 - instr_width) / 2, ((240 - instr_height) / 2) + 18, 0.5f, MENU_INFO_TITLE_COLOUR, "Press select to hide user-specific info.");
Draw_Text((400 - instr_width2) / 2, ((240 - instr_height) / 2) + 36, 0.5f, MENU_INFO_TITLE_COLOUR, "Press START + SELECT to use button tester.");
break;
}
C2D_SceneBegin(RENDER_BOTTOM);
Draw_Rect(15, 15, 290, 210, MENU_INFO_TITLE_COLOUR);
Draw_Rect(16, 16, 288, 208, MENU_BAR_COLOUR);
Draw_Rect(16, 16 + (DISTANCE_Y * selection), 288, 18, MENU_SELECTOR_COLOUR);
Draw_Text(22, 18, 0.5f, selection == 0? ITEM_SELECTED_COLOUR : ITEM_COLOUR, "Kernel");
Draw_Text(22, 38, 0.5f, selection == 1? ITEM_SELECTED_COLOUR : ITEM_COLOUR, "System");
Draw_Text(22, 58, 0.5f, selection == 2? ITEM_SELECTED_COLOUR : ITEM_COLOUR, "Battery");
Draw_Text(22, 78, 0.5f, selection == 3? ITEM_SELECTED_COLOUR : ITEM_COLOUR, "NNID");
Draw_Text(22, 98, 0.5f, selection == 4? ITEM_SELECTED_COLOUR : ITEM_COLOUR, "Config");
Draw_Text(22, 118, 0.5f, selection == 5? ITEM_SELECTED_COLOUR : ITEM_COLOUR, "Hardware");
Draw_Text(22, 138, 0.5f, selection == 6? ITEM_SELECTED_COLOUR : ITEM_COLOUR, "WiFi");
Draw_Text(22, 158, 0.5f, selection == 7? ITEM_SELECTED_COLOUR : ITEM_COLOUR, "Storage");
Draw_Text(22, 178, 0.5f, selection == 8? ITEM_SELECTED_COLOUR : ITEM_COLOUR, "Miscellaneous");
Draw_Text(22, 198, 0.5f, selection == 9? ITEM_SELECTED_COLOUR : ITEM_COLOUR, "Exit");
Draw_EndFrame();
hidScanInput();
hidTouchRead(&touch);
u32 kDown = hidKeysDown();
u32 kHeld = hidKeysHeld();
selection = touchButton(&touch, selection);
if (kDown & KEY_DDOWN)
selection++;
else if (kDown & KEY_DUP)
selection--;
if (selection > MAX_ITEMS)
selection = 0;
if (selection < 0)
selection = MAX_ITEMS;
if (kDown & KEY_SELECT)
display_info = !display_info;
if (((kHeld & KEY_START) && (kDown & KEY_SELECT)) || ((kHeld & KEY_SELECT) && (kDown & KEY_START)))
MENU_STATE_CONTROLS = true;
Menu_Controls();
if (kDown & KEY_A)
{
if (selection == 9)
longjmp(exitJmp, 1);
}
}
}

View File

@ -1,32 +0,0 @@
#include "sprites.h"
#include "textures.h"
static C2D_SpriteSheet spritesheet;
void Textures_Load(void)
{
spritesheet = C2D_SpriteSheetLoad("romfs:/res/drawable/sprites.t3x");
banner = C2D_SpriteSheetGetImage(spritesheet, sprites_icon_idx);
drive_icon = C2D_SpriteSheetGetImage(spritesheet, sprites_drive_idx);
btn_A = C2D_SpriteSheetGetImage(spritesheet, sprites_A_idx);
btn_B = C2D_SpriteSheetGetImage(spritesheet, sprites_B_idx);
btn_X = C2D_SpriteSheetGetImage(spritesheet, sprites_X_idx);
btn_Y = C2D_SpriteSheetGetImage(spritesheet, sprites_Y_idx);
btn_Start_Select = C2D_SpriteSheetGetImage(spritesheet, sprites_Start_select_idx);
btn_L = C2D_SpriteSheetGetImage(spritesheet, sprites_L_idx);
btn_R = C2D_SpriteSheetGetImage(spritesheet, sprites_R_idx);
btn_ZL = C2D_SpriteSheetGetImage(spritesheet, sprites_ZL_idx);
btn_ZR = C2D_SpriteSheetGetImage(spritesheet, sprites_ZR_idx);
btn_Dpad = C2D_SpriteSheetGetImage(spritesheet, sprites_D_pad_idx);
btn_Cpad = C2D_SpriteSheetGetImage(spritesheet, sprites_Circle_pad_idx);
btn_Cstick = C2D_SpriteSheetGetImage(spritesheet, sprites_C_stick_idx);
btn_home = C2D_SpriteSheetGetImage(spritesheet, sprites_Home_idx);
cursor = C2D_SpriteSheetGetImage(spritesheet, sprites_cursor_idx);
volumeIcon = C2D_SpriteSheetGetImage(spritesheet, sprites_volume_idx);
}
void Textures_Free(void)
{
C2D_SpriteSheetFree(spritesheet);
}

11
include/config.h Executable file
View File

@ -0,0 +1,11 @@
#pragma once
namespace Config {
const char *GetUsername(void);
const char *GetBirthday(void);
const char *GetEulaVersion(void);
const char *GetParentalPin(void);
const char *GetParentalEmail(void);
const char *GetParentalSecretAnswer(void);
const char *GetPowersaveStatus(void);
}

6
include/fs.h Executable file
View File

@ -0,0 +1,6 @@
#pragma once
namespace FS {
Result OpenArchive(FS_Archive *archive, FS_ArchiveID archiveID);
Result CloseArchive(FS_Archive archive);
}

9
include/gui.h Executable file
View File

@ -0,0 +1,9 @@
#pragma once
#include "service.h"
namespace GUI {
void Init(void);
void Exit(void);
void MainMenu(void);
}

20
include/hardware.h Executable file
View File

@ -0,0 +1,20 @@
#pragma once
#include <3ds.h>
typedef enum {
GSPLCD_SCREEN_TN,
GSPLCD_SCREEN_IPS,
GSPLCD_SCREEN_UNK
} gspLcdScreenType;
namespace Hardware {
Result GetScreenType(gspLcdScreenType& top, gspLcdScreenType& bottom);
bool GetAudioJackStatus(void);
bool GetCardSlotStatus(void);
FS_CardType GetCardType(void);
bool IsSdInserted(void);
const char *GetSoundOutputMode(void);
u32 GetBrightness(u32 screen);
const char *GetAutoBrightnessStatus(void);
}

15
include/kernel.h Executable file
View File

@ -0,0 +1,15 @@
#pragma once
typedef enum {
VERSION_INFO_KERNEL = 0,
VERSION_INFO_FIRM,
VERSION_INFO_SYSTEM
} VersionInfo;
namespace Kernel {
const char *GetInitalVersion(void);
const char *GetVersion(VersionInfo info);
const char *GetSdmcCid(void);
const char *GetNandCid(void);
u64 GetDeviceId(void);
}

6
include/misc.h Executable file
View File

@ -0,0 +1,6 @@
#pragma once
namespace Misc {
u32 GetTitleCount(FS_MediaType mediaType);
u32 GetTicketCount(void);
}

98
include/service.h Executable file
View File

@ -0,0 +1,98 @@
#pragma once
#include <3ds.h>
struct Birthday {
u16 year;
u8 month;
u8 day;
};
typedef struct {
const char *kernelVersion;
const char *firmVersion;
const char *systemVersion;
const char *initialVersion;
const char *sdmcCid;
const char *nandCid;
u64 deviceId;
} KernelInfo;
typedef struct {
const char *model;
const char *hardware;
const char *region;
const char *language;
u64 localFriendCodeSeed;
const char *macAddress;
u8 *serialNumber;
} SystemInfo;
typedef struct {
u32 principalID;
u32 persistentID;
u64 transferableID;
char country[0x3];
char nnid[0x11];
char timezone[0x41];
} NNIDInfo;
typedef struct {
const char *username;
const char *birthday;
const char *eulaVersion;
const char *parentalPin;
const char *parentalEmail;
const char *parentalSecretAnswer;
} ConfigInfo;
typedef struct {
const char *screenUpper;
const char *screenLower;
const char *soundOutputMode;
} HardwareInfo;
typedef struct {
u32 sdTitleCount;
u32 nandTitleCount;
u32 ticketCount;
} MiscInfo;
typedef struct {
u64 sdUsed;
u64 sdTotal;
u64 ctrUsed;
u64 ctrTotal;
u64 twlUsed;
u64 twlTotal;
u64 twlpUsed;
u64 twlpTotal;
char sdFreeSize[16];
char sdUsedSize[16];
char sdTotalSize[16];
char ctrFreeSize[16];
char ctrUsedSize[16];
char ctrTotalSize[16];
char twlFreeSize[16];
char twlUsedSize[16];
char twlTotalSize[16];
char twlpFreeSize[16];
char twlpUsedSize[16];
char twlpTotalSize[16];
} StorageInfo;
namespace MCUHWC {
Result GetBatteryTemperature(u8 *temp);
}
namespace Service {
void Init(void);
void Exit(void);
KernelInfo GetKernelInfo(void);
SystemInfo GetSystemInfo(void);
ConfigInfo GetConfigInfo(void);
HardwareInfo GetHardwareInfo(void);
StorageInfo GetStorageInfo(void);
MiscInfo GetMiscInfo(void);
}

9
include/storage.h Executable file
View File

@ -0,0 +1,9 @@
#pragma once
#include <3ds.h>
namespace Storage {
u64 GetFreeStorage(FS_SystemMediaType mediaType);
u64 GetTotalStorage(FS_SystemMediaType mediaType);
u64 GetUsedStorage(FS_SystemMediaType mediaType);
}

15
include/system.h Executable file
View File

@ -0,0 +1,15 @@
#pragma once
namespace System {
const char *GetModel(void);
const char *GetRegion(void);
const char *GetFirmRegion(void);
bool IsCoppacsSupported(void);
const char *GetLanguage(void);
const char *GetMacAddress(void);
const char *GetRunningHW(void);
const char *IsDebugUnit(void);
u64 GetLocalFriendCodeSeed(void);
u8 *GetSerialNumber(void);
u64 GetDeviceId(void);
}

11
include/textures.h Executable file
View File

@ -0,0 +1,11 @@
#pragma once
#include <citro2d.h>
extern C2D_Image banner, driveIcon, menuIcon[10], btnA, btnB, btnX, btnY, btnStartSelect, btnL, btnR,
btnZL, btnZR, btnDpad, btnCpad, btnCstick, btnHome, cursor, volumeIcon;
namespace Textures {
void Init(void);
void Exit(void);
}

10
include/utils.h Executable file
View File

@ -0,0 +1,10 @@
#pragma once
#include <string>
namespace Utils {
bool IsNew3DS(void);
void GetSizeString(char *string, u64 size);
std::string GetSubstring(const std::string &text, const std::string &start, const std::string &end);
void UTF16ToUTF8(u8 *buf, const u16 *data, size_t length);
}

0
console/res/app.rsf → res/app.rsf Normal file → Executable file
View File

0
console/res/banner.png → res/banner.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

0
console/res/banner.wav → res/banner.wav Normal file → Executable file
View File

0
gui/res/drawable/A.png → res/drawable/A.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

0
gui/res/drawable/B.png → res/drawable/B.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

0
gui/res/drawable/D_pad.png → res/drawable/D_pad.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

0
gui/res/drawable/L.png → res/drawable/L.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

0
gui/res/drawable/R.png → res/drawable/R.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

0
gui/res/drawable/X.png → res/drawable/X.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

0
gui/res/drawable/Y.png → res/drawable/Y.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

0
gui/res/drawable/ZL.png → res/drawable/ZL.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

0
gui/res/drawable/ZR.png → res/drawable/ZR.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

BIN
res/drawable/config.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 720 B

BIN
res/drawable/controller.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 B

View File

Before

Width:  |  Height:  |  Size: 764 B

After

Width:  |  Height:  |  Size: 764 B

0
gui/res/drawable/drive.png → res/drawable/drive.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

BIN
res/drawable/exit.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B

0
gui/res/drawable/Home.png → res/drawable/home.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

0
console/res/icon.png → res/drawable/icon.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
res/drawable/kernel.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

BIN
res/drawable/misc.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1006 B

BIN
res/drawable/nnid.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

BIN
res/drawable/power.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 B

28
res/drawable/sprites.t3s Executable file
View File

@ -0,0 +1,28 @@
--atlas -f rgba8888 -z auto
A.png
B.png
C_stick.png
circle_pad.png
config.png
controller.png
cursor.png
D_pad.png
drive.png
exit.png
home.png
icon.png
kernel.png
L.png
misc.png
nnid.png
power.png
R.png
start_select.png
storage.png
system.png
volume.png
wifi.png
X.png
Y.png
ZL.png
ZR.png

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
res/drawable/storage.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

BIN
res/drawable/system.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 808 B

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

BIN
res/drawable/wifi.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 793 B

0
gui/res/logo.lz11 → res/logo.lz11 Normal file → Executable file
View File

View File

@ -1,85 +0,0 @@
#include "ac.h"
static Handle acHandle;
Result aciInit(void)
{
return srvGetServiceHandle(&acHandle, "ac:i");
}
Result aciExit(void)
{
return svcCloseHandle(acHandle);
}
Result ACI_LoadWiFiSlot(u8 slot)
{
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x401,1,0); // 0x04010040
cmdbuf[1] = (u32)slot;
Result ret = 0;
if(R_FAILED(ret = svcSendSyncRequest(acHandle))) return ret;
return (Result)cmdbuf[1];
}
Result ACI_GetSSID(char * ssid)
{
u32* cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x40F,0,0); // 0x040F0000
u32* staticbufs = getThreadStaticBuffers();
staticbufs[0] = IPC_Desc_StaticBuffer(0x20, 0); //SSID length is 0x20
staticbufs[1] = (u32)ssid;
Result ret = 0;
if(R_FAILED(ret = svcSendSyncRequest(acHandle))) return ret;
return (Result)cmdbuf[1];
}
Result ACI_GetPassphrase(char * passphrase)
{
u32* cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x415,0,0); // 0x04150000
u32* staticbufs = getThreadStaticBuffers();
staticbufs[0] = IPC_Desc_StaticBuffer(0x40, 0); //passphrase length is 0x40
staticbufs[1] = (u32)passphrase;
Result ret = 0;
if(R_FAILED(ret = svcSendSyncRequest(acHandle))) return ret;
return (Result)cmdbuf[1];
}
Result ACI_GetSSIDLength(u8 * length)
{
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x411,0,0); // 0x04110000
Result ret = 0;
if(R_FAILED(ret = svcSendSyncRequest(acHandle))) return ret;
*length = (u8)cmdbuf[2];
return (Result)cmdbuf[1];
}
Result ACI_GetSecurityMode(u8 * securityMode)
{
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x413,0,0); // 0x04130000
Result ret = 0;
if(R_FAILED(ret = svcSendSyncRequest(acHandle))) return ret;
*securityMode = (u8)cmdbuf[2];
return (Result)cmdbuf[1];
}

View File

@ -1,14 +0,0 @@
#ifndef AC_H
#define AC_H
#include <3ds.h>
Result aciInit(void);
Result aciExit(void);
Result ACI_LoadWiFiSlot(u8 slot);
Result ACI_GetSSID(char * ssid);
Result ACI_GetPassphrase(char * passphrase);
Result ACI_GetSSIDLength(u8 * length);
Result ACI_GetSecurityMode(u8 * securityMode);
#endif

View File

@ -1,52 +0,0 @@
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include "actu.h"
static Handle actHandle;
static int actRefCount;
Result actInit(void)
{
Result ret = 0;
if (AtomicPostIncrement(&actRefCount))
return 0;
ret = srvGetServiceHandle(&actHandle, "act:u");
if (R_FAILED(ret))
ret = srvGetServiceHandle(&actHandle, "act:a");
if (R_FAILED(ret))
AtomicDecrement(&actRefCount);
return ret;
}
void actExit(void)
{
if (AtomicDecrement(&actRefCount))
return;
svcCloseHandle(actHandle);
}
Result ACTU_GetAccountDataBlock(void * buffer, u32 size, u32 blkId)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(6, 3, 2); // 0x00600C2
cmdbuf[1] = 0xFE;
cmdbuf[2] = size;
cmdbuf[3] = blkId;
cmdbuf[4] = 0x10 * size | 0xC;
cmdbuf[5] = (u32)buffer;
if (R_FAILED(ret = svcSendSyncRequest(actHandle)))
return ret;
return (Result)cmdbuf[1];
}

View File

@ -1,30 +0,0 @@
#ifndef ACTU_H
#define ACTU_H
#include <3ds.h>
struct Birthday
{
u16 year;
u8 month;
u8 day;
};
typedef struct
{
u32 persistentID; // Persistent ID
u32 padding1;
u64 transferableID; // Transferable ID Base
u8 miiData[0x60]; // Mii data struct (above)
u16 miiName[0x16]; // UTF-16 mii name
char accountID[0x11]; // ASCII NUL-terminated Nintendo Network ID
u8 padding2;
struct Birthday birthday;
u32 principalID; // Principal ID
} AccountDataBlock;
Result actInit(void);
void actExit(void);
Result ACTU_GetAccountDataBlock(void * buffer, u32 size, u32 blkId);
#endif

View File

@ -1,29 +0,0 @@
#include "am.h"
static Handle amHandle;
Result amGetServiceHandle(void)
{
return srvGetServiceHandle(&amHandle, "am:net");
}
Result amCloseServiceHandle(void)
{
return svcCloseHandle(amHandle);
}
Result amNetGetDeviceCert(u8 const * buffer)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x818, 1, 2); // 0x08180042
cmdbuf[1] = 0x180;
cmdbuf[2] = (0x180 << 4) | 0xC;
cmdbuf[3] = (u32)buffer;
if(R_FAILED(ret = svcSendSyncRequest(amHandle)))
return ret;
return (Result)cmdbuf[1];
}

View File

@ -1,10 +0,0 @@
#ifndef AM_H
#define AM_H
#include <3ds.h>
Result amGetServiceHandle(void);
Result amCloseServiceHandle(void);
Result amNetGetDeviceCert(u8 const * buffer);
#endif

123
source/config.cpp Executable file
View File

@ -0,0 +1,123 @@
#include <3ds.h>
#include <cstdio>
#include "utils.h"
namespace Config {
struct UsernameBlock {
u16 username[10];
u32 zero;
u32 ngWord;
};
struct EulaVersionBlock {
u8 minor;
u8 major;
u8 padding[2];
};
struct BirthdayBlock {
u8 month;
u8 day;
};
struct ParentalControlBlock {
u8 unk[13];
u8 pin[4];
u16 secretAnswer[32];
};
struct BacklightControlBlock {
u8 powerSavingEnabled;
u8 brightnessLevel;
};
const char *GetUsername(void) {
UsernameBlock usernameBlock;
if (R_FAILED(CFGU_GetConfigInfoBlk2(sizeof(UsernameBlock), 0x000A0000, std::addressof(usernameBlock)))) {
return "unknown";
}
static char username[10];
Utils::UTF16ToUTF8(reinterpret_cast<u8 *>(username), usernameBlock.username, 10);
return username;
}
const char *GetBirthday(void) {
BirthdayBlock birthdayBlock;
if (R_FAILED(CFGU_GetConfigInfoBlk2(sizeof(BirthdayBlock), 0x000A0001, std::addressof(birthdayBlock)))) {
return "unknown";
}
const char *months[] = {
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
};
static char date[15];
std::snprintf(date, 15, "%s %02d", months[birthdayBlock.month - 1], birthdayBlock.day);
return date;
}
const char *GetEulaVersion(void) {
EulaVersionBlock eulaVersionBlock;
if (R_FAILED(CFGU_GetConfigInfoBlk2(sizeof(EulaVersionBlock), 0x000D0000, std::addressof(eulaVersionBlock)))) {
return "unknown";
}
static char version[6];
std::snprintf(version, 6, "%1X.%02X", eulaVersionBlock.major, eulaVersionBlock.minor);
return version;
}
const char *GetParentalPin(void) {
ParentalControlBlock parentalControlBlock;
if (R_FAILED(CFG_GetConfigInfoBlk8(sizeof(ParentalControlBlock), 0x00100001, std::addressof(parentalControlBlock)))) {
return "unknown";
}
static char pin[5];
std::snprintf(pin, 5, "%u%u%u%u", (parentalControlBlock.pin[0] - 0x30), (parentalControlBlock.pin[1] - 0x30),
(parentalControlBlock.pin[2] - 0x30), (parentalControlBlock.pin[3] - 0x30));
return pin;
}
const char *GetParentalEmail(void) {
u8 data[0x200];
if (R_FAILED(CFGU_GetConfigInfoBlk2(sizeof(data), 0x000C0002, data))) {
return "unknown";
}
static char email[0x200];
std::snprintf(email, 0x200, "%s", (data + 1));
return email;
}
const char *GetParentalSecretAnswer(void) {
u8 data[0x94]; // block 0x00100001 is of size 0x94
if (R_FAILED(CFG_GetConfigInfoBlk8(0x94, 0x00100001, data))) {
return "unknown";
}
static char out[0x21];
Utils::UTF16ToUTF8(reinterpret_cast<u8 *>(out), reinterpret_cast<u16 *>(data + 16), 0x21);
return out + 1;
}
const char *GetPowersaveStatus(void) {
BacklightControlBlock backlightControlBlock;
if (R_FAILED(CFG_GetConfigInfoBlk8(sizeof(BacklightControlBlock), 0x00050001, std::addressof(backlightControlBlock)))) {
return "unknown";
}
return backlightControlBlock.powerSavingEnabled? "enabled" : "disabled";
}
}

23
source/fs.cpp Executable file
View File

@ -0,0 +1,23 @@
#include <3ds.h>
namespace FS {
Result OpenArchive(FS_Archive *archive, FS_ArchiveID archiveID) {
Result ret = 0;
if (R_FAILED(ret = FSUSER_OpenArchive(archive, archiveID, fsMakePath(PATH_EMPTY, "")))) {
return ret;
}
return 0;
}
Result CloseArchive(FS_Archive archive) {
Result ret = 0;
if (R_FAILED(ret = FSUSER_CloseArchive(archive))) {
return ret;
}
return 0;
}
}

535
source/gui.cpp Executable file
View File

@ -0,0 +1,535 @@
#include <3ds.h>
#include <citro2d.h>
#include <cstdarg>
#include <cstdio>
#include "config.h"
#include "gui.h"
#include "hardware.h"
#include "service.h"
#include "textures.h"
#include "utils.h"
namespace GUI {
enum {
TARGET_TOP = 0,
TARGET_BOTTOM,
TARGET_MAX
};
enum PageState {
KERNEL_INFO_PAGE = 0,
SYSTEM_INFO_PAGE,
BATTERY_INFO_PAGE,
NNID_INFO_PAGE,
CONFIG_INFO_PAGE,
HARDWARE_INFO_PAGE,
WIFI_INFO_PAGE,
STORAGE_INFO_PAGE,
MISC_INFO_PAGE,
EXIT_PAGE,
MAX_ITEMS
};
static C3D_RenderTarget *c3dRenderTarget[TARGET_MAX];
static C2D_TextBuf guiStaticBuf, guiDynamicBuf, guiSizeBuf;
static const u32 guiBgcolour = C2D_Color32(62, 62, 62, 255);
static const u32 guiStatusBarColour = C2D_Color32(44, 44, 44, 255);
static const u32 guiMenuBarColour = C2D_Color32(52, 52, 52, 255);
static const u32 guiSelectorColour = C2D_Color32(223, 74, 22, 255);
static const u32 guiTitleColour = C2D_Color32(252, 252, 252, 255);
static const u32 guiDescrColour = C2D_Color32(182, 182, 182, 255);
static const u32 guiItemDistance = 20, guiItemHeight = 18, guiItemStartX = 15, guiItemStartY = 84;
static const float guiTexSize = 0.5f;
void Init(void) {
romfsInit();
gfxInitDefault();
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
C2D_Init(C2D_DEFAULT_MAX_OBJECTS);
C2D_Prepare();
c3dRenderTarget[TARGET_TOP] = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
c3dRenderTarget[TARGET_BOTTOM] = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
guiStaticBuf = C2D_TextBufNew(4096);
guiDynamicBuf = C2D_TextBufNew(4096);
guiSizeBuf = C2D_TextBufNew(4096);
Textures::Init();
// Real time services
#if !defined BUILD_CITRA
mcuHwcInit();
#endif
ptmuInit();
}
void Exit(void) {
ptmuExit();
#if !defined BUILD_CITRA
mcuHwcExit();
#endif
Textures::Exit();
C2D_TextBufDelete(guiSizeBuf);
C2D_TextBufDelete(guiDynamicBuf);
C2D_TextBufDelete(guiStaticBuf);
C2D_Fini();
C3D_Fini();
gfxExit();
romfsExit();
}
static void GetTextDimensions(float size, float *width, float *height, const char *text) {
C2D_Text c2dText;
C2D_TextParse(&c2dText, guiSizeBuf, text);
C2D_TextGetDimensions(&c2dText, size, size, width, height);
}
static void DrawText(float x, float y, float size, u32 colour, const char *text) {
C2D_Text c2dText;
C2D_TextParse(&c2dText, guiDynamicBuf, text);
C2D_TextOptimize(&c2dText);
C2D_DrawText(&c2dText, C2D_WithColor, x, y, guiTexSize, size, size, colour);
}
static void DrawTextf(float x, float y, float size, u32 colour, const char* text, ...) {
char buffer[128];
va_list args;
va_start(args, text);
std::vsnprintf(buffer, 128, text, args);
GUI::DrawText(x, y, size, colour, buffer);
va_end(args);
}
static void DrawItem(float x, float y, const char *title, const char *text) {
float titleWidth = 0.f;
GUI::GetTextDimensions(guiTexSize, &titleWidth, nullptr, title);
GUI::DrawText(x, y, guiTexSize, guiTitleColour, title);
GUI::DrawText(x + titleWidth + 5, y, guiTexSize, guiDescrColour, text);
}
static void DrawItem(int index, const char *title, const char *text) {
float titleWidth = 0.f;
float y = guiItemStartY + ((guiItemDistance - guiItemHeight) / 2) + guiItemHeight * index;
GUI::GetTextDimensions(guiTexSize, &titleWidth, nullptr, title);
GUI::DrawText(guiItemStartX, y, guiTexSize, guiTitleColour, title);
GUI::DrawText(guiItemStartX + titleWidth + 5, y, guiTexSize, guiDescrColour, text);
}
static void DrawItemf(int index, const char *title, const char *text, ...) {
float titleWidth = 0.f;
float y = guiItemStartY + ((guiItemDistance - guiItemHeight) / 2) + guiItemHeight * index;
GUI::GetTextDimensions(guiTexSize, &titleWidth, nullptr, title);
GUI::DrawText(guiItemStartX, y, guiTexSize, guiTitleColour, title);
char buffer[256];
va_list args;
va_start(args, text);
std::vsnprintf(buffer, 256, text, args);
GUI::DrawText(guiItemStartX + titleWidth + 5, y, guiTexSize, guiDescrColour, buffer);
va_end(args);
}
static bool DrawImage(C2D_Image image, float x, float y) {
return C2D_DrawImageAt(image, x, y, guiTexSize, nullptr, 1.f, 1.f);
}
static bool DrawImageBlend(C2D_Image image, float x, float y, u32 colour) {
C2D_ImageTint tint;
C2D_PlainImageTint(std::addressof(tint), colour, 0.5f);
return C2D_DrawImageAt(image, x, y, guiTexSize, std::addressof(tint), 1.f, 1.f);
}
static void KernelInfoPage(const KernelInfo &info, bool &displayInfo) {
GUI::DrawItemf(1, "Kernel version:", info.kernelVersion);
GUI::DrawItem(2, "FIRM version:", info.firmVersion);
GUI::DrawItemf(3, "System version:", info.systemVersion);
GUI::DrawItemf(4, "Initial system version:", info.initialVersion);
GUI::DrawItemf(5, "SDMC CID:", displayInfo? info.sdmcCid : "");
GUI::DrawItemf(6, "NAND CID:", displayInfo? info.nandCid : "");
GUI::DrawItemf(7, "Device ID:", "%lu", displayInfo? info.deviceId : 0);
}
static void SystemInfoPage(const SystemInfo &info, bool &displayInfo) {
GUI::DrawItemf(1, "Model:", "%s (%s - %s)", info.model, info.hardware, info.region);
GUI::DrawItem(2, "Language:", info.language);
GUI::DrawItemf(3, "Original local friend code seed:", "%010llX", displayInfo? info.localFriendCodeSeed : 0);
GUI::DrawItemf(4, "NAND local friend code seed:", "%010llX", displayInfo? info.localFriendCodeSeed : 0);
GUI::DrawItemf(5, "MAC Address:", displayInfo? info.macAddress : "");
GUI::DrawItemf(6, "Serial number:", displayInfo? reinterpret_cast<const char *>(info.serialNumber) : "");
}
static void BatteryInfoPage(void) {
Result ret = 0;
u8 percentage = 0, status = 0, voltage = 0, fwVerHigh = 0, fwVerLow = 0, temp = 0;
bool connected = false;
ret = MCUHWC_GetBatteryLevel(std::addressof(percentage));
GUI::DrawItemf(1, "Battery percentage:", "%3d%%", R_FAILED(ret)? 0 : (percentage));
ret = PTMU_GetBatteryChargeState(std::addressof(status));
GUI::DrawItem(2, "Battery status:", R_FAILED(ret)? "unknown" : (status? "charging" : "not charging"));
ret = MCUHWC_GetBatteryVoltage(std::addressof(voltage));
GUI::DrawItemf(3, "Battery voltage:", "%d (%.1f V)", voltage, 5.f * (static_cast<float>(voltage) / 256.f));
ret = MCUHWC::GetBatteryTemperature(std::addressof(temp));
GUI::DrawItemf(4, "Battery temperature:", "%d", R_FAILED(ret)? 0 : (temp));
ret = PTMU_GetAdapterState(std::addressof(connected));
GUI::DrawItemf(5, "Adapter state:", R_FAILED(ret)? "unknown" : (connected? "connected" : "disconnected"));
ret = MCUHWC_GetFwVerHigh(std::addressof(fwVerHigh));
ret = MCUHWC_GetFwVerLow(std::addressof(fwVerLow));
GUI::DrawItemf(6, "MCU firmware:", "%u.%u", (fwVerHigh - 0x10), fwVerLow);
GUI::DrawItem(7, "Power-saving mode:", Config::GetPowersaveStatus());
}
static void ConfigInfoPage(const ConfigInfo &info, bool &displayInfo) {
GUI::DrawItem(1, "Username:", info.username);
GUI::DrawItem(2, "Birthday:", displayInfo? info.birthday : "");
GUI::DrawItem(3, "EULA version:", info.eulaVersion);
GUI::DrawItem(4, "Parental control pin:", displayInfo? info.parentalPin : "");
GUI::DrawItem(5, "Parental control email:", displayInfo? info.parentalEmail : "");
GUI::DrawItem(6, "Parental control answer:", displayInfo? info.parentalSecretAnswer : "");
}
static void HardwareInfoPage(const HardwareInfo &info, bool &isNew3DS) {
GUI::DrawItem(1, "Upper screen type:", info.screenUpper);
GUI::DrawItem(2, "Lower screen type:", info.screenLower);
GUI::DrawItem(3, "Headphone status:", Hardware::GetAudioJackStatus()? "inserted" : "not inserted");
GUI::DrawItem(4, "Card slot status:", Hardware::GetCardSlotStatus()? "inserted" : "not inserted");
GUI::DrawItem(5, "SD status:", Hardware::IsSdInserted()? "inserted" : "not inserted");
GUI::DrawItem(6, "Sound output:", info.soundOutputMode);
if (isNew3DS) {
GUI::DrawItemf(7, "Brightness level:", "%lu (auto-brightness mode: %s)", Hardware::GetBrightness(GSPLCD_SCREEN_TOP),
Hardware::GetAutoBrightnessStatus());
}
else {
GUI::DrawItemf(7, "Brightness level:", "%lu", Hardware::GetBrightness(GSPLCD_SCREEN_TOP));
}
}
static void StorageInfoPage(const StorageInfo &info) {
C2D_DrawRectSolid(0, 20, guiTexSize, 400, 220, guiBgcolour);
// SD info
C2D_DrawRectSolid(20, 105, guiTexSize, 60, 10, guiTitleColour);
C2D_DrawRectSolid(21, 106, guiTexSize, 58, 8, guiBgcolour);
C2D_DrawRectSolid(21, 106, guiTexSize, ((static_cast<double>(info.sdUsed) / static_cast<double>(info.sdTotal)) * 58.f), 8, guiSelectorColour);
GUI::DrawItem(85, 50, "SD:", "");
GUI::DrawItem(85, 71, "Free:", info.sdFreeSize);
GUI::DrawItem(85, 87, "Used:", info.sdUsedSize);
GUI::DrawItem(85, 103, "Total:", info.sdTotalSize);
GUI::DrawImage(driveIcon, 20, 40);
// Nand info
C2D_DrawRectSolid(220, 105, guiTexSize, 60, 10, guiTitleColour);
C2D_DrawRectSolid(221, 106, guiTexSize, 58, 8, guiBgcolour);
C2D_DrawRectSolid(221, 106, guiTexSize, ((static_cast<double>(info.ctrUsed) / static_cast<double>(info.ctrTotal)) * 58.f), 8, guiSelectorColour);
GUI::DrawItem(285, 50, "CTR Nand:", "");
GUI::DrawItem(285, 71, "Free:", info.ctrFreeSize);
GUI::DrawItem(285, 87, "Used:", info.ctrUsedSize);
GUI::DrawItem(285, 103, "Total:", info.ctrTotalSize);
GUI::DrawImage(driveIcon, 220, 40);
// TWL nand info
C2D_DrawRectSolid(20, 200, guiTexSize, 60, 10, guiTitleColour);
C2D_DrawRectSolid(21, 201, guiTexSize, 58, 8, guiBgcolour);
C2D_DrawRectSolid(21, 201, guiTexSize, ((static_cast<double>(info.twlUsed) / static_cast<double>(info.twlTotal)) * 58.f), 8, guiSelectorColour);
GUI::DrawItem(85, 145, "TWL Nand:", "");
GUI::DrawItem(85, 166, "Free:", info.twlFreeSize);
GUI::DrawItem(85, 182, "Used:", info.twlUsedSize);
GUI::DrawItem(85, 198, "Total:", info.twlTotalSize);
GUI::DrawImage(driveIcon, 20, 135);
// TWL photo info
C2D_DrawRectSolid(220, 200, guiTexSize, 60, 10, guiTitleColour);
C2D_DrawRectSolid(221, 201, guiTexSize, 58, 8, guiBgcolour);
C2D_DrawRectSolid(221, 201, guiTexSize, ((static_cast<double>(info.twlpUsed) / static_cast<double>(info.twlpTotal)) * 58.f), 8, guiSelectorColour);
GUI::DrawItem(285, 145, "TWL Photo:", "");
GUI::DrawItem(285, 166, "Free:", info.twlpFreeSize);
GUI::DrawItem(285, 182, "Used:", info.twlpUsedSize);
GUI::DrawItem(285, 198, "Total:", info.twlpTotalSize);
GUI::DrawImage(driveIcon, 220, 135);
}
static void MiscInfoPage(const MiscInfo &info, bool &displayInfo) {
GUI::DrawItemf(1, "Installed titles:", "SD: %lu (NAND: %lu)", info.sdTitleCount, info.nandTitleCount);
GUI::DrawItemf(2, "Installed tickets:", "%lu", info.ticketCount);
u8 wifiStrength = osGetWifiStrength();
GUI::DrawItemf(3, "WiFi signal strength:", "%lu", "%d (%.0lf%%)", wifiStrength, static_cast<float>(wifiStrength * 33.33));
char hostname[128];
gethostname(hostname, sizeof(hostname));
GUI::DrawItem(4, "IP:", displayInfo? hostname : "");
}
void ButtonTester(bool &enabled) {
circlePosition circlePad, cStick;
touchPosition touch;
u16 touchX = 0, touchY = 0;
u8 volume = 0;
const u32 guiButtonTesterText = C2D_Color32(77, 76, 74, 255);
const u32 guiButtonTesterSliderBorder = C2D_Color32(219, 219, 219, 255);
const u32 guiButtonTesterSlider = C2D_Color32(241, 122, 74, 255);
while (enabled) {
hidScanInput();
hidCircleRead(std::addressof(circlePad));
hidCstickRead(std::addressof(cStick));
u32 kDown = hidKeysDown();
u32 kHeld = hidKeysHeld();
HIDUSER_GetSoundVolume(std::addressof(volume));
if (((kHeld & KEY_ZL) && (kDown & KEY_ZR)) || ((kHeld & KEY_ZR) && (kDown & KEY_ZL))) {
enabled = false;
}
if (kHeld & KEY_TOUCH) {
hidTouchRead(&touch);
touchX = touch.px;
touchY = touch.py;
}
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
C2D_TargetClear(c3dRenderTarget[TARGET_TOP], C2D_Color32(60, 61, 63, 255));
C2D_TargetClear(c3dRenderTarget[TARGET_BOTTOM], C2D_Color32(94, 39, 80, 255));
C2D_SceneBegin(c3dRenderTarget[TARGET_TOP]);
C2D_DrawRectSolid(75, 30, guiTexSize, 250, 210, C2D_Color32(97, 101, 104, 255));
C2D_DrawRectSolid(85, 40, guiTexSize, 230, 175, C2D_Color32(242, 241, 239, 255));
C2D_DrawRectSolid(85, 40, guiTexSize, 230, 15, C2D_Color32(66, 65, 61, 255));
GUI::DrawText(90, 40, 0.45f, guiTitleColour, "3DSident Button Test");
GUI::DrawTextf(90, 56, 0.45f, guiButtonTesterText, "Circle pad: %04d, %04d", circlePad.dx, circlePad.dy);
GUI::DrawTextf(90, 70, 0.45f, guiButtonTesterText, "C stick: %04d, %04d", cStick.dx, cStick.dy);
GUI::DrawTextf(90, 84, 0.45f, guiButtonTesterText, "Touch position: %03d, %03d", touch.px, touch.py);
GUI::DrawImage(volumeIcon, 90, 98);
double volPercent = (volume * 1.5873015873);
C2D_DrawRectSolid(115, 104, guiTexSize, 190, 5, guiButtonTesterSliderBorder);
C2D_DrawRectSolid(115, 104, guiTexSize, ((volPercent / 100) * 190), 5, guiButtonTesterSlider);
GUI::DrawText(90, 118, 0.45f, guiButtonTesterText, "3D");
double _3dSliderPercent = (osGet3DSliderState() * 100.0);
C2D_DrawRectSolid(115, 122, guiTexSize, 190, 5, guiButtonTesterSliderBorder);
C2D_DrawRectSolid(115, 122, guiTexSize, ((_3dSliderPercent / 100) * 190), 5, guiButtonTesterSlider);
GUI::DrawText(90, 138, 0.45f, guiButtonTesterText, "Press ZL + ZR to return.");
GUI::DrawImage(btnHome, 180, 215);
kHeld & KEY_L? DrawImageBlend(btnL, 0, 0, guiSelectorColour) : GUI::DrawImage(btnL, 0, 0);
kHeld & KEY_R? DrawImageBlend(btnR, 345, 0, guiSelectorColour) : GUI::DrawImage(btnR, 345, 0);
kHeld & KEY_ZL? DrawImageBlend(btnZL, 60, 0, guiSelectorColour) : GUI::DrawImage(btnZL, 60, 0);
kHeld & KEY_ZR? DrawImageBlend(btnZR, 300, 0, guiSelectorColour) : GUI::DrawImage(btnZR, 300, 0);
kHeld & KEY_A? DrawImageBlend(btnA, 370, 80, guiSelectorColour) : GUI::DrawImage(btnA, 370, 80);
kHeld & KEY_B? DrawImageBlend(btnB, 350, 100, guiSelectorColour) : GUI::DrawImage(btnB, 350, 100);
kHeld & KEY_X? DrawImageBlend(btnX, 350, 60, guiSelectorColour) : GUI::DrawImage(btnX, 350, 60);
kHeld & KEY_Y? DrawImageBlend(btnY, 330, 80, guiSelectorColour) : GUI::DrawImage(btnY, 330, 80);
kHeld & KEY_START? DrawImageBlend(btnStartSelect, 330, 140, guiSelectorColour) : GUI::DrawImage(btnStartSelect, 330, 140);
kHeld & KEY_SELECT? DrawImageBlend(btnStartSelect, 330, 165, guiSelectorColour) : GUI::DrawImage(btnStartSelect, 330, 165);
if (kHeld & KEY_CPAD_LEFT) {
DrawImageBlend(btnCpad, 3, 55, guiSelectorColour);
}
else if (kHeld & KEY_CPAD_RIGHT) {
DrawImageBlend(btnCpad, 13, 55, guiSelectorColour);
}
else if (kHeld & KEY_CPAD_UP) {
DrawImageBlend(btnCpad, 8, 50, guiSelectorColour);
}
else if (kHeld & KEY_CPAD_DOWN) {
DrawImageBlend(btnCpad, 8, 60, guiSelectorColour);
}
else {
GUI::DrawImage(btnCpad, 8, 55);
}
if (kHeld & KEY_DLEFT) {
DrawImageBlend(btnDpad, 0, 110, guiSelectorColour);
}
else if (kHeld & KEY_DRIGHT) {
DrawImageBlend(btnDpad, 10, 110, guiSelectorColour);
}
else if (kHeld & KEY_DUP) {
DrawImageBlend(btnDpad, 5, 105, guiSelectorColour);
}
else if (kHeld & KEY_DDOWN) {
DrawImageBlend(btnDpad, 5, 115, guiSelectorColour);
}
else {
GUI::DrawImage(btnDpad, 5, 110);
}
if (kHeld & KEY_CSTICK_LEFT) {
DrawImageBlend(btnCstick, 325, 35, guiSelectorColour);
}
else if (kHeld & KEY_CSTICK_RIGHT) {
DrawImageBlend(btnCstick, 335, 35, guiSelectorColour);
}
else if (kHeld & KEY_CSTICK_UP) {
DrawImageBlend(btnCstick, 330, 30, guiSelectorColour);
}
else if (kHeld & KEY_CSTICK_DOWN) {
DrawImageBlend(btnCstick, 330, 40, guiSelectorColour);
}
else {
GUI::DrawImage(btnCstick, 330, 35);
}
C2D_SceneBegin(c3dRenderTarget[TARGET_BOTTOM]);
GUI::DrawImage(cursor, touchX, touchY);
C2D_TextBufClear(guiDynamicBuf);
C2D_TextBufClear(guiSizeBuf);
C3D_FrameEnd(0);
}
}
void MainMenu(void) {
int selection = 0;
bool isNew3DS = Utils::IsNew3DS(), displayInfo = true, buttonTestEnabled = false;
const char *items[] = {
"Kernel",
"System",
"Battery",
"NNID",
"Config",
"Hardware",
"Wi-Fi",
"Storage",
"Miscellaneous",
"Exit"
};
float titleHeight = 0.f;
GUI::GetTextDimensions(guiTexSize, nullptr, &titleHeight, "3DSident v0.0.0");
KernelInfo kernelInfo = { 0 };
SystemInfo systemInfo = { 0 };
ConfigInfo configInfo = { 0 };
HardwareInfo hardwareInfo = { 0 };
StorageInfo storageInfo = { 0 };
MiscInfo miscInfo = { 0 };
Service::Init();
kernelInfo = Service::GetKernelInfo();
systemInfo = Service::GetSystemInfo();
configInfo = Service::GetConfigInfo();
hardwareInfo = Service::GetHardwareInfo();
storageInfo = Service::GetStorageInfo();
miscInfo = Service::GetMiscInfo();
Service::Exit();
while (aptMainLoop()) {
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
C2D_TargetClear(c3dRenderTarget[TARGET_TOP], guiBgcolour);
C2D_TargetClear(c3dRenderTarget[TARGET_BOTTOM], guiBgcolour);
C2D_SceneBegin(c3dRenderTarget[TARGET_TOP]);
C2D_DrawRectSolid(0, 0, guiTexSize, 400, 20, guiStatusBarColour);
GUI::DrawTextf(5, (20 - titleHeight) / 2, guiTexSize, guiTitleColour, "3DSident v%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO);
GUI::DrawImage(banner, (400 - banner.subtex->width) / 2, ((82 - banner.subtex->height) / 2) + 20);
switch (selection) {
case KERNEL_INFO_PAGE:
GUI::KernelInfoPage(kernelInfo, displayInfo);
break;
case SYSTEM_INFO_PAGE:
GUI::SystemInfoPage(systemInfo, displayInfo);
break;
case BATTERY_INFO_PAGE:
GUI::BatteryInfoPage();
break;
case CONFIG_INFO_PAGE:
GUI::ConfigInfoPage(configInfo, displayInfo);
break;
case HARDWARE_INFO_PAGE:
GUI::HardwareInfoPage(hardwareInfo, isNew3DS);
break;
case STORAGE_INFO_PAGE:
GUI::StorageInfoPage(storageInfo);
break;
case MISC_INFO_PAGE:
GUI::MiscInfoPage(miscInfo, displayInfo);
break;
case EXIT_PAGE:
GUI::DrawItem(1, "Press select to hide user-specific info.", "");
GUI::DrawItem(2, "Press ZL + ZR to use button tester.", "");
break;
default:
break;
}
C2D_SceneBegin(c3dRenderTarget[TARGET_BOTTOM]);
C2D_DrawRectSolid(15, 15, guiTexSize, 290, 210, guiTitleColour);
C2D_DrawRectSolid(16, 16, guiTexSize, 288, 208, guiMenuBarColour);
C2D_DrawRectSolid(16, 16 + (guiItemDistance * selection), guiTexSize, 288, 18, guiSelectorColour);
for (int i = 0; i < MAX_ITEMS; i++) {
C2D_DrawImageAt(menuIcon[i], 20, 17 + ((guiItemDistance - guiItemHeight) / 2) + (guiItemDistance * i), guiTexSize, nullptr, 0.7f, 0.7f);
GUI::DrawText(40, 17 + ((guiItemDistance - guiItemHeight) / 2) + (guiItemDistance * i), guiTexSize, guiTitleColour, items[i]);
}
C2D_TextBufClear(guiDynamicBuf);
C2D_TextBufClear(guiSizeBuf);
C3D_FrameEnd(0);
GUI::ButtonTester(buttonTestEnabled);
hidScanInput();
u32 kDown = hidKeysDown();
u32 kHeld = hidKeysHeld();
if (kDown & KEY_DOWN) {
selection++;
}
else if (kDown & KEY_UP) {
selection--;
}
if (selection > EXIT_PAGE) {
selection = KERNEL_INFO_PAGE;
}
if (selection < KERNEL_INFO_PAGE) {
selection = EXIT_PAGE;
}
if (kDown & KEY_SELECT) {
displayInfo = !displayInfo;
}
if (((kHeld & KEY_ZL) && (kDown & KEY_ZR)) || ((kHeld & KEY_ZR) && (kDown & KEY_ZL))) {
buttonTestEnabled = true;
}
if (kDown & KEY_START) {
break;
}
}
}
}

143
source/hardware.cpp Executable file
View File

@ -0,0 +1,143 @@
#include "hardware.h"
#include "utils.h"
#define REG_LCD_TOP_SCREEN (u32)0x202200
#define REG_LCD_BOTTOM_SCREEN (u32)0x202A00
namespace Hardware {
Result GetScreenType(gspLcdScreenType& top, gspLcdScreenType& bottom) {
Result ret = 0;
u8 vendors = 0;
if (!Utils::IsNew3DS()) {
top = GSPLCD_SCREEN_TN;
bottom = GSPLCD_SCREEN_TN;
return 0;
}
if (R_FAILED(ret = gspLcdInit())) {
return ret;
}
if (R_FAILED(ret = GSPLCD_GetVendors(&vendors))) {
return ret;
}
switch ((vendors >> 4) & 0xF) {
case 0x01: // 0x01 = JDI => IPS
top = GSPLCD_SCREEN_IPS;
break;
case 0x0C: // 0x0C = SHARP => TN
top = GSPLCD_SCREEN_TN;
break;
default:
top = GSPLCD_SCREEN_UNK;
break;
}
switch (vendors & 0xF) {
case 0x01: // 0x01 = JDI => IPS
bottom = GSPLCD_SCREEN_IPS;
break;
case 0x0C: // 0x0C = SHARP => TN
bottom = GSPLCD_SCREEN_TN;
break;
default:
bottom = GSPLCD_SCREEN_UNK;
break;
}
gspLcdExit();
return 0;
}
bool GetAudioJackStatus(void) {
Result ret = 0;
bool status = false;
if (R_FAILED(ret = DSP_GetHeadphoneStatus(std::addressof(status)))) {
return false;
}
return status;
}
bool GetCardSlotStatus(void) {
Result ret = 0;
bool status = false;
if (R_FAILED(ret = FSUSER_CardSlotIsInserted(std::addressof(status)))) {
return false;
}
return status;
}
FS_CardType GetCardType(void) {
Result ret = 0;
FS_CardType type;
if (R_FAILED(ret = FSUSER_GetCardType(std::addressof(type)))) {
return CARD_CTR;
}
return type;
}
bool IsSdInserted(void) {
Result ret = 0;
bool detected = false;
if (R_FAILED(ret = FSUSER_IsSdmcDetected(std::addressof(detected)))) {
return false;
}
return detected;
}
const char *GetSoundOutputMode(void) {
u8 data;
const char *mode[] = {
"Mono",
"Stereo",
"Surround"
};
if (R_FAILED(CFGU_GetConfigInfoBlk2(sizeof(data), 0x00070001, std::addressof(data)))) {
return "unknown";
}
return mode[data];
}
u32 GetBrightness(u32 screen) {
Result ret = 0;
u32 brightness = 0;
u32 addr = (screen == GSPLCD_SCREEN_TOP? REG_LCD_TOP_SCREEN : REG_LCD_BOTTOM_SCREEN) + 0x40;
if (R_FAILED(ret = gspInit())) {
return ret;
}
if (R_FAILED(ret = GSPGPU_ReadHWRegs(addr, std::addressof(brightness), 4))) {
gspExit();
return ret;
}
gspExit();
return brightness;
}
const char *GetAutoBrightnessStatus(void) {
u8 data[0x8];
if (R_FAILED(CFGU_GetConfigInfoBlk2(sizeof(data), 0x00050009, data))) {
return "unknown";
}
return data[0x4] & 0xFF? "enabled" : "disabled";
}
}

142
source/kernel.cpp Executable file
View File

@ -0,0 +1,142 @@
#include <3ds.h>
#include "fs.h"
#include "kernel.h"
#include "system.h"
#include "utils.h"
namespace Kernel {
const char *GetInitalVersion(void) {
Result ret = 0;
FS_Archive archive;
FS::OpenArchive(std::addressof(archive), ARCHIVE_NAND_TWL_FS);
Handle handle;
if (R_FAILED(ret = FSUSER_OpenFileDirectly(&handle, ARCHIVE_NAND_TWL_FS, fsMakePath(PATH_EMPTY, ""), fsMakePath(PATH_ASCII, "/sys/log/product.log"), FS_OPEN_READ, 0))) {
return nullptr;
}
u64 size = 0;
if (R_FAILED(ret = FSFILE_GetSize(handle, std::addressof(size)))) {
return nullptr;
}
char *buf = new char[size + 1];
u32 bytesRead = 0;
if (R_FAILED(ret = FSFILE_Read(handle, std::addressof(bytesRead), 0, reinterpret_cast<u32 *>(buf), static_cast<u32>(size)))) {
return nullptr;
}
buf[size] = '\0';
std::string version = Utils::GetSubstring(buf, "cup:", " preInstall:");
if (version.length() == 0) {
version = Utils::GetSubstring(buf, "cup:", ",");
}
version.append("-");
version.append(Utils::GetSubstring(buf, "nup:", " cup:"));
if (R_FAILED(ret = FSFILE_Close(handle))) {
return nullptr;
}
delete[] buf;
FS::CloseArchive(archive);
return version.c_str();
}
const char *GetVersion(VersionInfo info) {
Result ret = 0;
u32 osVersion = osGetKernelVersion();
OS_VersionBin *nver = new OS_VersionBin[sizeof(OS_VersionBin)];
OS_VersionBin *cver = new OS_VersionBin[sizeof(OS_VersionBin)];
static char kernelString[128];
static char firmString[128];
static char systemVersionString[128];
std::snprintf(kernelString, 128, "%lu.%lu-%lu",
GET_VERSION_MAJOR(osVersion),
GET_VERSION_MINOR(osVersion),
GET_VERSION_REVISION(osVersion)
);
std::snprintf(firmString, 128, "%lu.%lu-%lu",
GET_VERSION_MAJOR(osVersion),
GET_VERSION_MINOR(osVersion),
GET_VERSION_REVISION(osVersion)
);
if (R_FAILED(ret = osGetSystemVersionData(nver, cver))) {
std::snprintf(systemVersionString, 128, "0x%08liX", ret);
}
else {
std::snprintf(systemVersionString, 128, "%d.%d.%d-%d%s",
cver->mainver,
cver->minor,
cver->build,
nver->mainver,
System::GetFirmRegion()
);
}
if (info == VERSION_INFO_KERNEL) {
return kernelString;
}
else if (info == VERSION_INFO_FIRM) {
return firmString;
}
return systemVersionString;
}
const char *GetSdmcCid(void) {
Result ret = 0;
u8 buf[16];
if (R_FAILED(ret = FSUSER_GetSdmcCid(buf, 0x10))) {
return nullptr;
}
static char cid[33];
for (int i = 0; i < 16; ++i) {
std::snprintf(cid + i * 2, 3, "%02X", buf[i]);
}
cid[32] = '\0';
return cid;
}
const char *GetNandCid(void) {
Result ret = 0;
u8 buf[16];
if (R_FAILED(ret = FSUSER_GetNandCid(buf, 0x10))) {
return nullptr;
}
static char cid[33];
for (int i = 0; i < 16; ++i) {
std::snprintf(cid + i * 2, 3, "%02X", buf[i]);
}
cid[32] = '\0';
return cid;
}
u64 GetDeviceId(void) {
Result ret = 0;
u32 id = 0;
if (R_FAILED(ret = AM_GetDeviceId(std::addressof(id)))) {
return ret;
}
return id;
}
}

8
source/main.cpp Executable file
View File

@ -0,0 +1,8 @@
#include "gui.h"
int main(int argc, char* argv[]) {
GUI::Init();
GUI::MainMenu();
GUI::Exit();
return 0;
}

26
source/misc.cpp Executable file
View File

@ -0,0 +1,26 @@
#include <3ds.h>
#include <memory>
namespace Misc {
u32 GetTitleCount(FS_MediaType mediaType) {
Result ret = 0;
u32 count = 0;
if (R_FAILED(ret = AM_GetTitleCount(mediaType, std::addressof(count)))) {
return ret;
}
return count;
}
u32 GetTicketCount(void) {
Result ret = 0;
u32 count = 0;
if (R_FAILED(ret = AM_GetTicketCount(std::addressof(count)))) {
return ret;
}
return count;
}
}

141
source/service.cpp Executable file
View File

@ -0,0 +1,141 @@
#include <3ds.h>
#include "config.h"
#include "hardware.h"
#include "kernel.h"
#include "misc.h"
#include "service.h"
#include "storage.h"
#include "system.h"
#include "utils.h"
namespace MCUHWC {
Result GetBatteryTemperature(u8 *temp) {
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0xE,2,0); // 0x000E0080
if (R_FAILED(ret = svcSendSyncRequest(*mcuHwcGetSessionHandle()))) {
return ret;
}
*temp = cmdbuf[2];
return static_cast<Result>(cmdbuf[1]);
}
}
namespace Service {
void Init(void) {
amInit();
acInit();
cfguInit();
}
void Exit(void) {
acExit();
cfguExit();
amExit();
}
KernelInfo GetKernelInfo(void) {
KernelInfo info = { 0 };
info.kernelVersion = Kernel::GetVersion(VERSION_INFO_KERNEL);
info.firmVersion = Kernel::GetVersion(VERSION_INFO_FIRM);
info.systemVersion = Kernel::GetVersion(VERSION_INFO_SYSTEM);
info.initialVersion = Kernel::GetInitalVersion();
info.sdmcCid = Kernel::GetSdmcCid();
info.nandCid = Kernel::GetNandCid();
info.deviceId = Kernel::GetDeviceId();
return info;
}
SystemInfo GetSystemInfo(void) {
SystemInfo info = { 0 };
info.model = System::GetModel();
info.hardware = System::GetRunningHW();
info.region = System::GetRegion();
info.language = System::GetLanguage();
info.localFriendCodeSeed = System::GetLocalFriendCodeSeed();
info.macAddress = System::GetMacAddress();
info.serialNumber = System::GetSerialNumber();
return info;
}
ConfigInfo GetConfigInfo(void) {
ConfigInfo info = { 0 };
info.username = Config::GetUsername();
info.birthday = Config::GetBirthday();
info.eulaVersion = Config::GetEulaVersion();
info.parentalPin = Config::GetParentalPin();
info.parentalEmail = Config::GetParentalEmail();
info.parentalSecretAnswer = Config::GetParentalSecretAnswer();
return info;
}
HardwareInfo GetHardwareInfo(void) {
HardwareInfo info = { 0 };
gspLcdScreenType top, bottom;
Hardware::GetScreenType(top, bottom);
if (top == GSPLCD_SCREEN_UNK) {
info.screenUpper = "unknown";
}
else {
info.screenUpper = (top == GSPLCD_SCREEN_TN)? "TN" : "IPS";
}
if (bottom == GSPLCD_SCREEN_UNK) {
info.screenLower = "unknown";
}
else {
info.screenLower = (bottom == GSPLCD_SCREEN_TN)? "TN" : "IPS";
}
info.soundOutputMode = Hardware::GetSoundOutputMode();
return info;
}
MiscInfo GetMiscInfo(void) {
MiscInfo info = { 0 };
info.sdTitleCount = Misc::GetTitleCount(MEDIATYPE_SD);
info.nandTitleCount = Misc::GetTitleCount(MEDIATYPE_NAND);
info.ticketCount = Misc::GetTicketCount();
return info;
}
StorageInfo GetStorageInfo(void) {
StorageInfo info = { 0 };
info.sdUsed = Storage::GetUsedStorage(SYSTEM_MEDIATYPE_SD);
info.sdTotal = Storage::GetTotalStorage(SYSTEM_MEDIATYPE_SD);
info.ctrUsed = Storage::GetUsedStorage(SYSTEM_MEDIATYPE_CTR_NAND);
info.ctrTotal = Storage::GetTotalStorage(SYSTEM_MEDIATYPE_CTR_NAND);
info.twlUsed = Storage::GetUsedStorage(SYSTEM_MEDIATYPE_TWL_NAND);
info.twlTotal = Storage::GetTotalStorage(SYSTEM_MEDIATYPE_TWL_NAND);
info.twlpUsed = Storage::GetUsedStorage(SYSTEM_MEDIATYPE_TWL_PHOTO);
info.twlpTotal = Storage::GetTotalStorage(SYSTEM_MEDIATYPE_TWL_PHOTO);
Utils::GetSizeString(info.sdFreeSize, Storage::GetFreeStorage(SYSTEM_MEDIATYPE_SD));
Utils::GetSizeString(info.sdUsedSize, Storage::GetUsedStorage(SYSTEM_MEDIATYPE_SD));
Utils::GetSizeString(info.sdTotalSize, Storage::GetTotalStorage(SYSTEM_MEDIATYPE_SD));
Utils::GetSizeString(info.ctrFreeSize, Storage::GetFreeStorage(SYSTEM_MEDIATYPE_CTR_NAND));
Utils::GetSizeString(info.ctrUsedSize, Storage::GetUsedStorage(SYSTEM_MEDIATYPE_CTR_NAND));
Utils::GetSizeString(info.ctrTotalSize, Storage::GetTotalStorage(SYSTEM_MEDIATYPE_CTR_NAND));
Utils::GetSizeString(info.twlFreeSize, Storage::GetFreeStorage(SYSTEM_MEDIATYPE_TWL_NAND));
Utils::GetSizeString(info.twlUsedSize, Storage::GetUsedStorage(SYSTEM_MEDIATYPE_TWL_NAND));
Utils::GetSizeString(info.twlTotalSize, Storage::GetTotalStorage(SYSTEM_MEDIATYPE_TWL_NAND));
Utils::GetSizeString(info.twlpFreeSize, Storage::GetFreeStorage(SYSTEM_MEDIATYPE_TWL_PHOTO));
Utils::GetSizeString(info.twlpUsedSize, Storage::GetUsedStorage(SYSTEM_MEDIATYPE_TWL_PHOTO));
Utils::GetSizeString(info.twlpTotalSize, Storage::GetTotalStorage(SYSTEM_MEDIATYPE_TWL_PHOTO));
return info;
}
}

Some files were not shown because too many files have changed in this diff Show More