From c6b6f560be56c74a0bd03da6ad8009b92d1ccfc6 Mon Sep 17 00:00:00 2001 From: Alex Taber Date: Tue, 7 May 2024 21:25:45 -0400 Subject: [PATCH] Require PIN for browser if browser access restricted --- include/fs.h | 18 ++++++++++++++++++ source/fs.c | 11 +++++++++++ source/remote.c | 20 ++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/include/fs.h b/include/fs.h index d140e17..4a36e93 100644 --- a/include/fs.h +++ b/include/fs.h @@ -35,8 +35,26 @@ extern FS_Archive ArchiveSD; extern FS_Archive ArchiveHomeExt; extern FS_Archive ArchiveThemeExt; +typedef struct { + u32 enable : 1; + u32 browser: 1; + u32 stereoscopic : 1; + u32 media_share : 1; + u32 online : 1; + u32 streetpass : 1; + u32 friends : 1; + u32 dsdownload : 1; + u32 shopping : 1; + u32 videos : 1; + u32 miiverse : 1; + u32 post : 1; + u32 null : 19; + u32 coppa : 1; +} Parental_Restrictions_s; + Result open_archives(void); Result close_archives(void); +Result load_parental_controls(Parental_Restrictions_s *restrictions); u32 file_to_buf(FS_Path path, FS_Archive archive, char** buf); u32 zip_memory_to_buf(char *file_name, void * zip_memory, size_t zip_size, char ** buf); diff --git a/source/fs.c b/source/fs.c index e8c45ab..6505f6c 100644 --- a/source/fs.c +++ b/source/fs.c @@ -111,6 +111,17 @@ Result close_archives(void) return 0; } +Result load_parental_controls(Parental_Restrictions_s *restrictions) +{ + char parental_data[0xC0] = {0}; + Result res; + + if (R_FAILED(res = CFG_GetConfigInfoBlk8(0xC0, 0x000C0000, &parental_data))) return res; + memcpy(restrictions, parental_data, 4); + + return 0; +} + u32 file_to_buf(FS_Path path, FS_Archive archive, char** buf) { Handle file; diff --git a/source/remote.c b/source/remote.c index be4522e..91c1980 100644 --- a/source/remote.c +++ b/source/remote.c @@ -490,6 +490,26 @@ bool themeplaza_browser(EntryMode mode) { bool downloaded = false; + Parental_Restrictions_s restrictions = {0}; + Result res = load_parental_controls(&restrictions); + if (R_SUCCEEDED(res)) + { + if (restrictions.enable && restrictions.browser) + { + SwkbdState swkbd; + char entered[5] = {0}; + swkbdInit(&swkbd, SWKBD_TYPE_NUMPAD, 2, 4); + swkbdSetFeatures(&swkbd, SWKBD_PARENTAL); + + swkbdInputText(&swkbd, entered, 5); + SwkbdResult swkbd_res = swkbdGetResult(&swkbd); + if (swkbd_res != SWKBD_PARENTAL_OK) + { + return downloaded; + } + } + } + bool preview_mode = false; int preview_offset = 0; audio_s * audio = NULL;