mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-27 13:44:15 +01:00
-all free should be safe now :P
This commit is contained in:
parent
04c4025766
commit
7e453d5b97
@ -566,9 +566,8 @@ unsigned char * MD5fromFile(unsigned char *dst, const char *src)
|
|||||||
else
|
else
|
||||||
blksize = 1048576;
|
blksize = 1048576;
|
||||||
|
|
||||||
unsigned char * buffer = MEM2_alloc(blksize);
|
unsigned char * buffer = MEM2_alloc(blksize);
|
||||||
|
if(buffer == NULL)
|
||||||
if(!!buffer)
|
|
||||||
{
|
{
|
||||||
//no memory
|
//no memory
|
||||||
fclose(file);
|
fclose(file);
|
||||||
@ -579,7 +578,6 @@ unsigned char * MD5fromFile(unsigned char *dst, const char *src)
|
|||||||
{
|
{
|
||||||
read = fread(buffer, 1, blksize, file);
|
read = fread(buffer, 1, blksize, file);
|
||||||
(void)auth_md5SumCtx( ctx, buffer, read ); /* Pass only one block. */
|
(void)auth_md5SumCtx( ctx, buffer, read ); /* Pass only one block. */
|
||||||
|
|
||||||
} while(read > 0);
|
} while(read > 0);
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
@ -82,7 +82,8 @@ Banner::Banner(u8 *bnr, u64 title)
|
|||||||
|
|
||||||
Banner::~Banner()
|
Banner::~Banner()
|
||||||
{
|
{
|
||||||
MEM2_free(opening);
|
if(opening != NULL)
|
||||||
|
MEM2_free(opening);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Banner::IsValid()
|
bool Banner::IsValid()
|
||||||
@ -152,10 +153,11 @@ Banner * Banner::GetBanner(u64 title, char *appname, bool isfs, bool imetOnly)
|
|||||||
{
|
{
|
||||||
u32 size = 0;
|
u32 size = 0;
|
||||||
|
|
||||||
buf = ISFS_GetFile((u8 *) appname, &size, imetOnly ? sizeof(IMET) + IMET_OFFSET : 0);
|
buf = ISFS_GetFile((u8 *)appname, &size, imetOnly ? sizeof(IMET) + IMET_OFFSET : 0);
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
{
|
{
|
||||||
free(buf);
|
if(buf != NULL)
|
||||||
|
MEM2_free(buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,12 +173,14 @@ Banner * Banner::GetBanner(u64 title, char *appname, bool isfs, bool imetOnly)
|
|||||||
size = ftell(fp);
|
size = ftell(fp);
|
||||||
fseek(fp, 0, SEEK_SET);
|
fseek(fp, 0, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = MEM2_alloc(size);
|
buf = MEM2_alloc(size);
|
||||||
|
if(!buf)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
fread(buf, size, 1, fp);
|
fread(buf, size, 1, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Banner((u8 *)buf, title);
|
return new Banner((u8 *)buf, title);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ s32 BootChannel(u8 *data, u64 chantitle, u8 vidMode, bool vipatch, bool countryS
|
|||||||
Identify(chantitle, &ios);
|
Identify(chantitle, &ios);
|
||||||
|
|
||||||
entryPoint = LoadChannel(data);
|
entryPoint = LoadChannel(data);
|
||||||
free(data);
|
MEM2_free(data);
|
||||||
|
|
||||||
/* Select an appropriate video mode */
|
/* Select an appropriate video mode */
|
||||||
GXRModeObj * vmode = __Disc_SelectVMode(vidMode, chantitle);
|
GXRModeObj * vmode = __Disc_SelectVMode(vidMode, chantitle);
|
||||||
@ -243,8 +243,8 @@ bool Identify(u64 titleid, u32 *ios)
|
|||||||
if (certBuffer == NULL || certSize == 0)
|
if (certBuffer == NULL || certSize == 0)
|
||||||
{
|
{
|
||||||
gprintf("Reading certs...Failed!\n");
|
gprintf("Reading certs...Failed!\n");
|
||||||
free(tmdBuffer);
|
MEM2_free(tmdBuffer);
|
||||||
free(tikBuffer);
|
MEM2_free(tikBuffer);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,9 +271,9 @@ bool Identify(u64 titleid, u32 *ios)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(tmdBuffer);
|
MEM2_free(tmdBuffer);
|
||||||
free(tikBuffer);
|
MEM2_free(tikBuffer);
|
||||||
free(certBuffer);
|
MEM2_free(certBuffer);
|
||||||
|
|
||||||
return ret < 0 ? false : true;
|
return ret < 0 ? false : true;
|
||||||
}
|
}
|
||||||
@ -297,10 +297,10 @@ u8 * GetDol(u64 title, u32 bootcontent)
|
|||||||
if (decompressLZ77content(data, contentSize, &decompressed, &size) < 0)
|
if (decompressLZ77content(data, contentSize, &decompressed, &size) < 0)
|
||||||
{
|
{
|
||||||
gprintf("Decompression failed\n");
|
gprintf("Decompression failed\n");
|
||||||
free(data);
|
MEM2_free(data);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
free(data);
|
MEM2_free(data);
|
||||||
data = decompressed;
|
data = decompressed;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
|
@ -92,12 +92,14 @@ u8 Channels::GetRequestedIOS(u64 title)
|
|||||||
sprintf(tmd, "/title/%08x/%08x/content/title.tmd", TITLE_UPPER(title), TITLE_LOWER(title));
|
sprintf(tmd, "/title/%08x/%08x/content/title.tmd", TITLE_UPPER(title), TITLE_LOWER(title));
|
||||||
|
|
||||||
u32 size;
|
u32 size;
|
||||||
u8 *titleTMD = (u8 *) ISFS_GetFile((u8 *) &tmd, &size, -1);
|
u8 *titleTMD = (u8 *)ISFS_GetFile((u8 *) &tmd, &size, -1);
|
||||||
|
if(titleTMD == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if(size > 0x18B)
|
if(size > 0x18B)
|
||||||
IOS = titleTMD[0x18B];
|
IOS = titleTMD[0x18B];
|
||||||
|
|
||||||
free(titleTMD);
|
MEM2_free(titleTMD);
|
||||||
|
|
||||||
return IOS;
|
return IOS;
|
||||||
}
|
}
|
||||||
@ -113,20 +115,18 @@ u64* Channels::GetChannelList(u32* count)
|
|||||||
if (ES_GetNumTitles(&countall) < 0 || !countall) return NULL;
|
if (ES_GetNumTitles(&countall) < 0 || !countall) return NULL;
|
||||||
|
|
||||||
u64* titles = (u64*)MEM2_alloc(countall * sizeof(u64));
|
u64* titles = (u64*)MEM2_alloc(countall * sizeof(u64));
|
||||||
if (!titles) return NULL;
|
if (!titles)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if(ES_GetTitles(titles, countall) < 0)
|
if(ES_GetTitles(titles, countall) < 0)
|
||||||
{
|
{
|
||||||
free(titles);
|
MEM2_free(titles);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64* channels = (u64*)MEM2_alloc(countall * sizeof(u64));
|
u64* channels = (u64*)MEM2_alloc(countall * sizeof(u64));
|
||||||
if (!channels)
|
if (!channels)
|
||||||
{
|
|
||||||
free(titles);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
*count = 0;
|
*count = 0;
|
||||||
for (u32 i = 0; i < countall; i++)
|
for (u32 i = 0; i < countall; i++)
|
||||||
@ -138,13 +138,12 @@ u64* Channels::GetChannelList(u32* count)
|
|||||||
if (TITLE_LOWER(titles[i]) == RF_NEWS_CHANNEL || // skip region free news and forecast channel
|
if (TITLE_LOWER(titles[i]) == RF_NEWS_CHANNEL || // skip region free news and forecast channel
|
||||||
TITLE_LOWER(titles[i]) == RF_FORECAST_CHANNEL)
|
TITLE_LOWER(titles[i]) == RF_FORECAST_CHANNEL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
channels[(*count)++] = titles[i];
|
channels[(*count)++] = titles[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(titles);
|
MEM2_free(titles);
|
||||||
|
|
||||||
return (u64*)MEM2_realloc(channels, *count * sizeof(u64));
|
return(u64*)MEM2_realloc(channels, *count * sizeof(u64));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Channels::GetAppNameFromTmd(u64 title, char* app, bool dol, u32* bootcontent)
|
bool Channels::GetAppNameFromTmd(u64 title, char* app, bool dol, u32* bootcontent)
|
||||||
@ -156,11 +155,13 @@ bool Channels::GetAppNameFromTmd(u64 title, char* app, bool dol, u32* bootconten
|
|||||||
|
|
||||||
u32 size;
|
u32 size;
|
||||||
u8 *data = ISFS_GetFile((u8 *) &tmd, &size, -1);
|
u8 *data = ISFS_GetFile((u8 *) &tmd, &size, -1);
|
||||||
if (data == NULL || size < 0x208) return ret;
|
if (data == NULL || size < 0x208)
|
||||||
|
return ret;
|
||||||
|
|
||||||
_tmd * tmd_file = (_tmd *) SIGNATURE_PAYLOAD((u32 *)data);
|
_tmd *tmd_file = (_tmd *)SIGNATURE_PAYLOAD((u32 *)data);
|
||||||
u16 i;
|
u16 i;
|
||||||
for(i = 0; i < tmd_file->num_contents; ++i)
|
for(i = 0; i < tmd_file->num_contents; ++i)
|
||||||
|
{
|
||||||
if(tmd_file->contents[i].index == (dol ? tmd_file->boot_index : 0))
|
if(tmd_file->contents[i].index == (dol ? tmd_file->boot_index : 0))
|
||||||
{
|
{
|
||||||
*bootcontent = tmd_file->contents[i].cid;
|
*bootcontent = tmd_file->contents[i].cid;
|
||||||
@ -168,8 +169,9 @@ bool Channels::GetAppNameFromTmd(u64 title, char* app, bool dol, u32* bootconten
|
|||||||
ret = true;
|
ret = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
free(data);
|
MEM2_free(data);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -224,7 +226,8 @@ void Channels::Search(u32 channelType, string lang)
|
|||||||
{
|
{
|
||||||
u32 count;
|
u32 count;
|
||||||
u64* list = GetChannelList(&count);
|
u64* list = GetChannelList(&count);
|
||||||
if (!list) return;
|
if (list == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
int language = lang.size() == 0 ? CONF_GetLanguage() : GetLanguage(lang.c_str());
|
int language = lang.size() == 0 ? CONF_GetLanguage() : GetLanguage(lang.c_str());
|
||||||
|
|
||||||
@ -245,7 +248,7 @@ void Channels::Search(u32 channelType, string lang)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(list);
|
MEM2_free(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t * Channels::GetName(int index)
|
wchar_t * Channels::GetName(int index)
|
||||||
|
@ -234,19 +234,27 @@ void Nand::__GetNameList(const char *source, namelist **entries, int *count)
|
|||||||
{
|
{
|
||||||
u32 i, j, k, l;
|
u32 i, j, k, l;
|
||||||
u32 numentries = 0;
|
u32 numentries = 0;
|
||||||
char *names;
|
char *names = NULL;
|
||||||
char curentry[ISFS_MAXPATH];
|
char curentry[ISFS_MAXPATH];
|
||||||
char entrypath[ISFS_MAXPATH];
|
char entrypath[ISFS_MAXPATH];
|
||||||
|
|
||||||
s32 ret = ISFS_ReadDir(source, NULL, &numentries);
|
s32 ret = ISFS_ReadDir(source, NULL, &numentries);
|
||||||
names = (char *)MEM2_alloc((ISFS_MAXPATH) * numentries);
|
names = (char *)MEM2_alloc((ISFS_MAXPATH) * numentries);
|
||||||
|
if(names == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
ret = ISFS_ReadDir(source, names, &numentries);
|
ret = ISFS_ReadDir(source, names, &numentries);
|
||||||
*count = numentries;
|
*count = numentries;
|
||||||
|
|
||||||
if(*entries)
|
if(*entries != NULL)
|
||||||
|
{
|
||||||
MEM2_free(*entries);
|
MEM2_free(*entries);
|
||||||
|
*entries = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
*entries = (namelist *)MEM2_alloc(sizeof(namelist)*numentries);
|
*entries = (namelist *)MEM2_alloc(sizeof(namelist) * numentries);
|
||||||
|
if(*entries == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
for(i = 0, k = 0; i < numentries; i++)
|
for(i = 0, k = 0; i < numentries; i++)
|
||||||
{
|
{
|
||||||
@ -273,6 +281,9 @@ s32 Nand::__configread(void)
|
|||||||
{
|
{
|
||||||
confbuffer = (u8 *)MEM2_alloc(0x4000);
|
confbuffer = (u8 *)MEM2_alloc(0x4000);
|
||||||
txtbuffer = (char *)MEM2_alloc(0x100);
|
txtbuffer = (char *)MEM2_alloc(0x100);
|
||||||
|
if(confbuffer == NULL || txtbuffer == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
cfg_hdr = (config_header *)NULL;
|
cfg_hdr = (config_header *)NULL;
|
||||||
|
|
||||||
FILE *f = fopen(cfgpath, "rb");
|
FILE *f = fopen(cfgpath, "rb");
|
||||||
@ -322,16 +333,16 @@ s32 Nand::__configwrite(void)
|
|||||||
fwrite(txtbuffer, 1, 0x100, f);
|
fwrite(txtbuffer, 1, 0x100, f);
|
||||||
gprintf("setting.txt written to: \"%s\"\n", settxtpath);
|
gprintf("setting.txt written to: \"%s\"\n", settxtpath);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
configloaded = configloaded ? false : true;
|
configloaded = configloaded ? false : true;
|
||||||
|
|
||||||
if(!tbdec && !configloaded)
|
if(!tbdec && !configloaded)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(confbuffer);
|
MEM2_free(confbuffer);
|
||||||
free(txtbuffer);
|
MEM2_free(txtbuffer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 Nand::__configsetbyte(const char *item, u8 val)
|
u32 Nand::__configsetbyte(const char *item, u8 val)
|
||||||
@ -512,6 +523,9 @@ s32 Nand::__FlashNandFile(const char *source, const char *dest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
u8 *buffer = (u8 *)MEM2_alloc(BLOCK);
|
u8 *buffer = (u8 *)MEM2_alloc(BLOCK);
|
||||||
|
if(buffer == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
u32 toread = fsize;
|
u32 toread = fsize;
|
||||||
while(toread > 0)
|
while(toread > 0)
|
||||||
{
|
{
|
||||||
@ -572,6 +586,9 @@ s32 Nand::__DumpNandFile(const char *source, const char *dest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fstats *status = (fstats *)MEM2_alloc(sizeof(fstats));
|
fstats *status = (fstats *)MEM2_alloc(sizeof(fstats));
|
||||||
|
if(status == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
s32 ret = ISFS_GetFileStats(fd, status);
|
s32 ret = ISFS_GetFileStats(fd, status);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -605,6 +622,9 @@ s32 Nand::__DumpNandFile(const char *source, const char *dest)
|
|||||||
gprintf("Dumping: %s (%ukb)...", source, (status->file_length / 0x400)+1);
|
gprintf("Dumping: %s (%ukb)...", source, (status->file_length / 0x400)+1);
|
||||||
|
|
||||||
u8 *buffer = (u8 *)MEM2_alloc(BLOCK);
|
u8 *buffer = (u8 *)MEM2_alloc(BLOCK);
|
||||||
|
if(buffer == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
u32 toread = status->file_length;
|
u32 toread = status->file_length;
|
||||||
while(toread > 0)
|
while(toread > 0)
|
||||||
{
|
{
|
||||||
@ -740,7 +760,7 @@ s32 Nand::__DumpNandFolder(const char *source, const char *dest)
|
|||||||
__DumpNandFolder(nsource, dest);
|
__DumpNandFolder(nsource, dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(names);
|
MEM2_free(names);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -777,9 +797,9 @@ void Nand::CreatePath(const char *path, ...)
|
|||||||
gprintf("Folder \"%s\" exists\n", folder);
|
gprintf("Folder \"%s\" exists\n", folder);
|
||||||
closedir(d);
|
closedir(d);
|
||||||
}
|
}
|
||||||
|
free(folder);
|
||||||
}
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
free(folder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nand::CreateTitleTMD(const char *path, dir_discHdr *hdr)
|
void Nand::CreateTitleTMD(const char *path, dir_discHdr *hdr)
|
||||||
@ -792,7 +812,7 @@ void Nand::CreateTitleTMD(const char *path, dir_discHdr *hdr)
|
|||||||
u32 tmd_size = wbfs_extract_file(disc, (char *) "TMD", (void **)&titleTMD);
|
u32 tmd_size = wbfs_extract_file(disc, (char *) "TMD", (void **)&titleTMD);
|
||||||
WBFS_CloseDisc(disc);
|
WBFS_CloseDisc(disc);
|
||||||
|
|
||||||
if(!titleTMD)
|
if(titleTMD == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
u32 highTID = *(u32*)(titleTMD+0x18c);
|
u32 highTID = *(u32*)(titleTMD+0x18c);
|
||||||
@ -810,7 +830,7 @@ void Nand::CreateTitleTMD(const char *path, dir_discHdr *hdr)
|
|||||||
struct stat filestat;
|
struct stat filestat;
|
||||||
if (stat(nandpath, &filestat) == 0)
|
if (stat(nandpath, &filestat) == 0)
|
||||||
{
|
{
|
||||||
free(titleTMD);
|
MEM2_free(titleTMD);
|
||||||
gprintf("%s Exists!\n", nandpath);
|
gprintf("%s Exists!\n", nandpath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -826,7 +846,7 @@ void Nand::CreateTitleTMD(const char *path, dir_discHdr *hdr)
|
|||||||
else
|
else
|
||||||
gprintf("Creating title TMD: %s failed (%i)\n", nandpath, file);
|
gprintf("Creating title TMD: %s failed (%i)\n", nandpath, file);
|
||||||
|
|
||||||
free(titleTMD);
|
MEM2_free(titleTMD);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 Nand::FlashToNAND(const char *source, const char *dest, dump_callback_t i_dumper, void *i_data)
|
s32 Nand::FlashToNAND(const char *source, const char *dest, dump_callback_t i_dumper, void *i_data)
|
||||||
|
@ -178,7 +178,8 @@ void PartitionHandle::UnMount(int pos)
|
|||||||
int PartitionHandle::FindPartitions()
|
int PartitionHandle::FindPartitions()
|
||||||
{
|
{
|
||||||
MASTER_BOOT_RECORD *mbr = (MASTER_BOOT_RECORD *)MEM2_alloc(MAX_BYTES_PER_SECTOR);
|
MASTER_BOOT_RECORD *mbr = (MASTER_BOOT_RECORD *)MEM2_alloc(MAX_BYTES_PER_SECTOR);
|
||||||
if(!mbr) return -1;
|
if(mbr == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
// Read the first sector on the device
|
// Read the first sector on the device
|
||||||
if(!interface->readSectors(0, 1, mbr))
|
if(!interface->readSectors(0, 1, mbr))
|
||||||
@ -249,6 +250,8 @@ int PartitionHandle::FindPartitions()
|
|||||||
void PartitionHandle::CheckEBR(u8 PartNum, sec_t ebr_lba)
|
void PartitionHandle::CheckEBR(u8 PartNum, sec_t ebr_lba)
|
||||||
{
|
{
|
||||||
EXTENDED_BOOT_RECORD *ebr = (EXTENDED_BOOT_RECORD *)MEM2_alloc(MAX_BYTES_PER_SECTOR);
|
EXTENDED_BOOT_RECORD *ebr = (EXTENDED_BOOT_RECORD *)MEM2_alloc(MAX_BYTES_PER_SECTOR);
|
||||||
|
if(ebr == NULL)
|
||||||
|
return;
|
||||||
sec_t next_erb_lba = 0;
|
sec_t next_erb_lba = 0;
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -293,12 +296,13 @@ void PartitionHandle::CheckEBR(u8 PartNum, sec_t ebr_lba)
|
|||||||
bool PartitionHandle::CheckGPT(void)
|
bool PartitionHandle::CheckGPT(void)
|
||||||
{
|
{
|
||||||
GPT_PARTITION_TABLE *gpt = (GPT_PARTITION_TABLE *)MEM2_alloc(MAX_BYTES_PER_SECTOR);
|
GPT_PARTITION_TABLE *gpt = (GPT_PARTITION_TABLE *)MEM2_alloc(MAX_BYTES_PER_SECTOR);
|
||||||
if(!gpt) return false;
|
if(gpt == NULL)
|
||||||
|
return false;
|
||||||
bool success = false; // To return false unless at least 1 partition is verified
|
bool success = false; // To return false unless at least 1 partition is verified
|
||||||
|
|
||||||
if(!interface->readSectors(1, 33, gpt))
|
if(!interface->readSectors(1, 33, gpt))
|
||||||
{
|
{
|
||||||
free(gpt);
|
MEM2_free(gpt);
|
||||||
return false; // To read all 128 possible partitions
|
return false; // To read all 128 possible partitions
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,14 +314,19 @@ bool PartitionHandle::CheckGPT(void)
|
|||||||
|| (le64(gpt->First_Usable_LBA) != 34)
|
|| (le64(gpt->First_Usable_LBA) != 34)
|
||||||
|| (gpt->Reserved != 0))
|
|| (gpt->Reserved != 0))
|
||||||
{
|
{
|
||||||
free(gpt);
|
MEM2_free(gpt);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(u8 i = 0; i < le32(gpt->Num_Entries) && PartitionList.size() <= 8; i++)
|
for(u8 i = 0; i < le32(gpt->Num_Entries) && PartitionList.size() <= 8; i++)
|
||||||
{
|
{
|
||||||
GUID_PARTITION_ENTRY * entry = (GUID_PARTITION_ENTRY *) &gpt->partitions[i];
|
GUID_PARTITION_ENTRY *entry = (GUID_PARTITION_ENTRY *) &gpt->partitions[i];
|
||||||
VOLUME_BOOT_RECORD *vbr = (VOLUME_BOOT_RECORD*)MEM2_alloc(MAX_BYTES_PER_SECTOR);
|
VOLUME_BOOT_RECORD *vbr = (VOLUME_BOOT_RECORD*)MEM2_alloc(MAX_BYTES_PER_SECTOR);
|
||||||
|
if(vbr == NULL)
|
||||||
|
{
|
||||||
|
MEM2_free(gpt);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int Start = le64(entry->First_LBA);
|
int Start = le64(entry->First_LBA);
|
||||||
int End = le64(entry->Last_LBA);
|
int End = le64(entry->Last_LBA);
|
||||||
@ -378,9 +387,9 @@ bool PartitionHandle::CheckGPT(void)
|
|||||||
success = true;
|
success = true;
|
||||||
PartitionList.push_back(PartitionEntry);
|
PartitionList.push_back(PartitionEntry);
|
||||||
}
|
}
|
||||||
free(vbr);
|
MEM2_free(vbr);
|
||||||
}
|
}
|
||||||
free(gpt);
|
MEM2_free(gpt);
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -196,10 +196,12 @@ bool fsop_CopyFile (char *source, char *target, progress_callback_t spinner, voi
|
|||||||
// Return to beginning....
|
// Return to beginning....
|
||||||
fseek(fs, 0, SEEK_SET);
|
fseek(fs, 0, SEEK_SET);
|
||||||
|
|
||||||
u8 * threadStack = NULL;
|
u8 *threadStack = NULL;
|
||||||
lwp_t hthread = LWP_THREAD_NULL;
|
lwp_t hthread = LWP_THREAD_NULL;
|
||||||
|
|
||||||
buff = MEM2_alloc(block*2);
|
buff = MEM2_alloc(block*2);
|
||||||
|
if(buff == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
blockIdx = 0;
|
blockIdx = 0;
|
||||||
blockReady = 0;
|
blockReady = 0;
|
||||||
@ -207,6 +209,9 @@ bool fsop_CopyFile (char *source, char *target, progress_callback_t spinner, voi
|
|||||||
blockInfo[1] = 0;
|
blockInfo[1] = 0;
|
||||||
|
|
||||||
threadStack = MEM2_alloc(STACKSIZE);
|
threadStack = MEM2_alloc(STACKSIZE);
|
||||||
|
if(threadStack == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
LWP_CreateThread (&hthread, thread_CopyFileReader, NULL, threadStack, STACKSIZE, 30);
|
LWP_CreateThread (&hthread, thread_CopyFileReader, NULL, threadStack, STACKSIZE, 30);
|
||||||
|
|
||||||
while (stopThread != 0)
|
while (stopThread != 0)
|
||||||
|
@ -151,6 +151,8 @@ void DML_New_SetOptions(char *GamePath, char *CheatPath, char *NewCheatPath, boo
|
|||||||
gprintf("Wiiflow DML: Launch game 'sd:/games/%s/game.iso' through memory (new method)\n", GamePath);
|
gprintf("Wiiflow DML: Launch game 'sd:/games/%s/game.iso' through memory (new method)\n", GamePath);
|
||||||
|
|
||||||
DMLCfg = (DML_CFG*)MEM2_alloc(sizeof(DML_CFG));
|
DMLCfg = (DML_CFG*)MEM2_alloc(sizeof(DML_CFG));
|
||||||
|
if(DMLCfg == NULL)
|
||||||
|
return;
|
||||||
memset(DMLCfg, 0, sizeof(DML_CFG));
|
memset(DMLCfg, 0, sizeof(DML_CFG));
|
||||||
|
|
||||||
DMLCfg->Magicbytes = 0xD1050CF6;
|
DMLCfg->Magicbytes = 0xD1050CF6;
|
||||||
@ -222,6 +224,8 @@ void DML_New_SetBootDiscOption()
|
|||||||
gprintf("Booting GC game\n");
|
gprintf("Booting GC game\n");
|
||||||
|
|
||||||
DMLCfg = (DML_CFG*)MEM2_alloc(sizeof(DML_CFG));
|
DMLCfg = (DML_CFG*)MEM2_alloc(sizeof(DML_CFG));
|
||||||
|
if(DMLCfg == NULL)
|
||||||
|
return;
|
||||||
memset(DMLCfg, 0, sizeof(DML_CFG));
|
memset(DMLCfg, 0, sizeof(DML_CFG));
|
||||||
|
|
||||||
DMLCfg->Magicbytes = 0xD1050CF6;
|
DMLCfg->Magicbytes = 0xD1050CF6;
|
||||||
|
@ -70,6 +70,9 @@ static void USBGeckoOutput()
|
|||||||
|
|
||||||
void WriteToFile(char* tmp)
|
void WriteToFile(char* tmp)
|
||||||
{
|
{
|
||||||
|
if(tmpfilebuffer == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
if(bufferMessages)
|
if(bufferMessages)
|
||||||
{
|
{
|
||||||
if((strlen(tmpfilebuffer) + strlen(tmp)) < filebuffer)
|
if((strlen(tmpfilebuffer) + strlen(tmp)) < filebuffer)
|
||||||
@ -77,11 +80,8 @@ void WriteToFile(char* tmp)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(tmpfilebuffer != NULL)
|
MEM2_free(tmpfilebuffer);
|
||||||
{
|
tmpfilebuffer = NULL;
|
||||||
MEM2_free(tmpfilebuffer);
|
|
||||||
tmpfilebuffer = NULL;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,19 +100,17 @@ void WriteToFile(char* tmp)
|
|||||||
//using the gprintf from crediar because it is smaller than mine
|
//using the gprintf from crediar because it is smaller than mine
|
||||||
void gprintf( const char *format, ... )
|
void gprintf( const char *format, ... )
|
||||||
{
|
{
|
||||||
char * tmp = NULL;
|
char *tmp = NULL;
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, format);
|
va_start(va, format);
|
||||||
if((vasprintf(&tmp, format, va) >= 0) && tmp)
|
if((vasprintf(&tmp, format, va) >= 0) && tmp)
|
||||||
{
|
{
|
||||||
WriteToFile(tmp);
|
WriteToFile(tmp);
|
||||||
WifiGecko_Send(tmp, strlen(tmp));
|
WifiGecko_Send(tmp, strlen(tmp));
|
||||||
if (geckoinit)
|
__out_write(NULL, 0, tmp, strlen(tmp));
|
||||||
__out_write(NULL, 0, tmp, strlen(tmp));
|
free(tmp);
|
||||||
}
|
}
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
free(tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char ascii(char s)
|
char ascii(char s)
|
||||||
@ -157,13 +155,14 @@ void ghexdump(void *d, int len)
|
|||||||
|
|
||||||
bool InitGecko()
|
bool InitGecko()
|
||||||
{
|
{
|
||||||
if (geckoinit)
|
if(geckoinit)
|
||||||
return geckoinit;
|
return geckoinit;
|
||||||
|
|
||||||
USBGeckoOutput();
|
USBGeckoOutput();
|
||||||
|
|
||||||
tmpfilebuffer = (char*)MEM2_alloc(filebuffer + 1 * sizeof(char));
|
tmpfilebuffer = (char*)MEM2_alloc(filebuffer + 1 * sizeof(char));
|
||||||
memset(tmpfilebuffer, 0, sizeof(tmpfilebuffer));
|
if(tmpfilebuffer != NULL)
|
||||||
|
memset(tmpfilebuffer, 0, sizeof(tmpfilebuffer));
|
||||||
|
|
||||||
#ifdef sd_write_log
|
#ifdef sd_write_log
|
||||||
WriteToSD = true;
|
WriteToSD = true;
|
||||||
|
@ -131,19 +131,3 @@ int WifiGecko_Send(const char * data, int datasize)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wifi_printf(const char * format, ...)
|
|
||||||
{
|
|
||||||
if (!init) return;
|
|
||||||
|
|
||||||
char * tmp = NULL;
|
|
||||||
va_list va;
|
|
||||||
va_start(va, format);
|
|
||||||
if((vasprintf(&tmp, format, va) >= 0) && tmp)
|
|
||||||
{
|
|
||||||
WifiGecko_Send(tmp, strlen(tmp));
|
|
||||||
}
|
|
||||||
va_end(va);
|
|
||||||
|
|
||||||
free(tmp);
|
|
||||||
}
|
|
||||||
|
@ -36,7 +36,6 @@ void WifiGecko_Init(const char *ip, u16 port);
|
|||||||
int WifiGecko_Connect();
|
int WifiGecko_Connect();
|
||||||
void WifiGecko_Close();
|
void WifiGecko_Close();
|
||||||
int WifiGecko_Send(const char * data, int datasize);
|
int WifiGecko_Send(const char * data, int datasize);
|
||||||
void wifi_printf(const char * format, ...);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,8 @@ bool WiiMovie::Play(bool loop)
|
|||||||
gprintf("Start playing video\n");
|
gprintf("Start playing video\n");
|
||||||
|
|
||||||
PlayThreadStack = (u8 *)MEM2_alloc(32768);
|
PlayThreadStack = (u8 *)MEM2_alloc(32768);
|
||||||
if (PlayThreadStack == NULL) return false;
|
if (PlayThreadStack == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
Playing = true;
|
Playing = true;
|
||||||
PlayTime.reset();
|
PlayTime.reset();
|
||||||
@ -151,13 +152,13 @@ void WiiMovie::Stop()
|
|||||||
gprintf("Stopping WiiMovie video\n");
|
gprintf("Stopping WiiMovie video\n");
|
||||||
ExitRequested = true;
|
ExitRequested = true;
|
||||||
if (PlayThread != LWP_THREAD_NULL)
|
if (PlayThread != LWP_THREAD_NULL)
|
||||||
{
|
|
||||||
LWP_JoinThread(PlayThread, NULL);
|
LWP_JoinThread(PlayThread, NULL);
|
||||||
}
|
|
||||||
PlayThread = LWP_THREAD_NULL;
|
PlayThread = LWP_THREAD_NULL;
|
||||||
gprintf("Playing thread stopped\n");
|
gprintf("Playing thread stopped\n");
|
||||||
|
|
||||||
MEM2_free(PlayThreadStack);
|
if(PlayThreadStack != NULL)
|
||||||
|
MEM2_free(PlayThreadStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiiMovie::SetVolume(int vol)
|
void WiiMovie::SetVolume(int vol)
|
||||||
|
@ -300,7 +300,8 @@ const u8* VideoFrame::getData() const
|
|||||||
|
|
||||||
void VideoFrame::dealloc()
|
void VideoFrame::dealloc()
|
||||||
{
|
{
|
||||||
MEM2_free(_data);
|
if(_data != NULL)
|
||||||
|
MEM2_free(_data);
|
||||||
_w = _h = _p = 0;
|
_w = _h = _p = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,16 +79,18 @@ IMGCTX PNGU_SelectImageFromDevice (const char *filename)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
IMGCTX ctx = MEM2_alloc(sizeof (struct _IMGCTX));
|
IMGCTX ctx = MEM2_alloc(sizeof (struct _IMGCTX));
|
||||||
if (!ctx) return NULL;
|
if (ctx == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
ctx->buffer = NULL;
|
ctx->buffer = NULL;
|
||||||
ctx->source = PNGU_SOURCE_DEVICE;
|
ctx->source = PNGU_SOURCE_DEVICE;
|
||||||
ctx->cursor = 0;
|
ctx->cursor = 0;
|
||||||
|
|
||||||
ctx->filename = MEM2_alloc(strlen (filename) + 1);
|
ctx->filename = MEM2_alloc(strlen (filename) + 1);
|
||||||
if (!ctx->filename)
|
if (ctx->filename == NULL)
|
||||||
{
|
{
|
||||||
MEM2_free(ctx);
|
if(ctx != NULL)
|
||||||
|
MEM2_free(ctx);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strcpy(ctx->filename, filename);
|
strcpy(ctx->filename, filename);
|
||||||
|
@ -45,7 +45,7 @@ bool cIOSInfo::D2X(u8 ios, u8 *base)
|
|||||||
if(!info)
|
if(!info)
|
||||||
return false;
|
return false;
|
||||||
*base = (u8)info->baseios;
|
*base = (u8)info->baseios;
|
||||||
free(info);
|
MEM2_free(info);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,25 +59,27 @@ iosinfo_t *cIOSInfo::GetInfo(u8 ios)
|
|||||||
u32 TMD_Length;
|
u32 TMD_Length;
|
||||||
if (ES_GetStoredTMDSize(TITLE_ID(1, ios), &TMD_Length) < 0) return NULL;
|
if (ES_GetStoredTMDSize(TITLE_ID(1, ios), &TMD_Length) < 0) return NULL;
|
||||||
|
|
||||||
signed_blob *TMD = (signed_blob*) MEM2_alloc(ALIGN32(TMD_Length));
|
signed_blob *TMD = (signed_blob*)MEM2_alloc(ALIGN32(TMD_Length));
|
||||||
if (!TMD) return NULL;
|
if (TMD == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (ES_GetStoredTMD(TITLE_ID(1, ios), TMD, TMD_Length) < 0)
|
if (ES_GetStoredTMD(TITLE_ID(1, ios), TMD, TMD_Length) < 0)
|
||||||
{
|
{
|
||||||
free(TMD);
|
MEM2_free(TMD);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
|
char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
|
||||||
sprintf(filepath, "/title/00000001/%08x/content/%08x.app", ios, *(u8 *)((u32)TMD+0x1E7));
|
sprintf(filepath, "/title/00000001/%08x/content/%08x.app", ios, *(u8 *)((u32)TMD+0x1E7));
|
||||||
|
|
||||||
free(TMD);
|
MEM2_free(TMD);
|
||||||
|
|
||||||
u32 size = 0;
|
u32 size = 0;
|
||||||
u8 *buffer = ISFS_GetFile((u8 *) filepath, &size, sizeof(iosinfo_t));
|
u8 *buffer = ISFS_GetFile((u8 *)filepath, &size, sizeof(iosinfo_t));
|
||||||
if(buffer == NULL || size == 0) return NULL;
|
if(buffer == NULL || size == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
iosinfo_t *iosinfo = (iosinfo_t *) buffer;
|
iosinfo_t *iosinfo = (iosinfo_t *)buffer;
|
||||||
|
|
||||||
bool baseMatch = false;
|
bool baseMatch = false;
|
||||||
for(u8 i = 0; i < ARRAY_SIZE(allowedBases); i++)
|
for(u8 i = 0; i < ARRAY_SIZE(allowedBases); i++)
|
||||||
@ -93,10 +95,9 @@ iosinfo_t *cIOSInfo::GetInfo(u8 ios)
|
|||||||
|| !baseMatch /* Base */
|
|| !baseMatch /* Base */
|
||||||
|| strncasecmp(iosinfo->name, "d2x", 3) != 0) /* Name */
|
|| strncasecmp(iosinfo->name, "d2x", 3) != 0) /* Name */
|
||||||
{
|
{
|
||||||
free(buffer);
|
MEM2_free(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
free(buffer);
|
|
||||||
|
|
||||||
return iosinfo;
|
return iosinfo;
|
||||||
}
|
}
|
||||||
|
@ -161,15 +161,19 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
|
|||||||
u32 length = strlen(path);
|
u32 length = strlen(path);
|
||||||
strcpy(fname, path);
|
strcpy(fname, path);
|
||||||
|
|
||||||
if(fname[length-1] > '0' && fname[length-1] < '9') return 0;
|
int ret, ret_val = -1;
|
||||||
|
u32 i, j;
|
||||||
|
|
||||||
|
if(fname[length-1] > '0' && fname[length-1] < '9')
|
||||||
|
return 0;
|
||||||
bool isWBFS = wbfs_part_fs != PART_FS_WBFS && strcasestr(strrchr(fname,'.'), ".wbfs") != 0;
|
bool isWBFS = wbfs_part_fs != PART_FS_WBFS && strcasestr(strrchr(fname,'.'), ".wbfs") != 0;
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
FragList *fs = MEM2_alloc(sizeof(FragList));
|
FragList *fs = MEM2_alloc(sizeof(FragList));
|
||||||
FragList *fa = MEM2_alloc(sizeof(FragList));
|
FragList *fa = MEM2_alloc(sizeof(FragList));
|
||||||
FragList *fw = MEM2_alloc(sizeof(FragList));
|
FragList *fw = MEM2_alloc(sizeof(FragList));
|
||||||
int ret, ret_val = -1;
|
if(fs == NULL || fa == NULL || fw == NULL)
|
||||||
u32 i, j;
|
goto out;
|
||||||
|
|
||||||
frag_init(fa, MAX_FRAG);
|
frag_init(fa, MAX_FRAG);
|
||||||
|
|
||||||
@ -238,6 +242,9 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
frag_list = MEM2_alloc((sizeof(FragList)+31)&(~31));
|
frag_list = MEM2_alloc((sizeof(FragList)+31)&(~31));
|
||||||
|
if(frag_list == NULL)
|
||||||
|
goto out;
|
||||||
|
|
||||||
frag_init(frag_list, MAX_FRAG);
|
frag_init(frag_list, MAX_FRAG);
|
||||||
if (isWBFS) // If this is a .wbfs file format, remap.
|
if (isWBFS) // If this is a .wbfs file format, remap.
|
||||||
{
|
{
|
||||||
@ -255,23 +262,26 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
WBFS_CloseDisc(disc); // Close before jumping on fail.
|
WBFS_CloseDisc(disc); // Close before jumping on fail.
|
||||||
if (frag_remap(frag_list, fw, fa))
|
if(frag_remap(frag_list, fw, fa))
|
||||||
{
|
{
|
||||||
ret_val = -6;
|
ret_val = -6;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else memcpy(frag_list, fa, sizeof(FragList)); // .iso files do not need a remap, just copy
|
else
|
||||||
|
memcpy(frag_list, fa, sizeof(FragList)); // .iso files do not need a remap, just copy
|
||||||
|
|
||||||
ret_val = 0;
|
ret_val = 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (ret_val)
|
if (frag_list != NULL)
|
||||||
MEM2_free(frag_list);
|
MEM2_free(frag_list);
|
||||||
MEM2_free(fs);
|
if(fs != NULL)
|
||||||
MEM2_free(fa);
|
MEM2_free(fs);
|
||||||
MEM2_free(fw);
|
if(fa != NULL)
|
||||||
|
MEM2_free(fa);
|
||||||
|
if(fw != NULL)
|
||||||
|
MEM2_free(fw);
|
||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ u8 *ISFS_GetFile(u8 *path, u32 *size, s32 length)
|
|||||||
{
|
{
|
||||||
if (length <= 0) length = stats.file_length;
|
if (length <= 0) length = stats.file_length;
|
||||||
if (length > 0)
|
if (length > 0)
|
||||||
buf = (u8 *) MEM2_alloc(ALIGN32(length));
|
buf = (u8 *)MEM2_alloc(ALIGN32(length));
|
||||||
|
|
||||||
if (buf)
|
if (buf)
|
||||||
{
|
{
|
||||||
@ -28,7 +28,7 @@ u8 *ISFS_GetFile(u8 *path, u32 *size, s32 length)
|
|||||||
if (ISFS_Read(fd, (char*)buf, length) != length)
|
if (ISFS_Read(fd, (char*)buf, length) != length)
|
||||||
{
|
{
|
||||||
*size = 0;
|
*size = 0;
|
||||||
free(buf);
|
MEM2_free(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -40,6 +40,5 @@ u8 *ISFS_GetFile(u8 *path, u32 *size, s32 length)
|
|||||||
DCFlushRange(buf, *size);
|
DCFlushRange(buf, *size);
|
||||||
ICInvalidateRange(buf, *size);
|
ICInvalidateRange(buf, *size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,9 @@ static u8 *FSTable ALIGNED(32);
|
|||||||
void GCDump::__AnalizeMultiDisc()
|
void GCDump::__AnalizeMultiDisc()
|
||||||
{
|
{
|
||||||
u8 *Buffer = (u8 *)MEM2_alloc(0x10);
|
u8 *Buffer = (u8 *)MEM2_alloc(0x10);
|
||||||
|
if(Buffer == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
MultiGameCnt = 0;
|
MultiGameCnt = 0;
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
@ -169,7 +172,9 @@ s32 GCDump::__DiscWriteFile(FILE *f, u64 offset, u32 length, u8 *ReadBuffer)
|
|||||||
bool GCDump::__WaitForDisc(u8 dsc, u32 msg)
|
bool GCDump::__WaitForDisc(u8 dsc, u32 msg)
|
||||||
{
|
{
|
||||||
u8 *ReadBuffer = (u8 *)MEM2_alloc(0x440);
|
u8 *ReadBuffer = (u8 *)MEM2_alloc(0x440);
|
||||||
|
if(ReadBuffer == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
u32 cover = 0;
|
u32 cover = 0;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
while(!done)
|
while(!done)
|
||||||
@ -200,7 +205,7 @@ bool GCDump::__WaitForDisc(u8 dsc, u32 msg)
|
|||||||
MEM2_free(ReadBuffer);
|
MEM2_free(ReadBuffer);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Disc_IsGC() == 0)
|
if(Disc_IsGC() == 0)
|
||||||
{
|
{
|
||||||
s32 ret = __DiscReadRaw(ReadBuffer, NextOffset, 0x440);
|
s32 ret = __DiscReadRaw(ReadBuffer, NextOffset, 0x440);
|
||||||
@ -209,10 +214,10 @@ bool GCDump::__WaitForDisc(u8 dsc, u32 msg)
|
|||||||
MEM2_free(ReadBuffer);
|
MEM2_free(ReadBuffer);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID2 = *(vu32*)(ReadBuffer);
|
ID2 = *(vu32*)(ReadBuffer);
|
||||||
Disc2 = *(vu8*)(ReadBuffer+0x06);
|
Disc2 = *(vu8*)(ReadBuffer+0x06);
|
||||||
|
|
||||||
if(ID == ID2 && Disc2 == dsc)
|
if(ID == ID2 && Disc2 == dsc)
|
||||||
{
|
{
|
||||||
done = true;
|
done = true;
|
||||||
@ -255,6 +260,8 @@ s32 GCDump::DumpGame()
|
|||||||
static gc_discHdr gcheader ATTRIBUTE_ALIGN(32);
|
static gc_discHdr gcheader ATTRIBUTE_ALIGN(32);
|
||||||
|
|
||||||
u8 *ReadBuffer = (u8 *)MEM2_alloc(gc_readsize);
|
u8 *ReadBuffer = (u8 *)MEM2_alloc(gc_readsize);
|
||||||
|
if(ReadBuffer == NULL)
|
||||||
|
return 0x31100;
|
||||||
|
|
||||||
gc_done = 0;
|
gc_done = 0;
|
||||||
gamedone = false;
|
gamedone = false;
|
||||||
@ -331,6 +338,8 @@ s32 GCDump::DumpGame()
|
|||||||
DiscSize = DataSize + GamePartOffset;
|
DiscSize = DataSize + GamePartOffset;
|
||||||
|
|
||||||
FSTBuffer = (u8 *)MEM2_alloc((FSTSize+31)&(~31));
|
FSTBuffer = (u8 *)MEM2_alloc((FSTSize+31)&(~31));
|
||||||
|
if(FSTBuffer == NULL)
|
||||||
|
return 0x31100;
|
||||||
|
|
||||||
ret = __DiscReadRaw(FSTBuffer, FSTOffset+NextOffset, (FSTSize+31)&(~31));
|
ret = __DiscReadRaw(FSTBuffer, FSTOffset+NextOffset, (FSTSize+31)&(~31));
|
||||||
|
|
||||||
@ -470,9 +479,8 @@ s32 GCDump::DumpGame()
|
|||||||
}
|
}
|
||||||
gprintf("Done!! Disc size: %d\n", DiscSize);
|
gprintf("Done!! Disc size: %d\n", DiscSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
MEM2_free(FSTBuffer);
|
MEM2_free(FSTBuffer);
|
||||||
|
|
||||||
if(FSTTotal > FSTSize && !multigamedisc)
|
if(FSTTotal > FSTSize && !multigamedisc)
|
||||||
{
|
{
|
||||||
if(Disc)
|
if(Disc)
|
||||||
@ -512,6 +520,9 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp)
|
|||||||
static gc_discHdr gcheader ATTRIBUTE_ALIGN(32);
|
static gc_discHdr gcheader ATTRIBUTE_ALIGN(32);
|
||||||
|
|
||||||
u8 *ReadBuffer = (u8 *)MEM2_alloc(0x440);
|
u8 *ReadBuffer = (u8 *)MEM2_alloc(0x440);
|
||||||
|
if(ReadBuffer == NULL)
|
||||||
|
return 1;
|
||||||
|
|
||||||
u32 size = 0;
|
u32 size = 0;
|
||||||
bool scnddisc = false;
|
bool scnddisc = false;
|
||||||
gamedone = false;
|
gamedone = false;
|
||||||
@ -573,6 +584,8 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
u8 *FSTBuffer = (u8 *)MEM2_alloc((FSTSize+31)&(~31));
|
u8 *FSTBuffer = (u8 *)MEM2_alloc((FSTSize+31)&(~31));
|
||||||
|
if(FSTBuffer == NULL)
|
||||||
|
return 1;
|
||||||
|
|
||||||
ret = __DiscReadRaw(FSTBuffer, FSTOffset+NextOffset, (FSTSize+31)&(~31));
|
ret = __DiscReadRaw(FSTBuffer, FSTOffset+NextOffset, (FSTSize+31)&(~31));
|
||||||
if(ret > 0)
|
if(ret > 0)
|
||||||
|
@ -1872,7 +1872,7 @@ bool CMenu::_loadChannelList(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
gprintf("Openning %s failed returning %i\n", filepath, file);
|
gprintf("Openning %s failed returning %i\n", filepath, file);
|
||||||
free(sysconf);
|
MEM2_free(sysconf);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(filepath, "/shared2/menu/FaceLib/RFL_DB.dat");
|
sprintf(filepath, "/shared2/menu/FaceLib/RFL_DB.dat");
|
||||||
@ -1890,7 +1890,7 @@ bool CMenu::_loadChannelList(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
gprintf("Openning %s failed returning %i\n", filepath, file);
|
gprintf("Openning %s failed returning %i\n", filepath, file);
|
||||||
free(meez);
|
MEM2_free(meez);
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
@ -2186,6 +2186,9 @@ void CMenu::_loadDefaultFont(bool korean)
|
|||||||
|
|
||||||
// Read content.map from ISFS
|
// Read content.map from ISFS
|
||||||
u8 *content = ISFS_GetFile((u8 *) "/shared1/content.map", &size, 0);
|
u8 *content = ISFS_GetFile((u8 *) "/shared1/content.map", &size, 0);
|
||||||
|
if(content == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
int items = size / sizeof(map_entry_t);
|
int items = size / sizeof(map_entry_t);
|
||||||
|
|
||||||
//gprintf("Open content.map, size %d, items %d\n", size, items);
|
//gprintf("Open content.map, size %d, items %d\n", size, items);
|
||||||
@ -2203,7 +2206,6 @@ retry:
|
|||||||
memcpy(u8_font_filename+9, cm[i].filename, 8);
|
memcpy(u8_font_filename+9, cm[i].filename, 8);
|
||||||
|
|
||||||
u8 *u8_font_archive = ISFS_GetFile((u8 *) u8_font_filename, &size, 0);
|
u8 *u8_font_archive = ISFS_GetFile((u8 *) u8_font_filename, &size, 0);
|
||||||
|
|
||||||
//gprintf("Opened fontfile: %s: %d bytes\n", u8_font_filename, size);
|
//gprintf("Opened fontfile: %s: %d bytes\n", u8_font_filename, size);
|
||||||
|
|
||||||
if (u8_font_archive != NULL)
|
if (u8_font_archive != NULL)
|
||||||
@ -2216,8 +2218,8 @@ retry:
|
|||||||
memcpy(m_base_font.get(), font_file, size);
|
memcpy(m_base_font.get(), font_file, size);
|
||||||
if(!!m_base_font)
|
if(!!m_base_font)
|
||||||
m_base_font_size = size;
|
m_base_font_size = size;
|
||||||
|
MEM2_free(u8_font_archive);
|
||||||
}
|
}
|
||||||
free(u8_font_archive);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2228,7 +2230,7 @@ retry:
|
|||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(content);
|
MEM2_free(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMenu::_cleanupDefaultFont()
|
void CMenu::_cleanupDefaultFont()
|
||||||
@ -2301,13 +2303,12 @@ bool CMenu::MIOSisDML()
|
|||||||
if(*(u32*)(appfile+i) == 0x44494F53)
|
if(*(u32*)(appfile+i) == 0x44494F53)
|
||||||
{
|
{
|
||||||
gprintf("DML is installed as MIOS\n");
|
gprintf("DML is installed as MIOS\n");
|
||||||
free(appfile);
|
MEM2_free(appfile);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MEM2_free(appfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(appfile);
|
|
||||||
gprintf("DML is not installed as MIOS\n");
|
gprintf("DML is not installed as MIOS\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ void CMenu::_textAbout(void)
|
|||||||
iosinfo_t * iosInfo = cIOSInfo::GetInfo(mainIOS);
|
iosinfo_t * iosInfo = cIOSInfo::GetInfo(mainIOS);
|
||||||
if(iosInfo != NULL)
|
if(iosInfo != NULL)
|
||||||
m_btnMgr.setText(m_aboutLblIOS, wfmt(_fmt("ios", L"IOS%i base %i v%i"), mainIOS, iosInfo->baseios, iosInfo->version), true);
|
m_btnMgr.setText(m_aboutLblIOS, wfmt(_fmt("ios", L"IOS%i base %i v%i"), mainIOS, iosInfo->baseios, iosInfo->version), true);
|
||||||
free(iosInfo);
|
MEM2_free(iosInfo);
|
||||||
|
|
||||||
if(m_current_view == COVERFLOW_CHANNEL && m_cfg.getInt("NAND", "emulation", 0) > 0)
|
if(m_current_view == COVERFLOW_CHANNEL && m_cfg.getInt("NAND", "emulation", 0) > 0)
|
||||||
Nand::Instance()->Enable_Emu();
|
Nand::Instance()->Enable_Emu();
|
||||||
|
@ -398,7 +398,7 @@ bool CMenu::_isNetworkAvailable()
|
|||||||
if (buf && size > 4)
|
if (buf && size > 4)
|
||||||
{
|
{
|
||||||
retval = buf[4] > 0; // There is a valid connection defined.
|
retval = buf[4] > 0; // There is a valid connection defined.
|
||||||
free(buf);
|
MEM2_free(buf);
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user