From be66aa76cf67b3cc73909aa869fc2cca793954cf Mon Sep 17 00:00:00 2001 From: 0verjoY <59394546+0verjoY@users.noreply.github.com> Date: Fri, 3 Mar 2023 18:54:53 +0100 Subject: [PATCH] - Fixed not able to select a source device - The device select menu will now report info about the system: - IOS # and version currently loaded - Sysmenu version and region - AHB access - Whether Priiloader is installed or not - Unmount source devices and disconnect controls before launching another application Note: This version will work fine with orignal untweaked sysmenu's, but will likely cause problems if things like version #'s are tweaked. This is WIP and will be solved soon --- .gitignore | 4 ---- source/menu.c | 20 ++++++++++++++-- source/wad-manager.c | 3 --- source/wad.c | 55 +++++++++++++++++++++++--------------------- source/wad.h | 4 +++- 5 files changed, 50 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index 232473e..77d7fca 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,4 @@ .vscode/ build/ source/boot/build/ -/yawmME.zip /wiiload -/yawmMEfinB.7z -/yawmME700PM.zip -/yawmME415PM.7z diff --git a/source/menu.c b/source/menu.c index a94f606..834ef28 100644 --- a/source/menu.c +++ b/source/menu.c @@ -323,6 +323,10 @@ void Menu_FatDevice(void) int codePosition = 0; extern bool skipRegionSafetyCheck; + GetSysMenuRegion(&gMenuVersion, &gMenuRegion); + bool havePriiloader = IsPriiloaderInstalled(); + u32 ios = *((u32*)0x80003140); + /* Select source device */ if (gConfig.fatDeviceIndex < 0) { @@ -332,6 +336,12 @@ void Menu_FatDevice(void) Con_Clear(); bool deviceOk = (FatGetDeviceCount() > 0); + printf("\tIOS %d v%d, System menu: %s%c %s\n\n", ((ios >> 16) & 0xFF), (ios & 0xFFFF), + GetSysMenuVersionString(gMenuVersion), gMenuRegion > 0 ? gMenuRegion : ' ', GetSysMenuRegionString(gMenuRegion)); + printf("\tAHB access: %s\n", AHBPROT_DISABLED ? "Yes" : "No"); + printf("\tPriiloader: %s\n\n", havePriiloader ? "Installed" : "Not installed"); + + if (!deviceOk) { printf("\t[+] No source devices found\n\n"); @@ -408,6 +418,8 @@ void Menu_FatDevice(void) printf("[+] Disabled SM region checks\n"); sleep(3); } + + break; } } } @@ -418,7 +430,7 @@ void Menu_FatDevice(void) gSelected = gConfig.fatDeviceIndex; } - printf("[+] Selected source device: %s.", FatGetDeviceName(gSelected)); + printf("[+] Selected source device: %s.\n", FatGetDeviceName(gSelected)); sleep(2); } @@ -893,7 +905,11 @@ void Menu_WadManage(fatFile *file, char *inFilePath) printf("launch dol/elf here \n"); if(LoadApp(inFilePath, file->filename)) + { + FatUnmount(); + Wpad_Disconnect(); LaunchApp(); + } return; } @@ -931,6 +947,7 @@ void Menu_WadList(void) return; } + Con_Clear(); printf("[+] Retrieving file list..."); fflush(stdout); @@ -1356,7 +1373,6 @@ void Menu_Loop(void) /* Retrieve IOS version */ iosVersion = IOS_GetVersion(); - GetSysMenuRegion(&gMenuVersion, &gMenuRegion); ndev = &ndevList[0]; diff --git a/source/wad-manager.c b/source/wad-manager.c index 54377e5..134affb 100644 --- a/source/wad-manager.c +++ b/source/wad-manager.c @@ -212,7 +212,6 @@ int ReadConfigFile(char* configFilePath) char* tmpStr = malloc(MAX_FILE_PATH_LEN); char tmpOutStr[40], path[128]; s32 i; - s32 ret = -1; bool found = false; if (tmpStr == NULL) @@ -230,8 +229,6 @@ int ReadConfigFile(char* configFilePath) if (!found) { - printf(" ERROR! (ret = %d)\n", ret); - // goto err; retval = -1; } else diff --git a/source/wad.c b/source/wad.c index 3f593be..afab6ec 100644 --- a/source/wad.c +++ b/source/wad.c @@ -24,12 +24,12 @@ // Turn upper and lower into a full title ID #define TITLE_LOWER(x) ((u32)(x)) -const char RegionLookupList[16] = +const char RegionLookupTable[16] = { - 'J', 'E', 'P', 0, 0, 0, 'K', 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'J', 'U', 'E', 0, 0, 0, 'K', 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -const u16 versionList[] = +const u16 VersionList[] = { // J E P K @@ -49,6 +49,18 @@ const u16 versionList[] = 512, 513, 514, 518, // 4.3 }; +const char* VersionLookupTable[7][17] = +{ + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 + { "", "", "1.0", "", "2.0", "", "2.2", "3.0", "3.1", "3.2", "", "3.3", "3.4", "4.0", "4.1", "4.2", "4.3", }, + { "", "1.0", "", "2.0", "", "", "2.2", "3.0", "3.1", "3.2", "", "3.3", "3.4", "4.0", "4.1", "4.2", "4.3", }, + { "", "", "1.0", "", "2.0", "2.1", "2.2", "3.0", "3.1", "3.2", "", "3.3", "3.4", "4.0", "4.1", "4.2", "4.3", }, + { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }, + { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }, + { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }, + { "", "", "", "", "", "", "", "", "", "", "3.3", "", "3.5", "", "4.1", "4.2", "4.3", }, +}; + u32 WaitButtons(void); static u32 gPriiloaderSize = 0; static bool gForcedInstall = false; @@ -145,24 +157,29 @@ s32 GetSysMenuRegion(u16* version, char* region) *version = v; if (region) - *region = RegionLookupList[(v & 0x0F)]; + *region = RegionLookupTable[(v & 0x0F)]; return 0; } -const char* GetSysMenuRegionString(const char* region) +const char* GetSysMenuRegionString(const char region) { - switch (*region) + switch (region) { case 'J': return "Japan (NTSC-J)"; - case 'E': return "USA (NTSC-U/C)"; - case 'P': return "Europe (PAL)"; + case 'U': return "USA (NTSC-U/C)"; + case 'E': return "Europe (PAL)"; case 'K': return "Korea (NTSC-K)"; } return "Unknown"; } +const char* GetSysMenuVersionString(u16 version) +{ + return VersionLookupTable[version % 32][version / 32]; +}; + static char* GetTitleExec(u64 tId, bool tweaked) { u32 size; @@ -192,7 +209,7 @@ static char* GetTitleExec(u64 tId, bool tweaked) return path; } -static inline bool IsPriiloaderInstalled() +bool IsPriiloaderInstalled() { char* path = GetTitleExec(0x100000002LL, true); if (!path) @@ -481,10 +498,6 @@ bool skipRegionSafetyCheck = false; s32 Wad_Install(FILE *fp) { - //fseek(fp, 0, SEEK_END); - //s32 wadSize = ftell(fp); - //fseek(fp, 0, SEEK_CUR); - SetPRButtons(false); wadHeader *header = NULL; signed_blob *p_certs = NULL, *p_crl = NULL, *p_tik = NULL, *p_tmd = NULL; @@ -623,9 +636,9 @@ s32 Wad_Install(FILE *fp) } int i, ret = -1; - for(i = 0; i < sizeof(versionList); i++) + for(i = 0; i < sizeof(VersionList); i++) { - if(versionList[i] == tmd_data->title_version) + if(VersionList[i] == tmd_data->title_version) { ret = 1; break; @@ -637,7 +650,7 @@ s32 Wad_Install(FILE *fp) ret = -999; goto err; } - if(region != RegionLookupList[(tmd_data->title_version & 0x0F)]) + if(region != RegionLookupTable[(tmd_data->title_version & 0x0F)]) { printf("\n I won't install the wrong regions SM by default.\n\n"); @@ -723,12 +736,6 @@ skipChecks: /* Fix ticket */ __Wad_FixTicket(p_tik); - //if (!MenuTestDevice()) - //{ - // ret = -996; - // goto err; - //} - printf("\t\t>> Installing ticket..."); fflush(stdout); @@ -781,10 +788,6 @@ skipChecks: if (size > BLOCK_SIZE) size = BLOCK_SIZE; - //if (offset + size > wadSize) - // size = wadSize - offset; - - //printf("\n>> Read Offset: %X (%d) Length: %d/%d", offset, size, idx, len); /* Read data */ ret = FSOPReadOpenFile(fp, &wadBuffer, offset, size); if (ret != 1) diff --git a/source/wad.h b/source/wad.h index 106f33f..c2575c7 100644 --- a/source/wad.h +++ b/source/wad.h @@ -5,6 +5,8 @@ s32 Wad_Install(FILE* fp); s32 Wad_Uninstall(FILE* fp); s32 GetSysMenuRegion(u16* version, char* region); -const char* GetSysMenuRegionString(const char* region); +const char* GetSysMenuRegionString(const char region); +const char* GetSysMenuVersionString(u16 version); +bool IsPriiloaderInstalled(); #endif