2022-04-27 19:10:44 +02:00
|
|
|
#include "FileInfos.h"
|
2022-03-04 01:07:01 +01:00
|
|
|
#include "SaveRedirection.h"
|
2022-02-04 15:19:43 +01:00
|
|
|
#include "filelist.h"
|
|
|
|
#include "fs/FSUtils.h"
|
2022-04-27 19:10:44 +02:00
|
|
|
#include "fs/FileReader.h"
|
|
|
|
#include "fs/FileReaderWUHB.h"
|
2022-02-04 15:19:43 +01:00
|
|
|
#include "utils/StringTools.h"
|
|
|
|
#include "utils/ini.h"
|
2022-04-17 21:56:14 +02:00
|
|
|
#include <content_redirection/redirection.h>
|
2019-09-08 21:06:53 +02:00
|
|
|
#include <coreinit/cache.h>
|
2022-02-04 15:19:43 +01:00
|
|
|
#include <coreinit/debug.h>
|
2019-09-06 17:02:09 +02:00
|
|
|
#include <coreinit/filesystem.h>
|
2022-02-04 15:19:43 +01:00
|
|
|
#include <coreinit/mcp.h>
|
2022-02-14 19:25:54 +01:00
|
|
|
#include <coreinit/mutex.h>
|
2022-02-04 15:19:43 +01:00
|
|
|
#include <coreinit/systeminfo.h>
|
|
|
|
#include <coreinit/title.h>
|
|
|
|
#include <cstring>
|
2022-04-27 19:10:44 +02:00
|
|
|
#include <forward_list>
|
2019-09-06 17:02:09 +02:00
|
|
|
#include <fs/DirList.h>
|
2022-02-14 19:30:59 +01:00
|
|
|
#include <malloc.h>
|
2022-04-17 21:56:14 +02:00
|
|
|
#include <mutex>
|
2022-02-04 15:19:43 +01:00
|
|
|
#include <nn/acp.h>
|
2022-04-27 19:10:44 +02:00
|
|
|
#include <optional>
|
2022-04-17 21:56:14 +02:00
|
|
|
#include <rpxloader/rpxloader.h>
|
2022-03-04 01:07:01 +01:00
|
|
|
#include <sdutils/sdutils.h>
|
2022-04-17 21:56:14 +02:00
|
|
|
#include <sysapp/launch.h>
|
2022-02-04 15:19:43 +01:00
|
|
|
#include <sysapp/title.h>
|
|
|
|
#include <utils/logger.h>
|
2022-04-17 21:56:14 +02:00
|
|
|
#include <wuhb_utils/utils.h>
|
2022-02-04 15:19:43 +01:00
|
|
|
#include <wups.h>
|
2019-12-07 22:15:43 +01:00
|
|
|
|
2021-01-01 01:50:00 +01:00
|
|
|
typedef struct ACPMetaData {
|
2020-06-17 22:15:45 +02:00
|
|
|
char bootmovie[80696];
|
|
|
|
char bootlogo[28604];
|
2021-01-01 01:50:00 +01:00
|
|
|
} ACPMetaData;
|
2020-06-17 22:15:45 +02:00
|
|
|
|
2020-06-17 22:20:59 +02:00
|
|
|
WUPS_PLUGIN_NAME("Homebrew in Wii U menu");
|
|
|
|
WUPS_PLUGIN_DESCRIPTION("Allows the user to load homebrew from the Wii U menu");
|
2019-11-24 14:14:45 +01:00
|
|
|
WUPS_PLUGIN_VERSION("0.1");
|
2019-09-06 17:02:09 +02:00
|
|
|
WUPS_PLUGIN_AUTHOR("Maschell");
|
|
|
|
WUPS_PLUGIN_LICENSE("GPL");
|
|
|
|
|
2020-06-17 14:28:15 +02:00
|
|
|
#define UPPER_TITLE_ID_HOMEBREW 0x0005000F
|
2022-02-04 15:19:43 +01:00
|
|
|
#define TITLE_ID_HOMEBREW_MASK (((uint64_t) UPPER_TITLE_ID_HOMEBREW) << 32)
|
2020-06-17 14:28:15 +02:00
|
|
|
|
2019-09-08 21:06:53 +02:00
|
|
|
ACPMetaXml gLaunchXML __attribute__((section(".data")));
|
2021-01-09 18:46:50 +01:00
|
|
|
MCPTitleListType current_launched_title_info __attribute__((section(".data")));
|
2019-09-08 21:06:53 +02:00
|
|
|
BOOL gHomebrewLaunched __attribute__((section(".data")));
|
|
|
|
|
2022-04-27 19:10:44 +02:00
|
|
|
std::mutex fileInfosMutex;
|
|
|
|
std::forward_list<std::shared_ptr<FileInfos>> fileInfos;
|
|
|
|
|
|
|
|
std::mutex fileReaderListMutex;
|
|
|
|
std::forward_list<std::unique_ptr<FileReader>> openFileReaders;
|
|
|
|
|
2021-01-09 18:46:50 +01:00
|
|
|
void readCustomTitlesFromSD();
|
|
|
|
|
2021-09-24 20:50:35 +02:00
|
|
|
WUPS_USE_WUT_DEVOPTAB();
|
2019-11-24 14:14:45 +01:00
|
|
|
|
2019-09-08 21:06:53 +02:00
|
|
|
INITIALIZE_PLUGIN() {
|
2021-01-09 18:46:50 +01:00
|
|
|
memset((void *) ¤t_launched_title_info, 0, sizeof(current_launched_title_info));
|
2020-06-17 13:45:15 +02:00
|
|
|
memset((void *) &gLaunchXML, 0, sizeof(gLaunchXML));
|
2019-09-08 21:06:53 +02:00
|
|
|
gHomebrewLaunched = FALSE;
|
2022-04-17 21:56:14 +02:00
|
|
|
|
|
|
|
// Use libwuhbutils.
|
|
|
|
WUHBUtilsStatus error;
|
|
|
|
if ((error = WUHBUtils_Init()) != WUHB_UTILS_RESULT_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Homebrew on Menu Plugin: Failed to init WUHBUtils. Error %d", error);
|
|
|
|
OSFatal("Homebrew on Menu Plugin: Failed to init WUHBUtils.");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use libcontentredirection.
|
|
|
|
ContentRedirectionStatus error2;
|
|
|
|
if ((error2 = ContentRedirection_Init()) != CONTENT_REDIRECTION_RESULT_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Homebrew on Menu Plugin: Failed to init ContentRedirection. Error %d", error2);
|
|
|
|
OSFatal("Homebrew on Menu Plugin: Failed to init ContentRedirection.");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use librpxloader.
|
|
|
|
RPXLoaderStatus error3;
|
2022-08-27 14:07:43 +02:00
|
|
|
if ((error3 = RPXLoader_InitLibrary()) != RPX_LOADER_RESULT_SUCCESS) {
|
2022-04-17 21:56:14 +02:00
|
|
|
DEBUG_FUNCTION_LINE_ERR("Homebrew on Menu Plugin: Failed to init RPXLoader. Error %d", error3);
|
|
|
|
OSFatal("Homebrew on Menu Plugin: Failed to init RPXLoader.");
|
|
|
|
}
|
2019-09-08 21:06:53 +02:00
|
|
|
}
|
2019-09-06 17:02:09 +02:00
|
|
|
|
2022-03-04 01:07:01 +01:00
|
|
|
bool sSDUtilsInitDone = false;
|
|
|
|
bool sSDIsMounted = false;
|
|
|
|
bool sTitleRebooting = false;
|
|
|
|
|
2022-04-27 19:10:44 +02:00
|
|
|
void Cleanup() {
|
|
|
|
{
|
|
|
|
const std::lock_guard<std::mutex> lock1(fileReaderListMutex);
|
|
|
|
openFileReaders.clear();
|
|
|
|
}
|
|
|
|
{
|
|
|
|
const std::lock_guard<std::mutex> lock(fileInfosMutex);
|
|
|
|
fileInfos.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-28 20:26:23 +02:00
|
|
|
void SDCleanUpHandlesHandler() {
|
|
|
|
Cleanup();
|
|
|
|
}
|
|
|
|
|
2022-04-17 21:56:14 +02:00
|
|
|
void SDAttachedHandler([[maybe_unused]] SDUtilsAttachStatus status) {
|
2022-03-04 01:07:01 +01:00
|
|
|
if (!sTitleRebooting) {
|
2022-04-17 21:56:14 +02:00
|
|
|
_SYSLaunchTitleWithStdArgsInNoSplash(OSGetTitleID(), nullptr);
|
2022-03-04 01:07:01 +01:00
|
|
|
sTitleRebooting = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-16 17:37:11 +01:00
|
|
|
ON_APPLICATION_START() {
|
2022-04-27 19:10:44 +02:00
|
|
|
Cleanup();
|
2022-01-30 20:38:48 +01:00
|
|
|
initLogging();
|
2022-04-28 20:26:02 +02:00
|
|
|
sSDIsMounted = false;
|
2019-09-08 21:06:53 +02:00
|
|
|
|
2021-01-09 18:46:50 +01:00
|
|
|
if (OSGetTitleID() == 0x0005001010040000L || // Wii U Menu JPN
|
|
|
|
OSGetTitleID() == 0x0005001010040100L || // Wii U Menu USA
|
2022-03-04 01:07:01 +01:00
|
|
|
OSGetTitleID() == 0x0005001010040200L) { // Wii U Menu EUR
|
2022-04-27 19:10:44 +02:00
|
|
|
gInWiiUMenu = true;
|
2022-03-04 01:07:01 +01:00
|
|
|
|
|
|
|
if (SDUtils_Init() >= 0) {
|
2022-04-28 20:26:02 +02:00
|
|
|
DEBUG_FUNCTION_LINE("SDUtils_Init done");
|
2022-03-04 01:07:01 +01:00
|
|
|
sSDUtilsInitDone = true;
|
|
|
|
sTitleRebooting = false;
|
2022-04-28 20:26:02 +02:00
|
|
|
if (SDUtils_AddAttachHandler(SDAttachedHandler) != SDUTILS_RESULT_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to add AttachedHandler");
|
|
|
|
}
|
2022-04-28 20:26:23 +02:00
|
|
|
if (SDUtils_AddCleanUpHandlesHandler(SDCleanUpHandlesHandler) != SDUTILS_RESULT_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to add CleanUpHandlesHandler");
|
|
|
|
}
|
2022-04-28 20:26:02 +02:00
|
|
|
if (SDUtils_IsSdCardMounted(&sSDIsMounted) != SDUTILS_RESULT_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("IsSdCardMounted failed");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to init SDUtils. Make sure to have the SDHotSwapModule loaded!");
|
2022-03-04 01:07:01 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
gInWiiUMenu = false;
|
2021-01-09 18:46:50 +01:00
|
|
|
}
|
|
|
|
|
2020-06-17 13:45:15 +02:00
|
|
|
if (_SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY) != OSGetTitleID()) {
|
2019-09-08 21:06:53 +02:00
|
|
|
gHomebrewLaunched = FALSE;
|
|
|
|
}
|
2019-09-06 17:02:09 +02:00
|
|
|
}
|
|
|
|
|
2022-01-30 20:38:48 +01:00
|
|
|
ON_APPLICATION_ENDS() {
|
2022-04-27 19:10:44 +02:00
|
|
|
Cleanup();
|
2022-04-17 21:56:14 +02:00
|
|
|
SaveRedirectionCleanUp();
|
2022-01-30 20:38:48 +01:00
|
|
|
deinitLogging();
|
2022-03-04 01:07:01 +01:00
|
|
|
gInWiiUMenu = false;
|
|
|
|
if (sSDUtilsInitDone) {
|
|
|
|
SDUtils_RemoveAttachHandler(SDAttachedHandler);
|
2022-04-28 20:26:23 +02:00
|
|
|
SDUtils_RemoveCleanUpHandlesHandler(SDCleanUpHandlesHandler);
|
2022-03-04 01:07:01 +01:00
|
|
|
SDUtils_DeInit();
|
|
|
|
sSDUtilsInitDone = false;
|
|
|
|
}
|
|
|
|
sSDIsMounted = false;
|
2019-09-06 17:02:09 +02:00
|
|
|
}
|
|
|
|
|
2022-04-27 19:10:44 +02:00
|
|
|
std::optional<std::shared_ptr<FileInfos>> getIDByLowerTitleID(uint32_t titleid_lower) {
|
|
|
|
std::lock_guard<std::mutex> lock(fileInfosMutex);
|
|
|
|
for (auto &cur : fileInfos) {
|
|
|
|
if (cur->lowerTitleID == titleid_lower) {
|
|
|
|
return cur;
|
|
|
|
}
|
2020-06-17 16:37:17 +02:00
|
|
|
}
|
2022-04-27 19:10:44 +02:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
void fillXmlForTitleID(uint32_t titleid_upper, uint32_t titleid_lower, ACPMetaXml *out_buf) {
|
|
|
|
auto titleIdInfoOpt = getIDByLowerTitleID(titleid_lower);
|
|
|
|
if (!titleIdInfoOpt.has_value()) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to get info by titleid");
|
2019-12-07 22:15:43 +01:00
|
|
|
return;
|
|
|
|
}
|
2022-04-27 19:10:44 +02:00
|
|
|
auto &titleInfo = titleIdInfoOpt.value();
|
|
|
|
|
|
|
|
out_buf->title_id = (((uint64_t) titleid_upper) << 32) + titleid_lower;
|
|
|
|
strncpy(out_buf->longname_en, titleInfo->longname.c_str(), sizeof(out_buf->longname_en) - 1);
|
|
|
|
strncpy(out_buf->shortname_en, titleInfo->shortname.c_str(), sizeof(out_buf->shortname_en) - 1);
|
|
|
|
strncpy(out_buf->publisher_en, titleInfo->author.c_str(), sizeof(out_buf->publisher_en) - 1);
|
2022-02-04 15:19:43 +01:00
|
|
|
out_buf->e_manual = 1;
|
|
|
|
out_buf->e_manual_version = 0;
|
|
|
|
out_buf->title_version = 1;
|
|
|
|
out_buf->network_use = 1;
|
|
|
|
out_buf->launching_flag = 4;
|
2019-11-24 14:14:45 +01:00
|
|
|
out_buf->online_account_use = 1;
|
2022-02-04 15:19:43 +01:00
|
|
|
out_buf->os_version = 0x000500101000400A;
|
|
|
|
out_buf->region = 0xFFFFFFFF;
|
|
|
|
out_buf->common_save_size = 0x0000000001790000;
|
|
|
|
out_buf->group_id = 0x400;
|
|
|
|
out_buf->drc_use = 1;
|
|
|
|
out_buf->version = 1;
|
|
|
|
out_buf->reserved_flag0 = 0x00010001;
|
|
|
|
out_buf->reserved_flag6 = 0x00000003;
|
|
|
|
out_buf->pc_usk = 128;
|
2022-04-27 19:10:44 +02:00
|
|
|
strncpy(out_buf->product_code, "WUP-P-HBLD", sizeof(out_buf->product_code) - 1);
|
|
|
|
strncpy(out_buf->content_platform, "WUP", sizeof(out_buf->content_platform) - 1);
|
|
|
|
strncpy(out_buf->company_code, "0001", sizeof(out_buf->company_code) - 1);
|
2020-06-17 14:31:38 +02:00
|
|
|
}
|
|
|
|
|
2021-01-09 19:37:41 +01:00
|
|
|
static int handler(void *user, const char *section, const char *name,
|
|
|
|
const char *value) {
|
2022-04-27 19:10:44 +02:00
|
|
|
auto *fInfo = (std::shared_ptr<FileInfos> *) user;
|
2021-01-09 19:37:41 +01:00
|
|
|
#define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0
|
2021-01-24 15:49:26 +01:00
|
|
|
|
2021-01-09 19:37:41 +01:00
|
|
|
if (MATCH("menu", "longname")) {
|
2022-04-27 19:10:44 +02:00
|
|
|
fInfo->operator->()->longname = value;
|
2021-01-09 19:37:41 +01:00
|
|
|
} else if (MATCH("menu", "shortname")) {
|
2022-04-27 19:10:44 +02:00
|
|
|
fInfo->operator->()->shortname = value;
|
2021-01-09 19:37:41 +01:00
|
|
|
} else if (MATCH("menu", "author")) {
|
2022-04-27 19:10:44 +02:00
|
|
|
fInfo->operator->()->author = value;
|
2021-01-09 19:37:41 +01:00
|
|
|
} else {
|
2022-02-04 15:19:43 +01:00
|
|
|
return 0; /* unknown section/name, error */
|
2021-01-09 19:37:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2022-04-17 21:56:14 +02:00
|
|
|
bool CheckFileExistsHelper(const char *path);
|
2021-01-09 18:46:50 +01:00
|
|
|
void readCustomTitlesFromSD() {
|
2022-04-27 19:10:44 +02:00
|
|
|
std::lock_guard<std::mutex> lock(fileInfosMutex);
|
|
|
|
if (!fileInfos.empty()) {
|
|
|
|
DEBUG_FUNCTION_LINE_VERBOSE("Using cached value");
|
|
|
|
return;
|
|
|
|
}
|
2021-01-09 18:46:50 +01:00
|
|
|
// Reset current infos
|
|
|
|
DirList dirList("fs:/vol/external01/wiiu/apps", ".rpx,.wuhb", DirList::Files | DirList::CheckSubfolders, 1);
|
2019-09-06 17:02:09 +02:00
|
|
|
dirList.SortList();
|
2019-11-24 14:14:45 +01:00
|
|
|
|
2020-06-17 13:45:15 +02:00
|
|
|
for (int i = 0; i < dirList.GetFilecount(); i++) {
|
2021-01-09 18:46:50 +01:00
|
|
|
//! skip wiiload temp files
|
|
|
|
if (strcasecmp(dirList.GetFilename(i), "temp.rpx") == 0) {
|
2019-09-06 17:02:09 +02:00
|
|
|
continue;
|
2019-11-24 14:14:45 +01:00
|
|
|
}
|
2021-01-09 18:46:50 +01:00
|
|
|
|
|
|
|
//! skip wiiload temp files
|
|
|
|
if (strcasecmp(dirList.GetFilename(i), "temp.wuhb") == 0) {
|
2019-09-06 17:02:09 +02:00
|
|
|
continue;
|
2019-11-24 14:14:45 +01:00
|
|
|
}
|
2019-09-06 17:02:09 +02:00
|
|
|
|
2021-01-24 15:49:26 +01:00
|
|
|
//! skip wiiload temp files
|
|
|
|
if (strcasecmp(dirList.GetFilename(i), "temp2.wuhb") == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-09-06 17:02:09 +02:00
|
|
|
//! skip hidden linux and mac files
|
2020-06-17 13:45:15 +02:00
|
|
|
if (dirList.GetFilename(i)[0] == '.' || dirList.GetFilename(i)[0] == '_') {
|
2019-09-06 17:02:09 +02:00
|
|
|
continue;
|
2019-11-24 14:14:45 +01:00
|
|
|
}
|
2019-09-08 21:06:53 +02:00
|
|
|
|
2022-04-27 19:10:44 +02:00
|
|
|
|
2022-04-17 21:56:14 +02:00
|
|
|
auto repl = "fs:/vol/external01/";
|
|
|
|
auto input = dirList.GetFilepath(i);
|
2022-04-27 19:27:07 +02:00
|
|
|
const char *relativeFilepath;
|
2019-11-24 14:14:45 +01:00
|
|
|
|
2022-04-17 21:56:14 +02:00
|
|
|
if (std::string_view(input).starts_with(repl)) {
|
2022-04-27 19:10:44 +02:00
|
|
|
relativeFilepath = &input[strlen(repl)];
|
2022-04-17 21:56:14 +02:00
|
|
|
} else {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Skip %s, Path doesn't start with %s (This should never happen", input, repl);
|
|
|
|
continue;
|
2019-11-24 14:14:45 +01:00
|
|
|
}
|
|
|
|
|
2022-04-27 19:10:44 +02:00
|
|
|
auto fileInfo = make_shared_nothrow<FileInfos>(relativeFilepath);
|
|
|
|
if (!fileInfo) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("No more memory");
|
|
|
|
break;
|
|
|
|
}
|
2020-06-17 22:13:21 +02:00
|
|
|
|
2022-04-27 19:10:44 +02:00
|
|
|
std::lock_guard<std::mutex> infoLock(fileInfo->accessLock);
|
2021-01-09 18:46:50 +01:00
|
|
|
|
2022-04-27 19:10:44 +02:00
|
|
|
auto *cur_title_info = &(fileInfo->titleInfo);
|
2022-02-14 19:29:52 +01:00
|
|
|
|
2022-04-27 19:10:44 +02:00
|
|
|
snprintf(cur_title_info->path, sizeof(cur_title_info->path), "/custom/%08X%08X", UPPER_TITLE_ID_HOMEBREW, fileInfo->lowerTitleID);
|
2019-11-24 14:14:45 +01:00
|
|
|
|
2020-06-17 13:45:15 +02:00
|
|
|
const char *indexedDevice = "mlc";
|
2022-04-27 19:10:44 +02:00
|
|
|
strncpy(cur_title_info->indexedDevice, indexedDevice, sizeof(cur_title_info->indexedDevice) - 1);
|
|
|
|
|
|
|
|
fileInfo->filename = dirList.GetFilename(i);
|
|
|
|
fileInfo->longname = dirList.GetFilename(i);
|
|
|
|
fileInfo->shortname = dirList.GetFilename(i);
|
|
|
|
fileInfo->author = dirList.GetFilename(i);
|
2020-12-12 17:38:02 +01:00
|
|
|
|
|
|
|
// System apps don't have a splash screen.
|
2021-01-09 18:46:50 +01:00
|
|
|
cur_title_info->appType = MCP_APP_TYPE_SYSTEM_APPS;
|
2020-12-12 17:38:02 +01:00
|
|
|
|
2022-04-27 19:10:44 +02:00
|
|
|
DEBUG_FUNCTION_LINE_VERBOSE("Check %s", fileInfo->filename.c_str());
|
|
|
|
|
2022-04-17 21:56:14 +02:00
|
|
|
// Check if the bootTvTex and bootDrcTex exists
|
2022-04-27 19:10:44 +02:00
|
|
|
if (std::string_view(fileInfo->filename).ends_with(".wuhb")) {
|
2021-09-24 20:50:35 +02:00
|
|
|
int result = 0;
|
2021-01-24 15:49:26 +01:00
|
|
|
|
2022-04-17 21:56:14 +02:00
|
|
|
#define TMP_BUNDLE_NAME "romfscheck"
|
2021-01-09 19:37:41 +01:00
|
|
|
|
2022-04-17 21:56:14 +02:00
|
|
|
if (WUHBUtils_MountBundle(TMP_BUNDLE_NAME, dirList.GetFilepath(i), BundleSource_FileDescriptor, &result) == WUHB_UTILS_RESULT_SUCCESS && result >= 0) {
|
2022-04-27 19:10:44 +02:00
|
|
|
fileInfo->isBundle = true;
|
2022-04-17 21:56:14 +02:00
|
|
|
uint8_t *buffer;
|
|
|
|
uint32_t bufferSize;
|
|
|
|
|
|
|
|
auto readRes = WUHBUtils_ReadWholeFile(TMP_BUNDLE_NAME ":/meta/meta.ini", &buffer, &bufferSize);
|
|
|
|
if (readRes == WUHB_UTILS_RESULT_SUCCESS) {
|
|
|
|
buffer[bufferSize - 1] = '\0';
|
2022-04-27 19:10:44 +02:00
|
|
|
if (ini_parse_string((const char *) buffer, handler, &fileInfo) < 0) {
|
2022-04-17 21:56:14 +02:00
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to parse meta.ini");
|
|
|
|
}
|
|
|
|
free(buffer);
|
|
|
|
buffer = nullptr;
|
|
|
|
} else {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to open or read meta.ini: %d", readRes);
|
2020-12-12 17:38:02 +01:00
|
|
|
}
|
2022-04-17 21:56:14 +02:00
|
|
|
|
|
|
|
auto bootTvTexPath = TMP_BUNDLE_NAME ":/meta/bootTvTex.tga";
|
|
|
|
auto bootDrcTexPath = TMP_BUNDLE_NAME ":/meta/bootDrcTex.tga";
|
|
|
|
if (CheckFileExistsHelper(bootTvTexPath) && CheckFileExistsHelper(bootDrcTexPath)) {
|
2020-12-12 17:38:02 +01:00
|
|
|
// Show splash screens
|
2021-01-09 18:46:50 +01:00
|
|
|
cur_title_info->appType = MCP_APP_TYPE_GAME;
|
2022-04-27 19:10:44 +02:00
|
|
|
DEBUG_FUNCTION_LINE_VERBOSE("Title has splashscreen");
|
2020-12-12 17:38:02 +01:00
|
|
|
}
|
2022-04-17 21:56:14 +02:00
|
|
|
|
|
|
|
int32_t unmountRes;
|
|
|
|
if (WUHBUtils_UnmountBundle(TMP_BUNDLE_NAME, &unmountRes) == WUHB_UTILS_RESULT_SUCCESS) {
|
|
|
|
if (unmountRes != 0) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Unmount result was \"%s\"", TMP_BUNDLE_NAME);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to unmount \"%s\"", TMP_BUNDLE_NAME);
|
|
|
|
}
|
2020-12-12 17:38:02 +01:00
|
|
|
} else {
|
2022-04-27 19:10:44 +02:00
|
|
|
DEBUG_FUNCTION_LINE_ERR("%s is not a valid .wuhb file: %d", dirList.GetFilepath(i), result);
|
2021-01-09 19:37:41 +01:00
|
|
|
continue;
|
2020-12-12 17:38:02 +01:00
|
|
|
}
|
2019-11-24 14:14:45 +01:00
|
|
|
}
|
2020-12-12 17:38:02 +01:00
|
|
|
|
2022-04-27 19:10:44 +02:00
|
|
|
cur_title_info->titleId = TITLE_ID_HOMEBREW_MASK | fileInfo->lowerTitleID;
|
2021-01-09 18:46:50 +01:00
|
|
|
cur_title_info->titleVersion = 1;
|
2022-02-04 15:19:43 +01:00
|
|
|
cur_title_info->groupId = 0x400;
|
2019-11-24 14:14:45 +01:00
|
|
|
|
2022-02-04 15:19:43 +01:00
|
|
|
cur_title_info->osVersion = OSGetOSID();
|
2021-01-09 18:46:50 +01:00
|
|
|
cur_title_info->sdkVersion = __OSGetProcessSDKVersion();
|
2022-02-04 15:19:43 +01:00
|
|
|
cur_title_info->unk0x60 = 0;
|
2019-09-08 21:06:53 +02:00
|
|
|
|
2022-04-27 19:10:44 +02:00
|
|
|
fileInfos.push_front(fileInfo);
|
2021-01-09 18:46:50 +01:00
|
|
|
}
|
|
|
|
}
|
2019-12-07 22:15:43 +01:00
|
|
|
|
2022-04-17 21:56:14 +02:00
|
|
|
bool CheckFileExistsHelper(const char *path) {
|
|
|
|
int32_t exists;
|
|
|
|
int32_t res;
|
|
|
|
if ((res = WUHBUtils_FileExists(path, &exists)) == WUHB_UTILS_RESULT_SUCCESS) {
|
|
|
|
if (!exists) {
|
|
|
|
DEBUG_FUNCTION_LINE_VERBOSE("## WARN ##: Missing %s", path);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to check if %s exists: %d", path, res);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-01-09 18:46:50 +01:00
|
|
|
DECL_FUNCTION(int32_t, MCP_TitleList, uint32_t handle, uint32_t *outTitleCount, MCPTitleListType *titleList, uint32_t size) {
|
2022-04-27 19:10:44 +02:00
|
|
|
int32_t result = real_MCP_TitleList(handle, outTitleCount, titleList, size);
|
2021-01-09 18:46:50 +01:00
|
|
|
|
2022-04-27 19:10:44 +02:00
|
|
|
if (!gInWiiUMenu) {
|
|
|
|
DEBUG_FUNCTION_LINE_VERBOSE("Not in Wii U Menu");
|
|
|
|
return result;
|
2019-09-06 17:02:09 +02:00
|
|
|
}
|
2019-09-08 21:06:53 +02:00
|
|
|
|
2022-04-27 19:10:44 +02:00
|
|
|
uint32_t titleCount = *outTitleCount;
|
|
|
|
|
|
|
|
std::lock_guard<std::mutex> lock(fileInfosMutex);
|
|
|
|
readCustomTitlesFromSD();
|
|
|
|
|
|
|
|
for (auto &gFileInfo : fileInfos) {
|
|
|
|
memcpy(&(titleList[titleCount]), &(gFileInfo->titleInfo), sizeof(MCPTitleListType));
|
|
|
|
titleCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*outTitleCount = titleCount;
|
2019-09-06 17:02:09 +02:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-06-17 13:45:15 +02:00
|
|
|
DECL_FUNCTION(int32_t, ACPCheckTitleLaunchByTitleListTypeEx, MCPTitleListType *title, uint32_t u2) {
|
2020-06-17 14:36:41 +02:00
|
|
|
if ((title->titleId & TITLE_ID_HOMEBREW_MASK) == TITLE_ID_HOMEBREW_MASK) {
|
2022-04-27 19:10:44 +02:00
|
|
|
std::lock_guard<std::mutex> lock(fileInfosMutex);
|
|
|
|
auto fileInfo = getIDByLowerTitleID(title->titleId & 0xFFFFFFFF);
|
|
|
|
if (fileInfo.has_value()) {
|
2021-01-01 01:51:11 +01:00
|
|
|
DEBUG_FUNCTION_LINE("Starting a homebrew title");
|
|
|
|
|
2021-01-24 15:49:26 +01:00
|
|
|
fillXmlForTitleID((title->titleId & 0xFFFFFFFF00000000) >> 32, (title->titleId & 0xFFFFFFFF), &gLaunchXML);
|
2020-06-17 14:31:38 +02:00
|
|
|
|
2021-01-09 18:46:50 +01:00
|
|
|
gHomebrewLaunched = TRUE;
|
|
|
|
|
2022-08-27 14:07:43 +02:00
|
|
|
if (RPXLoader_PrepareLaunchFromSD(fileInfo.value()->relativeFilepath.c_str()) == RPX_LOADER_RESULT_SUCCESS) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to prepare launch for %s", fileInfo.value()->relativeFilepath.c_str());
|
2020-06-17 14:31:38 +02:00
|
|
|
} else {
|
2022-04-27 19:10:44 +02:00
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to get info for titleID %016llX", title->titleId);
|
2019-11-24 14:14:45 +01:00
|
|
|
}
|
2019-09-12 18:55:49 +02:00
|
|
|
}
|
2019-09-08 21:06:53 +02:00
|
|
|
|
2022-08-27 14:07:43 +02:00
|
|
|
return real_ACPCheckTitleLaunchByTitleListTypeEx(title, u2);
|
2019-09-06 17:02:09 +02:00
|
|
|
}
|
|
|
|
|
2022-04-27 19:10:44 +02:00
|
|
|
|
2022-04-17 21:56:14 +02:00
|
|
|
DECL_FUNCTION(int, FSOpenFile, FSClient *client, FSCmdBlock *block, char *path, const char *mode, uint32_t *handle, int error) {
|
2022-02-04 15:19:43 +01:00
|
|
|
const char *start = "/vol/storage_mlc01/sys/title/0005000F";
|
2022-04-27 19:10:44 +02:00
|
|
|
const char *tga = ".tga";
|
2020-06-17 14:36:41 +02:00
|
|
|
const char *iconTex = "iconTex.tga";
|
2022-02-04 15:19:43 +01:00
|
|
|
const char *sound = ".btsnd";
|
2019-11-24 14:14:45 +01:00
|
|
|
|
2022-04-17 21:56:14 +02:00
|
|
|
std::string_view pathStr = path;
|
|
|
|
|
2022-04-27 19:10:44 +02:00
|
|
|
if (pathStr.starts_with(start)) {
|
|
|
|
std::unique_ptr<FileReader> reader;
|
|
|
|
if (pathStr.ends_with(tga) || pathStr.ends_with(sound)) {
|
|
|
|
char *id = path + 1 + strlen(start);
|
|
|
|
id[8] = 0;
|
|
|
|
char *relativePath = id + 9;
|
|
|
|
auto lowerTitleID = strtoul(id, 0, 16);
|
|
|
|
auto fileInfo = getIDByLowerTitleID(lowerTitleID);
|
|
|
|
if (fileInfo.has_value()) {
|
|
|
|
reader = make_unique_nothrow<FileReaderWUHB>(fileInfo.value(), relativePath, !gHomebrewLaunched);
|
|
|
|
if (reader && !reader->isReady()) {
|
|
|
|
reader.reset();
|
2022-03-05 22:42:43 +01:00
|
|
|
}
|
2019-11-24 14:14:45 +01:00
|
|
|
}
|
2022-04-27 19:10:44 +02:00
|
|
|
}
|
|
|
|
// If the icon is requested and loading it from a bundle failed, we fall back to a default one.
|
|
|
|
if (reader == nullptr && pathStr.ends_with(iconTex)) {
|
|
|
|
reader = make_unique_nothrow<FileReader>((uint8_t *) iconTex_tga, iconTex_tga_size);
|
|
|
|
if (reader && !reader->isReady()) {
|
|
|
|
reader.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (reader) {
|
|
|
|
std::lock_guard<std::mutex> lock(fileReaderListMutex);
|
|
|
|
*handle = reader->getHandle();
|
|
|
|
openFileReaders.push_front(std::move(reader));
|
|
|
|
return FS_STATUS_OK;
|
2019-11-24 14:14:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int result = real_FSOpenFile(client, block, path, mode, handle, error);
|
2019-09-12 18:55:49 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-11-24 14:14:45 +01:00
|
|
|
DECL_FUNCTION(FSStatus, FSCloseFile, FSClient *client, FSCmdBlock *block, FSFileHandle handle, uint32_t flags) {
|
2022-04-27 19:10:44 +02:00
|
|
|
if (remove_locked_first_if(fileReaderListMutex, openFileReaders, [handle](auto &cur) { return cur->getHandle() == handle; })) {
|
2019-11-24 14:14:45 +01:00
|
|
|
return FS_STATUS_OK;
|
|
|
|
}
|
2022-04-27 19:10:44 +02:00
|
|
|
|
2020-06-17 13:45:15 +02:00
|
|
|
return real_FSCloseFile(client, block, handle, flags);
|
2019-11-24 14:14:45 +01:00
|
|
|
}
|
|
|
|
|
2020-06-17 13:45:15 +02:00
|
|
|
DECL_FUNCTION(FSStatus, FSReadFile, FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count, FSFileHandle handle, uint32_t unk1, uint32_t flags) {
|
2022-04-27 19:10:44 +02:00
|
|
|
const std::lock_guard<std::mutex> lock(fileReaderListMutex);
|
|
|
|
for (auto &reader : openFileReaders) {
|
|
|
|
if ((uint32_t) reader.get() == (uint32_t) handle) {
|
|
|
|
return (FSStatus) (reader->read(buffer, size * count) / size);
|
2022-04-17 21:56:14 +02:00
|
|
|
}
|
2019-11-24 14:14:45 +01:00
|
|
|
}
|
|
|
|
FSStatus result = real_FSReadFile(client, block, buffer, size, count, handle, unk1, flags);
|
2019-09-06 17:02:09 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-06-17 13:45:15 +02:00
|
|
|
DECL_FUNCTION(int32_t, ACPGetTitleMetaXmlByDevice, uint32_t titleid_upper, uint32_t titleid_lower, ACPMetaXml *out_buf, uint32_t device, uint32_t u1) {
|
|
|
|
int result = real_ACPGetTitleMetaXmlByDevice(titleid_upper, titleid_lower, out_buf, device, u1);
|
2020-06-17 14:28:15 +02:00
|
|
|
if (titleid_upper == UPPER_TITLE_ID_HOMEBREW) {
|
2020-06-17 13:45:15 +02:00
|
|
|
fillXmlForTitleID(titleid_upper, titleid_lower, out_buf);
|
2019-09-06 17:02:09 +02:00
|
|
|
result = 0;
|
|
|
|
}
|
2019-09-08 21:06:53 +02:00
|
|
|
return result;
|
2019-09-06 17:02:09 +02:00
|
|
|
}
|
|
|
|
|
2020-06-17 13:45:15 +02:00
|
|
|
DECL_FUNCTION(int32_t, ACPGetTitleMetaDirByDevice, uint32_t titleid_upper, uint32_t titleid_lower, char *out_buf, uint32_t size, int device) {
|
2020-06-17 14:28:15 +02:00
|
|
|
if (titleid_upper == UPPER_TITLE_ID_HOMEBREW) {
|
2020-06-17 13:45:15 +02:00
|
|
|
snprintf(out_buf, 53, "/vol/storage_mlc01/sys/title/%08X/%08X/meta", titleid_upper, titleid_lower);
|
2019-11-24 14:14:45 +01:00
|
|
|
return 0;
|
2019-09-06 17:02:09 +02:00
|
|
|
}
|
2019-11-24 14:14:45 +01:00
|
|
|
int result = real_ACPGetTitleMetaDirByDevice(titleid_upper, titleid_lower, out_buf, size, device);
|
2019-09-06 17:02:09 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-01-01 01:50:00 +01:00
|
|
|
/*
|
|
|
|
* Load the H&S app instead
|
|
|
|
*/
|
2020-06-17 13:45:15 +02:00
|
|
|
DECL_FUNCTION(int32_t, _SYSLaunchTitleByPathFromLauncher, char *pathToLoad, uint32_t u2) {
|
|
|
|
const char *start = "/custom/";
|
|
|
|
if (strncmp(pathToLoad, start, strlen(start)) == 0) {
|
2021-01-09 18:46:50 +01:00
|
|
|
strcpy(current_launched_title_info.path, pathToLoad);
|
2019-11-24 14:14:45 +01:00
|
|
|
uint64_t titleID = _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY);
|
2020-06-17 13:45:15 +02:00
|
|
|
snprintf(pathToLoad, 47, "/vol/storage_mlc01/sys/title/%08x/%08x", (uint32_t) (titleID >> 32), (uint32_t) (0x00000000FFFFFFFF & titleID));
|
2019-09-08 21:06:53 +02:00
|
|
|
}
|
|
|
|
|
2019-09-06 17:02:09 +02:00
|
|
|
int32_t result = real__SYSLaunchTitleByPathFromLauncher(pathToLoad, strlen(pathToLoad));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-06-17 13:45:15 +02:00
|
|
|
DECL_FUNCTION(int32_t, ACPGetLaunchMetaXml, ACPMetaXml *metaxml) {
|
2019-09-08 21:06:53 +02:00
|
|
|
int result = real_ACPGetLaunchMetaXml(metaxml);
|
2020-06-17 13:45:15 +02:00
|
|
|
if (gHomebrewLaunched) {
|
2019-09-08 21:06:53 +02:00
|
|
|
memcpy(metaxml, &gLaunchXML, sizeof(gLaunchXML));
|
|
|
|
}
|
2019-09-06 17:02:09 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-06-17 13:45:15 +02:00
|
|
|
DECL_FUNCTION(uint32_t, ACPGetApplicationBox, uint32_t *u1, uint32_t *u2, uint32_t u3, uint32_t u4) {
|
2020-06-17 14:28:15 +02:00
|
|
|
if (u3 == UPPER_TITLE_ID_HOMEBREW) {
|
2019-11-24 14:14:45 +01:00
|
|
|
uint64_t titleID = _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY);
|
2022-02-04 15:19:43 +01:00
|
|
|
u3 = (uint32_t) (titleID >> 32);
|
|
|
|
u4 = (uint32_t) (0x00000000FFFFFFFF & titleID);
|
2019-09-08 21:06:53 +02:00
|
|
|
}
|
2020-06-17 13:45:15 +02:00
|
|
|
uint32_t result = real_ACPGetApplicationBox(u1, u2, u3, u4);
|
2019-09-12 18:55:49 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-01-01 01:50:00 +01:00
|
|
|
/*
|
|
|
|
* Redirect the launchable check to H&S
|
|
|
|
*/
|
2020-06-17 13:45:15 +02:00
|
|
|
DECL_FUNCTION(uint32_t, PatchChkStart__3RplFRCQ3_2nn6drmapp8StartArg, uint32_t *param) {
|
2020-06-17 14:28:15 +02:00
|
|
|
if (param[2] == UPPER_TITLE_ID_HOMEBREW) {
|
2019-11-24 14:14:45 +01:00
|
|
|
uint64_t titleID = _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY);
|
2022-02-04 15:19:43 +01:00
|
|
|
param[2] = (uint32_t) (titleID >> 32);
|
|
|
|
param[3] = (uint32_t) (0x00000000FFFFFFFF & titleID);
|
2019-09-12 18:55:49 +02:00
|
|
|
}
|
2019-11-24 14:14:45 +01:00
|
|
|
uint32_t result = real_PatchChkStart__3RplFRCQ3_2nn6drmapp8StartArg(param);
|
2019-09-12 18:55:49 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-01-01 01:50:00 +01:00
|
|
|
/*
|
|
|
|
* Redirect the launchable check to H&S
|
|
|
|
*/
|
2020-06-17 13:45:15 +02:00
|
|
|
DECL_FUNCTION(uint32_t, MCP_RightCheckLaunchable, uint32_t *u1, uint32_t *u2, uint32_t u3, uint32_t u4, uint32_t u5) {
|
2020-06-17 14:28:15 +02:00
|
|
|
if (u3 == UPPER_TITLE_ID_HOMEBREW) {
|
2019-11-24 14:14:45 +01:00
|
|
|
uint64_t titleID = _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY);
|
2022-02-04 15:19:43 +01:00
|
|
|
u3 = (uint32_t) (titleID >> 32);
|
|
|
|
u4 = (uint32_t) (0x00000000FFFFFFFF & titleID);
|
2019-11-24 14:14:45 +01:00
|
|
|
}
|
2020-06-17 13:45:15 +02:00
|
|
|
uint32_t result = real_MCP_RightCheckLaunchable(u1, u2, u3, u4, u5);
|
2019-11-24 14:14:45 +01:00
|
|
|
return result;
|
|
|
|
}
|
2019-09-12 18:55:49 +02:00
|
|
|
|
2021-01-01 01:50:00 +01:00
|
|
|
/*
|
|
|
|
* Patch the boot movie and and boot logo
|
|
|
|
*/
|
|
|
|
DECL_FUNCTION(uint32_t, ACPGetLaunchMetaData, struct ACPMetaData *metadata) {
|
2020-06-17 22:15:45 +02:00
|
|
|
uint32_t result = real_ACPGetLaunchMetaData(metadata);
|
|
|
|
|
|
|
|
if (gHomebrewLaunched) {
|
|
|
|
memcpy(metadata->bootmovie, bootMovie_h264, bootMovie_h264_size);
|
|
|
|
memcpy(metadata->bootlogo, bootLogoTex_tga, bootLogoTex_tga_size);
|
2021-01-01 01:50:00 +01:00
|
|
|
DCFlushRange(metadata->bootmovie, bootMovie_h264_size);
|
|
|
|
DCFlushRange(metadata->bootlogo, bootMovie_h264_size);
|
2020-06-17 22:15:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-04-17 00:03:24 +02:00
|
|
|
typedef struct TitleVersionInfo TitleVersionInfo;
|
|
|
|
|
|
|
|
struct WUT_PACKED TitleVersionInfo {
|
|
|
|
uint16_t currentVersion;
|
|
|
|
uint16_t neededVersion;
|
|
|
|
uint8_t needsUpdate;
|
|
|
|
};
|
|
|
|
WUT_CHECK_OFFSET(TitleVersionInfo, 0x00, currentVersion);
|
|
|
|
WUT_CHECK_OFFSET(TitleVersionInfo, 0x02, neededVersion);
|
|
|
|
WUT_CHECK_OFFSET(TitleVersionInfo, 0x04, needsUpdate);
|
|
|
|
WUT_CHECK_SIZE(TitleVersionInfo, 0x05);
|
2021-01-01 01:50:00 +01:00
|
|
|
|
2021-04-17 00:03:24 +02:00
|
|
|
|
|
|
|
DECL_FUNCTION(uint32_t, GetTitleVersionInfo__Q2_2nn4vctlFPQ3_2nn4vctl16TitleVersionInfoULQ3_2nn4Cafe9MediaType, TitleVersionInfo *titleVersionInfo, uint32_t u2, uint32_t u3, uint32_t u4, uint32_t u5) {
|
|
|
|
int32_t result = real_GetTitleVersionInfo__Q2_2nn4vctlFPQ3_2nn4vctl16TitleVersionInfoULQ3_2nn4Cafe9MediaType(titleVersionInfo, u2, u3, u4, u5);
|
|
|
|
|
|
|
|
if (result < 0) {
|
|
|
|
// Fake result if it's H&S
|
|
|
|
uint64_t titleID = _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY);
|
2021-09-24 20:50:35 +02:00
|
|
|
auto expected_u3 = (uint32_t) (titleID >> 32);
|
|
|
|
auto expected_u4 = (uint32_t) (0x00000000FFFFFFFF & titleID);
|
2021-04-17 00:03:24 +02:00
|
|
|
|
|
|
|
if (expected_u3 == u3 && expected_u4 == u4) {
|
|
|
|
if (titleVersionInfo != nullptr) {
|
|
|
|
titleVersionInfo->currentVersion = 129;
|
2022-02-04 15:19:43 +01:00
|
|
|
titleVersionInfo->neededVersion = 129;
|
|
|
|
titleVersionInfo->needsUpdate = 0;
|
2021-04-17 00:03:24 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
DECL_FUNCTION(uint32_t, GetUpdateInfo__Q2_2nn4vctlFPQ3_2nn4vctl10UpdateInfoULQ3_2nn4Cafe9MediaType, uint32_t u1, uint32_t u2, uint32_t u3, uint32_t u4, uint32_t u5, uint32_t u6) {
|
|
|
|
uint32_t result = real_GetUpdateInfo__Q2_2nn4vctlFPQ3_2nn4vctl10UpdateInfoULQ3_2nn4Cafe9MediaType(u1, u2, u3, u4, u5, u6);
|
|
|
|
|
|
|
|
uint64_t titleID = _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY);
|
2021-09-24 20:50:35 +02:00
|
|
|
auto expected_u3 = (uint32_t) (titleID >> 32);
|
|
|
|
auto expected_u4 = (uint32_t) (0x00000000FFFFFFFF & titleID);
|
2021-04-17 00:03:24 +02:00
|
|
|
|
|
|
|
if (expected_u3 == u3 && expected_u4 == u4) {
|
|
|
|
return 0xa121f480;
|
|
|
|
}
|
|
|
|
|
2021-10-16 14:08:39 +02:00
|
|
|
return result;
|
2021-04-17 00:03:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DECL_FUNCTION(uint32_t, MCPGetTitleInternal, uint32_t mcp_handle, void *input, uint32_t type, MCPTitleListType *titles, uint32_t out_cnt) {
|
|
|
|
if (input != nullptr) {
|
|
|
|
auto *inputPtrAsU32 = (uint32_t *) input;
|
|
|
|
if (inputPtrAsU32[0] == UPPER_TITLE_ID_HOMEBREW && out_cnt >= 1) {
|
2022-04-27 19:10:44 +02:00
|
|
|
for (auto &gFileInfo : fileInfos) {
|
|
|
|
if (gFileInfo->lowerTitleID == inputPtrAsU32[1]) {
|
|
|
|
memcpy(&titles[0], &(gFileInfo->titleInfo), sizeof(MCPTitleListType));
|
2021-04-17 00:03:24 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2022-04-17 21:56:14 +02:00
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to find lower TID %08X", inputPtrAsU32[1]);
|
2021-04-17 00:03:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t result = real_MCPGetTitleInternal(mcp_handle, input, type, titles, out_cnt);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
WUPS_MUST_REPLACE(GetTitleVersionInfo__Q2_2nn4vctlFPQ3_2nn4vctl16TitleVersionInfoULQ3_2nn4Cafe9MediaType, WUPS_LOADER_LIBRARY_NN_VCTL, GetTitleVersionInfo__Q2_2nn4vctlFPQ3_2nn4vctl16TitleVersionInfoULQ3_2nn4Cafe9MediaType);
|
|
|
|
WUPS_MUST_REPLACE(GetUpdateInfo__Q2_2nn4vctlFPQ3_2nn4vctl10UpdateInfoULQ3_2nn4Cafe9MediaType, WUPS_LOADER_LIBRARY_NN_VCTL, GetUpdateInfo__Q2_2nn4vctlFPQ3_2nn4vctl10UpdateInfoULQ3_2nn4Cafe9MediaType);
|
2020-06-17 13:45:15 +02:00
|
|
|
WUPS_MUST_REPLACE(ACPGetApplicationBox, WUPS_LOADER_LIBRARY_NN_ACP, ACPGetApplicationBox);
|
|
|
|
WUPS_MUST_REPLACE(PatchChkStart__3RplFRCQ3_2nn6drmapp8StartArg, WUPS_LOADER_LIBRARY_DRMAPP, PatchChkStart__3RplFRCQ3_2nn6drmapp8StartArg);
|
|
|
|
WUPS_MUST_REPLACE(MCP_RightCheckLaunchable, WUPS_LOADER_LIBRARY_COREINIT, MCP_RightCheckLaunchable);
|
|
|
|
|
|
|
|
WUPS_MUST_REPLACE(MCP_TitleList, WUPS_LOADER_LIBRARY_COREINIT, MCP_TitleList);
|
|
|
|
|
|
|
|
WUPS_MUST_REPLACE(ACPCheckTitleLaunchByTitleListTypeEx, WUPS_LOADER_LIBRARY_NN_ACP, ACPCheckTitleLaunchByTitleListTypeEx);
|
|
|
|
WUPS_MUST_REPLACE(ACPGetTitleMetaXmlByDevice, WUPS_LOADER_LIBRARY_NN_ACP, ACPGetTitleMetaXmlByDevice);
|
|
|
|
WUPS_MUST_REPLACE(ACPGetLaunchMetaXml, WUPS_LOADER_LIBRARY_NN_ACP, ACPGetLaunchMetaXml);
|
|
|
|
WUPS_MUST_REPLACE(ACPGetTitleMetaDirByDevice, WUPS_LOADER_LIBRARY_NN_ACP, ACPGetTitleMetaDirByDevice);
|
|
|
|
WUPS_MUST_REPLACE(_SYSLaunchTitleByPathFromLauncher, WUPS_LOADER_LIBRARY_SYSAPP, _SYSLaunchTitleByPathFromLauncher);
|
2020-06-17 22:15:45 +02:00
|
|
|
WUPS_MUST_REPLACE(ACPGetLaunchMetaData, WUPS_LOADER_LIBRARY_NN_ACP, ACPGetLaunchMetaData);
|
2021-01-01 01:50:00 +01:00
|
|
|
|
|
|
|
WUPS_MUST_REPLACE(FSReadFile, WUPS_LOADER_LIBRARY_COREINIT, FSReadFile);
|
|
|
|
WUPS_MUST_REPLACE(FSOpenFile, WUPS_LOADER_LIBRARY_COREINIT, FSOpenFile);
|
|
|
|
WUPS_MUST_REPLACE(FSCloseFile, WUPS_LOADER_LIBRARY_COREINIT, FSCloseFile);
|
2021-04-17 00:03:24 +02:00
|
|
|
|
|
|
|
WUPS_MUST_REPLACE_PHYSICAL(MCPGetTitleInternal, (0x3001C400 + 0x0205a590), (0x0205a590 - 0xFE3C00));
|