-fixed booting big homebrew applications (32MB max, but

only tested with 7MB so not sure if so much still works)
This commit is contained in:
fix94.1 2012-04-06 10:16:01 +00:00
parent 3153ef3d2e
commit 091e9bcb1e

View File

@ -30,7 +30,8 @@ bool IsDollZ (u8 *buff)
int dollz_offs = 0x100;
int ret = memcmp (&buff[dollz_offs], dollz_stamp, sizeof(dollz_stamp));
if (ret == 0) return true;
if (ret == 0)
return true;
return false;
}
@ -46,7 +47,6 @@ int CopyHomebrewMemory(u8 *temp, u32 pos, u32 len)
homebrewsize += len;
memcpy(homebrewbuffer+pos, temp, len);
DCFlushRange(homebrewbuffer+pos, len);
return 1;
}
@ -60,23 +60,21 @@ void FreeHomebrewBuffer()
int LoadHomebrew(const char * filepath)
{
if(!filepath) return -1;
if(!filepath)
return -1;
FILE *file = fopen(filepath ,"rb");
if(!file) return -2;
if(!file)
return -2;
fseek(file, 0, SEEK_END);
u32 filesize = ftell(file);
rewind(file);
SmartBuf buffer = smartAnyAlloc(filesize);
if (!buffer)
{
SAFE_CLOSE(file);
if(filesize > 33554431)
return -3;
}
bool good_read = fread((u8 *)buffer.get(), 1, filesize, file) == filesize;
bool good_read = fread(homebrewbuffer, 1, filesize, file) == filesize;
if (!good_read)
{
SAFE_CLOSE(file);
@ -84,14 +82,14 @@ int LoadHomebrew(const char * filepath)
}
SAFE_CLOSE(file);
DCFlushRange((u8 *)buffer.get(), filesize);
return CopyHomebrewMemory((u8*)buffer.get(), 0, filesize);
homebrewsize += filesize;
return 1;
}
static int SetupARGV(struct __argv * args)
{
if(!args) return -1;
if(!args)
return -1;
bzero(args, sizeof(struct __argv));
args->argvMagic = ARGV_MAGIC;
@ -129,7 +127,8 @@ static int SetupARGV(struct __argv * args)
int BootHomebrew()
{
if(homebrewsize == 0) return -1;
if(homebrewsize == 0)
return -1;
struct __argv args;
if (!IsDollZ(homebrewbuffer))