diff --git a/Dockerfile b/Dockerfile index 7416a67..38e71d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM wiiuenv/devkitppc:20220806 COPY --from=wiiuenv/libkernel:20220724 /artifacts $DEVKITPRO +COPY --from=wiiuenv/libmocha:20220831 /artifacts $DEVKITPRO COPY --from=wiiuenv/wiiupluginsystem:20220826 /artifacts $DEVKITPRO WORKDIR /app diff --git a/Inkay-pretendo.wps b/Inkay-pretendo.wps index 06c9ba8..c34ba78 100644 Binary files a/Inkay-pretendo.wps and b/Inkay-pretendo.wps differ diff --git a/Makefile b/Makefile index a22249a..6da1339 100644 --- a/Makefile +++ b/Makefile @@ -40,13 +40,13 @@ LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) LDFLAGS += -T$(WUMS_ROOT)/share/libkernel.ld $(WUPSSPECS) -LIBS := -lwups -lkernel -lwut +LIBS := -lwups -lmocha -lkernel -lwut #------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level # containing include and lib #------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) $(WUMS_ROOT) $(WUPS_ROOT) $(WUT_ROOT) +LIBDIRS := $(PORTLIBS) $(WUMS_ROOT) $(WUPS_ROOT) $(WUT_ROOT) $(WUT_ROOT)/usr #------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional diff --git a/src/main.cpp b/src/main.cpp index 0f357ab..62e779a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,10 +19,13 @@ #include #include #include +#include #include #include #include +#include "wut_extra.h" #include +#include "url_patches.h" /** Mandatory plugin information. @@ -35,6 +38,7 @@ WUPS_PLUGIN_AUTHOR("Pretendo contributors"); WUPS_PLUGIN_LICENSE("ISC"); #include +#include //#ifdef OLD_WUPS extern "C" { @@ -52,14 +56,72 @@ _Static_assert(sizeof(original_url) > sizeof(new_url), // We'll keep a handle to nn_olv, just to ensure it doesn't get unloaded static OSDynLoad_Module olv_handle; -#ifndef OLD_WUPS +//thanks @Gary#4139 :p +static void write_string(uint32_t addr, const char* str) +{ + int len = strlen(str) + 1; + int remaining = len % 4; + int num = len - remaining; + + for (int i = 0; i < (num / 4); i++) { + Mocha_IOSUKernelWrite32(addr + i * 4, *(uint32_t*)(str + i * 4)); + } + + if (remaining > 0) { + uint8_t buf[4]; + Mocha_IOSUKernelRead32(addr + num, (uint32_t*)&buf); + + for (int i = 0; i < remaining; i++) { + buf[i] = *(str + num + i); + } + + Mocha_IOSUKernelWrite32(addr + num, *(uint32_t*)&buf); + } +} + +static bool is555(MCP_SystemVersion version) { + return (version.major == 5) && (version.minor == 5) && (version.patch >= 5); +} + INITIALIZE_PLUGIN() { WHBLogUdpInit(); + auto res = Mocha_InitLibrary(); + + if (res != MOCHA_RESULT_SUCCESS) { + DEBUG_FUNCTION_LINE("Mocha init failed with code %d!", res); + return; + } + + //get os version + MCP_SystemVersion os_version; + int mcp = MCP_Open(); + int ret = MCP_GetSystemVersion(mcp, &os_version); + if (ret < 0) { + DEBUG_FUNCTION_LINE("getting system version failed (%d/%d)!", mcp, ret); + os_version = (MCP_SystemVersion) { + .major = 5, .minor = 5, .patch = 5, .region = 'E' + }; + } + DEBUG_FUNCTION_LINE("Running on %d.%d.%d%c", + os_version.major, os_version.minor, os_version.patch, os_version.region + ); + + if (is555(os_version)) { + Mocha_IOSUKernelWrite32(0xE1019F78, 0xE3A00001); // mov r0, #1 + } else { + Mocha_IOSUKernelWrite32(0xE1019E84, 0xE3A00001); // mov r0, #1 + } + + for (const auto& patch : url_patches) { + write_string(patch.address, patch.url); + } + + DEBUG_FUNCTION_LINE("Pretendo URL and NoSSL patches applied successfully.") } DEINITIALIZE_PLUGIN() { WHBLogUdpDeinit(); + Mocha_DeinitLibrary(); } -#endif bool checkForOlvLibs() { OSDynLoad_Module olv_handle = 0; @@ -121,21 +183,3 @@ ON_APPLICATION_ENDS() { DEBUG_FUNCTION_LINE("Inkay: shutting down...\n"); OSDynLoad_Release(olv_handle); } - -DECL_FUNCTION(NSSLContextHandle, NSSLCreateContext, int32_t unk) { - NSSLContextHandle context = real_NSSLCreateContext(unk); - - //Add all commercial certs - for (int cert = NSSL_SERVER_CERT_GROUP_COMMERCIAL_FIRST; - cert <= NSSL_SERVER_CERT_GROUP_COMMERCIAL_LAST; cert++) { - NSSLAddServerPKI(context, (NSSLServerCertId)cert); - } - for (int cert = NSSL_SERVER_CERT_GROUP_COMMERCIAL_4096_FIRST; - cert <= NSSL_SERVER_CERT_GROUP_COMMERCIAL_4096_LAST; cert++) { - NSSLAddServerPKI(context, (NSSLServerCertId)cert); - } - - return context; -} - -WUPS_MUST_REPLACE(NSSLCreateContext, WUPS_LOADER_LIBRARY_NSYSNET, NSSLCreateContext); diff --git a/src/url_patches.h b/src/url_patches.h new file mode 100644 index 0000000..8065f98 --- /dev/null +++ b/src/url_patches.h @@ -0,0 +1,44 @@ +#ifndef _PATCHER_H +#define _PATCHER_H + +typedef struct URL_Patch +{ + unsigned int address; + char url[80]; +} URL_Patch; + +static const URL_Patch url_patches[] = { + //nim-boss .rodata + {0xE2282550, "http://pushmore.wup.shop.pretendo.cc/pushmore/r/%s"}, + {0xE229A0A0, "http://npns-dev.c.app.pretendo.cc/bst.dat"}, + {0xE229A0D0, "http://npns-dev.c.app.pretendo.cc/bst2.dat"}, + {0xE2281964, "https://tagaya.wup.shop.pretendo.cc/tagaya/versionlist/%s/%s/%s"}, + {0xE22819B4, "https://tagaya.wup.shop.pretendo.cc/tagaya/versionlist/%s/%s/latest_version"}, + {0xE2282584, "http://pushmo.wup.shop.pretendo.cc/pushmo/d/%s/%u"}, + {0xE22825B8, "http://pushmo.wup.shop.pretendo.cc/pushmo/c/%u/%u"}, + {0xE2282DB4, "https://ecs.wup.shop.pretendo.cc/ecs/services/ECommerceSOAP"}, + {0xE22830A0, "https://ecs.wup.shop.pretendo.cc/ecs/services/ECommerceSOAP"}, + {0xE22830E0, "https://nus.wup.shop.pretendo.cc/nus/services/NetUpdateSOAP"}, + {0xE2299990, "nppl.app.pretendo.cc"}, + {0xE229A600, "https://pls.wup.shop.pretendo.cc/pls/upload"}, + {0xE229A6AC, "https://npvk-dev.app.pretendo.cc/reports"}, + {0xE229A6D8, "https://npvk.app.pretendo.cc/reports"}, + {0xE229B1F4, "https://npts.app.pretendo.cc/p01/tasksheet/%s/%s/%s/%s?c=%s&l=%s"}, + {0xE229B238, "https://npts.app.pretendo.cc/p01/tasksheet/%s/%s/%s?c=%s&l=%s"}, + {0xE22AB2D8, "https://idbe-wup.cdn.pretendo.cc/icondata/%02X/%016llX.idbe"}, + {0xE22AB318, "https://idbe-ctr.cdn.pretendo.cc/icondata/%02X/%016llX.idbe"}, + {0xE22AB358, "https://idbe-wup.cdn.pretendo.cc/icondata/%02X/%016llX-%d.idbe"}, + {0xE22AB398, "https://idbe-ctr.cdn.pretendo.cc/icondata/%02X/%016llX-%d.idbe"}, + {0xE22B3EF8, "https://ecs.c.shop.pretendo.cc"}, + {0xE22B3F30, "https://ecs.c.shop.pretendo.cc/ecs/services/ECommerceSOAP"}, + {0xE22B3F70, "https://ias.c.shop.pretendo.cc/ias/services/IdentityAuthenticationSOAP"}, + {0xE22B3FBC, "https://cas.c.shop.pretendo.cc/cas/services/CatalogingSOAP"}, + {0xE22B3FFC, "https://nus.c.shop.pretendo.cc/nus/services/NetUpdateSOAP"}, + {0xE229DE0C, "n.app.pretendo.cc"}, + //nim-boss .bss + {0xE24B8A24, "https://nppl.app.pretendo.cc/p01/policylist/1/1/UNK"}, //bit of a hack + {0xE31930D4, "https://%s%saccount.pretendo.cc/v%u/api/"} + +}; + +#endif diff --git a/src/wut_extra.h b/src/wut_extra.h new file mode 100644 index 0000000..1cffa35 --- /dev/null +++ b/src/wut_extra.h @@ -0,0 +1,21 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +//remove all this if wut adds it and it causes errors +typedef struct { + uint32_t major; + uint32_t minor; + uint32_t patch; + char region; +} MCP_SystemVersion; +static_assert(sizeof(MCP_SystemVersion) == 0x10); +int MCP_GetSystemVersion(int handle, MCP_SystemVersion* version); + +#ifdef __cplusplus +} +#endif