From e599e9cf583ff7f5898d82ba4c3cfa5fb4f99861 Mon Sep 17 00:00:00 2001 From: HackingNewbie <31167380+HackingNewbie@users.noreply.github.com> Date: Sat, 26 Aug 2017 17:48:37 +0100 Subject: [PATCH] Add support for SD cheat codes --- src/main.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index fffaa64..c1dbdd1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "dynamic_libs/os_functions.h" #include "dynamic_libs/fs_functions.h" #include "dynamic_libs/sys_functions.h" @@ -35,6 +36,22 @@ void applyFunctionPatches() { patchIndividualMethodHooks(method_hooks_coreinit, method_hooks_size_coreinit, method_calls_coreinit); } +void applyCheatCodes(){ + uint64_t titleIDNum = OSGetTitleID(); + char titleID[17]; + sprintf(titleID, "%" PRIu64, titleIDNum); + char fileName[24]; + strncat(fileName, titleID, 16); + strncat(fileName, ".gctu", 5); + FILE * fPointer; + fPointer = fopen(fileName, "r"); + char codes[8192]; + if (fPointer != NULL){ + fgets(codes, 8192, fPointer); + memcpy((void*)0x10015000, (void*)codes, sizeof(codes)); + } +} + /* Entry point */ int Menu_Main(void) { //!******************************************************************* @@ -149,6 +166,8 @@ int Menu_Main(void) { isCodeHandlerInstalled = true; launchMethod = TCP_GECKO; + + applyCheatCodes(); initializeUDPLog(); log_print("Patching functions\n"); @@ -179,4 +198,4 @@ int Menu_Main(void) { } return EXIT_RELAUNCH_ON_LOAD; -} \ No newline at end of file +}