Add IOSU-side SSL and URL patches
This commit is contained in:
parent
d23f774f7b
commit
24a17536fc
6 changed files with 132 additions and 22 deletions
84
src/main.cpp
84
src/main.cpp
|
|
@ -19,10 +19,13 @@
|
|||
#include <nsysnet/nssl.h>
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/dynload.h>
|
||||
#include <coreinit/mcp.h>
|
||||
#include <coreinit/memory.h>
|
||||
#include <coreinit/memorymap.h>
|
||||
#include <coreinit/memexpheap.h>
|
||||
#include "wut_extra.h"
|
||||
#include <utils/logger.h>
|
||||
#include "url_patches.h"
|
||||
|
||||
/**
|
||||
Mandatory plugin information.
|
||||
|
|
@ -35,6 +38,7 @@ WUPS_PLUGIN_AUTHOR("Pretendo contributors");
|
|||
WUPS_PLUGIN_LICENSE("ISC");
|
||||
|
||||
#include <kernel/kernel.h>
|
||||
#include <mocha/mocha.h>
|
||||
|
||||
//#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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue