From 37b7ba190f9f83ddc87854b2aba79e3e0ebb7d44 Mon Sep 17 00:00:00 2001 From: ITotalJustice <47043333+ITotalJustice@users.noreply.github.com> Date: Fri, 24 Jan 2020 22:09:10 +0000 Subject: [PATCH] Update for version 1.1.0 Added a bunch of new functions. Added a way to delete parental controls in-app. --- Makefile | 4 +- source/main.c | 146 ++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 143 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 49ab91e..a08f821 100644 --- a/Makefile +++ b/Makefile @@ -32,9 +32,9 @@ include $(DEVKITPRO)/libnx/switch_rules APP_TITLE := Reset Partental Controls APP_AUTHOR := TotalJustice -APP_VERSION := 1.0.0 +APP_VERSION := 1.1.0 -TARGET := reset_paretnal_controls +TARGET := reset_parental_controls BUILD := build SOURCES := source DATA := data diff --git a/source/main.c b/source/main.c index 32c7875..6846712 100644 --- a/source/main.c +++ b/source/main.c @@ -1,7 +1,109 @@ #include +#include +#include #include +typedef enum +{ + PctlSafteyLevel_None = 0x0, + PctlSafteyLevel_Custom = 0x1, + PctlSafteyLevel_YoungChild = 0x2, + PctlSafteyLevel_Child = 0x3, + PctlSafteyLevel_Teen = 0x4, +} PctlSafteyLevel; + + +// not tested +Result pctlConfirmLaunchApplicationPermission(uint64_t app_id) +{ + return serviceDispatchIn(pctlGetServiceSession_Service(), 1002, app_id); +} + +// not tested +Result pctlConfirmResumeApplicationPermission(uint64_t app_id) +{ + return serviceDispatchIn(pctlGetServiceSession_Service(), 1003, app_id); +} + +// not tested +Result pctlIsRestrictionTemporaryUnlocked(bool *out) +{ + return serviceDispatchOut(pctlGetServiceSession_Service(), 1006, *out); +} + +// not tested +Result pctlIsRestrictedSystemSettingsEntered(bool *out) +{ + return serviceDispatchOut(pctlGetServiceSession_Service(), 1010, *out); +} + +// works +Result pctlGetSafetyLevel(uint32_t *out) +{ + return serviceDispatchOut(pctlGetServiceSession_Service(), 1032, *out); +} + +// works +Result pctlSetSafetyLevel(uint32_t level) +{ + return serviceDispatchIn(pctlGetServiceSession_Service(), 1033, level); +} + +// works +Result pctlDeleteParentalControls(void) +{ + return serviceDispatch(pctlGetServiceSession_Service(), 1043); +} + +// not tested +Result pctlNotifyApplicationDownloadStarted(void) +{ + return serviceDispatch(pctlGetServiceSession_Service(), 1047); +} + +// doesn't work +Result pctlUnlockRestrictionTemporarily(void) +{ + return serviceDispatch(pctlGetServiceSession_Service(), 1201); +} + +// doesn't work +Result pctlSetPinCode(uint32_t pin) +{ + return serviceDispatchIn(pctlGetServiceSession_Service(), 1203, pin); +} + +// works +Result pctlGetPinCodeLength(uint32_t *out) +{ + return serviceDispatchOut(pctlGetServiceSession_Service(), 1206, *out); +} + +// doesn't work +Result pctlGetPinCode(uint32_t *out) +{ + return serviceDispatchOut(pctlGetServiceSession_Service(), 1208, *out); +} + +// doesn't work +Result pctlPostEnableAllFeatures(void) +{ + return serviceDispatch(pctlGetServiceSession_Service(), 1602); +} + +// works +Result pctlIsAllFeaturesDisabled(bool *out) +{ + return serviceDispatch(pctlGetServiceSession_Service(), 1603, *out); +} + +// works +Result pctlDeletePairing(void) +{ + return serviceDispatch(pctlGetServiceSession_Service(), 1941); +} + void init_app(void) { consoleInit(NULL); @@ -20,6 +122,17 @@ void print_display(const char *message) consoleUpdate(NULL); } +void print_lock(const char *message) +{ + print_display(message); + while (appletMainLoop()) + { + hidScanInput(); + uint64_t k = hidKeysDown(CONTROLLER_P1_AUTO); + if (k & KEY_B) break; + } +} + int main(int argc, char *argv[]) { init_app(); @@ -27,6 +140,8 @@ int main(int argc, char *argv[]) print_display("Reset Parental Controls: Reseting the pin made easy!\n\n\n\n"); print_display("Press (A) to set parental control pin\n\n"); + print_display("Press (X) to delete parental controls\n\n"); + print_display("Press (Y) to remove parental control app pairing\n\n"); print_display("Press (B) to exit\n\n"); while (appletMainLoop()) @@ -36,16 +151,37 @@ int main(int argc, char *argv[]) if (k & KEY_A) { - if (R_FAILED(pctlauthRegisterPasscode())) + if (R_FAILED(pctlauthChangePasscode())) { - print_display("Failed to launch pctl change passcode\n\n"); + print_display("Failed to change passcode\n\n"); } else { print_display("\n\n\n\nParental control pin succesfully set!\n\n\n\n"); - print_display("### To remove parental controls, please follow the steps below: ###\n\n"); - print_display("System settings -> Parental Controls -> Change settings (enter pin).\n\n"); - print_display("From there press (X) to remove parental controls\n\n"); + } + } + + if (k & KEY_X) + { + if (R_FAILED(pctlDeleteParentalControls())) + { + print_display("Failed to delete parental controls\n\n"); + } + else + { + print_display("\n\n\n\nParental controls succesfully deleted!\n\n\n\n"); + } + } + + if (k & KEY_Y) + { + if (R_FAILED(pctlDeletePairing())) + { + print_display("Failed to remove app pairing\n\n"); + } + else + { + print_display("\n\n\n\nRemoved app pairing!\n\n\n\n"); } }