mirror of
https://github.com/wiiu-env/homebrew_on_menu_plugin.git
synced 2024-11-25 20:06:53 +01:00
Only read the files only once, check for .whb instead of .wuhb files
This commit is contained in:
parent
94da9549d3
commit
037a170925
101
src/main.cpp
101
src/main.cpp
@ -39,13 +39,15 @@ WUPS_PLUGIN_LICENSE("GPL");
|
|||||||
|
|
||||||
char gIconCache[65580] __attribute__((section(".data")));
|
char gIconCache[65580] __attribute__((section(".data")));
|
||||||
ACPMetaXml gLaunchXML __attribute__((section(".data")));
|
ACPMetaXml gLaunchXML __attribute__((section(".data")));
|
||||||
MCPTitleListType template_title __attribute__((section(".data")));
|
MCPTitleListType current_launched_title_info __attribute__((section(".data")));
|
||||||
BOOL gHomebrewLaunched __attribute__((section(".data")));
|
BOOL gHomebrewLaunched __attribute__((section(".data")));
|
||||||
|
|
||||||
|
void readCustomTitlesFromSD();
|
||||||
|
|
||||||
WUPS_USE_WUT_CRT()
|
WUPS_USE_WUT_CRT()
|
||||||
|
|
||||||
INITIALIZE_PLUGIN() {
|
INITIALIZE_PLUGIN() {
|
||||||
memset((void *) &template_title, 0, sizeof(template_title));
|
memset((void *) ¤t_launched_title_info, 0, sizeof(current_launched_title_info));
|
||||||
memset((void *) &gLaunchXML, 0, sizeof(gLaunchXML));
|
memset((void *) &gLaunchXML, 0, sizeof(gLaunchXML));
|
||||||
memset((void *) &gFileInfos, 0, sizeof(gFileInfos));
|
memset((void *) &gFileInfos, 0, sizeof(gFileInfos));
|
||||||
memset((void *) &gFileReadInformation, 0, sizeof(gFileReadInformation));
|
memset((void *) &gFileReadInformation, 0, sizeof(gFileReadInformation));
|
||||||
@ -53,10 +55,15 @@ INITIALIZE_PLUGIN() {
|
|||||||
gHomebrewLaunched = FALSE;
|
gHomebrewLaunched = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ON_APPLICATION_START(args) {
|
ON_APPLICATION_START(args) {
|
||||||
WHBLogUdpInit();
|
WHBLogUdpInit();
|
||||||
|
|
||||||
|
if (OSGetTitleID() == 0x0005001010040000L || // Wii U Menu JPN
|
||||||
|
OSGetTitleID() == 0x0005001010040100L || // Wii U Menu USA
|
||||||
|
OSGetTitleID() == 0x0005001010040200L) { // Wii U Menu ERU
|
||||||
|
readCustomTitlesFromSD();
|
||||||
|
}
|
||||||
|
|
||||||
if (_SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY) != OSGetTitleID()) {
|
if (_SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY) != OSGetTitleID()) {
|
||||||
DEBUG_FUNCTION_LINE("gHomebrewLaunched to FALSE");
|
DEBUG_FUNCTION_LINE("gHomebrewLaunched to FALSE");
|
||||||
gHomebrewLaunched = FALSE;
|
gHomebrewLaunched = FALSE;
|
||||||
@ -113,11 +120,12 @@ unsigned int hash(char *str) {
|
|||||||
return h; // or, h % ARRAY_SIZE;
|
return h; // or, h % ARRAY_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DECL_FUNCTION(int32_t, MCP_TitleList, uint32_t handle, uint32_t *outTitleCount, MCPTitleListType *titleList, uint32_t size) {
|
void readCustomTitlesFromSD() {
|
||||||
int32_t result = real_MCP_TitleList(handle, outTitleCount, titleList, size);
|
// Reset current infos
|
||||||
uint32_t titlecount = *outTitleCount;
|
unmountAllRomfs();
|
||||||
|
memset((void *) &gFileInfos, 0, sizeof(gFileInfos));
|
||||||
|
|
||||||
DirList dirList("fs:/vol/external01/wiiu/apps", ".rpx,.wbf", DirList::Files | DirList::CheckSubfolders, 1);
|
DirList dirList("fs:/vol/external01/wiiu/apps", ".rpx,.wuhb", DirList::Files | DirList::CheckSubfolders, 1);
|
||||||
dirList.SortList();
|
dirList.SortList();
|
||||||
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
@ -126,12 +134,14 @@ DECL_FUNCTION(int32_t, MCP_TitleList, uint32_t handle, uint32_t *outTitleCount,
|
|||||||
DEBUG_FUNCTION_LINE("TOO MANY TITLES");
|
DEBUG_FUNCTION_LINE("TOO MANY TITLES");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//! skip our own application in the listing
|
|
||||||
if (strcasecmp(dirList.GetFilename(i), "homebrew_launcher.rpx") == 0) {
|
//! skip wiiload temp files
|
||||||
|
if (strcasecmp(dirList.GetFilename(i), "temp.rpx") == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//! skip our own application in the listing
|
|
||||||
if (strcasecmp(dirList.GetFilename(i), "temp.rpx") == 0) {
|
//! skip wiiload temp files
|
||||||
|
if (strcasecmp(dirList.GetFilename(i), "temp.wuhb") == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,28 +155,30 @@ DECL_FUNCTION(int32_t, MCP_TitleList, uint32_t handle, uint32_t *outTitleCount,
|
|||||||
char *input = (char *) dirList.GetFilepath(i);
|
char *input = (char *) dirList.GetFilepath(i);
|
||||||
|
|
||||||
char *path = StringTools::str_replace(input, repl, with);
|
char *path = StringTools::str_replace(input, repl, with);
|
||||||
if (path != NULL) {
|
if (path != nullptr) {
|
||||||
strncpy(gFileInfos[j].path, path, 255);
|
strncpy(gFileInfos[j].path, path, 255);
|
||||||
free(path);
|
free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
gFileInfos[j].lowerTitleID = hash(gFileInfos[j].path);
|
gFileInfos[j].lowerTitleID = hash(gFileInfos[j].path);
|
||||||
|
|
||||||
|
MCPTitleListType *cur_title_info = &(gFileInfos[j].titleInfo);
|
||||||
|
|
||||||
char buffer[25];
|
char buffer[25];
|
||||||
snprintf(buffer, 25, "/custom/%08X%08X", UPPER_TITLE_ID_HOMEBREW, gFileInfos[j].lowerTitleID);
|
snprintf(buffer, 25, "/custom/%08X%08X", UPPER_TITLE_ID_HOMEBREW, gFileInfos[j].lowerTitleID);
|
||||||
strcpy(template_title.path, buffer);
|
strcpy(cur_title_info->path, buffer);
|
||||||
|
|
||||||
strncpy(gFileInfos[j].name, dirList.GetFilename(i), 255);
|
strncpy(gFileInfos[j].name, dirList.GetFilename(i), 255);
|
||||||
gFileInfos[j].source = 0; //SD Card;
|
gFileInfos[j].source = 0; //SD Card;
|
||||||
|
|
||||||
const char *indexedDevice = "mlc";
|
const char *indexedDevice = "mlc";
|
||||||
strcpy(template_title.indexedDevice, indexedDevice);
|
strcpy(cur_title_info->indexedDevice, indexedDevice);
|
||||||
|
|
||||||
// System apps don't have a splash screen.
|
// System apps don't have a splash screen.
|
||||||
template_title.appType = MCP_APP_TYPE_SYSTEM_APPS;
|
cur_title_info->appType = MCP_APP_TYPE_SYSTEM_APPS;
|
||||||
|
|
||||||
// Check if the have bootTvTex and bootDrcTex that could be shown.
|
// Check if the have bootTvTex and bootDrcTex that could be shown.
|
||||||
if (StringTools::EndsWith(gFileInfos[j].name, ".wbf")) {
|
if (StringTools::EndsWith(gFileInfos[j].name, ".wuhb")) {
|
||||||
if (romfsMount("romfscheck", dirList.GetFilepath(i), RomfsSource_FileDescriptor) == 0) {
|
if (romfsMount("romfscheck", dirList.GetFilepath(i), RomfsSource_FileDescriptor) == 0) {
|
||||||
bool foundSplashScreens = true;
|
bool foundSplashScreens = true;
|
||||||
if (!FSUtils::CheckFile("romfscheck:/meta/bootTvTex.tga") && !FSUtils::CheckFile("romfscheck:/meta/bootTvTex.tga.gz")) {
|
if (!FSUtils::CheckFile("romfscheck:/meta/bootTvTex.tga") && !FSUtils::CheckFile("romfscheck:/meta/bootTvTex.tga.gz")) {
|
||||||
@ -178,7 +190,7 @@ DECL_FUNCTION(int32_t, MCP_TitleList, uint32_t handle, uint32_t *outTitleCount,
|
|||||||
if (foundSplashScreens) {
|
if (foundSplashScreens) {
|
||||||
DEBUG_FUNCTION_LINE("Show splash screens");
|
DEBUG_FUNCTION_LINE("Show splash screens");
|
||||||
// Show splash screens
|
// Show splash screens
|
||||||
template_title.appType = MCP_APP_TYPE_GAME;
|
cur_title_info->appType = MCP_APP_TYPE_GAME;
|
||||||
}
|
}
|
||||||
romfsUnmount("romfscheck");
|
romfsUnmount("romfscheck");
|
||||||
} else {
|
} else {
|
||||||
@ -186,21 +198,31 @@ DECL_FUNCTION(int32_t, MCP_TitleList, uint32_t handle, uint32_t *outTitleCount,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template_title.titleId = TITLE_ID_HOMEBREW_MASK | gFileInfos[j].lowerTitleID;
|
cur_title_info->titleId = TITLE_ID_HOMEBREW_MASK | gFileInfos[j].lowerTitleID;
|
||||||
template_title.titleVersion = 1;
|
cur_title_info->titleVersion = 1;
|
||||||
template_title.groupId = 0x400;
|
cur_title_info->groupId = 0x400;
|
||||||
|
|
||||||
template_title.osVersion = OSGetOSID();
|
cur_title_info->osVersion = OSGetOSID();
|
||||||
template_title.sdkVersion = __OSGetProcessSDKVersion();
|
cur_title_info->sdkVersion = __OSGetProcessSDKVersion();
|
||||||
template_title.unk0x60 = 0;
|
cur_title_info->unk0x60 = 0;
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("[%d] %s [%016llX]", j, gFileInfos[j].path, template_title.titleId);
|
DEBUG_FUNCTION_LINE("[%d] %s [%016llX]", j, gFileInfos[j].path, cur_title_info->titleId);
|
||||||
|
|
||||||
memcpy(&(titleList[titlecount]), &template_title, sizeof(template_title));
|
|
||||||
|
|
||||||
titlecount++;
|
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DECL_FUNCTION(int32_t, MCP_TitleList, uint32_t handle, uint32_t *outTitleCount, MCPTitleListType *titleList, uint32_t size) {
|
||||||
|
int32_t result = real_MCP_TitleList(handle, outTitleCount, titleList, size);
|
||||||
|
uint32_t titlecount = *outTitleCount;
|
||||||
|
|
||||||
|
for (auto &gFileInfo : gFileInfos) {
|
||||||
|
if (gFileInfo.lowerTitleID == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
memcpy(&(titleList[titlecount]), &(gFileInfo.titleInfo), sizeof(gFileInfo.titleInfo));
|
||||||
|
titlecount++;
|
||||||
|
}
|
||||||
|
|
||||||
*outTitleCount = titlecount;
|
*outTitleCount = titlecount;
|
||||||
|
|
||||||
@ -208,16 +230,15 @@ DECL_FUNCTION(int32_t, MCP_TitleList, uint32_t handle, uint32_t *outTitleCount,
|
|||||||
}
|
}
|
||||||
|
|
||||||
DECL_FUNCTION(int32_t, MCP_GetTitleInfoByTitleAndDevice, uint32_t mcp_handle, uint32_t titleid_lower_1, uint32_t titleid_upper, uint32_t titleid_lower_2, uint32_t unknown, MCPTitleListType *title) {
|
DECL_FUNCTION(int32_t, MCP_GetTitleInfoByTitleAndDevice, uint32_t mcp_handle, uint32_t titleid_lower_1, uint32_t titleid_upper, uint32_t titleid_lower_2, uint32_t unknown, MCPTitleListType *title) {
|
||||||
if (gHomebrewLaunched) {
|
if (titleid_upper == UPPER_TITLE_ID_HOMEBREW) {
|
||||||
memcpy(title, &(template_title), sizeof(MCPTitleListType));
|
DEBUG_FUNCTION_LINE("%08X %08X", titleid_lower_1, titleid_lower_2);
|
||||||
} else if (titleid_upper == UPPER_TITLE_ID_HOMEBREW) {
|
for (auto &gFileInfo : gFileInfos) {
|
||||||
char buffer[25];
|
if (gFileInfo.lowerTitleID == titleid_lower_2) {
|
||||||
snprintf(buffer, 25, "/custom/%08X%08X", titleid_upper, titleid_lower_2);
|
memcpy(title, &(gFileInfo.titleInfo), sizeof(MCPTitleListType));
|
||||||
strcpy(template_title.path, buffer);
|
|
||||||
template_title.titleId = TITLE_ID_HOMEBREW_MASK | titleid_lower_1;
|
|
||||||
memcpy(title, &(template_title), sizeof(MCPTitleListType));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
int result = real_MCP_GetTitleInfoByTitleAndDevice(mcp_handle, titleid_lower_1, titleid_upper, titleid_lower_2, unknown, title);
|
int result = real_MCP_GetTitleInfoByTitleAndDevice(mcp_handle, titleid_lower_1, titleid_upper, titleid_lower_2, unknown, title);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -232,17 +253,15 @@ DECL_FUNCTION(int32_t, ACPCheckTitleLaunchByTitleListTypeEx, MCPTitleListType *t
|
|||||||
|
|
||||||
OSDynLoad_Error dyn_res = OSDynLoad_Acquire("homebrew_rpx_loader", &module);
|
OSDynLoad_Error dyn_res = OSDynLoad_Acquire("homebrew_rpx_loader", &module);
|
||||||
if (dyn_res != OS_DYNLOAD_OK) {
|
if (dyn_res != OS_DYNLOAD_OK) {
|
||||||
OSFatal("Failed to acquire homebrew_rpx_loader");
|
OSFatal("Missing RPXLoader module");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool (*loadRPXFromSDOnNextLaunch)(const std::string &path);
|
bool (*loadRPXFromSDOnNextLaunch)(const std::string &path);
|
||||||
dyn_res = OSDynLoad_FindExport(module, false, "loadRPXFromSDOnNextLaunch", reinterpret_cast<void **>(&loadRPXFromSDOnNextLaunch));
|
dyn_res = OSDynLoad_FindExport(module, false, "loadRPXFromSDOnNextLaunch", reinterpret_cast<void **>(&loadRPXFromSDOnNextLaunch));
|
||||||
if (dyn_res != OS_DYNLOAD_OK) {
|
if (dyn_res != OS_DYNLOAD_OK) {
|
||||||
OSFatal("Failed to find export loadRPXFromSDOnNextLaunch");
|
OSFatal("Failed to find export loadRPXFromSDOnNextLaunch");
|
||||||
}
|
}
|
||||||
|
|
||||||
gHomebrewLaunched = TRUE;
|
|
||||||
fillXmlForTitleID((title->titleId & 0xFFFFFFFF00000000) >> 32, (title->titleId & 0xFFFFFFFF), &gLaunchXML);
|
fillXmlForTitleID((title->titleId & 0xFFFFFFFF00000000) >> 32, (title->titleId & 0xFFFFFFFF), &gLaunchXML);
|
||||||
|
|
||||||
romfs_fileInfo info;
|
romfs_fileInfo info;
|
||||||
@ -251,9 +270,9 @@ DECL_FUNCTION(int32_t, ACPCheckTitleLaunchByTitleListTypeEx, MCPTitleListType *t
|
|||||||
loadFileIntoBuffer((title->titleId & 0xFFFFFFFF), "meta/iconTex.tga", gIconCache, sizeof(gIconCache));
|
loadFileIntoBuffer((title->titleId & 0xFFFFFFFF), "meta/iconTex.tga", gIconCache, sizeof(gIconCache));
|
||||||
}
|
}
|
||||||
|
|
||||||
unmountRomfs(id);
|
gHomebrewLaunched = TRUE;
|
||||||
|
|
||||||
loadRPXFromSDOnNextLaunch(gFileInfos[id].path);
|
loadRPXFromSDOnNextLaunch(gFileInfos[id].path);
|
||||||
mountRomfs(id);
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
DEBUG_FUNCTION_LINE("Failed to get the id for titleID %016llX", title->titleId);
|
DEBUG_FUNCTION_LINE("Failed to get the id for titleID %016llX", title->titleId);
|
||||||
@ -385,7 +404,7 @@ DECL_FUNCTION(int32_t, ACPGetTitleMetaDirByDevice, uint32_t titleid_upper, uint3
|
|||||||
DECL_FUNCTION(int32_t, _SYSLaunchTitleByPathFromLauncher, char *pathToLoad, uint32_t u2) {
|
DECL_FUNCTION(int32_t, _SYSLaunchTitleByPathFromLauncher, char *pathToLoad, uint32_t u2) {
|
||||||
const char *start = "/custom/";
|
const char *start = "/custom/";
|
||||||
if (strncmp(pathToLoad, start, strlen(start)) == 0) {
|
if (strncmp(pathToLoad, start, strlen(start)) == 0) {
|
||||||
strcpy(template_title.path, pathToLoad);
|
strcpy(current_launched_title_info.path, pathToLoad);
|
||||||
uint64_t titleID = _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY);
|
uint64_t titleID = _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY);
|
||||||
snprintf(pathToLoad, 47, "/vol/storage_mlc01/sys/title/%08x/%08x", (uint32_t) (titleID >> 32), (uint32_t) (0x00000000FFFFFFFF & titleID));
|
snprintf(pathToLoad, 47, "/vol/storage_mlc01/sys/title/%08x/%08x", (uint32_t) (titleID >> 32), (uint32_t) (0x00000000FFFFFFFF & titleID));
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <coreinit/mcp.h>
|
||||||
|
|
||||||
#include <romfs_dev.h>
|
#include <romfs_dev.h>
|
||||||
|
|
||||||
@ -10,6 +11,7 @@ typedef struct WUT_PACKED FileInfos_ {
|
|||||||
uint32_t lowerTitleID;
|
uint32_t lowerTitleID;
|
||||||
bool romfsMounted;
|
bool romfsMounted;
|
||||||
int openedFiles;
|
int openedFiles;
|
||||||
|
MCPTitleListType titleInfo;
|
||||||
} FileInfos;
|
} FileInfos;
|
||||||
|
|
||||||
#define FILE_INFO_SIZE 300
|
#define FILE_INFO_SIZE 300
|
||||||
|
Loading…
Reference in New Issue
Block a user