2022-08-31 09:45:59 +10:00
|
|
|
/* Copyright 2022 Pretendo Network contributors <pretendo.network>
|
|
|
|
|
Copyright 2022 Ash Logan <ash@heyquark.com>
|
2019-04-07 22:13:09 +10:00
|
|
|
Copyright 2019 Maschell
|
|
|
|
|
|
2022-08-31 09:45:59 +10:00
|
|
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
|
|
|
|
|
granted, provided that the above copyright notice and this permission notice appear in all copies.
|
2019-04-07 22:13:09 +10:00
|
|
|
|
2022-08-31 09:45:59 +10:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
|
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
|
|
|
|
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
PERFORMANCE OF THIS SOFTWARE.
|
2019-04-07 22:13:09 +10:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdint.h>
|
2021-09-12 20:59:09 +10:00
|
|
|
#include <stdlib.h>
|
2019-04-07 22:13:09 +10:00
|
|
|
#include <wups.h>
|
|
|
|
|
#include <nsysnet/nssl.h>
|
2021-09-12 20:59:09 +10:00
|
|
|
#include <coreinit/cache.h>
|
2019-04-07 22:13:09 +10:00
|
|
|
#include <coreinit/dynload.h>
|
2022-08-31 22:07:57 +10:00
|
|
|
#include <coreinit/mcp.h>
|
2021-09-12 20:59:09 +10:00
|
|
|
#include <coreinit/memory.h>
|
|
|
|
|
#include <coreinit/memorymap.h>
|
|
|
|
|
#include <coreinit/memexpheap.h>
|
2022-09-09 21:19:23 -04:00
|
|
|
#include <coreinit/launch.h>
|
|
|
|
|
#include <sysapp/launch.h>
|
2022-08-31 22:07:57 +10:00
|
|
|
#include "wut_extra.h"
|
2019-04-07 22:13:09 +10:00
|
|
|
#include <utils/logger.h>
|
2022-09-26 21:56:56 +10:00
|
|
|
#include "patcher/ingame.h"
|
2019-04-07 22:13:09 +10:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Mandatory plugin information.
|
|
|
|
|
If not set correctly, the loader will refuse to use the plugin.
|
|
|
|
|
**/
|
2022-10-24 21:57:58 +11:00
|
|
|
WUPS_PLUGIN_NAME("Meowth");
|
|
|
|
|
WUPS_PLUGIN_DESCRIPTION("SSL Patcher");
|
|
|
|
|
WUPS_PLUGIN_VERSION("v0.1");
|
|
|
|
|
WUPS_PLUGIN_AUTHOR("quarky + Pretendo contributors");
|
2019-04-07 22:13:09 +10:00
|
|
|
WUPS_PLUGIN_LICENSE("ISC");
|
|
|
|
|
|
2021-09-12 20:59:09 +10:00
|
|
|
#include <kernel/kernel.h>
|
2022-08-31 22:07:57 +10:00
|
|
|
#include <mocha/mocha.h>
|
2021-09-12 20:59:09 +10:00
|
|
|
|
2022-08-31 22:07:57 +10:00
|
|
|
static bool is555(MCP_SystemVersion version) {
|
|
|
|
|
return (version.major == 5) && (version.minor == 5) && (version.patch >= 5);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-12 20:59:09 +10:00
|
|
|
INITIALIZE_PLUGIN() {
|
|
|
|
|
WHBLogUdpInit();
|
2022-09-09 21:19:23 -04:00
|
|
|
|
2022-08-31 22:07:57 +10:00
|
|
|
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
|
|
|
|
|
);
|
|
|
|
|
|
2022-10-24 21:57:58 +11:00
|
|
|
// IOS-NSEC SSL patch
|
|
|
|
|
if (is555(os_version)) {
|
|
|
|
|
Mocha_IOSUKernelWrite32(0xE1019F78, 0xE3A00001); // mov r0, #1
|
|
|
|
|
} else {
|
|
|
|
|
Mocha_IOSUKernelWrite32(0xE1019E84, 0xE3A00001); // mov r0, #1
|
2022-09-09 21:19:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MCP_Close(mcp);
|
2021-09-12 20:59:09 +10:00
|
|
|
}
|
|
|
|
|
DEINITIALIZE_PLUGIN() {
|
|
|
|
|
WHBLogUdpDeinit();
|
2022-09-09 21:19:23 -04:00
|
|
|
Mocha_DeInitLibrary();
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-12 20:59:09 +10:00
|
|
|
ON_APPLICATION_START() {
|
|
|
|
|
WHBLogUdpInit();
|
2022-10-24 21:57:58 +11:00
|
|
|
RunPatcher();
|
2019-04-07 22:13:09 +10:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 21:57:58 +11:00
|
|
|
ON_APPLICATION_ENDS() {}
|