diff --git a/include/menu.h b/include/menu.h index f159d3d..f1a3ce9 100644 --- a/include/menu.h +++ b/include/menu.h @@ -24,7 +24,7 @@ struct menuEntry{ static const menuEntry menu[]={ {"e-shop spoof ", "Patches nim for E-Shop access ", SETTING}, {"region patch ", "Patches the home menu to show out of\nregion games and nim to ignore out of\nregion Updates", SETTING}, {"no auto download ", "Patches nim to stop automatic update\ndownload\n(Might be unstable)", SETTING}, - {"serial patch", "Patches the serial to allow E-Shop \nacces after region change\n(not implemented)", PLACEHOLDER}, + {"serial patch ", "Patches the serial to allow E-Shop \nacces after region change\n(not implemented)", PLACEHOLDER}, {"save", "Save current selection for later use", SAVE}, {"exit", "Exit without applying patches ", EXIT} }; diff --git a/include/patches.h b/include/patches.h index 8ca45f7..695fa3d 100644 --- a/include/patches.h +++ b/include/patches.h @@ -2,14 +2,14 @@ #include <3ds.h> -int PatchPid(); +/*int PatchPid(); int UnpatchPid(); void ReinitSrv(); -void PatchSrvAccess(); +void PatchSrvAccess();*/ int patchNimEshop(); int patchNimAutoUpdate(); int patchRegionFree(); int patchMenu(); int patchNs(); //int patchDlp(); -//int changeSerial(); \ No newline at end of file +int changeSerial(); \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index dda61f3..1ca6029 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -21,7 +21,7 @@ static const string settingsFileName="settings.cfg"; bool applyPatches(bool patchlist[]){ SaveVersionConstants(); - PatchSrvAccess(); + //PatchSrvAccess(); gputDrawString("srv patched", (gpuGetViewportWidth() - gputGetStringWidth("srv patched", 8)) / 2, 130, 8, 8, 0 ,0 ,0); if(patchlist[ESHOPSPOOF]==true) @@ -44,6 +44,14 @@ bool applyPatches(bool patchlist[]){ gputDrawString("patch applied!", (gpuGetViewportWidth() - gputGetStringWidth("patch applied!", 8)) / 2 + 50, 70, 8, 8, 0 ,0 ,0); } } + + //will crash + /*if(patchlist[SERIALCHANGE]==true) + { + if(!KernelBackdoor(changeSerial)){ + gputDrawString("patch applied!", (gpuGetViewportWidth() - gputGetStringWidth("patch applied!", 8)) / 2 + 50, 70, 8, 8, 0 ,0 ,0); + } + }*/ HB_FlushInvalidateCache(); // Just to be sure! diff --git a/source/patches.cpp b/source/patches.cpp index 3f353d7..a3bd063 100644 --- a/source/patches.cpp +++ b/source/patches.cpp @@ -9,7 +9,7 @@ #include "kobjects.h" //----------------------------------------------------------------------------- - +/* u32 self_pid = 0; int PatchPid() @@ -46,7 +46,7 @@ void PatchSrvAccess() // Cleanup; won't take effect until srv is reinitialized KernelBackdoor(UnpatchPid); } - +*/ //----------------------------------------------------------------------------- int findAndPatchCode( const char* titleId, short titleIdSize, const u32 startAddress, const u32 area, unsigned char originalcode[], const char patchcode[],u32 patchcodeSize) @@ -185,7 +185,7 @@ int patchNs() return 0; } /* -Todo: +Todo: find offsets int patchDlp() { // Set generell informations for patching @@ -203,31 +203,23 @@ int patchDlp() /* Todo: -//doesnt work atm(crashes) +//doesnt work atm(crashes)*/ int changeSerial() { // Target title id //change console Serial - static const char * title_id = "cfg"; - static const u32 patch_offset = 0x0fefffd5; + static const char * titleIdCfg = "cfg"; + static const u32 startAddressCfg = 0x0fefffd5; - static const char * title_id2 = "act"; - static const u32 patch_offset2 = 0x0003E74C; + static const char * titleIdAct = "act"; + static const u32 startAddressAct = 0x0003E74C; - static const char serial[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + //todo read from file + static unsigned char orgSerial[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + static char serial[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - KCodeSet* code_set = FindTitleCodeSet(title_id,3); - if (code_set == nullptr) - return 1; - - KCodeSet* code_set2 = FindTitleCodeSet(title_id2,3); - if (code_set2 == nullptr) - return 1; - - void * destination = (u64*)FindCodeOffsetKAddr(code_set, patch_offset); - void * destination2 = (u64*)FindCodeOffsetKAddr(code_set2, patch_offset2); - memcpy(destination, serial, sizeof(serial)); - memcpy(destination2, serial, sizeof(serial)); + findAndReplace(titleIdCfg, 3, startAddressCfg, 0x00000010, 1, orgSerial, sizeof(orgSerial), serial, sizeof(serial)); + findAndReplace(titleIdAct, 3, startAddressAct, 0x00000030, 1, orgSerial, sizeof(orgSerial), serial, sizeof(serial)); return 0; -}*/ +}