-Internals - changed online update URL paths

-GC - updated nintendont config support to version 0x0000000A

-Usability - Wiimmfi WFC patching fixed
This commit is contained in:
unknown 2024-09-03 19:52:15 +02:00
parent c9df95e9d1
commit 613134151a
7 changed files with 678 additions and 92 deletions

View File

@ -15,7 +15,7 @@ include $(DEVKITPPC)/wii_rules
# SOURCES is a list of directories containing source code # SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files # INCLUDES is a list of directories containing extra header files
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
VERSION := 70r78.11 VERSION := 70r78.12
RELEASE := release RELEASE := release
# to override RELEASE use: make announce RELEASE=beta # to override RELEASE use: make announce RELEASE=beta
ifeq ($(findstring compat,$(VERSION)),compat) ifeq ($(findstring compat,$(VERSION)),compat)

View File

@ -1,11 +1,11 @@
#ifndef __NINTENDONT_CONFIG_H__ #ifndef __COMMON_CONFIG_H__
#define __NINTENDONT_CONFIG_H__ #define __COMMON_CONFIG_H__
//#include "NintendontVersion.h" //#include "NintendontVersion.h"
//#include "Metadata.h" //#include "Metadata.h"
#define NIN_CFG_VERSION 0x00000006 #define NIN_CFG_VERSION 0x0000000A
#define NIN_CFG_MAXPAD 4 #define NIN_CFG_MAXPAD 4
@ -23,12 +23,13 @@ typedef struct NIN_CFG
unsigned char MemCardBlocks; unsigned char MemCardBlocks;
signed char VideoScale; signed char VideoScale;
signed char VideoOffset; signed char VideoOffset;
unsigned char Unused; unsigned char NetworkProfile;
unsigned int WiiUGamepadSlot;
} NIN_CFG; } NIN_CFG;
enum ninconfigbitpos enum ninconfigbitpos
{ {
NIN_CFG_BIT_CHEATS = (0), NIN_CFG_BIT_CHEATS = (0),
NIN_CFG_BIT_DEBUGGER = (1), // Only for Wii Version NIN_CFG_BIT_DEBUGGER = (1), // Only for Wii Version
NIN_CFG_BIT_DEBUGWAIT = (2), // Only for Wii Version NIN_CFG_BIT_DEBUGWAIT = (2), // Only for Wii Version
NIN_CFG_BIT_MEMCARDEMU = (3), NIN_CFG_BIT_MEMCARDEMU = (3),
@ -36,17 +37,24 @@ enum ninconfigbitpos
NIN_CFG_BIT_FORCE_WIDE = (5), NIN_CFG_BIT_FORCE_WIDE = (5),
NIN_CFG_BIT_FORCE_PROG = (6), NIN_CFG_BIT_FORCE_PROG = (6),
NIN_CFG_BIT_AUTO_BOOT = (7), NIN_CFG_BIT_AUTO_BOOT = (7),
NIN_CFG_BIT_HID = (8), // Old Versions NIN_CFG_BIT_HID = (8), // Old Versions
NIN_CFG_BIT_REMLIMIT = (8), // New Versions NIN_CFG_BIT_REMLIMIT = (8), // New Versions
NIN_CFG_BIT_OSREPORT = (9), NIN_CFG_BIT_OSREPORT = (9),
NIN_CFG_BIT_USB = (10), NIN_CFG_BIT_USB = (10),
NIN_CFG_BIT_LED = (11), NIN_CFG_BIT_LED = (11),
NIN_CFG_BIT_LOG = (12), NIN_CFG_BIT_LOG = (12),
NIN_CFG_BIT_LAST = (13), NIN_CFG_BIT_LAST = (13),
NIN_CFG_BIT_MC_MULTI = (13), NIN_CFG_BIT_MC_MULTI = (13),
NIN_CFG_BIT_NATIVE_SI = (14), NIN_CFG_BIT_NATIVE_SI = (14),
NIN_CFG_BIT_WIIU_WIDE = (15), NIN_CFG_BIT_WIIU_WIDE = (15),
NIN_CFG_BIT_ARCADE_MODE = (16),
NIN_CFG_BIT_CC_RUMBLE = (17),
NIN_CFG_BIT_SKIP_IPL = (18),
NIN_CFG_BIT_BBA_EMU = (19),
// Internal kernel settings.
NIN_CFG_BIT_MC_SLOTB = (31), // Slot B image is loaded
}; };
enum ninconfig enum ninconfig
@ -59,15 +67,22 @@ enum ninconfig
NIN_CFG_FORCE_WIDE = (1<<NIN_CFG_BIT_FORCE_WIDE), NIN_CFG_FORCE_WIDE = (1<<NIN_CFG_BIT_FORCE_WIDE),
NIN_CFG_FORCE_PROG = (1<<NIN_CFG_BIT_FORCE_PROG), NIN_CFG_FORCE_PROG = (1<<NIN_CFG_BIT_FORCE_PROG),
NIN_CFG_AUTO_BOOT = (1<<NIN_CFG_BIT_AUTO_BOOT), NIN_CFG_AUTO_BOOT = (1<<NIN_CFG_BIT_AUTO_BOOT),
NIN_CFG_HID = (1<<NIN_CFG_BIT_HID), NIN_CFG_HID = (1<<NIN_CFG_BIT_HID),
NIN_CFG_REMLIMIT = (1<<NIN_CFG_BIT_REMLIMIT), NIN_CFG_REMLIMIT = (1<<NIN_CFG_BIT_REMLIMIT),
NIN_CFG_OSREPORT = (1<<NIN_CFG_BIT_OSREPORT), NIN_CFG_OSREPORT = (1<<NIN_CFG_BIT_OSREPORT),
NIN_CFG_USB = (1<<NIN_CFG_BIT_USB), NIN_CFG_USB = (1<<NIN_CFG_BIT_USB),
NIN_CFG_LED = (1<<NIN_CFG_BIT_LED), NIN_CFG_LED = (1<<NIN_CFG_BIT_LED), // Only for Wii Version
NIN_CFG_LOG = (1<<NIN_CFG_BIT_LOG), NIN_CFG_LOG = (1<<NIN_CFG_BIT_LOG),
NIN_CFG_MC_MULTI = (1<<NIN_CFG_BIT_MC_MULTI), NIN_CFG_MC_MULTI = (1<<NIN_CFG_BIT_MC_MULTI),
NIN_CFG_NATIVE_SI = (1<<NIN_CFG_BIT_NATIVE_SI), NIN_CFG_NATIVE_SI = (1<<NIN_CFG_BIT_NATIVE_SI), // Only for Wii Version
NIN_CFG_WIIU_WIDE = (1<<NIN_CFG_BIT_WIIU_WIDE), NIN_CFG_WIIU_WIDE = (1<<NIN_CFG_BIT_WIIU_WIDE), // Only for Wii U Version
NIN_CFG_ARCADE_MODE = (1<<NIN_CFG_BIT_ARCADE_MODE),
NIN_CFG_CC_RUMBLE = (1<<NIN_CFG_BIT_CC_RUMBLE),
NIN_CFG_SKIP_IPL = (1<<NIN_CFG_BIT_SKIP_IPL),
NIN_CFG_BBA_EMU = (1<<NIN_CFG_BIT_BBA_EMU),
NIN_CFG_MC_SLOTB = (1<<NIN_CFG_BIT_MC_SLOTB),
}; };
enum ninextrasettings enum ninextrasettings
@ -156,4 +171,13 @@ enum VideoModes
#define MEM_CARD_SIZE(x) (1<<(x+19)) #define MEM_CARD_SIZE(x) (1<<(x+19))
#define MEM_CARD_BLOCKS(x) ((1<<(x+6))-5) #define MEM_CARD_BLOCKS(x) ((1<<(x+6))-5)
// bi2.bin region codes. (0x458)
enum BI2region_codes
{
BI2_REGION_JAPAN = 0,
BI2_REGION_USA = 1,
BI2_REGION_PAL = 2,
BI2_REGION_SOUTH_KOREA = 4,
};
#endif #endif

View File

@ -614,27 +614,24 @@ void NoSSLPatch(void *addr, u32 len)
} while (++cur < end); } while (++cur < end);
} }
void WFCPatch(void *addr, u32 len, const char* domain) void WFCPatchWimmifi(void *addr, u32 len)
{ {
if(strlen("nintendowifi.net") < strlen(domain)) char GameID[5];
return; memset(GameID, 0, 5);
memcpy(GameID, (char*)0x80000000, 4);
char *cur = (char *)addr; if(memcmp("RMC", GameID, 3) != 0) {
const char *end = cur + len - 16; // This isn't MKWii, perform the patch for other games.
do_new_wiimmfi_nonMKWii();
// Do the plain old patching with the string search
WFCPatch(addr, len, PRIVSERV_WIIMMFI);
}
else {
// This is MKWii, perform the known patch from 2018.
do_new_wiimmfi();
}
do
{
if (memcmp(cur, "nintendowifi.net", 16) == 0)
{
int len = strlen(cur);
u8 i;
memcpy(cur, domain, strlen(domain));
memmove(cur + strlen(domain), cur + 16, len - 16);
for(i = 16 - strlen(domain); i > 0 ; i--)
cur[len - i ] = 0;
cur += len;
}
} while (++cur < end);
} }
// from sneek by crediar // from sneek by crediar
@ -762,7 +759,7 @@ void maindolpatches(void *dst, int len)
switch (CFG.game.private_server) switch (CFG.game.private_server)
{ {
case 2: case 2:
WFCPatch(dst, len, "wiimmfi.de"); WFCPatchWimmifi(dst, len);
break; break;
case 3: case 3:
WFCPatch(dst, len, CFG.custom_private_server); WFCPatch(dst, len, CFG.custom_private_server);

View File

@ -535,4 +535,545 @@ bool PatchReturnTo(void *Address, int Size, u32 id) {
return patched; return patched;
} }
void WFCPatch(void *addr, u32 len, const char* domain)
{
if(strlen("nintendowifi.net") < strlen(domain))
return;
char *cur = (char *)addr;
const char *end = cur + len - 16;
do
{
if (memcmp(cur, "nintendowifi.net", 16) == 0)
{
int len = strlen(cur);
u8 i;
memcpy(cur, domain, strlen(domain));
memmove(cur + strlen(domain), cur + 16, len - 16);
for(i = 16 - strlen(domain); i > 0 ; i--)
cur[len - i ] = 0;
cur += len;
}
} while (++cur < end);
}
static inline int GetOpcode(unsigned int* instructionAddr)
{
return ((*instructionAddr >> 26) & 0x3f);
}
static inline int GetImmediateDataVal(unsigned int* instructionAddr)
{
return (*instructionAddr & 0xffff);
}
static inline int GetLoadTargetReg(unsigned int* instructionAddr)
{
return (int)((*instructionAddr >> 21) & 0x1f);
}
static inline int GetComparisonTargetReg(unsigned int* instructionAddr)
{
return (int)((*instructionAddr >> 16) & 0x1f);
}
u32 do_new_wiimmfi_nonMKWii() {
// As of February 2021, Wiimmfi requires a special Wiimmfi patcher
// update which does a bit more than just patch the server adresses.
// This function is being called by apploader.c, right before
// jumping to the entry point (only for non-MKWii games on Wiimmfi),
// and applies all the necessary security fixes to the game.
// This function has been implemented by Leseratte. Please don't
// try to modify it without speaking to the Wiimmfi team because
// doing so could have unintended side effects.
int hasGT2Error = 0;
int i = 0;
int dynamic = 0;
char gt2locator[] = { 0x38, 0x61, 0x00, 0x08, 0x38, 0xA0, 0x00, 0x14};
unsigned char opCodeChainP2P_v1[22] = { 32, 32, 21, 21, 21, 21, 20, 20, 31, 40, 21, 20, 20, 31, 31, 10, 20, 36, 21, 44, 36, 16 };
unsigned char opCodeChainP2P_v2[22] = { 32, 32, 21, 21, 20, 21, 20, 21, 31, 40, 21, 20, 20, 31, 31, 10, 20, 36, 21, 44, 36, 16 };
unsigned char opCodeChainMASTER_v1[22] = { 21, 21, 21, 21, 40, 20, 20, 20, 20, 31, 31, 14, 31, 20, 21, 44, 21, 36, 36, 18, 11, 16 };
unsigned char opCodeChainMASTER_v2[22] = { 21, 21, 21, 21, 40, 20, 20, 20, 20, 31, 31, 14, 31, 20, 21, 36, 21, 44, 36, 18, 11, 16 };
int MASTERopcodeChainOffset = 0;
char * cur = (char *)0x80004000;
const char * end = (const char *)0x80900000;
// Check if the game needs the new patch.
do {
if (memcmp(cur, "<GT2> RECV-0x%02x <- [--------:-----] [pid=%u]", 0x2e) == 0)
{
hasGT2Error++;
}
} while (++cur < end);
cur = (char *)0x80004000;
if (hasGT2Error > 1) return 1; // error, this either doesn't exist, or exists once. Can't exist multiple times.
int successful_patch_p2p = 0;
int successful_patch_master = 0;
do {
// Patch the User-Agent so Wiimmfi knows this game has been patched.
// This also identifies patcher (U=CfgUSBLoader) and patch version (=1), please
// do not change this without talking to Leseratte first.
if (memcmp(cur, "User-Agent\x00\x00RVL SDK/", 20) == 0) {
if (hasGT2Error)
memcpy(cur + 12, "U-3-1\x00", 6);
else
memcpy(cur + 12, "U-3-0\x00", 6);
}
if (hasGT2Error)
{
if (memcmp(cur, &gt2locator, 8) == 0)
{
int found_opcode_chain_P2P_v1 = 1;
int found_opcode_chain_P2P_v2 = 1;
for (i = 0; i < 22; i++) {
int offset = (i * 4) + 12;
if (opCodeChainP2P_v1[i] != (unsigned char)(GetOpcode((unsigned int *)(cur + offset)))) {
found_opcode_chain_P2P_v1 = 0;
}
if (opCodeChainP2P_v2[i] != (unsigned char)(GetOpcode((unsigned int *)(cur + offset)))) {
found_opcode_chain_P2P_v2 = 0;
}
}
int found_opcode_chain_MASTER;
for (dynamic = 0; dynamic < 40; dynamic += 4) {
found_opcode_chain_MASTER = 1;
int offset = 0;
for (i = 0; i < 22; i++) {
offset = (i * 4) + 12 + dynamic;
if (
(opCodeChainMASTER_v1[i] != (unsigned char)(GetOpcode((unsigned int *)(cur + offset)))) &&
(opCodeChainMASTER_v2[i] != (unsigned char)(GetOpcode((unsigned int *)(cur + offset))))
) {
found_opcode_chain_MASTER = 0;
}
}
if (found_opcode_chain_MASTER) {
MASTERopcodeChainOffset = (int)(cur + 12 + dynamic);
break;
}
}
if (found_opcode_chain_P2P_v1 || found_opcode_chain_P2P_v2) {
if (
GetImmediateDataVal((unsigned int *)(cur + 0x0c)) == 0x0c &&
GetImmediateDataVal((unsigned int *)(cur + 0x10)) == 0x18 &&
GetImmediateDataVal((unsigned int *)(cur + 0x30)) == 0x12 &&
GetImmediateDataVal((unsigned int *)(cur + 0x48)) == 0x5a &&
GetImmediateDataVal((unsigned int *)(cur + 0x50)) == 0x0c &&
GetImmediateDataVal((unsigned int *)(cur + 0x58)) == 0x12 &&
GetImmediateDataVal((unsigned int *)(cur + 0x5c)) == 0x18 &&
GetImmediateDataVal((unsigned int *)(cur + 0x60)) == 0x18
)
{
int loadedDataReg = GetLoadTargetReg((unsigned int *)(cur + 0x14));
int comparisonDataReg = GetComparisonTargetReg((unsigned int *)(cur + 0x48));
if (found_opcode_chain_P2P_v1) {
*(int *)(cur + 0x14) = (0x88010011 | (comparisonDataReg << 21));
*(int *)(cur + 0x18) = (0x28000080 | (comparisonDataReg << 16));
*(int *)(cur + 0x24) = 0x41810064;
*(int *)(cur + 0x28) = 0x60000000;
*(int *)(cur + 0x2c) = 0x60000000;
*(int *)(cur + 0x34) = (0x3C005A00 | (comparisonDataReg << 21));
*(int *)(cur + 0x48) = (0x7C000000 | (comparisonDataReg << 16) | (loadedDataReg << 11));
successful_patch_p2p++;
}
if (found_opcode_chain_P2P_v2) {
loadedDataReg = 12;
*(int *)(cur + 0x14) = (0x88010011 | (comparisonDataReg << 21));
*(int *)(cur + 0x18) = (0x28000080 | (comparisonDataReg << 16));
*(int *)(cur + 0x1c) = 0x41810070;
*(int *)(cur + 0x24) = *(int *)(cur + 0x28);
*(int *)(cur + 0x28) = (0x8001000c | (loadedDataReg << 21));
*(int *)(cur + 0x2c) = (0x3C005A00 | (comparisonDataReg << 21));
*(int *)(cur + 0x34) = (0x7c000000 | (comparisonDataReg << 16) | (loadedDataReg << 11));
*(int *)(cur + 0x48) = 0x60000000;
successful_patch_p2p++;
}
}
}
else if (found_opcode_chain_MASTER) {
if (
GetImmediateDataVal((unsigned int *)(MASTERopcodeChainOffset + 0x10)) == 0x12 &&
GetImmediateDataVal((unsigned int *)(MASTERopcodeChainOffset + 0x2c)) == 0x04 &&
GetImmediateDataVal((unsigned int *)(MASTERopcodeChainOffset + 0x48)) == 0x18 &&
GetImmediateDataVal((unsigned int *)(MASTERopcodeChainOffset + 0x50)) == 0x00 &&
GetImmediateDataVal((unsigned int *)(MASTERopcodeChainOffset + 0x54)) == 0x18
)
{
int master_patch_version = 0;
// Check which version we have:
if ((GetImmediateDataVal((unsigned int *)(MASTERopcodeChainOffset + 0x3c)) == 0x12 &&
GetImmediateDataVal((unsigned int *)(MASTERopcodeChainOffset + 0x44)) == 0x0c) ) {
master_patch_version = 1;
}
else if ((GetImmediateDataVal((unsigned int *)(MASTERopcodeChainOffset + 0x3c)) == 0x0c &&
GetImmediateDataVal((unsigned int *)(MASTERopcodeChainOffset + 0x44)) == 0x12) ) {
master_patch_version = 2;
}
if (master_patch_version == 2) {
// Different opcode order ...
*(int *)(MASTERopcodeChainOffset + 0x3c) = *(int *)(MASTERopcodeChainOffset + 0x44);
}
if (master_patch_version != 0) {
int rY = GetComparisonTargetReg((unsigned int *)MASTERopcodeChainOffset);
int rX = GetLoadTargetReg((unsigned int *)MASTERopcodeChainOffset);
*(int *)(MASTERopcodeChainOffset + 0x00) = 0x38000004 | (rX << 21);
*(int *)(MASTERopcodeChainOffset + 0x04) = 0x7c00042c | (rY << 21) | (3 << 16) | (rX << 11);
*(int *)(MASTERopcodeChainOffset + 0x14) = 0x9000000c | (rY << 21) | (1 << 16);
*(int *)(MASTERopcodeChainOffset + 0x18) = 0x88000011 | (rY << 21) | (1 << 16);
*(int *)(MASTERopcodeChainOffset + 0x28) = 0x28000080 | (rY << 16);
*(int *)(MASTERopcodeChainOffset + 0x38) = 0x60000000;
*(int *)(MASTERopcodeChainOffset + 0x44) = 0x41810014;
successful_patch_master++;
}
}
}
}
}
} while (++cur < end);
if (hasGT2Error) {
if (successful_patch_master == 0 || successful_patch_p2p == 0) {
return 2;
}
}
return 0;
}
u32 do_new_wiimmfi() {
// As of November 2018, Wiimmfi requires a special Wiimmfi patcher
// update which does a bit more than just patch the server adresses.
// This function is being called by apploader.c, right before
// jumping to the entry point (only for Mario Kart Wii & Wiimmfi),
// and applies all the necessary new patches to the game.
// This includes support for the new patcher update plus
// support for StaticR.rel patching.
// This function has been implemented by Leseratte. Please don't
// try to modify it without speaking to the Wiimmfi team because
// doing so could have unintended side effects.
// Updated in 2021 to add the 51420 error fix.
// check region:
char region = *((char *)(0x80000003));
char * patched;
void * patch1_offset, *patch2_offset, *patch3_offset;
void * errorfix_offset;
// define some offsets and variables depending on the region:
switch (region) {
case 'P':
patched = (char*)0x80276054;
patch1_offset = (void*)0x800ee3a0;
patch2_offset = (void*)0x801d4efc;
patch3_offset = (void*)0x801A72E0;
errorfix_offset = (void*)0x80658ce4;
break;
case 'E':
patched = (char*)0x80271d14;
patch1_offset = (void*)0x800ee300;
patch2_offset = (void*)0x801d4e5c;
patch3_offset = (void*)0x801A7240;
errorfix_offset = (void*)0x8065485c;
break;
case 'J':
patched = (char*)0x802759f4;
patch1_offset = (void*)0x800ee2c0;
patch2_offset = (void*)0x801d4e1c;
patch3_offset = (void*)0x801A7200;
errorfix_offset = (void*)0x80658360;
break;
case 'K':
patched = (char*)0x80263E34;
patch1_offset = (void*)0x800ee418;
patch2_offset = (void*)0x801d5258;
patch3_offset = (void*)0x801A763c;
errorfix_offset = (void*)0x80646ffc;
break;
default:
return -1;
}
if (*patched != '*') return -2; // ISO already patched
// This RAM address is set (no asterisk) by all officially
// updated patchers, so if it is modified, the image is already
// patched with a new patcher and we don't need to patch anything.
// For statistics and easier debugging in case of problems, Wiimmfi
// wants to know what patcher a game has been patched with, thus,
// let the game know the exact USB-Loader version. Max length 42
// chars, padded with whitespace, without null terminator
char * fmt = "%s v%-50s";
char patcher[100] = {0};
snprintf((char *)&patcher, 99, fmt, APP_NAME, APP_VERSION);
strncpy(patched, (char *)&patcher, 42);
// Do the plain old patching with the string search
WFCPatch((void*)0x80004000, 0x385200, PRIVSERV_WIIMMFI);
// Replace some URLs for Wiimmfi's new update system
char newURL1[] = "http://ca.nas.wiimmfi.de/ca";
char newURL2[] = "http://naswii.wiimmfi.de/ac";
char newURL3P[] = "https://main.nas.wiimmfi.de/pp";
char newURL3E[] = "https://main.nas.wiimmfi.de/pe";
char newURL3J[] = "https://main.nas.wiimmfi.de/pj";
char newURL3K[] = "https://main.nas.wiimmfi.de/pk";
// Write the URLs to the proper place and do some other patching.
switch (region) {
case 'P':
memcpy((void*)0x8027A400, newURL1, sizeof(newURL1));
memcpy((void*)0x8027A400 + 0x28, newURL2, sizeof(newURL2));
memcpy((void*)0x8027A400 + 0x4C, newURL3P, sizeof(newURL3P));
*(u32*)0x802a146c = 0x733a2f2f;
*(u32*)0x800ecaac = 0x3bc00000;
break;
case 'E':
memcpy((void*)0x802760C0, newURL1, sizeof(newURL1));
memcpy((void*)0x802760C0 + 0x28, newURL2, sizeof(newURL2));
memcpy((void*)0x802760C0 + 0x4C, newURL3E, sizeof(newURL3E));
*(u32*)0x8029D12C = 0x733a2f2f;
*(u32*)0x800ECA0C = 0x3bc00000;
break;
case 'J':
memcpy((void*)0x80279DA0, newURL1, sizeof(newURL1));
memcpy((void*)0x80279DA0 + 0x28, newURL2, sizeof(newURL2));
memcpy((void*)0x80279DA0 + 0x4C, newURL3J, sizeof(newURL3J));
*(u32*)0x802A0E0C = 0x733a2f2f;
*(u32*)0x800EC9CC = 0x3bc00000;
break;
case 'K':
memcpy((void*)0x802682B0, newURL1, sizeof(newURL1));
memcpy((void*)0x802682B0 + 0x28, newURL2, sizeof(newURL2));
memcpy((void*)0x802682B0 + 0x4C, newURL3K, sizeof(newURL3K));
*(u32*)0x8028F474 = 0x733a2f2f;
*(u32*)0x800ECB24 = 0x3bc00000;
break;
}
// Make some space on heap (0x500) for our custom code.
u32 old_heap_ptr = *(u32*)0x80003110;
*((u32*)0x80003110) = (old_heap_ptr - 0x500);
u32 heap_space = old_heap_ptr-0x500;
memset((void*)old_heap_ptr-0x500, 0xed, 0x500);
// Binary blobs with Wiimmfi patches. Do not modify.
// Provided by Leseratte on 2018-12-14.
int binary[] = { 0x37C849A2, 0x8BC32FA4, 0xC9A34B71, 0x1BCB49A2,
0x2F119304, 0x5F402684, 0x3E4FDA29, 0x50849A21,
0xB88B3452, 0x627FC9C1, 0xDC24D119, 0x5844350F,
0xD893444F, 0x19A588DC, 0x16C91184, 0x0C3E237C,
0x75906CED, 0x6E68A55E, 0x58791842, 0x072237E9,
0xAB24906F, 0x0A8BDF21, 0x4D11BE42, 0x1AAEDDC8,
0x1C42F908, 0x280CF2B2, 0x453A1BA4, 0x9A56C869,
0x786F108E, 0xE8DF05D2, 0x6DB641EB, 0x6DFC84BB,
0x7E980914, 0x0D7FB324, 0x23442185, 0xA7744966,
0x53901359, 0xBF2103CC, 0xC24A4EB7, 0x32049A02,
0xC1683466, 0xCA93689D, 0xD8245106, 0xA84987CF,
0xEC9B47C9, 0x6FA688FE, 0x0A4D11A6, 0x8B653C7B,
0x09D27E30, 0x5B936208, 0x5DD336DE, 0xCD092487,
0xEF2C6D36, 0x1E09DF2D, 0x75B1BE47, 0xE68A7F22,
0xB0E5F90D, 0xEC49F216, 0xAD1DCC24, 0xE2B5C841,
0x066F6F63, 0xF4D90926, 0x299F42CD, 0xA3F125D6,
0x077B093C, 0xB5721268, 0x1BE424D1, 0xEBC30BF0,
0x77867BED, 0x4F0C9BCA, 0x3E195930, 0xDC32DE2C,
0x1865D189, 0x70C67E7A, 0x71FA7329, 0x532233D3,
0x06D2E87B, 0x6CBEBA7F, 0x99F08532, 0x52FA601C,
0x05F4B82C, 0x4B64839C, 0xB5C65009, 0x1B8396E3,
0x0A8B2DAF, 0x0DB85BE6, 0x12F1B71D, 0x186F6E4D,
0x2870DC2E, 0x5960B8E6, 0x8F4D71BD, 0x0614E3C3,
0x05E8C725, 0x365D8E3D, 0x74351CDE, 0xE1AB3930,
0xFEDA721B, 0xE53AE4E9, 0xC3B4C9A6, 0xBAE59346,
0x6D45269D, 0x634E4D1A, 0x2FD99A30, 0x26393449,
0xE49768D1, 0x81E1D1A1, 0xFCE1A34A, 0x7EB44697,
0xEB2F8D2D, 0xCECFE5AF, 0x81BD34B6, 0xB1F1696E,
0x5E6ED2B2, 0xA473A4A0, 0x41664B70, 0xBF40968A,
0x662F2CCB, 0xC5DF5B8C, 0xB632B772, 0x74EB6F39,
0xE017DC71, 0xFDA3B890, 0xE3C9713D, 0xCE53E397,
0xA12BC743, 0x5AD98EA5, 0xBC721C9F, 0x4568395A,
0x925E72B4, 0x2D7DE4D7, 0x6777C9C7, 0xD6619396,
0xA502268A, 0x77884D75, 0xF79E9AF0, 0xE6FC3461,
0xF07468A5, 0xF866D11D, 0xF90CA342, 0xCF9546FF,
0x87A48D81, 0x06881A51, 0x309C34D1, 0x79B669CE,
0xFAADD2D7, 0xC8D7A5D1, 0x89214BE5, 0x1B8396EF,
0x0A8B2DE9, 0x0D985B06, 0x12F1B711, 0x186F6E57,
0x2850DC0E, 0x5960B8EA, 0x8F4D71AC, 0x0614E3E3,
0x05E8C729, 0x365D8E39, 0x74351CFE, 0x518E3943,
0x4A397268, 0x9D58E4B8, 0xD394C9A2, 0x0E069344,
0xB522268B, 0x636E4D77, 0x2FF99A37, 0xF6DC346D,
0xE49268B4, 0x2001D1A0, 0x4929A365, 0x7B764691,
0xFFC68D49, 0x16A81A53, 0x247A34D2, 0xA1D16967,
0x4B6DD2D5, 0xDDF4A5B7, 0x454A4B70, 0x0FAE96E2,
0x0A8A2DC7, 0x0D98A47A, 0x06DCB71D, 0x0CCC6E38,
0x55F25CFB, 0xB08C1E88, 0xDF4259C9, 0x0714E387,
0xB00D47AF, 0x7B722975, 0x48BE349A, 0x29CC393C,
0xEA797228, 0x98986471, 0x3778E1A3, 0xD7626D06,
0x1567268D, 0x668ECD00, 0xD614F5C8, 0x133037CF,
0x92F26CF2, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000};
// Fix for error 51420:
int patchCodeFix51420[] = {
0x4800000d, 0x00000000,
0x00000000, 0x7cc803a6,
0x80860000, 0x7c041800,
0x4182004c, 0x80a60004,
0x38a50001, 0x2c050003,
0x4182003c, 0x90a60004,
0x90660000, 0x38610010,
0x3ca08066, 0x38a58418,
0x3c808066, 0x38848498,
0x90a10010, 0x90810014,
0x3ce08066, 0x38e78ce4,
0x38e7fef0, 0x7ce903a6,
0x4e800420, 0x3c80801d,
0x388415f4, 0x7c8803a6,
0x4e800021, 0x00000000
};
// Prepare patching process ....
int i = 3;
int idx = 0;
for (; i < 202; i++) {
if (i == 67 || i == 82) idx++;
binary[i] = binary[i] ^ binary[idx];
binary[idx] = ((binary[idx] << 1) | ((binary[idx] >> (32 - 1)) & ~(-1 << 1)));
}
// Binary blob needs some changes for regions other than PAL ...
switch (region) {
case 'E':
binary[29] = binary[67];
binary[37] = binary[68];
binary[43] = binary[69];
binary[185] = 0x61295C74;
binary[189] = 0x61295D40;
binary[198] = 0x61086F5C;
patchCodeFix51420[14] = 0x3ca08065;
patchCodeFix51420[15] = 0x38a53f90;
patchCodeFix51420[16] = 0x3c808065;
patchCodeFix51420[17] = 0x38844010;
patchCodeFix51420[20] = 0x3ce08065;
patchCodeFix51420[21] = 0x38e7485c;
patchCodeFix51420[26] = 0x38841554;
break;
case 'J':
binary[29] = binary[70];
binary[37] = binary[71];
binary[43] = binary[72];
binary[185] = 0x612997CC;
binary[189] = 0x61299898;
binary[198] = 0x61086F1C;
patchCodeFix51420[14] = 0x3ca08065;
patchCodeFix51420[15] = 0x38a57a84;
patchCodeFix51420[16] = 0x3c808065;
patchCodeFix51420[17] = 0x38847b04;
patchCodeFix51420[20] = 0x3ce08065;
patchCodeFix51420[21] = 0x38e78350;
patchCodeFix51420[26] = 0x38841514;
break;
case 'K':
binary[6] = binary[73];
binary[9] = binary[74];
binary[11] = binary[75];
binary[23] = binary[76];
binary[29] = binary[77];
binary[33] = binary[78];
binary[37] = binary[79];
binary[43] = binary[80];
binary[63] = binary[81];
binary[184] = 0x3D208088;
binary[185] = 0x61298AA4;
binary[188] = 0x3D208088;
binary[189] = 0x61298B58;
binary[198] = 0x61087358;
patchCodeFix51420[14] = 0x3ca08064;
patchCodeFix51420[15] = 0x38a56730;
patchCodeFix51420[16] = 0x3c808064;
patchCodeFix51420[17] = 0x388467b0;
patchCodeFix51420[20] = 0x3ce08064;
patchCodeFix51420[21] = 0x38e76ffc;
patchCodeFix51420[26] = 0x38841950;
break;
}
// Installing all the patches.
memcpy((void*)heap_space, (void*)binary, 820);
u32 code_offset_1 = heap_space + 12;
u32 code_offset_2 = heap_space + 88;
u32 code_offset_3 = heap_space + 92;
u32 code_offset_4 = heap_space + 264;
u32 code_offset_5 = heap_space + 328;
*((u32*)patch1_offset) = 0x48000000 + (((u32)(code_offset_1) - ((u32)(patch1_offset))) & 0x3ffffff);
*((u32*)code_offset_2) = 0x48000000 + (((u32)(patch1_offset + 4) - ((u32)(code_offset_2))) & 0x3ffffff);
*((u32*)patch2_offset) = 0x48000000 + (((u32)(code_offset_3) - ((u32)(patch2_offset))) & 0x3ffffff);
*((u32*)code_offset_4) = 0x48000000 + (((u32)(patch2_offset + 4) - ((u32)(code_offset_4))) & 0x3ffffff);
*((u32*)patch3_offset) = 0x48000000 + (((u32)(code_offset_5) - ((u32)(patch3_offset))) & 0x3ffffff);
// Add the 51420 fix:
memcpy((void*)heap_space + 0x400, (void*)patchCodeFix51420, 0x78);
*((u32*)errorfix_offset) = 0x48000000 + (((u32)(heap_space + 0x400) - ((u32)(errorfix_offset))) & 0x3ffffff);
*((u32*)heap_space + 0x400 + 0x74) = 0x48000000 + (((u32)(errorfix_offset + 4) - ((u32)(heap_space + 0x400 + 0x74))) & 0x3ffffff);
// Patches successfully installed
// returns 0 when all patching is done and game is ready to be booted.
return 0;
}

View File

@ -29,11 +29,19 @@ extern u8 configbytes[2];
extern u32 regionfree; extern u32 regionfree;
extern bool hookpatched; extern bool hookpatched;
#define APP_NAME "Cfg USB Loader MOD patched"
#define APP_VERSION "70r78.12"
#define PRIVSERV_WIIMMFI "wiimmfi.de"
// Function prototypes // Function prototypes
bool dogamehooks(void *addr, u32 len); bool dogamehooks(void *addr, u32 len);
void langpatcher(void *addr, u32 len); void langpatcher(void *addr, u32 len);
void vidolpatcher(void *addr, u32 len); void vidolpatcher(void *addr, u32 len);
void patchdebug(void *addr, u32 len); void patchdebug(void *addr, u32 len);
bool PatchReturnTo(void *Address, int Size, u32 id); bool PatchReturnTo(void *Address, int Size, u32 id);
void WFCPatch(void *addr, u32 len, const char* domain);
u32 do_new_wiimmfi();
u32 do_new_wiimmfi_nonMKWii();
#endif // __PATCHCODE_H__ #endif // __PATCHCODE_H__

View File

@ -14,10 +14,18 @@ metaxml=</long_description>
metaxml=<ahb_access/> metaxml=<ahb_access/>
metaxml=</app> metaxml=</app>
release = 70r78.12
size = 1908544
date = 2024-09-03
url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r12/cfg70r78.12-222.dol
-Internals - changed online update URL paths
-GC - updated nintendont config support to version 0x0000000A
-Usability - Wiimmfi WFC patching fixed
release = 70r78.11 release = 70r78.11
size = 1904192 size = 1904192
date = 2017-01-15 date = 2017-01-15
url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binaries/dol/r11/cfg70r78.11-222.dol url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r11/cfg70r78.11-222.dol
-GC - updated nintendont config support to version 0x00000006 -GC - updated nintendont config support to version 0x00000006
-GC - if nintendont_config_mode=arg is set nintendont configuration is passed via command line argument -GC - if nintendont_config_mode=arg is set nintendont configuration is passed via command line argument
-GC - added minimum nitnendont version check before game load -GC - added minimum nitnendont version check before game load
@ -30,13 +38,13 @@ url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binari
release = 70r78.10 release = 70r78.10
size = 1902240 size = 1902240
date = 2015-05-23 date = 2015-05-23
url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binaries/dol/r10/cfg70r78.10-222.dol url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r10/cfg70r78.10-222.dol
-GC - fixed wide screen support in vWii for nintendont (CFG.vwii_mode was set too early) -GC - fixed wide screen support in vWii for nintendont (CFG.vwii_mode was set too early)
release = 70r78.9 release = 70r78.9
size = 1902240 size = 1902240
date = 2015-05-13 date = 2015-05-13
url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binaries/dol/r9/cfg70r78.9-222.dol url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r9/cfg70r78.9-222.dol
-Usability - added filter persistance per profile on config save -Usability - added filter persistance per profile on config save
-Usability - added "FWD Emulators" GameType for most common emulator forwarder channels (to use with emunand) -Usability - added "FWD Emulators" GameType for most common emulator forwarder channels (to use with emunand)
-Usability - re-enabled online update from http://cfgusbloader.ntd.homelinux.org releases -Usability - re-enabled online update from http://cfgusbloader.ntd.homelinux.org releases
@ -45,7 +53,7 @@ url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binari
release = 70r78.8 release = 70r78.8
size = 1897504 size = 1897504
date = 2015-03-14 date = 2015-03-14
url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binaries/dol/r8/cfg70r78.8-222.dol url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r8/cfg70r78.8-222.dol
-Compilation - code cleanup to remove all compilation warnings -Compilation - code cleanup to remove all compilation warnings
-GC - updated nintendont config support to version 0x00000003 -GC - updated nintendont config support to version 0x00000003
-Internals - added Wii / vWii identification capability -Internals - added Wii / vWii identification capability
@ -58,14 +66,14 @@ url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binari
release = 70r78.7 release = 70r78.7
size = 1894720 size = 1894720
date = 2015-01-17 date = 2015-01-17
url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binaries/dol/r7/cfg70r78-222_stub.dol url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r7/cfg70r78-222_stub.dol
-Usability - added stub binary for return to loader and functions to manage the return TID via "return_to_channel" configuration key -Usability - added stub binary for return to loader and functions to manage the return TID via "return_to_channel" configuration key
-Compilation - added all prebuild libraries for old PPC versions -Compilation - added all prebuild libraries for old PPC versions
release = 70r78.6 release = 70r78.6
size = 1890368 size = 1890368
date = 2015-01-17 date = 2015-01-17
url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binaries/dol/r6/cfg70r78-222_ppc27.dol url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r6/cfg70r78-222_ppc27.dol
-Build - ported to Devkit PPC v27 -Build - ported to Devkit PPC v27
Unreleased = 70r78.5 Unreleased = 70r78.5
@ -75,11 +83,11 @@ date = 2015-01-17
release = 70r78.4 release = 70r78.4
size = 1931072 size = 1931072
date = 2015-01-17 date = 2015-01-17
url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binaries/dol/r4/cfg70r78-222_ios252.dol url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r4/cfg70r78-222_ios252.dol
-Games - added ios 252 support (to allow a dx2 installation schema like the one in the wiiflow pack) -Games - added ios 252 support (to allow a dx2 installation schema like the one in the wiiflow pack)
release = 70r78.3 release = 70r78.3
size = 1931008 size = 1931008
date = 2015-01-17 date = 2015-01-17
url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binaries/dol/r3/cfg70r78-222_cheatfix.dol url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r3/cfg70r78-222_cheatfix.dol
-Cheat - porting of my download patch that disables referer only for geckocodes.org -Cheat - porting of my download patch that disables referer only for geckocodes.org

View File

@ -14,10 +14,18 @@ metaxml=</long_description>
metaxml=<ahb_access/> metaxml=<ahb_access/>
metaxml=</app> metaxml=</app>
release = 70r78.12
size = 1908512
date = 2024-09-03
url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r12/cfg70r78.12.dol
-Internals - changed online update URL paths
-GC - updated nintendont config support to version 0x0000000A
-Usability - Wiimmfi WFC patching fixed
release = 70r78.11 release = 70r78.11
size = 1904192 size = 1904192
date = 2017-01-15 date = 2017-01-15
url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binaries/dol/r11/cfg70r78.11.dol url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r11/cfg70r78.11.dol
-GC - updated nintendont config support to version 0x00000006 -GC - updated nintendont config support to version 0x00000006
-GC - if nintendont_config_mode=arg is set nintendont configuration is passed via command line argument -GC - if nintendont_config_mode=arg is set nintendont configuration is passed via command line argument
-GC - added minimum nitnendont version check before game load -GC - added minimum nitnendont version check before game load
@ -30,13 +38,13 @@ url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binari
release = 70r78.10 release = 70r78.10
size = 1902208 size = 1902208
date = 2015-05-23 date = 2015-05-23
url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binaries/dol/r10/cfg70r78.10.dol url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r10/cfg70r78.10.dol
-GC - fixed wide screen support in vWii for nintendont (CFG.vwii_mode was set too early) -GC - fixed wide screen support in vWii for nintendont (CFG.vwii_mode was set too early)
release = 70r78.9 release = 70r78.9
size = 1902208 size = 1902208
date = 2015-05-13 date = 2015-05-13
url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binaries/dol/r9/cfg70r78.9.dol url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r9/cfg70r78.9.dol
-Usability - added filter persistance per profile on config save -Usability - added filter persistance per profile on config save
-Usability - added "FWD Emulators" GameType for most common emulator forwarder channels (to use with emunand) -Usability - added "FWD Emulators" GameType for most common emulator forwarder channels (to use with emunand)
-Usability - re-enabled online update from http://cfgusbloader.ntd.homelinux.org releases -Usability - re-enabled online update from http://cfgusbloader.ntd.homelinux.org releases
@ -45,7 +53,7 @@ url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binari
release = 70r78.8 release = 70r78.8
size = 1897472 size = 1897472
date = 2015-03-14 date = 2015-03-14
url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binaries/dol/r8/cfg70r78.8.dol url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r8/cfg70r78.8.dol
-Compilation - code cleanup to remove all compilation warnings -Compilation - code cleanup to remove all compilation warnings
-GC - updated nintendont config support to version 0x00000003 -GC - updated nintendont config support to version 0x00000003
-Internals - added Wii / vWii identification capability -Internals - added Wii / vWii identification capability
@ -58,14 +66,14 @@ url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binari
release = 70r78.7 release = 70r78.7
size = 1894720 size = 1894720
date = 2015-01-17 date = 2015-01-17
url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binaries/dol/r7/cfg70r78_stub.dol url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r7/cfg70r78_stub.dol
-Usability - added stub binary for return to loader and functions to manage the return TID via "return_to_channel" configuration key -Usability - added stub binary for return to loader and functions to manage the return TID via "return_to_channel" configuration key
-Compilation - added all prebuild libraries for old PPC versions -Compilation - added all prebuild libraries for old PPC versions
release = 70r78.6 release = 70r78.6
size = 1890368 size = 1890368
date = 2015-01-17 date = 2015-01-17
url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binaries/dol/r6/cfg70r78_ppc27.dol url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r6/cfg70r78_ppc27.dol
-Build - ported to Devkit PPC v27 -Build - ported to Devkit PPC v27
Unreleased = 70r78.5 Unreleased = 70r78.5
@ -75,11 +83,11 @@ date = 2015-01-17
release = 70r78.4 release = 70r78.4
size = 1931040 size = 1931040
date = 2015-01-17 date = 2015-01-17
url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binaries/dol/r4/cfg70r78_ios252.dol url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r4/cfg70r78_ios252.dol
-Games - added ios 252 support (to allow a dx2 installation schema like the one in the wiiflow pack) -Games - added ios 252 support (to allow a dx2 installation schema like the one in the wiiflow pack)
release = 70r78.3 release = 70r78.3
size = 1930976 size = 1930976
date = 2015-01-17 date = 2015-01-17
url = http://cfgusbloader.ntd.homelinux.org/trac/CfgUSBLoader/chrome/site/binaries/dol/r3/cfg70r78_cheatfix.dol url = http://cfgusbloader.ntd.homelinux.org/binaries/dol/r3/cfg70r78_cheatfix.dol
-Cheat - porting of my download patch that disables referer only for geckocodes.org -Cheat - porting of my download patch that disables referer only for geckocodes.org