diff --git a/source/booter/external_booter.cpp b/source/booter/external_booter.cpp index 343e25bf..6220cdfc 100644 --- a/source/booter/external_booter.cpp +++ b/source/booter/external_booter.cpp @@ -73,7 +73,7 @@ void WiiFlow_ExternalBooter(u8 vidMode, bool vipatch, bool countryString, u8 pat normalCFG.wip_list = get_wip_list(); normalCFG.wip_count = get_wip_count(); - ShutdownBeforeExit(); + ShutdownBeforeExit(BootType == TYPE_CHANNEL); /* Copy CFG into new memory region */ memcpy(BooterConfig, &normalCFG, sizeof(the_CFG)); DCFlushRange(BooterConfig, sizeof(the_CFG)); @@ -103,9 +103,9 @@ void ExternalBooter_ChannelSetup(u64 title) memcpy(&normalCFG.title, &title, sizeof(u64)); } -void ShutdownBeforeExit() +void ShutdownBeforeExit(bool KeepPatches) { DeviceHandle.UnMountAll(); - NandHandle.DeInit_ISFS(); + NandHandle.DeInit_ISFS(KeepPatches); WDVD_Close(); } diff --git a/source/booter/external_booter.hpp b/source/booter/external_booter.hpp index 34604894..8ace2c97 100644 --- a/source/booter/external_booter.hpp +++ b/source/booter/external_booter.hpp @@ -32,6 +32,6 @@ void WiiFlow_ExternalBooter(u8 vidMode, bool vipatch, bool countryString, u8 pat int aspectRatio, u32 returnTo, u8 BootType); void ExternalBooter_ChannelSetup(u64 title); void ExternalBooter_WiiGameSetup(bool wbfs, bool dvd, const char *ID); -void ShutdownBeforeExit(); +void ShutdownBeforeExit(bool KeepPatches = false); #endif diff --git a/source/channel/channel_launcher.cpp b/source/channel/channel_launcher.cpp index 1c4a048f..edb9269a 100644 --- a/source/channel/channel_launcher.cpp +++ b/source/channel/channel_launcher.cpp @@ -11,6 +11,7 @@ #include "loader/fs.h" #include "loader/fst.h" #include "loader/utils.h" +#include "loader/sys.h" #include "memory/mem2.hpp" #include "memory/memory.h" #include "unzip/lz77.h" @@ -105,7 +106,7 @@ bool Identify(u64 titleid) break; } } - gprintf("Key ID: %u\n", keyId); + gprintf("AHBPROT: %d, Key ID: %u\n", AHBRPOT_Patched(), keyId); free(tmdBuffer); free(tikBuffer); free(certBuffer); diff --git a/source/channel/nand.cpp b/source/channel/nand.cpp index e32ebb8c..34aa2291 100644 --- a/source/channel/nand.cpp +++ b/source/channel/nand.cpp @@ -1073,11 +1073,11 @@ void Nand::Init_ISFS() } } -void Nand::DeInit_ISFS() +void Nand::DeInit_ISFS(bool KeepPatches) { gprintf("Deinit ISFS\n"); ISFS_Deinitialize(); - if(AccessPatched) + if(AccessPatched && !KeepPatches) { Disable_ISFS_Patches(); AccessPatched = false; diff --git a/source/channel/nand.hpp b/source/channel/nand.hpp index 4f5b4757..1c429313 100644 --- a/source/channel/nand.hpp +++ b/source/channel/nand.hpp @@ -69,7 +69,7 @@ public: void Patch_AHB(); void Init_ISFS(); - void DeInit_ISFS(); + void DeInit_ISFS(bool KeepPatches = false); const char * Get_NandPath(void) { return NandPath; }; u32 Get_Partition(void) { return Partition; }; diff --git a/source/menu/menu_download.cpp b/source/menu/menu_download.cpp index 4297ecac..089cb681 100644 --- a/source/menu/menu_download.cpp +++ b/source/menu/menu_download.cpp @@ -349,8 +349,10 @@ int CMenu::_coverDownloaderMissing(CMenu *m) static bool checkPNGBuf(u8 *data) { - PNGUPROP imgProp; + if(data == NULL) + return false; + PNGUPROP imgProp; IMGCTX ctx = PNGU_SelectImageFromBuffer(data); if (ctx == NULL) return false; @@ -363,18 +365,22 @@ static bool checkPNGFile(const char *filename) { u8 *buffer = NULL; FILE *file = fopen(filename, "rb"); - if (file == NULL) return false; + if(file == NULL) + return false; fseek(file, 0, SEEK_END); - long fileSize = ftell(file); + u32 fileSize = ftell(file); fseek(file, 0, SEEK_SET); - if (fileSize > 0) + if(fileSize > 0) { buffer = (u8*)MEM2_alloc(fileSize); if(buffer != NULL) fread(buffer, 1, fileSize, file); } fclose(file); - return buffer == NULL ? false : checkPNGBuf(buffer); + bool ret = checkPNGBuf(buffer); + if(buffer != NULL) + MEM2_free(buffer); + return ret; } void CMenu::_initAsyncNetwork() diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index b6d1192e..e3f73b89 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -947,7 +947,7 @@ void CMenu::_launchHomebrew(const char *filepath, vector arguments) int CMenu::_loadIOS(u8 gameIOS, int userIOS, string id, bool RealNAND_Channels) { gprintf("Game ID# %s requested IOS %d. User selected %d\n", id.c_str(), gameIOS, userIOS); - if(neek2o() || RealNAND_Channels) + if(neek2o() || (RealNAND_Channels && IOS_GetType(mainIOS) == IOS_TYPE_STUB)) { if(!loadIOS(gameIOS, false)) { @@ -1132,6 +1132,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr) setLanguage(language); ocarina_load_code(cheatFile, cheatSize); Patch_Channel_Boot(); /* Patch for everything */ + NandHandle.Patch_AHB(); /* Identify may takes it */ Identify(gameTitle); ExternalBooter_ChannelSetup(gameTitle); WiiFlow_ExternalBooter(videoMode, vipatch, countryPatch, patchVidMode, aspectRatio, 0, TYPE_CHANNEL);