Skip to content
This repository has been archived by the owner on Mar 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1 from hartmannaf/regionfree
Browse files Browse the repository at this point in the history
Release 0.5
  • Loading branch information
Hartie95 committed Jul 7, 2015
2 parents 96dbb60 + df612d2 commit eae05ad
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 18 deletions.
2 changes: 1 addition & 1 deletion include/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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", 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},
{"save", "Save current selection for later use", SAVE},
Expand Down
7 changes: 5 additions & 2 deletions include/patches.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ int PatchPid();
int UnpatchPid();
void ReinitSrv();
void PatchSrvAccess();
int changeSerial();
int patchNimEshop();
int patchNimAutoUpdate();
int patchMenu();
int patchRegionFree();
int patchMenu();
int patchNs();
//int patchDlp();
//int changeSerial();
Binary file removed release/FreemultiPatcher 0.4.zip
Binary file not shown.
Binary file added release/FreemultiPatcher 0.5.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool applyPatches(bool patchlist[]){

if(patchlist[REGIONFREE]==true)
{
if(!KernelBackdoor(patchMenu)){
if(!KernelBackdoor(patchRegionFree)){
gputDrawString("patch applied!", (gpuGetViewportWidth() - gputGetStringWidth("patch applied!", 8)) / 2 + 25, 70, 8, 8, 0 ,0 ,0);
}
}
Expand Down
106 changes: 92 additions & 14 deletions source/patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,17 @@ int findAndPatchCode( const char* titleId, short titleIdSize, const u32 startAd
if (code_set == nullptr)
return 1;

unsigned char * beginn = (unsigned char*)FindCodeOffsetKAddr(code_set, startAddress);
unsigned char * startAddressPointer = (unsigned char*)FindCodeOffsetKAddr(code_set, startAddress);
unsigned char * destination=nullptr;
unsigned char* currentAddress = beginn;
for(int i = 0; i < 0x00010000 && destination==nullptr; i+=4)
for(unsigned int i = 0; i < area && destination==nullptr; i+=4)
{
//check for the original code position
if( (*((unsigned int*)(currentAddress + i + 0x0)) == *((unsigned int*)&originalcode[0x0])) &&
(*((unsigned int*)(currentAddress + i + 0x4)) == *((unsigned int*)&originalcode[0x4])) &&
(*((unsigned int*)(currentAddress + i + 0x8)) == *((unsigned int*)&originalcode[0x8])) &&
(*((unsigned int*)(currentAddress + i + 0xC)) == *((unsigned int*)&originalcode[0xC])))
if( (*((unsigned int*)(startAddressPointer + i + 0x0)) == *((unsigned int*)&originalcode[0x0])) &&
(*((unsigned int*)(startAddressPointer + i + 0x4)) == *((unsigned int*)&originalcode[0x4])) &&
(*((unsigned int*)(startAddressPointer + i + 0x8)) == *((unsigned int*)&originalcode[0x8])) &&
(*((unsigned int*)(startAddressPointer + i + 0xC)) == *((unsigned int*)&originalcode[0xC])))
{
destination = currentAddress + i;
destination = startAddressPointer + i;
}
}

Expand All @@ -79,52 +78,131 @@ int findAndPatchCode( const char* titleId, short titleIdSize, const u32 startAd
return 0;
}

int findAndReplace( const char * titleId, short titleIdSize, const u32 startAddress, const u32 area, short numberOfReplaces, unsigned char originalcode[],u32 originalcodeSize,const char patchcode[],u32 patchcodeSize)
{
KCodeSet* code_set = FindTitleCodeSet(titleId,titleIdSize);
if (code_set == nullptr)
return 1;

int numberOfFounds=0;
unsigned char * startAddressPointer = (unsigned char*)FindCodeOffsetKAddr(code_set, startAddress);
unsigned char * destination[numberOfReplaces];

for(int i=0;i<numberOfReplaces;i++)
{
destination[i]=nullptr;
}

for(unsigned int i = 0; i < area && numberOfFounds<=numberOfReplaces; i+=4)
{
//check for the original code position
bool found=true;
for(unsigned int x = 0;x<originalcodeSize&&found==true;x+=4)
{
if((*((unsigned int*)(startAddressPointer + i + x)) != *((unsigned int*)&originalcode[x])))
found=false;
}
if( found==true)
{
destination[numberOfFounds] = startAddressPointer + i;
numberOfFounds++;
}
}

//Apply patches, if the addresses was found
for(int i = 0; i < numberOfFounds && destination[i]!=nullptr; i++)
{
memcpy(destination[i], patchcode, patchcodeSize);
}

return 0;
}

int patchNimEshop()
{
// Set generell informations for patching
static const char * title_id = "nim";
static const char * titleId = "nim";
static const u32 startAddress = 0x00001000;

// Patch nim to answer, that no update is available
// 9.0.0 Address: 0x0000DD28
static unsigned char originalcode[] = { 0x35, 0x22, 0x10, 0xB5, 0xD2, 0x01, 0x80, 0x18, 0x00, 0x79, 0x00, 0x28, 0x03, 0xD0, 0x08, 0x46};
static const char patchcode[] = { 0x00, 0x20, 0x08, 0x60, 0x70, 0x47 };
findAndPatchCode(title_id,3,startAddress,0x00010000,originalcode,patchcode,sizeof(patchcode));
findAndPatchCode(titleId, 3, startAddress, 0x00010000, originalcode, patchcode, sizeof(patchcode));

return 0;
}

int patchNimAutoUpdate()
{
// Set generell informations for patching
static const char * title_id = "nim";
static const char * titleId = "nim";
static const u32 startAddress = 0x00001000;

// Patch nim to stop automatic update download(could be unstable)
// 9.0.0 Address: 0x0000EA00
static unsigned char originalcode[] = { 0x25, 0x79, 0x0B, 0x99, 0x00, 0x24, 0x00, 0x2D, 0x29, 0xD0, 0x16, 0x4D, 0x2D, 0x68, 0x01, 0x91};
static char patchcode[] = { 0xE3, 0xA0, 0x00, 0x00 };
findAndPatchCode(title_id,3,startAddress,0x00010000,originalcode,patchcode,sizeof(patchcode));
findAndPatchCode(titleId, 3, startAddress, 0x00010000, originalcode, patchcode, sizeof(patchcode));

return 0;
}

int patchRegionFree()
{
patchMenu();
patchNs();
return 0;
}

int patchMenu()
{
// Set generell informations for patching
static const char * title_id = "menu";
static const char * titleId = "menu";
static const u32 startAddress = 0x00100000;

// patch Homemenu to show out of region applications
// 9.0.0 Address: 0x00101B8C;
static unsigned char originalcode[] = { 0x00, 0x00, 0x55, 0xE3, 0x01, 0x10, 0xA0, 0xE3, 0x11, 0x00, 0xA0, 0xE1, 0x03, 0x00, 0x00, 0x0A };
static char patchcode[] = { 0x01, 0x00, 0xA0, 0xE3, 0x70, 0x80, 0xBD, 0xE8 };
findAndPatchCode(title_id,4,startAddress,0x00100000,originalcode,patchcode,sizeof(patchcode));
findAndPatchCode(titleId, 4, startAddress, 0x00100000, originalcode, patchcode, sizeof(patchcode));

return 0;
}

int patchNs()
{
// Set generell informations for patching
static const char * titleId = "ns";
static const u32 startAddress = 0x00018000;

// patch NS to return update doesnt need to be installed intead of CVer not found error code after Update Check
// 9.0.0 Addresses: 0x00102acc, 0x001894f4;
static char patchcode[] = { 0x0B, 0x18, 0x21, 0xC8 };
static unsigned char originalcode[] = { 0x0C, 0x18, 0xE1, 0xD8 };
findAndReplace(titleId, 2, startAddress, 0x00010000, 2, originalcode, sizeof(originalcode), patchcode, sizeof(patchcode));

return 0;
}
/*
Todo:
int patchDlp()
{
// Set generell informations for patching
static const char * titleId = "dlp";
static const u32 startAddress = 0x00008000;
// patch NS to return update doesnt need to be installed intead of CVer not found error code after Update Check
// 9.0.0 Addresses: 0x00102acc, 0x001894f4;
static char patchcode[] = { 0x0B, 0x18, 0x21, 0xC8 };
static unsigned char originalcode[] = { 0x0C, 0x18, 0xE1, 0xD8 };
findAndReplace(titleId, 2, startAddress, 0x00010000, 2, originalcode, sizeof(originalcode), patchcode, sizeof(patchcode));
return 0;
}*/

/*
Todo:
//doesnt work atm(crashes)
int changeSerial()
{
Expand Down

0 comments on commit eae05ad

Please sign in to comment.