-fixed memory leak in download manager

-keep AHBPROT patched out on channel load
-only if no cIOS is found boot a real nand channel with a normal IOS
This commit is contained in:
fix94.1 2012-12-09 20:21:47 +00:00
parent e564058569
commit a8ba1f8e49
7 changed files with 22 additions and 14 deletions

View File

@ -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();
}

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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; };

View File

@ -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()

View File

@ -947,7 +947,7 @@ void CMenu::_launchHomebrew(const char *filepath, vector<string> 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);