mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2025-02-18 21:16:21 +01:00
-code cleanup and correction, should print more debug messages
than before if problems occur -replaced most malloc by MEM2_alloc, as well as free and SAFE_FREE replaced by MEM2_free
This commit is contained in:
parent
b8fd3e623d
commit
1a0908497a
4
Makefile
4
Makefile
@ -70,8 +70,8 @@ ios := 249
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# options for code generation
|
# options for code generation
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
CFLAGS = -g -Os -Wall $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H
|
CFLAGS = -g -Os -Wall -Wextra -Wno-multichar $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H
|
||||||
CXXFLAGS = -g -Os -Wall -Wextra -Wno-multichar $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H
|
CXXFLAGS = $(CFLAGS)
|
||||||
|
|
||||||
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80A00000,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size -T../scripts/rvl.ld
|
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80A00000,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size -T../scripts/rvl.ld
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ Banner::Banner(u8 *bnr, u64 title)
|
|||||||
|
|
||||||
Banner::~Banner()
|
Banner::~Banner()
|
||||||
{
|
{
|
||||||
SAFE_FREE(opening);
|
MEM2_free(opening);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Banner::IsValid()
|
bool Banner::IsValid()
|
||||||
@ -135,7 +135,7 @@ bool Banner::GetName(wchar_t *name, int language)
|
|||||||
for (int i = 0; i < IMET_MAX_NAME_LEN; i++)
|
for (int i = 0; i < IMET_MAX_NAME_LEN; i++)
|
||||||
{
|
{
|
||||||
name[i] = channelname[i];
|
name[i] = channelname[i];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -174,11 +174,11 @@ Banner * Banner::GetBanner(u64 title, char *appname, bool isfs, bool imetOnly)
|
|||||||
fseek(fp, 0, SEEK_SET);
|
fseek(fp, 0, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = malloc(size);
|
buf = MEM2_alloc(size);
|
||||||
|
|
||||||
fread(buf, size, 1, fp);
|
fread(buf, size, 1, fp);
|
||||||
SAFE_CLOSE(fp);
|
SAFE_CLOSE(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Banner((u8 *) buf, title);
|
return new Banner((u8 *)buf, title);
|
||||||
}
|
}
|
@ -174,8 +174,8 @@ void PatchChannel(u8 vidMode, GXRModeObj *vmode, bool vipatch, bool countryStrin
|
|||||||
{
|
{
|
||||||
bool hookpatched = false;
|
bool hookpatched = false;
|
||||||
|
|
||||||
int i;
|
u32 i;
|
||||||
for (i=0;i < dolchunkcount;i++)
|
for (i=0; i < dolchunkcount; i++)
|
||||||
{
|
{
|
||||||
patchVideoModes(dolchunkoffset[i], dolchunksize[i], vidMode, vmode, patchVidModes);
|
patchVideoModes(dolchunkoffset[i], dolchunksize[i], vidMode, vmode, patchVidModes);
|
||||||
if (vipatch) vidolpatcher(dolchunkoffset[i], dolchunksize[i]);
|
if (vipatch) vidolpatcher(dolchunkoffset[i], dolchunksize[i]);
|
||||||
@ -278,7 +278,7 @@ bool Identify(u64 titleid, u32 *ios)
|
|||||||
return ret < 0 ? false : true;
|
return ret < 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 * GetDol(u64 title, char *id, u32 bootcontent)
|
u8 * GetDol(u64 title, u32 bootcontent)
|
||||||
{
|
{
|
||||||
char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
|
char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
|
||||||
sprintf(filepath, "/title/%08x/%08x/content/%08x.app", TITLE_UPPER(title), TITLE_LOWER(title), bootcontent);
|
sprintf(filepath, "/title/%08x/%08x/content/%08x.app", TITLE_UPPER(title), TITLE_LOWER(title), bootcontent);
|
||||||
|
@ -13,7 +13,7 @@ s32 BootChannel(u8 *data, u64 chantitle, u8 vidMode, bool vipatch, bool countryS
|
|||||||
u32 LoadChannel(u8 *buffer);
|
u32 LoadChannel(u8 *buffer);
|
||||||
void PatchChannel(u8 vidMode, GXRModeObj *vmode, bool vipatch, bool countryString, u8 patchVidModes, int aspectRatio);
|
void PatchChannel(u8 vidMode, GXRModeObj *vmode, bool vipatch, bool countryString, u8 patchVidModes, int aspectRatio);
|
||||||
|
|
||||||
u8 * GetDol(u64 title, char *id, u32 bootcontent);
|
u8 * GetDol(u64 title, u32 bootcontent);
|
||||||
|
|
||||||
bool Identify(u64 titleid, u32 *ios);
|
bool Identify(u64 titleid, u32 *ios);
|
||||||
bool Identify_GenerateTik(signed_blob **outbuf, u32 *outlen);
|
bool Identify_GenerateTik(signed_blob **outbuf, u32 *outlen);
|
||||||
|
@ -74,7 +74,7 @@ Channels::~Channels()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 * Channels::Load(u64 title, char *id)
|
u8 * Channels::Load(u64 title)
|
||||||
{
|
{
|
||||||
char app[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
|
char app[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
|
||||||
u32 bootcontent;
|
u32 bootcontent;
|
||||||
@ -82,7 +82,7 @@ u8 * Channels::Load(u64 title, char *id)
|
|||||||
if(!GetAppNameFromTmd(title, app, true, &bootcontent))
|
if(!GetAppNameFromTmd(title, app, true, &bootcontent))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return GetDol(title, id, bootcontent);
|
return GetDol(title, bootcontent);
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 Channels::GetRequestedIOS(u64 title)
|
u8 Channels::GetRequestedIOS(u64 title)
|
||||||
|
@ -54,7 +54,7 @@ class Channels
|
|||||||
|
|
||||||
void Init(u32 channelType, string lang, bool reload = false);
|
void Init(u32 channelType, string lang, bool reload = false);
|
||||||
|
|
||||||
u8 * Load(u64 title, char* id);
|
u8 * Load(u64 title);
|
||||||
u8 GetRequestedIOS(u64 title);
|
u8 GetRequestedIOS(u64 title);
|
||||||
bool Launch(u8 *data, u64 chantitle, u8 vidMode, bool vipatch, bool countryString, u8 patchVidMode, bool disableIOSreload, int aspectRatio);
|
bool Launch(u8 *data, u64 chantitle, u8 vidMode, bool vipatch, bool countryString, u8 patchVidMode, bool disableIOSreload, int aspectRatio);
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ s32 __decompressLZ77_11(u8 *in, u32 inputLen, u8 **output, u32 *outputLen)
|
|||||||
compressedPos += 2;
|
compressedPos += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (y = 0; y < copyLen; y++)
|
for (y = 0; y < (int)copyLen; y++)
|
||||||
{
|
{
|
||||||
out[decompressedPos + y] = out[decompressedPos - pos + y];
|
out[decompressedPos + y] = out[decompressedPos - pos + y];
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ s32 __decompressLZ77_11(u8 *in, u32 inputLen, u8 **output, u32 *outputLen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 __decompressLZ77_10(u8 *in, u32 inputLen, u8 **output, u32 *outputLen)
|
s32 __decompressLZ77_10(u8 *in, u8 **output, u32 *outputLen)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ int decompressLZ77content(u8 *buffer, u32 length, u8 **output, u32 *outputLen)
|
|||||||
{
|
{
|
||||||
case LZ77_0x10_FLAG:
|
case LZ77_0x10_FLAG:
|
||||||
printf("LZ77 variant 0x10 compressed content...unpacking may take a while...\n");
|
printf("LZ77 variant 0x10 compressed content...unpacking may take a while...\n");
|
||||||
ret = __decompressLZ77_10(buffer, length, output, outputLen);
|
ret = __decompressLZ77_10(buffer, output, outputLen);
|
||||||
break;
|
break;
|
||||||
case LZ77_0x11_FLAG:
|
case LZ77_0x11_FLAG:
|
||||||
printf("LZ77 variant 0x11 compressed content...unpacking may take a while...\n");
|
printf("LZ77 variant 0x11 compressed content...unpacking may take a while...\n");
|
||||||
|
@ -104,11 +104,11 @@ wbfs_t *wbfs_open_partition(rw_sector_callback_t read_hdsector, rw_sector_callba
|
|||||||
else
|
else
|
||||||
read_hdsector(callback_data, p->part_lba, 1, head);
|
read_hdsector(callback_data, p->part_lba, 1, head);
|
||||||
if (head->magic != wbfs_htonl( WBFS_MAGIC ))
|
if (head->magic != wbfs_htonl( WBFS_MAGIC ))
|
||||||
ERROR( "bad magic" );
|
ERROR( "bad magic\n" );
|
||||||
if (!force_mode && hd_sector_size && head->hd_sec_sz_s != size_to_shift(hd_sector_size))
|
if (!force_mode && hd_sector_size && head->hd_sec_sz_s != size_to_shift(hd_sector_size))
|
||||||
ERROR( "hd sector size doesn't match" );
|
ERROR( "hd sector size doesn't match\n" );
|
||||||
if (!force_mode && num_hd_sector && head->n_hd_sec != (u32) wbfs_htonl( num_hd_sector ))
|
if (!force_mode && num_hd_sector && head->n_hd_sec != (u32) wbfs_htonl( num_hd_sector ))
|
||||||
ERROR( "hd num sector doesn't match" );
|
ERROR( "hd num sector doesn't match\n" );
|
||||||
p->hd_sec_sz = 1 << head->hd_sec_sz_s;
|
p->hd_sec_sz = 1 << head->hd_sec_sz_s;
|
||||||
p->hd_sec_sz_s = head->hd_sec_sz_s;
|
p->hd_sec_sz_s = head->hd_sec_sz_s;
|
||||||
p->n_hd_sec = wbfs_ntohl(head->n_hd_sec);
|
p->n_hd_sec = wbfs_ntohl(head->n_hd_sec);
|
||||||
@ -156,7 +156,7 @@ void wbfs_sync(wbfs_t *p)
|
|||||||
// copy back descriptors
|
// copy back descriptors
|
||||||
if(p->write_hdsector)
|
if(p->write_hdsector)
|
||||||
{
|
{
|
||||||
p->write_hdsector(p->callback_data,p->part_lba+0,1, p->head);
|
p->write_hdsector(p->callback_data, p->part_lba + 0, 1, p->head);
|
||||||
if(p->freeblks)
|
if(p->freeblks)
|
||||||
p->write_hdsector(p->callback_data, p->part_lba + p->freeblks_lba, ALIGN_LBA(p->n_wbfs_sec / 8) >> p->hd_sec_sz_s, p->freeblks);
|
p->write_hdsector(p->callback_data, p->part_lba + p->freeblks_lba, ALIGN_LBA(p->n_wbfs_sec / 8) >> p->hd_sec_sz_s, p->freeblks);
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ void wbfs_close(wbfs_t *p)
|
|||||||
wbfs_sync(p);
|
wbfs_sync(p);
|
||||||
|
|
||||||
if(p->n_disc_open)
|
if(p->n_disc_open)
|
||||||
ERROR("trying to close wbfs while discs still open");
|
ERROR("trying to close wbfs while discs still open\n");
|
||||||
|
|
||||||
wbfs_iofree(p->head);
|
wbfs_iofree(p->head);
|
||||||
wbfs_iofree(p->tmp_buffer);
|
wbfs_iofree(p->tmp_buffer);
|
||||||
@ -189,17 +189,17 @@ wbfs_disc_t *wbfs_open_disc(wbfs_t* p, const u8 *discid)
|
|||||||
{
|
{
|
||||||
if (p->head->disc_table[i])
|
if (p->head->disc_table[i])
|
||||||
{
|
{
|
||||||
p->read_hdsector(p->callback_data, p->part_lba+1+i*disc_info_sz_lba,1,p->tmp_buffer);
|
p->read_hdsector(p->callback_data, p->part_lba + 1 + i * disc_info_sz_lba, 1, p->tmp_buffer);
|
||||||
if(wbfs_memcmp(discid,p->tmp_buffer,6)==0)
|
if(wbfs_memcmp(discid,p->tmp_buffer,6)==0)
|
||||||
{
|
{
|
||||||
d = wbfs_malloc(sizeof(*d));
|
d = wbfs_malloc(sizeof(*d));
|
||||||
if(!d)
|
if(!d)
|
||||||
ERROR("allocating memory");
|
ERROR("allocating memory\n");
|
||||||
d->p = p;
|
d->p = p;
|
||||||
d->i = i;
|
d->i = i;
|
||||||
d->header = wbfs_ioalloc(p->disc_info_sz);
|
d->header = wbfs_ioalloc(p->disc_info_sz);
|
||||||
if(!d->header)
|
if(!d->header)
|
||||||
ERROR("allocating memory");
|
ERROR("allocating memory\n");
|
||||||
p->read_hdsector(p->callback_data, p->part_lba + 1 + i * disc_info_sz_lba, disc_info_sz_lba, d->header);
|
p->read_hdsector(p->callback_data, p->part_lba + 1 + i * disc_info_sz_lba, disc_info_sz_lba, d->header);
|
||||||
p->n_disc_open ++;
|
p->n_disc_open ++;
|
||||||
//for(i = 0; i < p->n_wbfs_sec_per_disc; i++)
|
//for(i = 0; i < p->n_wbfs_sec_per_disc; i++)
|
||||||
@ -340,7 +340,8 @@ u32 wbfs_get_disc_info(wbfs_t *p, u32 index,u8 *header,int header_size,u32 *size
|
|||||||
if(count++ == index)
|
if(count++ == index)
|
||||||
{
|
{
|
||||||
p->read_hdsector(p->callback_data, p->part_lba + 1 + i * disc_info_sz_lba, 1, p->tmp_buffer);
|
p->read_hdsector(p->callback_data, p->part_lba + 1 + i * disc_info_sz_lba, 1, p->tmp_buffer);
|
||||||
if(header_size > (int)p->hd_sec_sz) header_size = p->hd_sec_sz;
|
if(header_size > (int)p->hd_sec_sz)
|
||||||
|
header_size = p->hd_sec_sz;
|
||||||
u32 magic = wbfs_ntohl(*(u32*)(p->tmp_buffer + 24));
|
u32 magic = wbfs_ntohl(*(u32*)(p->tmp_buffer + 24));
|
||||||
if(magic != 0x5D1C9EA3)
|
if(magic != 0x5D1C9EA3)
|
||||||
{
|
{
|
||||||
@ -451,13 +452,13 @@ u32 wbfs_add_disc(wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, void *ca
|
|||||||
used = wbfs_malloc(p->n_wii_sec_per_disc);
|
used = wbfs_malloc(p->n_wii_sec_per_disc);
|
||||||
|
|
||||||
if(!used)
|
if(!used)
|
||||||
ERROR("unable to alloc memory");
|
ERROR("unable to alloc memory\n");
|
||||||
// copy_1_1 needs disk usage for layers detection
|
// copy_1_1 needs disk usage for layers detection
|
||||||
//if(!copy_1_1)
|
//if(!copy_1_1)
|
||||||
{
|
{
|
||||||
d = wd_open_disc(read_src_wii_disc, callback_data);
|
d = wd_open_disc(read_src_wii_disc, callback_data);
|
||||||
if(!d)
|
if(!d)
|
||||||
ERROR("unable to open wii disc");
|
ERROR("unable to open wii disc\n");
|
||||||
|
|
||||||
wd_build_disc_usage(d, sel, used);
|
wd_build_disc_usage(d, sel, used);
|
||||||
wd_close_disc(d);
|
wd_close_disc(d);
|
||||||
@ -471,7 +472,7 @@ u32 wbfs_add_disc(wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, void *ca
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(i == p->max_disc)
|
if(i == p->max_disc)
|
||||||
ERROR("no space left on device (table full)");
|
ERROR("no space left on device (table full)\n");
|
||||||
p->head->disc_table[i] = 1;
|
p->head->disc_table[i] = 1;
|
||||||
discn = i;
|
discn = i;
|
||||||
load_freeblocks(p);
|
load_freeblocks(p);
|
||||||
@ -482,7 +483,7 @@ u32 wbfs_add_disc(wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, void *ca
|
|||||||
|
|
||||||
copy_buffer = wbfs_ioalloc(p->wii_sec_sz);
|
copy_buffer = wbfs_ioalloc(p->wii_sec_sz);
|
||||||
if(!copy_buffer)
|
if(!copy_buffer)
|
||||||
ERROR("alloc memory");
|
ERROR("alloc memory\n");
|
||||||
tot = 0;
|
tot = 0;
|
||||||
cur = 0;
|
cur = 0;
|
||||||
num_wbfs_sect_to_copy = p->n_wbfs_sec_per_disc;
|
num_wbfs_sect_to_copy = p->n_wbfs_sec_per_disc;
|
||||||
@ -523,7 +524,7 @@ u32 wbfs_add_disc(wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, void *ca
|
|||||||
|
|
||||||
bl = alloc_block(p);
|
bl = alloc_block(p);
|
||||||
if (bl==0xffff)
|
if (bl==0xffff)
|
||||||
ERROR("no space left on device (disc full)");
|
ERROR("no space left on device (disc full)\n");
|
||||||
for(j = 0; j < wii_sec_per_wbfs_sect; j++)
|
for(j = 0; j < wii_sec_per_wbfs_sect; j++)
|
||||||
{
|
{
|
||||||
u32 offset = (i * (p->wbfs_sec_sz >> 2)) + (j * (p->wii_sec_sz >> 2));
|
u32 offset = (i * (p->wbfs_sec_sz >> 2)) + (j * (p->wii_sec_sz >> 2));
|
||||||
@ -540,12 +541,12 @@ u32 wbfs_add_disc(wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, void *ca
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//ERROR("read error");
|
//ERROR("read error");
|
||||||
printf("\rWARNING: read (%u) error (%d)\n", offset, ret);
|
gprintf("\rWARNING: read (%u) error (%d)\n", offset, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fix the partition table
|
//fix the partition table
|
||||||
if(offset == (0x40000>>2))
|
if(offset == (0x40000>>2))
|
||||||
wd_fix_partition_table(d, sel, copy_buffer);
|
wd_fix_partition_table(sel, copy_buffer);
|
||||||
p->write_hdsector(p->callback_data, p->part_lba + bl * (p->wbfs_sec_sz / p->hd_sec_sz) + j
|
p->write_hdsector(p->callback_data, p->part_lba + bl * (p->wbfs_sec_sz / p->hd_sec_sz) + j
|
||||||
* (p->wii_sec_sz / p->hd_sec_sz), p->wii_sec_sz / p->hd_sec_sz, copy_buffer);
|
* (p->wii_sec_sz / p->hd_sec_sz), p->wii_sec_sz / p->hd_sec_sz, copy_buffer);
|
||||||
cur++;
|
cur++;
|
||||||
@ -559,7 +560,7 @@ u32 wbfs_add_disc(wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, void *ca
|
|||||||
}
|
}
|
||||||
// write disc info
|
// write disc info
|
||||||
int disc_info_sz_lba = p->disc_info_sz>>p->hd_sec_sz_s;
|
int disc_info_sz_lba = p->disc_info_sz>>p->hd_sec_sz_s;
|
||||||
p->write_hdsector(p->callback_data,p->part_lba+1+discn*disc_info_sz_lba,disc_info_sz_lba,info);
|
p->write_hdsector(p->callback_data, p->part_lba+1+discn*disc_info_sz_lba,disc_info_sz_lba,info);
|
||||||
wbfs_sync(p);
|
wbfs_sync(p);
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
||||||
@ -594,7 +595,7 @@ u32 wbfs_rm_disc(wbfs_t *p, u8* discid)
|
|||||||
free_block(p,iwlba);
|
free_block(p,iwlba);
|
||||||
}
|
}
|
||||||
memset(d->header,0,p->disc_info_sz);
|
memset(d->header,0,p->disc_info_sz);
|
||||||
p->write_hdsector(p->callback_data,p->part_lba+1+discn*disc_info_sz_lba,disc_info_sz_lba,d->header);
|
p->write_hdsector(p->callback_data, p->part_lba+1+discn*disc_info_sz_lba,disc_info_sz_lba,d->header);
|
||||||
p->head->disc_table[discn] = 0;
|
p->head->disc_table[discn] = 0;
|
||||||
wbfs_close_disc(d);
|
wbfs_close_disc(d);
|
||||||
wbfs_sync(p);
|
wbfs_sync(p);
|
||||||
@ -615,36 +616,6 @@ u32 wbfs_trim(wbfs_t *p)
|
|||||||
return maxbl;
|
return maxbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// data extraction
|
|
||||||
u32 wbfs_extract_disc(wbfs_disc_t*d, rw_sector_callback_t write_dst_wii_sector,
|
|
||||||
void *callback_data,progress_callback_t spinner)
|
|
||||||
{
|
|
||||||
wbfs_t *p = d->p;
|
|
||||||
u8* copy_buffer = 0;
|
|
||||||
int i;
|
|
||||||
int src_wbs_nlb = p->wbfs_sec_sz / p->hd_sec_sz;
|
|
||||||
int dst_wbs_nlb = p->wbfs_sec_sz / p->wii_sec_sz;
|
|
||||||
copy_buffer = wbfs_ioalloc(p->wbfs_sec_sz);
|
|
||||||
if (!copy_buffer)
|
|
||||||
ERROR("alloc memory");
|
|
||||||
|
|
||||||
for(i = 0; i < p->n_wbfs_sec_per_disc; i++)
|
|
||||||
{
|
|
||||||
u32 iwlba = wbfs_ntohs(d->header->wlba_table[i]);
|
|
||||||
if (iwlba)
|
|
||||||
{
|
|
||||||
if(spinner)
|
|
||||||
spinner(i, p->n_wbfs_sec_per_disc, NULL);
|
|
||||||
p->read_hdsector(p->callback_data, p->part_lba + iwlba * src_wbs_nlb, src_wbs_nlb, copy_buffer);
|
|
||||||
write_dst_wii_sector(callback_data, i * dst_wbs_nlb, dst_wbs_nlb, copy_buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wbfs_iofree(copy_buffer);
|
|
||||||
return 0;
|
|
||||||
error:
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 wbfs_size_disc(wbfs_t *p,read_wiidisc_callback_t read_src_wii_disc,
|
u32 wbfs_size_disc(wbfs_t *p,read_wiidisc_callback_t read_src_wii_disc,
|
||||||
void *callback_data,partition_selector_t sel, u32 *comp_size, u32 *real_size)
|
void *callback_data,partition_selector_t sel, u32 *comp_size, u32 *real_size)
|
||||||
{
|
{
|
||||||
@ -655,11 +626,11 @@ u32 wbfs_size_disc(wbfs_t *p,read_wiidisc_callback_t read_src_wii_disc,
|
|||||||
|
|
||||||
u8 *used = wbfs_malloc(p->n_wii_sec_per_disc);
|
u8 *used = wbfs_malloc(p->n_wii_sec_per_disc);
|
||||||
if(!used)
|
if(!used)
|
||||||
ERROR("unable to alloc memory");
|
ERROR("unable to alloc memory\n");
|
||||||
|
|
||||||
d = wd_open_disc(read_src_wii_disc,callback_data);
|
d = wd_open_disc(read_src_wii_disc,callback_data);
|
||||||
if(!d)
|
if(!d)
|
||||||
ERROR("unable to open wii disc");
|
ERROR("unable to open wii disc\n");
|
||||||
|
|
||||||
wd_build_disc_usage(d, sel, used);
|
wd_build_disc_usage(d, sel, used);
|
||||||
wd_close_disc(d);
|
wd_close_disc(d);
|
||||||
@ -707,7 +678,7 @@ u32 wbfs_extract_file(wbfs_disc_t *d, char *path, void **data)
|
|||||||
wd = wd_open_disc(read_wiidisc_wbfsdisc, d);
|
wd = wd_open_disc(read_wiidisc_wbfsdisc, d);
|
||||||
if (!wd)
|
if (!wd)
|
||||||
{
|
{
|
||||||
wbfs_error( "opening wbfs disc" );
|
wbfs_error( "opening wbfs disc\n" );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*data = wd_extract_file(wd, &ret, ONLY_GAME_PARTITION, path);
|
*data = wd_extract_file(wd, &ret, ONLY_GAME_PARTITION, path);
|
||||||
@ -762,11 +733,10 @@ int wbfs_iso_file_read(wbfs_disc_t*d,u32 offset, u8 *data, u32 len)
|
|||||||
//int fd = d->i;
|
//int fd = d->i;
|
||||||
off_t off = ((u64)offset) << 2;
|
off_t off = ((u64)offset) << 2;
|
||||||
off_t ret_off;
|
off_t ret_off;
|
||||||
int ret;
|
|
||||||
ret_off = lseek(fd, off, SEEK_SET);
|
ret_off = lseek(fd, off, SEEK_SET);
|
||||||
if (ret_off != off)
|
if (ret_off != off)
|
||||||
return -1;
|
return -1;
|
||||||
ret = read(fd, data, len);
|
u32 ret = read(fd, data, len);
|
||||||
if (ret != len)
|
if (ret != len)
|
||||||
return -2;
|
return -2;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -63,8 +63,8 @@ typedef struct wbfs_disc_info
|
|||||||
//
|
//
|
||||||
|
|
||||||
// callback definition. Return 1 on fatal error (callback is supposed to make retries until no hopes..)
|
// callback definition. Return 1 on fatal error (callback is supposed to make retries until no hopes..)
|
||||||
typedef int (*rw_sector_callback_t)(void*fp,u32 lba,u32 count,void*iobuf);
|
typedef int (*rw_sector_callback_t)(void *fp, u32 lba, u32 count, void *iobuf);
|
||||||
typedef void (*progress_callback_t)(int status,int total,void *user_data);
|
typedef void (*progress_callback_t)(int status, int total, void *user_data);
|
||||||
|
|
||||||
|
|
||||||
typedef struct wbfs_s
|
typedef struct wbfs_s
|
||||||
@ -123,10 +123,10 @@ typedef struct wbfs_disc_s
|
|||||||
calls wbfs_error() to have textual meaning of errors
|
calls wbfs_error() to have textual meaning of errors
|
||||||
@return NULL in case of error
|
@return NULL in case of error
|
||||||
*/
|
*/
|
||||||
wbfs_t*wbfs_open_hd(rw_sector_callback_t read_hdsector,
|
wbfs_t *wbfs_open_hd(rw_sector_callback_t read_hdsector,
|
||||||
rw_sector_callback_t write_hdsector,
|
rw_sector_callback_t write_hdsector,
|
||||||
void *callback_data,
|
void *callback_data,
|
||||||
int hd_sector_size, int num_hd_sector, int reset);
|
int hd_sector_size, int num_hd_sector, int reset);
|
||||||
|
|
||||||
/*! @brief open a wbfs partition
|
/*! @brief open a wbfs partition
|
||||||
@param read_hdsector,write_hdsector: accessors to the partition
|
@param read_hdsector,write_hdsector: accessors to the partition
|
||||||
@ -137,10 +137,10 @@ wbfs_t*wbfs_open_hd(rw_sector_callback_t read_hdsector,
|
|||||||
calls wbfs_error() to have textual meaning of errors
|
calls wbfs_error() to have textual meaning of errors
|
||||||
@return NULL in case of error
|
@return NULL in case of error
|
||||||
*/
|
*/
|
||||||
wbfs_t*wbfs_open_partition(rw_sector_callback_t read_hdsector,
|
wbfs_t *wbfs_open_partition(rw_sector_callback_t read_hdsector,
|
||||||
rw_sector_callback_t write_hdsector,
|
rw_sector_callback_t write_hdsector,
|
||||||
void *callback_data,
|
void *callback_data,
|
||||||
int hd_sector_size, int num_hd_sector, u32 partition_lba, int reset);
|
int hd_sector_size, int num_hd_sector, u32 partition_lba, int reset);
|
||||||
|
|
||||||
|
|
||||||
/*! @brief close a wbfs partition, and sync the metadatas to the disc */
|
/*! @brief close a wbfs partition, and sync the metadatas to the disc */
|
||||||
@ -205,11 +205,6 @@ u32 wbfs_rm_disc(wbfs_t*p, u8* discid);
|
|||||||
*/
|
*/
|
||||||
u32 wbfs_trim(wbfs_t*p);
|
u32 wbfs_trim(wbfs_t*p);
|
||||||
|
|
||||||
/*! extract a disc from the wbfs, unused sectors are just untouched, allowing descent filesystem to only really usefull space to store the disc.
|
|
||||||
Even if the filesize is 4.7GB, the disc usage will be less.
|
|
||||||
*/
|
|
||||||
u32 wbfs_extract_disc(wbfs_disc_t*d, rw_sector_callback_t write_dst_wii_sector,void *callback_data,progress_callback_t spinner);
|
|
||||||
|
|
||||||
/*! extract a file from the wii disc filesystem.
|
/*! extract a file from the wii disc filesystem.
|
||||||
E.G. Allows to extract the opening.bnr to install a game as a system menu channel
|
E.G. Allows to extract the opening.bnr to install a game as a system menu channel
|
||||||
*/
|
*/
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
|
|
||||||
#ifndef LIBWBFS_GLUE_H
|
#ifndef LIBWBFS_GLUE_H
|
||||||
#define LIBWBFS_GLUE_H
|
#define LIBWBFS_GLUE_H
|
||||||
|
|
||||||
#include <gctypes.h>
|
#include <gctypes.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "mem2.hpp"
|
#include "mem2.hpp"
|
||||||
|
#include "gecko/gecko.h"
|
||||||
|
|
||||||
#define debug_printf(fmt, ...);
|
#define wbfs_fatal(x) do { gprintf(x); wd_last_error = 1; } while(0)
|
||||||
|
#define wbfs_error(x) do { gprintf(x); wd_last_error = 2; } while(0)
|
||||||
#include <stdio.h>
|
|
||||||
#define wbfs_fatal(x) do { wd_last_error = 1; } while(0)
|
|
||||||
#define wbfs_error(x) do { wd_last_error = 2; } while(0)
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
|
|
||||||
#define wbfs_malloc(x) MEM2_alloc(x)
|
#define wbfs_malloc(x) MEM2_alloc(x)
|
||||||
#define wbfs_free(x) SAFE_FREE(x)
|
#define wbfs_free(x) MEM2_free(x)
|
||||||
|
|
||||||
#define wbfs_ioalloc(x) MEM2_alloc(((x) + 31) & ~31)
|
#define wbfs_ioalloc(x) MEM2_alloc(((x) + 31) & ~31)
|
||||||
#define wbfs_iofree(x) SAFE_FREE(x)
|
#define wbfs_iofree(x) MEM2_free(x)
|
||||||
|
|
||||||
#define wbfs_be16(x) (*((u16*)(x)))
|
#define wbfs_be16(x) (*((u16*)(x)))
|
||||||
#define wbfs_be32(x) (*((u32*)(x)))
|
#define wbfs_be32(x) (*((u32*)(x)))
|
||||||
@ -27,11 +27,8 @@
|
|||||||
#define wbfs_ntohs(x) (x)
|
#define wbfs_ntohs(x) (x)
|
||||||
#define wbfs_htons(x) (x)
|
#define wbfs_htons(x) (x)
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define wbfs_memcmp(x,y,z) memcmp(x,y,z)
|
#define wbfs_memcmp(x,y,z) memcmp(x,y,z)
|
||||||
#define wbfs_memcpy(x,y,z) memcpy(x,y,z)
|
#define wbfs_memcpy(x,y,z) memcpy(x,y,z)
|
||||||
#define wbfs_memset(x,y,z) memset(x,y,z)
|
#define wbfs_memset(x,y,z) memset(x,y,z)
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -382,7 +382,6 @@ void aes_decrypt(u8 *iv, u8 *inbuf, u8 *outbuf, unsigned long long len)
|
|||||||
}
|
}
|
||||||
else fraction = 16;
|
else fraction = 16;
|
||||||
|
|
||||||
// debug_printf("block %d: fraction = %d\n", blockno, fraction);
|
|
||||||
memcpy(block, inbuf + blockno * sizeof(block), fraction);
|
memcpy(block, inbuf + blockno * sizeof(block), fraction);
|
||||||
decrypt((char*) block);
|
decrypt((char*) block);
|
||||||
u8 *ctext_ptr;
|
u8 *ctext_ptr;
|
||||||
@ -392,8 +391,6 @@ void aes_decrypt(u8 *iv, u8 *inbuf, u8 *outbuf, unsigned long long len)
|
|||||||
|
|
||||||
for (i = 0; i < fraction; i++)
|
for (i = 0; i < fraction; i++)
|
||||||
outbuf[blockno * sizeof(block) + i] = ctext_ptr[i] ^ block[i];
|
outbuf[blockno * sizeof(block) + i] = ctext_ptr[i] ^ block[i];
|
||||||
// debug_printf("Block %d output: ", blockno);
|
|
||||||
// hexdump(outbuf + blockno*sizeof(block), 16);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,8 +400,6 @@ void aes_encrypt(u8 *iv, u8 *inbuf, u8 *outbuf, unsigned long long len)
|
|||||||
u8 block[16];
|
u8 block[16];
|
||||||
unsigned int blockno = 0, i;
|
unsigned int blockno = 0, i;
|
||||||
|
|
||||||
// debug_printf("aes_decrypt(%p, %p, %p, %lld)\n", iv, inbuf, outbuf, len);
|
|
||||||
|
|
||||||
for (blockno = 0; blockno <= (len / sizeof(block)); blockno++)
|
for (blockno = 0; blockno <= (len / sizeof(block)); blockno++)
|
||||||
{
|
{
|
||||||
unsigned int fraction;
|
unsigned int fraction;
|
||||||
@ -416,7 +411,6 @@ void aes_encrypt(u8 *iv, u8 *inbuf, u8 *outbuf, unsigned long long len)
|
|||||||
}
|
}
|
||||||
else fraction = 16;
|
else fraction = 16;
|
||||||
|
|
||||||
// debug_printf("block %d: fraction = %d\n", blockno, fraction);
|
|
||||||
memcpy(block, inbuf + blockno * sizeof(block), fraction);
|
memcpy(block, inbuf + blockno * sizeof(block), fraction);
|
||||||
|
|
||||||
for (i = 0; i < fraction; i++)
|
for (i = 0; i < fraction; i++)
|
||||||
@ -425,8 +419,6 @@ void aes_encrypt(u8 *iv, u8 *inbuf, u8 *outbuf, unsigned long long len)
|
|||||||
encrypt((char*) block);
|
encrypt((char*) block);
|
||||||
memcpy(iv, block, sizeof(block));
|
memcpy(iv, block, sizeof(block));
|
||||||
memcpy(outbuf + blockno * sizeof(block), block, sizeof(block));
|
memcpy(outbuf + blockno * sizeof(block), block, sizeof(block));
|
||||||
// debug_printf("Block %d output: ", blockno);
|
|
||||||
// hexdump(outbuf + blockno*sizeof(block), 16);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,9 +40,12 @@ static void disc_read(wiidisc_t *d, u32 offset, u8 *data, u32 len)
|
|||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (len == 0) return;
|
if (len == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
ret = d->read(d->fp, offset, len, data);
|
ret = d->read(d->fp, offset, len, data);
|
||||||
if (ret) wbfs_fatal("error reading disc");
|
if(ret)
|
||||||
|
wbfs_fatal("error reading disc\n");
|
||||||
}
|
}
|
||||||
if (d->sector_usage_table)
|
if (d->sector_usage_table)
|
||||||
{
|
{
|
||||||
@ -169,7 +172,8 @@ static void do_files(wiidisc_t*d)
|
|||||||
if (fst_size)
|
if (fst_size)
|
||||||
{
|
{
|
||||||
fst = wbfs_ioalloc(fst_size);
|
fst = wbfs_ioalloc(fst_size);
|
||||||
if (fst == 0) wbfs_fatal("malloc fst");
|
if (fst == 0)
|
||||||
|
wbfs_fatal("malloc fst\n");
|
||||||
partition_read(d, fst_offset, fst, fst_size,0);
|
partition_read(d, fst_offset, fst, fst_size,0);
|
||||||
n_files = _be32(fst + 8);
|
n_files = _be32(fst + 8);
|
||||||
|
|
||||||
@ -217,7 +221,8 @@ static void do_partition(wiidisc_t*d)
|
|||||||
d->partition_data_offset = _be32(b + 0x14);
|
d->partition_data_offset = _be32(b + 0x14);
|
||||||
d->partition_block = (d->partition_raw_offset + d->partition_data_offset) >> 13;
|
d->partition_block = (d->partition_raw_offset + d->partition_data_offset) >> 13;
|
||||||
tmd = wbfs_ioalloc(tmd_size);
|
tmd = wbfs_ioalloc(tmd_size);
|
||||||
if (tmd == 0) wbfs_fatal("malloc tmd");
|
if (tmd == 0)
|
||||||
|
wbfs_fatal("malloc tmd\n");
|
||||||
partition_raw_read(d, tmd_offset, tmd, tmd_size);
|
partition_raw_read(d, tmd_offset, tmd, tmd_size);
|
||||||
|
|
||||||
if(d->extract_pathname && strcmp(d->extract_pathname, "TMD") == 0 && !d->extracted_buffer)
|
if(d->extract_pathname && strcmp(d->extract_pathname, "TMD") == 0 && !d->extracted_buffer)
|
||||||
@ -227,7 +232,8 @@ static void do_partition(wiidisc_t*d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cert = wbfs_ioalloc(cert_size);
|
cert = wbfs_ioalloc(cert_size);
|
||||||
if (cert == 0) wbfs_fatal("malloc cert");
|
if (cert == 0)
|
||||||
|
wbfs_fatal("malloc cert\n");
|
||||||
partition_raw_read(d, cert_offset, cert, cert_size);
|
partition_raw_read(d, cert_offset, cert, cert_size);
|
||||||
|
|
||||||
_decrypt_title_key(tik, d->disc_key);
|
_decrypt_title_key(tik, d->disc_key);
|
||||||
@ -339,7 +345,7 @@ void wd_build_disc_usage(wiidisc_t *d, partition_selector_t selector, u8 *usage_
|
|||||||
d->sector_usage_table = 0;
|
d->sector_usage_table = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wd_fix_partition_table(wiidisc_t *d, partition_selector_t selector, u8 *partition_table)
|
void wd_fix_partition_table(partition_selector_t selector, u8 *partition_table)
|
||||||
{
|
{
|
||||||
u8 *b = partition_table;
|
u8 *b = partition_table;
|
||||||
u32 partition_offset;
|
u32 partition_offset;
|
||||||
@ -349,7 +355,7 @@ void wd_fix_partition_table(wiidisc_t *d, partition_selector_t selector, u8 *par
|
|||||||
if (selector == ALL_PARTITIONS) return;
|
if (selector == ALL_PARTITIONS) return;
|
||||||
n_partitions = _be32(b);
|
n_partitions = _be32(b);
|
||||||
if (_be32(b + 4) - (0x40000 >> 2) > 0x50)
|
if (_be32(b + 4) - (0x40000 >> 2) > 0x50)
|
||||||
wbfs_fatal("cannot modify this partition table. Please report the bug.");
|
wbfs_fatal("cannot modify this partition table. Please report the bug.\n");
|
||||||
|
|
||||||
b += (_be32(b + 4) - (0x40000 >> 2)) * 4;
|
b += (_be32(b + 4) - (0x40000 >> 2)) * 4;
|
||||||
j = 0;
|
j = 0;
|
||||||
|
@ -58,7 +58,7 @@ extern "C"
|
|||||||
void wd_build_disc_usage(wiidisc_t *d, partition_selector_t selector, u8 *usage_table);
|
void wd_build_disc_usage(wiidisc_t *d, partition_selector_t selector, u8 *usage_table);
|
||||||
|
|
||||||
// effectively remove not copied partition from the partition table.
|
// effectively remove not copied partition from the partition table.
|
||||||
void wd_fix_partition_table(wiidisc_t *d, partition_selector_t selector, u8 *partition_table);
|
void wd_fix_partition_table(partition_selector_t selector, u8 *partition_table);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,8 @@ bool SDHC_ReadSectors(u32 sector, u32 count, void *buffer)
|
|||||||
if (!sdhc_buf2)
|
if (!sdhc_buf2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int cnt;
|
u32 cnt;
|
||||||
int max_sec = SDHC_MEM2_SIZE / sector_size;
|
u32 max_sec = SDHC_MEM2_SIZE / sector_size;
|
||||||
//dbg_printf("sdhc_read(%u,%u) unaligned(%p)\n", sector, count, buffer);
|
//dbg_printf("sdhc_read(%u,%u) unaligned(%p)\n", sector, count, buffer);
|
||||||
while (count)
|
while (count)
|
||||||
{
|
{
|
||||||
@ -173,8 +173,8 @@ bool SDHC_WriteSectors(u32 sector, u32 count, void *buffer)
|
|||||||
if (!sdhc_buf2)
|
if (!sdhc_buf2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int cnt;
|
u32 cnt;
|
||||||
int max_sec = SDHC_MEM2_SIZE / sector_size;
|
u32 max_sec = SDHC_MEM2_SIZE / sector_size;
|
||||||
|
|
||||||
while (count)
|
while (count)
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@ static u32 block = 32768;
|
|||||||
static u32 blockIdx = 0;
|
static u32 blockIdx = 0;
|
||||||
static u32 blockInfo[2] = {0,0};
|
static u32 blockInfo[2] = {0,0};
|
||||||
static u32 blockReady = 0;
|
static u32 blockReady = 0;
|
||||||
static u32 stopThread;
|
static s32 stopThread;
|
||||||
static u64 folderSize = 0;
|
static u64 folderSize = 0;
|
||||||
|
|
||||||
// return false if the file doesn't exist
|
// return false if the file doesn't exist
|
||||||
@ -138,7 +138,7 @@ bool fsop_DirExist (char *path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *thread_CopyFileReader (void *arg)
|
static void *thread_CopyFileReader()
|
||||||
{
|
{
|
||||||
u32 rb;
|
u32 rb;
|
||||||
stopThread = 0;
|
stopThread = 0;
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
// Coverflow
|
// Coverflow
|
||||||
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
#include <cwctype>
|
#include <cwctype>
|
||||||
|
|
||||||
#include "coverflow.hpp"
|
#include "coverflow.hpp"
|
||||||
@ -18,8 +16,6 @@
|
|||||||
#include "fonts.h"
|
#include "fonts.h"
|
||||||
#include "gecko.h"
|
#include "gecko.h"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
extern const u8 dvdskin_png[];
|
extern const u8 dvdskin_png[];
|
||||||
extern const u8 dvdskin_red_png[];
|
extern const u8 dvdskin_red_png[];
|
||||||
extern const u8 dvdskin_black_png[];
|
extern const u8 dvdskin_black_png[];
|
||||||
@ -84,6 +80,9 @@ static inline wchar_t upperCaseWChar(wchar_t c)
|
|||||||
return c >= L'a' && c <= L'z' ? c & 0x00DF : c;
|
return c >= L'a' && c <= L'z' ? c & 0x00DF : c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float m_normal_speed;
|
||||||
|
float m_selected_speed;
|
||||||
|
|
||||||
CCoverFlow::CCoverFlow(void)
|
CCoverFlow::CCoverFlow(void)
|
||||||
{
|
{
|
||||||
m_loNormal.camera = Vector3D(0.f, 1.5f, 5.f);
|
m_loNormal.camera = Vector3D(0.f, 1.5f, 5.f);
|
||||||
@ -212,22 +211,24 @@ CCoverFlow::CCoverFlow(void)
|
|||||||
sndCopyNum = 0;
|
sndCopyNum = 0;
|
||||||
m_soundVolume = 0xFF;
|
m_soundVolume = 0xFF;
|
||||||
m_sorting = SORT_ALPHA;
|
m_sorting = SORT_ALPHA;
|
||||||
|
m_normal_speed = 0.1f;
|
||||||
|
m_selected_speed = 0.07f;
|
||||||
//
|
//
|
||||||
LWP_MutexInit(&m_mutex, 0);
|
LWP_MutexInit(&m_mutex, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCoverFlow::init(const SmartBuf &font, u32 font_size, bool vid_50hz)
|
bool CCoverFlow::init(const SmartBuf &font, u32 font_size, bool vid_50hz)
|
||||||
{
|
{
|
||||||
m_50hz = vid_50hz;
|
|
||||||
|
|
||||||
// Load font
|
// Load font
|
||||||
m_font.fromBuffer(font, font_size, TITLEFONT);
|
m_font.fromBuffer(font, font_size, TITLEFONT);
|
||||||
m_fontColor = CColor(0xFFFFFFFF);
|
m_fontColor = CColor(0xFFFFFFFF);
|
||||||
m_fanartFontColor = CColor(0xFFFFFFFF);
|
m_fanartFontColor = CColor(0xFFFFFFFF);
|
||||||
|
|
||||||
if(m_50hz)
|
if(vid_50hz)
|
||||||
{
|
{
|
||||||
gprintf("WiiFlow is in 50hz mode\n");
|
gprintf("WiiFlow is in 50hz mode\n");
|
||||||
|
m_normal_speed = 0.12f;
|
||||||
|
m_selected_speed = 0.084f;
|
||||||
m_minDelay = 4;
|
m_minDelay = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1448,16 +1449,16 @@ void CCoverFlow::_loadCover(int i, int item)
|
|||||||
m_covers[i].title.setText(m_font, m_items[item].hdr->title);
|
m_covers[i].title.setText(m_font, m_items[item].hdr->title);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CCoverFlow::getId(void) const
|
string CCoverFlow::getId(void) const
|
||||||
{
|
{
|
||||||
if (m_covers.empty() || m_items.empty()) return "";
|
if (m_covers.empty() || m_items.empty()) return "";
|
||||||
return std::string((char *) &m_items[loopNum(m_covers[m_range / 2].index + m_jump, m_items.size())].hdr->hdr.id);
|
return string((char *) &m_items[loopNum(m_covers[m_range / 2].index + m_jump, m_items.size())].hdr->hdr.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CCoverFlow::getNextId(void) const
|
string CCoverFlow::getNextId(void) const
|
||||||
{
|
{
|
||||||
if (m_covers.empty() || m_items.empty()) return "";
|
if (m_covers.empty() || m_items.empty()) return "";
|
||||||
return std::string((char *) &m_items[loopNum(m_covers[m_range / 2].index + m_jump + 1, m_items.size())].hdr->hdr.id);
|
return string((char *) &m_items[loopNum(m_covers[m_range / 2].index + m_jump + 1, m_items.size())].hdr->hdr.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
dir_discHdr * CCoverFlow::getHdr(void) const
|
dir_discHdr * CCoverFlow::getHdr(void) const
|
||||||
@ -2008,7 +2009,7 @@ bool CCoverFlow::findId(const char *id, bool instant)
|
|||||||
for (i = 0; i < m_items.size(); ++i)
|
for (i = 0; i < m_items.size(); ++i)
|
||||||
if (memcmp(&m_items[i].hdr->hdr.id, id, strlen(id)) == 0)
|
if (memcmp(&m_items[i].hdr->hdr.id, id, strlen(id)) == 0)
|
||||||
break;
|
break;
|
||||||
else if (strlen(id) > 6 && memcmp(&m_items[i].hdr->path[std::string(m_items[i].hdr->path).find_last_of("/")], id, strlen(id)) == 0)
|
else if (strlen(id) > 6 && memcmp(&m_items[i].hdr->path[string(m_items[i].hdr->path).find_last_of("/")], id, strlen(id)) == 0)
|
||||||
break;
|
break;
|
||||||
if (i >= m_items.size())
|
if (i >= m_items.size())
|
||||||
return false;
|
return false;
|
||||||
@ -2355,7 +2356,7 @@ void CCoverFlow::prevID(wchar_t *c)
|
|||||||
|
|
||||||
void CCoverFlow::_coverTick(int i)
|
void CCoverFlow::_coverTick(int i)
|
||||||
{
|
{
|
||||||
float speed = m_selected ? (m_50hz ? 0.085f : 0.07f) : (m_50hz ? 0.12f : 0.1f);
|
float speed = m_selected ? m_selected_speed : m_normal_speed;
|
||||||
Vector3D posDist(m_covers[i].targetPos - m_covers[i].pos);
|
Vector3D posDist(m_covers[i].targetPos - m_covers[i].pos);
|
||||||
|
|
||||||
if (posDist.sqNorm() < 0.5f)
|
if (posDist.sqNorm() < 0.5f)
|
||||||
@ -2546,7 +2547,7 @@ bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq)
|
|||||||
SmartBuf zBuffer = m_compressCache ? smartMem2Alloc(zBufferSize) : tex.data;
|
SmartBuf zBuffer = m_compressCache ? smartMem2Alloc(zBufferSize) : tex.data;
|
||||||
if (!!zBuffer && (!m_compressCache || compress(zBuffer.get(), &zBufferSize, tex.data.get(), bufSize) == Z_OK))
|
if (!!zBuffer && (!m_compressCache || compress(zBuffer.get(), &zBufferSize, tex.data.get(), bufSize) == Z_OK))
|
||||||
{
|
{
|
||||||
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == 0x4c4f4c4f ? &m_items[i].hdr->path[std::string(m_items[i].hdr->path).find_last_of("/")] : (char*)m_items[i].hdr->hdr.id)), "wb");
|
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == 0x4c4f4c4f ? &m_items[i].hdr->path[string(m_items[i].hdr->path).find_last_of("/")] : (char*)m_items[i].hdr->hdr.id)), "wb");
|
||||||
if (file != 0)
|
if (file != 0)
|
||||||
{
|
{
|
||||||
SWFCHeader header(tex, box, m_compressCache);
|
SWFCHeader header(tex, box, m_compressCache);
|
||||||
@ -2613,7 +2614,7 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq)
|
|||||||
// Try to find the texture in the cache
|
// Try to find the texture in the cache
|
||||||
if (!m_cachePath.empty())
|
if (!m_cachePath.empty())
|
||||||
{
|
{
|
||||||
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == 0x4c4f4c4f ? &m_items[i].hdr->path[std::string(m_items[i].hdr->path).find_last_of("/")] : (char*)m_items[i].hdr->hdr.id)), "rb");
|
FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == 0x4c4f4c4f ? &m_items[i].hdr->path[string(m_items[i].hdr->path).find_last_of("/")] : (char*)m_items[i].hdr->hdr.id)), "rb");
|
||||||
if (file != 0)
|
if (file != 0)
|
||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include "disc.h"
|
#include "disc.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
enum Sorting
|
enum Sorting
|
||||||
{
|
{
|
||||||
SORT_ALPHA,
|
SORT_ALPHA,
|
||||||
@ -81,7 +83,7 @@ public:
|
|||||||
void setCompression(bool enable) { m_compressTextures = enable; }
|
void setCompression(bool enable) { m_compressTextures = enable; }
|
||||||
bool getBoxMode(void) const { return m_box;}
|
bool getBoxMode(void) const { return m_box;}
|
||||||
void setBufferSize(u32 numCovers);
|
void setBufferSize(u32 numCovers);
|
||||||
void setTextures(const std::string &loadingPic, const std::string &loadingPicFlat, const std::string &noCoverPic, const std::string &noCoverPicFlat);
|
void setTextures(const string &loadingPic, const string &loadingPicFlat, const string &noCoverPic, const string &noCoverPicFlat);
|
||||||
void setFont(SFont font, const CColor &color);
|
void setFont(SFont font, const CColor &color);
|
||||||
void setRange(u32 rows, u32 columns);
|
void setRange(u32 rows, u32 columns);
|
||||||
void setBoxMode(bool box);
|
void setBoxMode(bool box);
|
||||||
@ -123,8 +125,8 @@ public:
|
|||||||
bool fullCoverCached(const char *id);
|
bool fullCoverCached(const char *id);
|
||||||
bool preCacheCover(const char *id, const u8 *png, bool full);
|
bool preCacheCover(const char *id, const u8 *png, bool full);
|
||||||
//
|
//
|
||||||
std::string getId(void) const;
|
string getId(void) const;
|
||||||
std::string getNextId(void) const;
|
string getNextId(void) const;
|
||||||
dir_discHdr * getHdr(void) const;
|
dir_discHdr * getHdr(void) const;
|
||||||
dir_discHdr * getNextHdr(void) const;
|
dir_discHdr * getNextHdr(void) const;
|
||||||
wstringEx getTitle(void) const;
|
wstringEx getTitle(void) const;
|
||||||
@ -185,8 +187,8 @@ private:
|
|||||||
struct CItem
|
struct CItem
|
||||||
{
|
{
|
||||||
dir_discHdr *hdr;
|
dir_discHdr *hdr;
|
||||||
std::string picPath;
|
string picPath;
|
||||||
std::string boxPicPath;
|
string boxPicPath;
|
||||||
int playcount;
|
int playcount;
|
||||||
unsigned int lastPlayed;
|
unsigned int lastPlayed;
|
||||||
STexture texture;
|
STexture texture;
|
||||||
@ -246,10 +248,10 @@ private:
|
|||||||
STexture m_dvdSkin_GreenOne;
|
STexture m_dvdSkin_GreenOne;
|
||||||
STexture m_dvdSkin_GreenTwo;
|
STexture m_dvdSkin_GreenTwo;
|
||||||
// Settings
|
// Settings
|
||||||
std::string m_pngLoadCover;
|
string m_pngLoadCover;
|
||||||
std::string m_pngLoadCoverFlat;
|
string m_pngLoadCoverFlat;
|
||||||
std::string m_pngNoCover;
|
string m_pngNoCover;
|
||||||
std::string m_pngNoCoverFlat;
|
string m_pngNoCoverFlat;
|
||||||
u32 m_numBufCovers;
|
u32 m_numBufCovers;
|
||||||
SFont m_font;
|
SFont m_font;
|
||||||
CColor m_fontColor;
|
CColor m_fontColor;
|
||||||
@ -257,7 +259,6 @@ private:
|
|||||||
bool m_fanartPlaying;
|
bool m_fanartPlaying;
|
||||||
bool m_box;
|
bool m_box;
|
||||||
bool m_useHQcover;
|
bool m_useHQcover;
|
||||||
bool m_50hz;
|
|
||||||
u32 m_range;
|
u32 m_range;
|
||||||
u32 m_rows;
|
u32 m_rows;
|
||||||
u32 m_columns;
|
u32 m_columns;
|
||||||
@ -267,7 +268,7 @@ private:
|
|||||||
bool m_hideCover;
|
bool m_hideCover;
|
||||||
bool m_compressTextures;
|
bool m_compressTextures;
|
||||||
bool m_compressCache;
|
bool m_compressCache;
|
||||||
std::string m_cachePath;
|
string m_cachePath;
|
||||||
bool m_deletePicsAfterCaching;
|
bool m_deletePicsAfterCaching;
|
||||||
bool m_mirrorBlur;
|
bool m_mirrorBlur;
|
||||||
float m_mirrorAlpha;
|
float m_mirrorAlpha;
|
||||||
|
@ -26,13 +26,15 @@
|
|||||||
* gcvid.cpp
|
* gcvid.cpp
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "gcvid.h"
|
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
#include <cstdlib> //NULL
|
#include <cstdlib> //NULL
|
||||||
#include <cstring> //memcmp
|
#include <cstring> //memcmp
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
#include "gcvid.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "mem2.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void readThpHeader(FILE* f, ThpHeader& h)
|
void readThpHeader(FILE* f, ThpHeader& h)
|
||||||
@ -278,7 +280,7 @@ void VideoFrame::resize(int width, int height)
|
|||||||
_p = 3*width;
|
_p = 3*width;
|
||||||
_p += (4 - _p%4)%4;
|
_p += (4 - _p%4)%4;
|
||||||
|
|
||||||
_data = (u8 *) malloc(_p * _h);
|
_data = (u8 *)MEM2_alloc(_p * _h);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VideoFrame::getWidth() const
|
int VideoFrame::getWidth() const
|
||||||
@ -298,7 +300,7 @@ const u8* VideoFrame::getData() const
|
|||||||
|
|
||||||
void VideoFrame::dealloc()
|
void VideoFrame::dealloc()
|
||||||
{
|
{
|
||||||
SAFE_FREE(_data);
|
MEM2_free(_data);
|
||||||
_w = _h = _p = 0;
|
_w = _h = _p = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,9 +15,7 @@ More info : http://frontier-dev.net
|
|||||||
#include "png.h"
|
#include "png.h"
|
||||||
#include "mem2.hpp"
|
#include "mem2.hpp"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "gecko/gecko.h"
|
||||||
#undef malloc
|
|
||||||
#define malloc MEM2_alloc
|
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
#define PNGU_SOURCE_BUFFER 1
|
#define PNGU_SOURCE_BUFFER 1
|
||||||
@ -30,7 +28,6 @@ int pngu_decode (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlph
|
|||||||
void pngu_free_info (IMGCTX ctx);
|
void pngu_free_info (IMGCTX ctx);
|
||||||
void pngu_read_data_from_buffer (png_structp png_ptr, png_bytep data, png_size_t length);
|
void pngu_read_data_from_buffer (png_structp png_ptr, png_bytep data, png_size_t length);
|
||||||
void pngu_write_data_to_buffer (png_structp png_ptr, png_bytep data, png_size_t length);
|
void pngu_write_data_to_buffer (png_structp png_ptr, png_bytep data, png_size_t length);
|
||||||
void pngu_flush_data_to_buffer (png_structp png_ptr);
|
|
||||||
int pngu_clamp (int value, int min, int max);
|
int pngu_clamp (int value, int min, int max);
|
||||||
|
|
||||||
|
|
||||||
@ -62,7 +59,7 @@ IMGCTX PNGU_SelectImageFromBuffer (const void *buffer)
|
|||||||
{
|
{
|
||||||
if (!buffer) return NULL;
|
if (!buffer) return NULL;
|
||||||
|
|
||||||
IMGCTX ctx = malloc (sizeof (struct _IMGCTX));
|
IMGCTX ctx = MEM2_alloc(sizeof (struct _IMGCTX));
|
||||||
if (!ctx) return NULL;
|
if (!ctx) return NULL;
|
||||||
|
|
||||||
ctx->buffer = (void *) buffer;
|
ctx->buffer = (void *) buffer;
|
||||||
@ -79,19 +76,20 @@ IMGCTX PNGU_SelectImageFromBuffer (const void *buffer)
|
|||||||
|
|
||||||
IMGCTX PNGU_SelectImageFromDevice (const char *filename)
|
IMGCTX PNGU_SelectImageFromDevice (const char *filename)
|
||||||
{
|
{
|
||||||
if (!filename) return NULL;
|
if (!filename)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
IMGCTX ctx = malloc (sizeof (struct _IMGCTX));
|
IMGCTX ctx = MEM2_alloc(sizeof (struct _IMGCTX));
|
||||||
if (!ctx) return NULL;
|
if (!ctx) 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 = malloc (strlen (filename) + 1);
|
ctx->filename = MEM2_alloc(strlen (filename) + 1);
|
||||||
if (!ctx->filename)
|
if (!ctx->filename)
|
||||||
{
|
{
|
||||||
SAFE_FREE(ctx);
|
MEM2_free(ctx);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strcpy(ctx->filename, filename);
|
strcpy(ctx->filename, filename);
|
||||||
@ -105,16 +103,18 @@ IMGCTX PNGU_SelectImageFromDevice (const char *filename)
|
|||||||
|
|
||||||
void PNGU_ReleaseImageContext (IMGCTX ctx)
|
void PNGU_ReleaseImageContext (IMGCTX ctx)
|
||||||
{
|
{
|
||||||
if (!ctx) return;
|
if(!ctx)
|
||||||
|
return;
|
||||||
|
|
||||||
if (ctx->filename) SAFE_FREE (ctx->filename);
|
if(ctx->filename)
|
||||||
|
MEM2_free(ctx->filename);
|
||||||
|
|
||||||
if ((ctx->propRead) && (ctx->prop.trans))
|
if((ctx->propRead) && (ctx->prop.trans))
|
||||||
SAFE_FREE (ctx->prop.trans);
|
MEM2_free(ctx->prop.trans);
|
||||||
|
|
||||||
pngu_free_info (ctx);
|
pngu_free_info(ctx);
|
||||||
|
|
||||||
SAFE_FREE (ctx);
|
MEM2_free(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -766,21 +766,21 @@ int PNGU_DecodeToCMPR(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer)
|
|||||||
outBuf += 4;
|
outBuf += 4;
|
||||||
}
|
}
|
||||||
// Free resources
|
// Free resources
|
||||||
SAFE_FREE (ctx->img_data);
|
MEM2_free(ctx->img_data);
|
||||||
SAFE_FREE (ctx->row_pointers);
|
MEM2_free(ctx->row_pointers);
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
return PNGU_OK;
|
return PNGU_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void user_error(png_structp png_ptr, png_const_charp c)
|
||||||
void user_error (png_structp png_ptr, png_const_charp c)
|
|
||||||
{
|
{
|
||||||
longjmp(png_jmpbuf(png_ptr), 1);
|
longjmp(png_jmpbuf(png_ptr), 1);
|
||||||
|
gprintf("%s\n", c);
|
||||||
}
|
}
|
||||||
int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
int PNGU_EncodeFromYCbYCr(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride)
|
||||||
|
{
|
||||||
// Erase from the context any readed info
|
// Erase from the context any readed info
|
||||||
pngu_free_info (ctx);
|
pngu_free_info (ctx);
|
||||||
ctx->propRead = 0;
|
ctx->propRead = 0;
|
||||||
@ -820,7 +820,7 @@ int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu
|
|||||||
{
|
{
|
||||||
// Installation of our custom data writer function
|
// Installation of our custom data writer function
|
||||||
ctx->cursor = 0;
|
ctx->cursor = 0;
|
||||||
png_set_write_fn (ctx->png_ptr, ctx, pngu_write_data_to_buffer, pngu_flush_data_to_buffer);
|
png_set_write_fn (ctx->png_ptr, ctx, pngu_write_data_to_buffer, NULL);
|
||||||
}
|
}
|
||||||
else if (ctx->source == PNGU_SOURCE_DEVICE)
|
else if (ctx->source == PNGU_SOURCE_DEVICE)
|
||||||
{
|
{
|
||||||
@ -837,7 +837,7 @@ int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu
|
|||||||
if (rowbytes % 4)
|
if (rowbytes % 4)
|
||||||
rowbytes = ((rowbytes / 4) + 1) * 4; // Add extra padding so each row starts in a 4 byte boundary
|
rowbytes = ((rowbytes / 4) + 1) * 4; // Add extra padding so each row starts in a 4 byte boundary
|
||||||
|
|
||||||
ctx->img_data = malloc (rowbytes * height);
|
ctx->img_data = MEM2_alloc(rowbytes * height);
|
||||||
if (!ctx->img_data)
|
if (!ctx->img_data)
|
||||||
{
|
{
|
||||||
png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL);
|
png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL);
|
||||||
@ -846,7 +846,7 @@ int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu
|
|||||||
return PNGU_LIB_ERROR;
|
return PNGU_LIB_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->row_pointers = malloc (sizeof (png_bytep) * height);
|
ctx->row_pointers = MEM2_alloc(sizeof (png_bytep) * height);
|
||||||
if (!ctx->row_pointers)
|
if (!ctx->row_pointers)
|
||||||
{
|
{
|
||||||
png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL);
|
png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL);
|
||||||
@ -878,8 +878,8 @@ int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu
|
|||||||
png_write_end (ctx->png_ptr, (png_infop) NULL);
|
png_write_end (ctx->png_ptr, (png_infop) NULL);
|
||||||
|
|
||||||
// Free resources
|
// Free resources
|
||||||
SAFE_FREE (ctx->img_data);
|
MEM2_free(ctx->img_data);
|
||||||
SAFE_FREE (ctx->row_pointers);
|
MEM2_free(ctx->row_pointers);
|
||||||
png_destroy_write_struct (&(ctx->png_ptr), &(ctx->info_ptr));
|
png_destroy_write_struct (&(ctx->png_ptr), &(ctx->info_ptr));
|
||||||
if (ctx->source == PNGU_SOURCE_DEVICE)
|
if (ctx->source == PNGU_SOURCE_DEVICE)
|
||||||
fclose (ctx->fd);
|
fclose (ctx->fd);
|
||||||
@ -1048,7 +1048,7 @@ int pngu_info (IMGCTX ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Query list of transparent colors, if any.
|
// Query list of transparent colors, if any.
|
||||||
int i;
|
u32 i;
|
||||||
png_bytep trans;
|
png_bytep trans;
|
||||||
png_color_16p trans_values;
|
png_color_16p trans_values;
|
||||||
ctx->prop.numTrans = 0;
|
ctx->prop.numTrans = 0;
|
||||||
@ -1058,7 +1058,7 @@ int pngu_info (IMGCTX ctx)
|
|||||||
{
|
{
|
||||||
if (ctx->prop.numTrans)
|
if (ctx->prop.numTrans)
|
||||||
{
|
{
|
||||||
ctx->prop.trans = malloc (sizeof (PNGUCOLOR) * ctx->prop.numTrans);
|
ctx->prop.trans = MEM2_alloc(sizeof (PNGUCOLOR) * ctx->prop.numTrans);
|
||||||
if (ctx->prop.trans)
|
if (ctx->prop.trans)
|
||||||
{
|
{
|
||||||
for (i = 0; i < ctx->prop.numTrans; i++)
|
for (i = 0; i < ctx->prop.numTrans; i++)
|
||||||
@ -1077,7 +1077,7 @@ int pngu_info (IMGCTX ctx)
|
|||||||
{
|
{
|
||||||
if (ctx->prop.numTrans)
|
if (ctx->prop.numTrans)
|
||||||
{
|
{
|
||||||
ctx->prop.trans = malloc (sizeof (PNGUCOLOR) * ctx->prop.numTrans);
|
ctx->prop.trans = MEM2_alloc(sizeof (PNGUCOLOR) * ctx->prop.numTrans);
|
||||||
if (ctx->prop.trans)
|
if (ctx->prop.trans)
|
||||||
for (i = 0; i < ctx->prop.numTrans; i++)
|
for (i = 0; i < ctx->prop.numTrans; i++)
|
||||||
ctx->prop.trans[i].r = ctx->prop.trans[i].g = ctx->prop.trans[i].b =
|
ctx->prop.trans[i].r = ctx->prop.trans[i].g = ctx->prop.trans[i].b =
|
||||||
@ -1099,7 +1099,7 @@ int pngu_info (IMGCTX ctx)
|
|||||||
|
|
||||||
int pngu_decode (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlpha, int force32bit)
|
int pngu_decode (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlpha, int force32bit)
|
||||||
{
|
{
|
||||||
int i;
|
u32 i;
|
||||||
int mem_err = 0;
|
int mem_err = 0;
|
||||||
|
|
||||||
// Read info if it hasn't been read before
|
// Read info if it hasn't been read before
|
||||||
@ -1130,7 +1130,7 @@ int pngu_decode (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlph
|
|||||||
//printf("*** This is a corrupted image!!\n"); sleep(5);
|
//printf("*** This is a corrupted image!!\n"); sleep(5);
|
||||||
return mem_err ? PNGU_LIB_ERROR : -666;
|
return mem_err ? PNGU_LIB_ERROR : -666;
|
||||||
}
|
}
|
||||||
png_set_error_fn (ctx->png_ptr, NULL, user_error, user_error);
|
png_set_error_fn(ctx->png_ptr, NULL, user_error, user_error);
|
||||||
// Scale 16 bit samples to 8 bit
|
// Scale 16 bit samples to 8 bit
|
||||||
if (ctx->prop.imgBitDepth == 16)
|
if (ctx->prop.imgBitDepth == 16)
|
||||||
png_set_strip_16 (ctx->png_ptr);
|
png_set_strip_16 (ctx->png_ptr);
|
||||||
@ -1159,14 +1159,14 @@ int pngu_decode (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlph
|
|||||||
if (rowbytes % 4)
|
if (rowbytes % 4)
|
||||||
rowbytes = ((rowbytes / 4) + 1) * 4; // Add extra padding so each row starts in a 4 byte boundary
|
rowbytes = ((rowbytes / 4) + 1) * 4; // Add extra padding so each row starts in a 4 byte boundary
|
||||||
|
|
||||||
ctx->img_data = malloc (rowbytes * ctx->prop.imgHeight);
|
ctx->img_data = MEM2_alloc(rowbytes * ctx->prop.imgHeight);
|
||||||
if (!ctx->img_data)
|
if (!ctx->img_data)
|
||||||
{
|
{
|
||||||
mem_err = 1;
|
mem_err = 1;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->row_pointers = malloc (sizeof (png_bytep) * ctx->prop.imgHeight);
|
ctx->row_pointers = MEM2_alloc(sizeof (png_bytep) * ctx->prop.imgHeight);
|
||||||
if (!ctx->row_pointers)
|
if (!ctx->row_pointers)
|
||||||
{
|
{
|
||||||
mem_err = 1;
|
mem_err = 1;
|
||||||
@ -1195,8 +1195,9 @@ int pngu_decode (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlph
|
|||||||
|
|
||||||
// restore default error handling
|
// restore default error handling
|
||||||
memcpy(png_jmpbuf(ctx->png_ptr), save_jmp, sizeof(save_jmp));
|
memcpy(png_jmpbuf(ctx->png_ptr), save_jmp, sizeof(save_jmp));
|
||||||
|
|
||||||
// Free resources
|
// Free resources
|
||||||
pngu_free_info (ctx);
|
pngu_free_info(ctx);
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
return PNGU_OK;
|
return PNGU_OK;
|
||||||
@ -1239,13 +1240,6 @@ void pngu_write_data_to_buffer (png_structp png_ptr, png_bytep data, png_size_t
|
|||||||
ctx->cursor += length;
|
ctx->cursor += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void pngu_flush_data_to_buffer (png_structp png_ptr)
|
|
||||||
{
|
|
||||||
// Nothing to do here
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Function used in YCbYCr to RGB decoding
|
// Function used in YCbYCr to RGB decoding
|
||||||
int pngu_clamp (int value, int min, int max)
|
int pngu_clamp (int value, int min, int max)
|
||||||
{
|
{
|
||||||
|
@ -26,11 +26,7 @@ static u32 buffer[0x20] ATTRIBUTE_ALIGN(32);
|
|||||||
|
|
||||||
static bool maindolpatches(void *dst, int len, u8 vidMode, GXRModeObj *vmode, bool vipatch, bool countryString, u8 patchVidModes, int aspectRatio);
|
static bool maindolpatches(void *dst, int len, u8 vidMode, GXRModeObj *vmode, bool vipatch, bool countryString, u8 patchVidModes, int aspectRatio);
|
||||||
static bool Remove_001_Protection(void *Address, int Size);
|
static bool Remove_001_Protection(void *Address, int Size);
|
||||||
static bool PrinceOfPersiaPatch();
|
static bool PrinceOfPersiaPatch();
|
||||||
|
|
||||||
static void __noprint(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 Apploader_Run(entry_point *entry, u8 vidMode, GXRModeObj *vmode, bool vipatch, bool countryString, u8 patchVidModes, int aspectRatio)
|
s32 Apploader_Run(entry_point *entry, u8 vidMode, GXRModeObj *vmode, bool vipatch, bool countryString, u8 patchVidModes, int aspectRatio)
|
||||||
{
|
{
|
||||||
@ -53,7 +49,8 @@ s32 Apploader_Run(entry_point *entry, u8 vidMode, GXRModeObj *vmode, bool vipatc
|
|||||||
/* Read apploader code */
|
/* Read apploader code */
|
||||||
// Either you limit memory usage or you don't touch the heap after that, because this is writing at 0x1200000
|
// Either you limit memory usage or you don't touch the heap after that, because this is writing at 0x1200000
|
||||||
ret = WDVD_Read(APPLOADER_START, appldr_len, APPLDR_OFFSET + 0x20);
|
ret = WDVD_Read(APPLOADER_START, appldr_len, APPLDR_OFFSET + 0x20);
|
||||||
if (ret < 0) return ret;
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
DCFlushRange(APPLOADER_START, appldr_len);
|
DCFlushRange(APPLOADER_START, appldr_len);
|
||||||
|
|
||||||
@ -64,7 +61,7 @@ s32 Apploader_Run(entry_point *entry, u8 vidMode, GXRModeObj *vmode, bool vipatc
|
|||||||
appldr_entry(&appldr_init, &appldr_main, &appldr_final);
|
appldr_entry(&appldr_init, &appldr_main, &appldr_final);
|
||||||
|
|
||||||
/* Initialize apploader */
|
/* Initialize apploader */
|
||||||
appldr_init(__noprint);
|
appldr_init(gprintf);
|
||||||
|
|
||||||
bool hookpatched = false;
|
bool hookpatched = false;
|
||||||
|
|
||||||
@ -269,10 +266,12 @@ static bool Remove_001_Protection(void *Address, int Size)
|
|||||||
u8 *Addr;
|
u8 *Addr;
|
||||||
|
|
||||||
for (Addr = Address; Addr <= Addr_end - sizeof SearchPattern; Addr += 4)
|
for (Addr = Address; Addr <= Addr_end - sizeof SearchPattern; Addr += 4)
|
||||||
|
{
|
||||||
if (memcmp(Addr, SearchPattern, sizeof SearchPattern) == 0)
|
if (memcmp(Addr, SearchPattern, sizeof SearchPattern) == 0)
|
||||||
{
|
{
|
||||||
memcpy(Addr, PatchData, sizeof PatchData);
|
memcpy(Addr, PatchData, sizeof PatchData);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#ifndef _DISC_H_
|
#ifndef _DISC_H_
|
||||||
#define _DISC_H_
|
#define _DISC_H_
|
||||||
|
|
||||||
#ifndef APPLOADER_START /* Also defined in mem2.hpp */
|
#ifndef APPLOADER_START
|
||||||
#define APPLOADER_START (void *)0x81200000
|
#define APPLOADER_START (void *)0x81200000
|
||||||
#endif
|
#endif
|
||||||
#ifndef APPLOADER_END /* Also defined in mem2.hpp */
|
#ifndef APPLOADER_END
|
||||||
#define APPLOADER_END (void *)0x81700000
|
#define APPLOADER_END (void *)0x81700000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define Sys_Magic ((vu32*)0x80000020)
|
#define Sys_Magic ((vu32*)0x80000020)
|
||||||
@ -92,18 +92,18 @@ struct gc_discHdr
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
s32 Disc_Init(void);
|
s32 Disc_Init(void);
|
||||||
s32 Disc_Open(void);
|
s32 Disc_Open(void);
|
||||||
s32 Disc_Wait(void);
|
s32 Disc_Wait(void);
|
||||||
s32 Disc_SetUSB(const u8 *);
|
s32 Disc_SetUSB(const u8 *);
|
||||||
s32 Disc_ReadHeader(void *);
|
s32 Disc_ReadHeader(void *);
|
||||||
s32 Disc_ReadGCHeader(void *);
|
s32 Disc_ReadGCHeader(void *);
|
||||||
s32 Disc_Type(bool);
|
s32 Disc_Type(bool);
|
||||||
s32 Disc_IsWii(void);
|
s32 Disc_IsWii(void);
|
||||||
s32 Disc_IsGC(void);
|
s32 Disc_IsGC(void);
|
||||||
s32 Disc_BootPartition(u64, u8, bool, bool, u8, bool, int);
|
s32 Disc_BootPartition(u64, u8, bool, bool, u8, bool, int);
|
||||||
s32 Disc_WiiBoot(u8, bool, bool, u8, bool, int);
|
s32 Disc_WiiBoot(u8, bool, bool, u8, bool, int);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ void frag_init(FragList *ff, int maxnum)
|
|||||||
|
|
||||||
void frag_dump(FragList *ff)
|
void frag_dump(FragList *ff)
|
||||||
{
|
{
|
||||||
int i;
|
u32 i;
|
||||||
gprintf("frag list: %d %d 0x%x\n", ff->num, ff->size, ff->size);
|
gprintf("frag list: %d %d 0x%x\n", ff->num, ff->size, ff->size);
|
||||||
for (i = 0; i < ff->num; i++)
|
for (i = 0; i < ff->num; i++)
|
||||||
{
|
{
|
||||||
@ -72,7 +72,8 @@ int _frag_append(void *ff, u32 offset, u32 sector, u32 count)
|
|||||||
|
|
||||||
int frag_concat(FragList *ff, FragList *src)
|
int frag_concat(FragList *ff, FragList *src)
|
||||||
{
|
{
|
||||||
int i, ret;
|
int ret;
|
||||||
|
u32 i;
|
||||||
u32 size = ff->size;
|
u32 size = ff->size;
|
||||||
|
|
||||||
for (i=0; i<src->num; i++)
|
for (i=0; i<src->num; i++)
|
||||||
@ -91,7 +92,7 @@ int frag_concat(FragList *ff, FragList *src)
|
|||||||
// the difference should be filled with 0
|
// the difference should be filled with 0
|
||||||
int frag_get(FragList *ff, u32 offset, u32 count, u32 *poffset, u32 *psector, u32 *pcount)
|
int frag_get(FragList *ff, u32 offset, u32 count, u32 *poffset, u32 *psector, u32 *pcount)
|
||||||
{
|
{
|
||||||
int i;
|
u32 i;
|
||||||
u32 delta;
|
u32 delta;
|
||||||
for (i=0; i<ff->num; i++)
|
for (i=0; i<ff->num; i++)
|
||||||
{
|
{
|
||||||
@ -130,7 +131,7 @@ int frag_get(FragList *ff, u32 offset, u32 count, u32 *poffset, u32 *psector, u3
|
|||||||
|
|
||||||
int frag_remap(FragList *ff, FragList *log, FragList *phy)
|
int frag_remap(FragList *ff, FragList *log, FragList *phy)
|
||||||
{
|
{
|
||||||
int i;
|
u32 i;
|
||||||
u32 offset;
|
u32 offset;
|
||||||
u32 sector;
|
u32 sector;
|
||||||
for (i=0; i<log->num; i++)
|
for (i=0; i<log->num; i++)
|
||||||
@ -164,10 +165,11 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
|
|||||||
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 = malloc(sizeof(FragList));
|
FragList *fs = MEM2_alloc(sizeof(FragList));
|
||||||
FragList *fa = malloc(sizeof(FragList));
|
FragList *fa = MEM2_alloc(sizeof(FragList));
|
||||||
FragList *fw = malloc(sizeof(FragList));
|
FragList *fw = MEM2_alloc(sizeof(FragList));
|
||||||
int ret, ret_val = -1, i, j;
|
int ret, ret_val = -1;
|
||||||
|
u32 i, j;
|
||||||
|
|
||||||
frag_init(fa, MAX_FRAG);
|
frag_init(fa, MAX_FRAG);
|
||||||
|
|
||||||
@ -228,7 +230,8 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
|
|||||||
{
|
{
|
||||||
gprintf("Shifting all frags by sector: %d\n", wbfs_part_lba);
|
gprintf("Shifting all frags by sector: %d\n", wbfs_part_lba);
|
||||||
// offset to start of partition
|
// offset to start of partition
|
||||||
for (j = 0; j < fs->num; j++) fs->frag[j].sector += wbfs_part_lba;
|
for (j = 0; j < fs->num; j++)
|
||||||
|
fs->frag[j].sector += wbfs_part_lba;
|
||||||
}
|
}
|
||||||
|
|
||||||
frag_concat(fa, fs);
|
frag_concat(fa, fs);
|
||||||
@ -263,10 +266,11 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
|
|||||||
ret_val = 0;
|
ret_val = 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (ret_val) SAFE_FREE(frag_list);
|
if (ret_val)
|
||||||
SAFE_FREE(fs);
|
MEM2_free(frag_list);
|
||||||
SAFE_FREE(fa);
|
MEM2_free(fs);
|
||||||
SAFE_FREE(fw);
|
MEM2_free(fa);
|
||||||
|
MEM2_free(fw);
|
||||||
|
|
||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,13 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <sys/unistd.h>
|
#include <sys/unistd.h>
|
||||||
#include <ogc/ipc.h>
|
#include <ogc/ipc.h>
|
||||||
#include "fst.h"
|
#include "fst.h"
|
||||||
|
|
||||||
#include "gecko.h"
|
#include "gecko.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
|
#include "mem2.hpp"
|
||||||
|
|
||||||
#include "patchcode.h"
|
#include "patchcode.h"
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ int app_gameconfig_load(u8 *discid, const u8 *gameconfig, u32 tempgameconfsize)
|
|||||||
|
|
||||||
if (gameconf == NULL)
|
if (gameconf == NULL)
|
||||||
{
|
{
|
||||||
gameconf = malloc(65536);
|
gameconf = MEM2_alloc(65536);
|
||||||
if (gameconf == NULL)
|
if (gameconf == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ int app_gameconfig_load(u8 *discid, const u8 *gameconfig, u32 tempgameconfsize)
|
|||||||
if (gameconfig == NULL || tempgameconfsize == 0)
|
if (gameconfig == NULL || tempgameconfsize == 0)
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
u8 *tempgameconf = (u8 *) gameconfig;
|
u8 *tempgameconf = (u8 *)gameconfig;
|
||||||
|
|
||||||
u32 ret;
|
u32 ret;
|
||||||
s32 gameidmatch, maxgameidmatch = -1, maxgameidmatch2 = -1;
|
s32 gameidmatch, maxgameidmatch = -1, maxgameidmatch2 = -1;
|
||||||
@ -158,270 +158,81 @@ int app_gameconfig_load(u8 *discid, const u8 *gameconfig, u32 tempgameconfsize)
|
|||||||
if (parsebufpos == 17) break;
|
if (parsebufpos == 17) break;
|
||||||
}
|
}
|
||||||
parsebuffer[parsebufpos] = 0;
|
parsebuffer[parsebufpos] = 0;
|
||||||
//if (!autobootcheck)
|
if (strncasecmp("codeliststart", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 13)
|
||||||
{
|
{
|
||||||
//if (strncasecmp("addtocodelist(", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 14)
|
sscanf((char *)(tempgameconf + i), " = %x", (unsigned int *)&codelist);
|
||||||
//{
|
}
|
||||||
// ret = sscanf(tempgameconf + i, "%x %x", &codeaddr, &codeval);
|
if (strncasecmp("codelistend", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 11)
|
||||||
// if (ret == 2)
|
{
|
||||||
// addtocodelist(codeaddr, codeval);
|
sscanf((char *)(tempgameconf + i), " = %x", (unsigned int *)&codelistend);
|
||||||
//}
|
}
|
||||||
if (strncasecmp("codeliststart", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 13)
|
if (strncasecmp("poke", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 4)
|
||||||
|
{
|
||||||
|
ret = sscanf((char *)tempgameconf + i, "( %x , %x", &codeaddr, &codeval);
|
||||||
|
if (ret == 2)
|
||||||
{
|
{
|
||||||
sscanf((char *)(tempgameconf + i), " = %x", (unsigned int *)&codelist);
|
*(gameconf + (gameconfsize / 4)) = 0;
|
||||||
|
gameconfsize += 4;
|
||||||
|
*(gameconf + (gameconfsize / 4)) = 0;
|
||||||
|
gameconfsize += 8;
|
||||||
|
*(gameconf + (gameconfsize / 4)) = codeaddr;
|
||||||
|
gameconfsize += 4;
|
||||||
|
*(gameconf + (gameconfsize / 4)) = codeval;
|
||||||
|
gameconfsize += 4;
|
||||||
|
DCFlushRange((void *) (gameconf + (gameconfsize / 4) - 5), 20);
|
||||||
}
|
}
|
||||||
if (strncasecmp("codelistend", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 11)
|
}
|
||||||
|
if (strncasecmp("pokeifequal", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 11)
|
||||||
|
{
|
||||||
|
ret = sscanf((char *)(tempgameconf + i), "( %x , %x , %x , %x", &codeaddr, &codeval, &codeaddr2, &codeval2);
|
||||||
|
if (ret == 4)
|
||||||
{
|
{
|
||||||
sscanf((char *)(tempgameconf + i), " = %x", (unsigned int *)&codelistend);
|
*(gameconf + (gameconfsize / 4)) = 0;
|
||||||
|
gameconfsize += 4;
|
||||||
|
*(gameconf + (gameconfsize / 4)) = codeaddr;
|
||||||
|
gameconfsize += 4;
|
||||||
|
*(gameconf + (gameconfsize / 4)) = codeval;
|
||||||
|
gameconfsize += 4;
|
||||||
|
*(gameconf + (gameconfsize / 4)) = codeaddr2;
|
||||||
|
gameconfsize += 4;
|
||||||
|
*(gameconf + (gameconfsize / 4)) = codeval2;
|
||||||
|
gameconfsize += 4;
|
||||||
|
DCFlushRange((void *) (gameconf + (gameconfsize / 4) - 5), 20);
|
||||||
}
|
}
|
||||||
/*
|
}
|
||||||
if (strncasecmp("hooktype", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 8)
|
if (strncasecmp("searchandpoke", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 13)
|
||||||
|
{
|
||||||
|
ret = sscanf((char *)(tempgameconf + i), "( %x%n", &codeval, &tempoffset);
|
||||||
|
if (ret == 1)
|
||||||
{
|
{
|
||||||
if (hookset == 1)
|
gameconfsize += 4;
|
||||||
|
temp = 0;
|
||||||
|
while (ret == 1)
|
||||||
{
|
{
|
||||||
ret = sscanf(tempgameconf + i, " = %u", &temp);
|
|
||||||
if (ret == 1)
|
|
||||||
if (temp >= 0 && temp <= 7)
|
|
||||||
config_bytes[2] = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (strncasecmp("poke", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 4)
|
|
||||||
{
|
|
||||||
ret = sscanf((char *)tempgameconf + i, "( %x , %x", &codeaddr, &codeval);
|
|
||||||
if (ret == 2)
|
|
||||||
{
|
|
||||||
*(gameconf + (gameconfsize / 4)) = 0;
|
|
||||||
gameconfsize += 4;
|
|
||||||
*(gameconf + (gameconfsize / 4)) = 0;
|
|
||||||
gameconfsize += 8;
|
|
||||||
*(gameconf + (gameconfsize / 4)) = codeaddr;
|
|
||||||
gameconfsize += 4;
|
|
||||||
*(gameconf + (gameconfsize / 4)) = codeval;
|
*(gameconf + (gameconfsize / 4)) = codeval;
|
||||||
gameconfsize += 4;
|
gameconfsize += 4;
|
||||||
DCFlushRange((void *) (gameconf + (gameconfsize / 4) - 5), 20);
|
temp++;
|
||||||
|
i += tempoffset;
|
||||||
|
ret = sscanf((char *)(tempgameconf + i), " %x%n", &codeval, &tempoffset);
|
||||||
}
|
}
|
||||||
}
|
*(gameconf + (gameconfsize / 4) - temp - 1) = temp;
|
||||||
if (strncasecmp("pokeifequal", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 11)
|
ret = sscanf((char *)(tempgameconf + i), " , %x , %x , %x , %x", &codeaddr, &codeaddr2, &codeoffset, &codeval2);
|
||||||
{
|
|
||||||
ret = sscanf((char *)(tempgameconf + i), "( %x , %x , %x , %x", &codeaddr, &codeval, &codeaddr2, &codeval2);
|
|
||||||
if (ret == 4)
|
if (ret == 4)
|
||||||
{
|
{
|
||||||
*(gameconf + (gameconfsize / 4)) = 0;
|
|
||||||
gameconfsize += 4;
|
|
||||||
*(gameconf + (gameconfsize / 4)) = codeaddr;
|
*(gameconf + (gameconfsize / 4)) = codeaddr;
|
||||||
gameconfsize += 4;
|
gameconfsize += 4;
|
||||||
*(gameconf + (gameconfsize / 4)) = codeval;
|
|
||||||
gameconfsize += 4;
|
|
||||||
*(gameconf + (gameconfsize / 4)) = codeaddr2;
|
*(gameconf + (gameconfsize / 4)) = codeaddr2;
|
||||||
gameconfsize += 4;
|
gameconfsize += 4;
|
||||||
|
*(gameconf + (gameconfsize / 4)) = codeoffset;
|
||||||
|
gameconfsize += 4;
|
||||||
*(gameconf + (gameconfsize / 4)) = codeval2;
|
*(gameconf + (gameconfsize / 4)) = codeval2;
|
||||||
gameconfsize += 4;
|
gameconfsize += 4;
|
||||||
DCFlushRange((void *) (gameconf + (gameconfsize / 4) - 5), 20);
|
DCFlushRange((void *) (gameconf + (gameconfsize / 4) - temp - 5), temp * 4 + 20);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
gameconfsize -= temp * 4 + 4;
|
||||||
}
|
}
|
||||||
if (strncasecmp("searchandpoke", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 13)
|
|
||||||
{
|
|
||||||
ret = sscanf((char *)(tempgameconf + i), "( %x%n", &codeval, &tempoffset);
|
|
||||||
if (ret == 1)
|
|
||||||
{
|
|
||||||
gameconfsize += 4;
|
|
||||||
temp = 0;
|
|
||||||
while (ret == 1)
|
|
||||||
{
|
|
||||||
*(gameconf + (gameconfsize / 4)) = codeval;
|
|
||||||
gameconfsize += 4;
|
|
||||||
temp++;
|
|
||||||
i += tempoffset;
|
|
||||||
ret = sscanf((char *)(tempgameconf + i), " %x%n", &codeval, &tempoffset);
|
|
||||||
}
|
|
||||||
*(gameconf + (gameconfsize / 4) - temp - 1) = temp;
|
|
||||||
ret = sscanf((char *)(tempgameconf + i), " , %x , %x , %x , %x", &codeaddr, &codeaddr2, &codeoffset, &codeval2);
|
|
||||||
if (ret == 4)
|
|
||||||
{
|
|
||||||
*(gameconf + (gameconfsize / 4)) = codeaddr;
|
|
||||||
gameconfsize += 4;
|
|
||||||
*(gameconf + (gameconfsize / 4)) = codeaddr2;
|
|
||||||
gameconfsize += 4;
|
|
||||||
*(gameconf + (gameconfsize / 4)) = codeoffset;
|
|
||||||
gameconfsize += 4;
|
|
||||||
*(gameconf + (gameconfsize / 4)) = codeval2;
|
|
||||||
gameconfsize += 4;
|
|
||||||
DCFlushRange((void *) (gameconf + (gameconfsize / 4) - temp - 5), temp * 4 + 20);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
gameconfsize -= temp * 4 + 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
if (strncasecmp("hook", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 4)
|
|
||||||
{
|
|
||||||
ret = sscanf(tempgameconf + i, "( %x %x %x %x %x %x %x %x", customhook, customhook + 1, customhook + 2, customhook + 3, customhook + 4, customhook + 5, customhook + 6, customhook + 7);
|
|
||||||
if (ret >= 3)
|
|
||||||
{
|
|
||||||
if (hookset != 1)
|
|
||||||
configwarn |= 4;
|
|
||||||
config_bytes[2] = 0x08;
|
|
||||||
customhooksize = ret * 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (strncasecmp("002fix", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 6)
|
|
||||||
{
|
|
||||||
ret = sscanf(tempgameconf + i, " = %u", &temp);
|
|
||||||
if (ret == 1)
|
|
||||||
if (temp >= 0 && temp <= 0x1)
|
|
||||||
fakeiosversion = temp;
|
|
||||||
}
|
|
||||||
if (strncasecmp("switchios", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 9)
|
|
||||||
{
|
|
||||||
ret = sscanf(tempgameconf + i, " = %u", &temp);
|
|
||||||
if (ret == 1)
|
|
||||||
if (temp >= 0 && temp <= 1)
|
|
||||||
willswitchios = temp;
|
|
||||||
}
|
|
||||||
if (strncasecmp("videomode", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 9)
|
|
||||||
{
|
|
||||||
ret = sscanf(tempgameconf + i, " = %u", &temp);
|
|
||||||
if (ret == 1)
|
|
||||||
{
|
|
||||||
if (temp == 0)
|
|
||||||
{
|
|
||||||
if (config_bytes[1] != 0x00)
|
|
||||||
configwarn |= 1;
|
|
||||||
config_bytes[1] = 0x00;
|
|
||||||
}
|
|
||||||
else if (temp == 1)
|
|
||||||
{
|
|
||||||
if (config_bytes[1] != 0x03)
|
|
||||||
configwarn |= 1;
|
|
||||||
config_bytes[1] = 0x03;
|
|
||||||
}
|
|
||||||
else if (temp == 2)
|
|
||||||
{
|
|
||||||
if (config_bytes[1] != 0x01)
|
|
||||||
configwarn |= 1;
|
|
||||||
config_bytes[1] = 0x01;
|
|
||||||
}
|
|
||||||
else if (temp == 3)
|
|
||||||
{
|
|
||||||
if (config_bytes[1] != 0x02)
|
|
||||||
configwarn |= 1;
|
|
||||||
config_bytes[1] = 0x02;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (strncasecmp("language", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 8)
|
|
||||||
{
|
|
||||||
ret = sscanf(tempgameconf + i, " = %u", &temp);
|
|
||||||
if (ret == 1)
|
|
||||||
{
|
|
||||||
if (temp == 0)
|
|
||||||
{
|
|
||||||
if (config_bytes[0] != 0xCD)
|
|
||||||
configwarn |= 2;
|
|
||||||
config_bytes[0] = 0xCD;
|
|
||||||
}
|
|
||||||
else if (temp > 0 && temp <= 10)
|
|
||||||
{
|
|
||||||
if (config_bytes[0] != temp-1)
|
|
||||||
configwarn |= 2;
|
|
||||||
config_bytes[0] = temp-1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (strncasecmp("diagnostic", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 10)
|
|
||||||
{
|
|
||||||
ret = sscanf(tempgameconf + i, " = %u", &temp);
|
|
||||||
if (ret == 1)
|
|
||||||
{
|
|
||||||
if (temp == 0 || temp == 1)
|
|
||||||
diagcreate = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (strncasecmp("vidtv", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 5)
|
|
||||||
{
|
|
||||||
ret = sscanf(tempgameconf + i, " = %u", &temp);
|
|
||||||
if (ret == 1)
|
|
||||||
if (temp >= 0 && temp <= 1)
|
|
||||||
vipatchon = temp;
|
|
||||||
}
|
|
||||||
if (strncasecmp("fwritepatch", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 11)
|
|
||||||
{
|
|
||||||
ret = sscanf(tempgameconf + i, " = %u", &temp);
|
|
||||||
if (ret == 1)
|
|
||||||
if (temp >= 0 && temp <= 1)
|
|
||||||
applyfwritepatch = temp;
|
|
||||||
}
|
|
||||||
if (strncasecmp("dumpmaindol", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 11)
|
|
||||||
{
|
|
||||||
ret = sscanf(tempgameconf + i, " = %u", &temp);
|
|
||||||
if (ret == 1)
|
|
||||||
if (temp >= 0 && temp <= 1)
|
|
||||||
dumpmaindol = temp;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
/*else
|
|
||||||
{
|
|
||||||
|
|
||||||
if (strncasecmp("autoboot", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 8)
|
|
||||||
{
|
|
||||||
ret = sscanf(tempgameconf + i, " = %u", &temp);
|
|
||||||
if (ret == 1)
|
|
||||||
if (temp >= 0 && temp <= 1)
|
|
||||||
autoboot = temp;
|
|
||||||
}
|
|
||||||
if (strncasecmp("autobootwait", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 12)
|
|
||||||
{
|
|
||||||
ret = sscanf(tempgameconf + i, " = %u", &temp);
|
|
||||||
if (ret == 1)
|
|
||||||
if (temp >= 0 && temp <= 255)
|
|
||||||
autobootwait = temp;
|
|
||||||
}
|
|
||||||
if (strncasecmp("autoboothbc", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 11)
|
|
||||||
{
|
|
||||||
ret = sscanf(tempgameconf + i, " = %u", &temp);
|
|
||||||
if (ret == 1)
|
|
||||||
if (temp >= 0 && temp <= 1)
|
|
||||||
autoboothbc = temp;
|
|
||||||
}
|
|
||||||
if (strncasecmp("autobootocarina", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 15)
|
|
||||||
{
|
|
||||||
ret = sscanf(tempgameconf + i, " = %u", &temp);
|
|
||||||
if (ret == 1)
|
|
||||||
if (temp >= 0 && temp <= 1)
|
|
||||||
config_bytes[4] = temp;
|
|
||||||
}
|
|
||||||
if (strncasecmp("autobootdebugger", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 16)
|
|
||||||
{
|
|
||||||
ret = sscanf(tempgameconf + i, " = %u", &temp);
|
|
||||||
if (ret == 1)
|
|
||||||
if (temp >= 0 && temp <= 1)
|
|
||||||
config_bytes[7] = temp;
|
|
||||||
}
|
|
||||||
if (strncasecmp("rebootermenuitem", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 16)
|
|
||||||
{
|
|
||||||
ret = sscanf(tempgameconf + i, " = %u", &temp);
|
|
||||||
if (ret == 1)
|
|
||||||
if (temp >= 0 && temp <= 1)
|
|
||||||
rebooterasmenuitem = temp;
|
|
||||||
}
|
|
||||||
if (strncasecmp("startupios", parsebuffer, strlen(parsebuffer)) == 0 && strlen(parsebuffer) == 10)
|
|
||||||
{
|
|
||||||
ret = sscanf(tempgameconf + i, " = %u", &temp);
|
|
||||||
if (ret == 1)
|
|
||||||
if (temp >= 0 && temp <= 255)
|
|
||||||
{
|
|
||||||
sdio_Shutdown();
|
|
||||||
IOS_ReloadIOS(temp);
|
|
||||||
detectIOScapabilities();
|
|
||||||
sd_init();
|
|
||||||
startupiosloaded = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}*/
|
|
||||||
if (tempgameconf[i] != ':')
|
if (tempgameconf[i] != ':')
|
||||||
{
|
{
|
||||||
while ((i != tempgameconfsize) && (tempgameconf[i] != 10 && tempgameconf[i] != 13)) i++;
|
while ((i != tempgameconfsize) && (tempgameconf[i] != 10 && tempgameconf[i] != 13)) i++;
|
||||||
@ -431,14 +242,14 @@ int app_gameconfig_load(u8 *discid, const u8 *gameconfig, u32 tempgameconfsize)
|
|||||||
if (i != tempgameconfsize) while ((tempgameconf[i] != 10 && tempgameconf[i] != 13) && (i != 0)) i--;
|
if (i != tempgameconfsize) while ((tempgameconf[i] != 10 && tempgameconf[i] != 13) && (i != 0)) i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MEM2_free(gameconf);
|
||||||
return 0;
|
return 0;
|
||||||
//tempcodelist = ((u8 *) gameconf) + gameconfsize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 *code_buf = NULL;
|
u8 *code_buf = NULL;
|
||||||
int code_size = 0;
|
u32 code_size = 0;
|
||||||
|
|
||||||
int ocarina_load_code(u8 *id, const u8 *cheat, u32 cheatSize)
|
int ocarina_load_code(const u8 *cheat, u32 cheatSize)
|
||||||
{
|
{
|
||||||
if (debuggerselect == 0x00)
|
if (debuggerselect == 0x00)
|
||||||
codelist = (u8 *) 0x800022A8;
|
codelist = (u8 *) 0x800022A8;
|
||||||
@ -446,10 +257,8 @@ int ocarina_load_code(u8 *id, const u8 *cheat, u32 cheatSize)
|
|||||||
codelist = (u8 *) 0x800028B8;
|
codelist = (u8 *) 0x800028B8;
|
||||||
codelistend = (u8 *) 0x80003000;
|
codelistend = (u8 *) 0x80003000;
|
||||||
|
|
||||||
// app_loadgameconfig((char *)id);
|
|
||||||
|
|
||||||
code_buf = (u8 *)cheat;
|
code_buf = (u8 *)cheat;
|
||||||
code_size = cheatSize;
|
code_size = cheatSize;
|
||||||
|
|
||||||
if(code_size <= 0)
|
if(code_size <= 0)
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ extern u8 debuggerselect;
|
|||||||
#define MAX_GCT_SIZE 2056
|
#define MAX_GCT_SIZE 2056
|
||||||
|
|
||||||
int app_gameconfig_load(u8 *id, const u8 *gameconfig, u32 gameconfigsize);
|
int app_gameconfig_load(u8 *id, const u8 *gameconfig, u32 gameconfigsize);
|
||||||
int ocarina_load_code(u8 *id, const u8 *cheat, u32 cheatSize);
|
int ocarina_load_code(const u8 *cheat, u32 cheatSize);
|
||||||
int ocarina_do_code();
|
int ocarina_do_code();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#define FMT_llu "%llu"
|
#define FMT_llu "%llu"
|
||||||
#define FMT_lld "%lld"
|
#define FMT_lld "%lld"
|
||||||
|
|
||||||
#define split_error(x) do { printf("\nsplit error: %s\n\n",x); } while(0)
|
#define split_error(x) do { gprintf("\nsplit error: %s\n\n",x); } while(0)
|
||||||
|
|
||||||
// 1 cluster less than 4gb
|
// 1 cluster less than 4gb
|
||||||
u64 OPT_split_size = (u64) 4LL * 1024 * 1024 * 1024 - 32 * 1024;
|
u64 OPT_split_size = (u64) 4LL * 1024 * 1024 * 1024 - 32 * 1024;
|
||||||
@ -65,12 +65,16 @@ int split_open_file(split_info_t *s, int idx)
|
|||||||
int write_zero(int fd, off_t size)
|
int write_zero(int fd, off_t size)
|
||||||
{
|
{
|
||||||
int buf[0x4000]; //64kb
|
int buf[0x4000]; //64kb
|
||||||
int chunk;
|
|
||||||
int ret;
|
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
while (size) {
|
|
||||||
|
u32 chunk;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
while (size)
|
||||||
|
{
|
||||||
chunk = size;
|
chunk = size;
|
||||||
if (chunk > sizeof(buf)) chunk = sizeof(buf);
|
if (chunk > sizeof(buf))
|
||||||
|
chunk = sizeof(buf);
|
||||||
ret = write(fd, buf, chunk);
|
ret = write(fd, buf, chunk);
|
||||||
// gprintf("WZ %d %d / %lld \n", ret, chunk, size);
|
// gprintf("WZ %d %d / %lld \n", ret, chunk, size);
|
||||||
size -= chunk;
|
size -= chunk;
|
||||||
@ -84,7 +88,8 @@ int split_fill(split_info_t *s, int idx, u64 size)
|
|||||||
int fd = split_open_file(s, idx);
|
int fd = split_open_file(s, idx);
|
||||||
|
|
||||||
off64_t fsize = lseek(fd, 0, SEEK_END);
|
off64_t fsize = lseek(fd, 0, SEEK_END);
|
||||||
if (fsize < size) {
|
if ((u64)fsize < size)
|
||||||
|
{
|
||||||
// gprintf("TRUNC %d "FMT_lld" "FMT_lld"\n", idx, size, fsize); // Wpad_WaitButtons();
|
// gprintf("TRUNC %d "FMT_lld" "FMT_lld"\n", idx, size, fsize); // Wpad_WaitButtons();
|
||||||
ftruncate(fd, size);
|
ftruncate(fd, size);
|
||||||
// write_zero(fd, size - fsize);
|
// write_zero(fd, size - fsize);
|
||||||
@ -97,13 +102,13 @@ int split_get_file(split_info_t *s, u32 lba, u32 *sec_count, int fill)
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
if (lba >= s->total_sec) {
|
if (lba >= s->total_sec) {
|
||||||
fprintf(stderr, "SPLIT: invalid sector %u / %u\n", lba, (u32)s->total_sec);
|
gprintf( "SPLIT: invalid sector %u / %u\n", lba, (u32)s->total_sec);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int idx;
|
int idx;
|
||||||
idx = lba / s->split_sec;
|
idx = lba / s->split_sec;
|
||||||
if (idx >= s->max_split) {
|
if (idx >= s->max_split) {
|
||||||
fprintf(stderr, "SPLIT: invalid split %d / %d\n", idx, s->max_split - 1);
|
gprintf( "SPLIT: invalid split %d / %d\n", idx, s->max_split - 1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fd = s->fd[idx];
|
fd = s->fd[idx];
|
||||||
@ -118,7 +123,7 @@ int split_get_file(split_info_t *s, u32 lba, u32 *sec_count, int fill)
|
|||||||
fd = split_open_file(s, idx);
|
fd = split_open_file(s, idx);
|
||||||
}
|
}
|
||||||
if (fd<0) {
|
if (fd<0) {
|
||||||
fprintf(stderr, "SPLIT %d: no file\n", idx);
|
gprintf( "SPLIT %d: no file\n", idx);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
u32 sec = lba % s->split_sec; // inside file
|
u32 sec = lba % s->split_sec; // inside file
|
||||||
@ -141,7 +146,7 @@ int split_get_file(split_info_t *s, u32 lba, u32 *sec_count, int fill)
|
|||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
int split_read_sector(void *_fp,u32 lba,u32 count,void*buf)
|
int split_read_sector(void *_fp, u32 lba, u32 count, void *buf)
|
||||||
{
|
{
|
||||||
split_info_t *s = _fp;
|
split_info_t *s = _fp;
|
||||||
int fd;
|
int fd;
|
||||||
@ -150,28 +155,30 @@ int split_read_sector(void *_fp,u32 lba,u32 count,void*buf)
|
|||||||
int i;
|
int i;
|
||||||
u32 chunk;
|
u32 chunk;
|
||||||
size_t ret;
|
size_t ret;
|
||||||
//fprintf(stderr,"READ %d %d\n", lba, count);
|
//gprintf("READ %d %d\n", lba, count);
|
||||||
for (i=0; i<(int)count; i+=chunk) {
|
for (i=0; i<(int)count; i+=chunk)
|
||||||
|
{
|
||||||
chunk = count - i;
|
chunk = count - i;
|
||||||
fd = split_get_file(s, lba+i, &chunk, 1);
|
fd = split_get_file(s, lba+i, &chunk, 1);
|
||||||
if (fd<0) {
|
if (fd<0)
|
||||||
fprintf(stderr,"\n\n"FMT_lld" %d %p\n",off,count,_fp);
|
{
|
||||||
split_error("error seeking in disc partition");
|
gprintf("\n\n"FMT_lld" %d %p\n",off,count,_fp);
|
||||||
|
split_error("error seeking in disc partition\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//ret = fread(buf+i*512, 512ULL, chunk, f);
|
//ret = fread(buf+i*512, 512ULL, chunk, f);
|
||||||
ret = read(fd, buf+i*512, chunk * 512);
|
ret = read(fd, buf+i*512, chunk * 512);
|
||||||
if (ret != chunk * 512) {
|
if (ret != chunk * 512)
|
||||||
fprintf(stderr, "error reading %u %u [%u] %u = %u\n",
|
{
|
||||||
lba, count, i, chunk, ret);
|
gprintf( "error reading %u %u [%u] %u = %u\n", lba, count, i, chunk, ret);
|
||||||
split_error("error reading disc");
|
split_error("error reading disc\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int split_write_sector(void *_fp,u32 lba,u32 count,void*buf)
|
int split_write_sector(void *_fp, u32 lba, u32 count, void *buf)
|
||||||
{
|
{
|
||||||
split_info_t *s = _fp;
|
split_info_t *s = _fp;
|
||||||
int fd;
|
int fd;
|
||||||
@ -181,23 +188,26 @@ int split_write_sector(void *_fp,u32 lba,u32 count,void*buf)
|
|||||||
u32 chunk;
|
u32 chunk;
|
||||||
size_t ret;
|
size_t ret;
|
||||||
// gprintf("WRITE %d %d %p \n", lba, count, buf);
|
// gprintf("WRITE %d %d %p \n", lba, count, buf);
|
||||||
for (i=0; i<(int)count; i+=chunk) {
|
for (i=0; i<(int)count; i+=chunk)
|
||||||
|
{
|
||||||
chunk = count - i;
|
chunk = count - i;
|
||||||
fd = split_get_file(s, lba+i, &chunk, 0);
|
fd = split_get_file(s, lba+i, &chunk, 0);
|
||||||
// gprintf("WRITE Got file: %d\n", fd);
|
// gprintf("WRITE Got file: %d\n", fd);
|
||||||
//if (chunk != count)
|
//if (chunk != count)
|
||||||
// fprintf(stderr, "WRITE CHUNK %d %d/%d\n", lba+i, chunk, count);
|
// gprintf( "WRITE CHUNK %d %d/%d\n", lba+i, chunk, count);
|
||||||
if (fd<0 || !chunk) {
|
if (fd<0 || !chunk)
|
||||||
fprintf(stderr,"\n\n"FMT_lld" %d %p\n",off,count,_fp);
|
{
|
||||||
split_error("error seeking in disc partition");
|
gprintf("\n\n"FMT_lld" %d %p\n",off,count,_fp);
|
||||||
|
split_error("error seeking in disc partition\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//if (fwrite(buf+i*512, 512ULL, chunk, f) != chunk) {
|
//if (fwrite(buf+i*512, 512ULL, chunk, f) != chunk) {
|
||||||
// gprintf("write %d %p %d \n", fd, buf+i*512, chunk * 512);
|
// gprintf("write %d %p %d \n", fd, buf+i*512, chunk * 512);
|
||||||
ret = write(fd, buf+i*512, chunk * 512);
|
ret = write(fd, buf+i*512, chunk * 512);
|
||||||
// gprintf("write ret = %d \n", ret);
|
// gprintf("write ret = %d \n", ret);
|
||||||
if (ret != chunk * 512) {
|
if (ret != chunk * 512)
|
||||||
split_error("error writing disc");
|
{
|
||||||
|
split_error("error writing disc\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,7 +276,7 @@ int split_create(split_info_t *s, char *fname,
|
|||||||
} else {
|
} else {
|
||||||
fd = open(sname, O_RDONLY);
|
fd = open(sname, O_RDONLY);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
fprintf(stderr, "Error: file already exists: %s\n", sname);
|
gprintf( "Error: file already exists: %s\n", sname);
|
||||||
close(fd);
|
close(fd);
|
||||||
error = 1;
|
error = 1;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "devicemounter/libwbfs/libwbfs.h"
|
||||||
|
|
||||||
#define MAX_SPLIT 10
|
#define MAX_SPLIT 10
|
||||||
|
|
||||||
typedef struct split_info
|
typedef struct split_info
|
||||||
@ -28,8 +30,8 @@ void split_get_fname(split_info_t *s, int idx, char *fname);
|
|||||||
int split_open_file(split_info_t *s, int idx);
|
int split_open_file(split_info_t *s, int idx);
|
||||||
int split_get_file(split_info_t *s, u32 lba, u32 *sec_count, int fill);
|
int split_get_file(split_info_t *s, u32 lba, u32 *sec_count, int fill);
|
||||||
int split_fill(split_info_t *s, int idx, u64 size);
|
int split_fill(split_info_t *s, int idx, u64 size);
|
||||||
int split_read_sector(void *_fp,u32 lba,u32 count,void*buf);
|
int split_read_sector(void *_fp, u32 lba, u32 count, void *buf);
|
||||||
int split_write_sector(void *_fp,u32 lba,u32 count,void*buf);
|
int split_write_sector(void *_fp, u32 lba, u32 count, void *buf);
|
||||||
void split_init(split_info_t *s, char *fname);
|
void split_init(split_info_t *s, char *fname);
|
||||||
void split_set_size(split_info_t *s, u64 split_size, u64 total_size);
|
void split_set_size(split_info_t *s, u64 split_size, u64 total_size);
|
||||||
void split_close(split_info_t *s);
|
void split_close(split_info_t *s);
|
||||||
|
@ -25,7 +25,7 @@ static bool return_to_disable = false;
|
|||||||
static bool return_to_bootmii = false;
|
static bool return_to_bootmii = false;
|
||||||
|
|
||||||
|
|
||||||
void __Wpad_PowerCallback(s32 chan)
|
void __Wpad_PowerCallback()
|
||||||
{
|
{
|
||||||
/* Poweroff console */
|
/* Poweroff console */
|
||||||
shutdown = 1;
|
shutdown = 1;
|
||||||
|
@ -48,7 +48,6 @@ static rw_sector_callback_t writeCallback = NULL;
|
|||||||
|
|
||||||
s32 __WBFS_ReadDVD(void *fp, u32 lba, u32 len, void *iobuf)
|
s32 __WBFS_ReadDVD(void *fp, u32 lba, u32 len, void *iobuf)
|
||||||
{
|
{
|
||||||
void *buffer = NULL;
|
|
||||||
s32 ret;
|
s32 ret;
|
||||||
|
|
||||||
/* Calculate offset */
|
/* Calculate offset */
|
||||||
@ -62,22 +61,25 @@ s32 __WBFS_ReadDVD(void *fp, u32 lba, u32 len, void *iobuf)
|
|||||||
if (size)
|
if (size)
|
||||||
{
|
{
|
||||||
ret = WDVD_UnencryptedRead(iobuf, size, offset);
|
ret = WDVD_UnencryptedRead(iobuf, size, offset);
|
||||||
if (ret < 0) goto out;
|
if (ret < 0)
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read non-aligned data */
|
/* Read non-aligned data */
|
||||||
if (mod)
|
if (mod)
|
||||||
{
|
{
|
||||||
/* Allocate memory */
|
/* Allocate memory */
|
||||||
buffer = MEM2_alloc(0x20);
|
fp = MEM2_alloc(0x20);
|
||||||
if (!buffer) return -1;
|
if (!fp)
|
||||||
|
return -1;
|
||||||
|
|
||||||
/* Read data */
|
/* Read data */
|
||||||
ret = WDVD_UnencryptedRead(buffer, 0x20, offset + size);
|
ret = WDVD_UnencryptedRead(fp, 0x20, offset + size);
|
||||||
if (ret < 0) goto out;
|
if (ret < 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
/* Copy data */
|
/* Copy data */
|
||||||
memcpy(iobuf + size, buffer, mod);
|
memcpy(iobuf + size, fp, mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Success */
|
/* Success */
|
||||||
@ -85,19 +87,19 @@ s32 __WBFS_ReadDVD(void *fp, u32 lba, u32 len, void *iobuf)
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
/* Free memory */
|
/* Free memory */
|
||||||
SAFE_FREE(buffer);
|
SAFE_FREE(fp);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 __WBFS_ReadUSB(void *fp, u32 lba, u32 count, void *iobuf)
|
s32 __WBFS_ReadUSB(void* fp, u32 lba, u32 count, void *iobuf)
|
||||||
{
|
{
|
||||||
u32 cnt = 0;
|
u32 cnt = 0;
|
||||||
|
|
||||||
/* Do reads */
|
/* Do reads */
|
||||||
while (cnt < count)
|
while (cnt < count)
|
||||||
{
|
{
|
||||||
void *ptr = ((u8 *)iobuf) + (cnt * sector_size);
|
fp = ((u8 *)iobuf) + (cnt * sector_size);
|
||||||
u32 sectors = (count - cnt);
|
u32 sectors = (count - cnt);
|
||||||
|
|
||||||
/* Read sectors is too big */
|
/* Read sectors is too big */
|
||||||
@ -105,7 +107,7 @@ s32 __WBFS_ReadUSB(void *fp, u32 lba, u32 count, void *iobuf)
|
|||||||
sectors = MAX_NB_SECTORS;
|
sectors = MAX_NB_SECTORS;
|
||||||
|
|
||||||
/* USB read */
|
/* USB read */
|
||||||
s32 ret = USBStorage_ReadSectors(lba + cnt, sectors, ptr);
|
s32 ret = USBStorage_ReadSectors(lba + cnt, sectors, fp);
|
||||||
if (ret < 0) return ret;
|
if (ret < 0) return ret;
|
||||||
|
|
||||||
/* Increment counter */
|
/* Increment counter */
|
||||||
@ -115,14 +117,14 @@ s32 __WBFS_ReadUSB(void *fp, u32 lba, u32 count, void *iobuf)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 __WBFS_WriteUSB(void *fp, u32 lba, u32 count, void *iobuf)
|
s32 __WBFS_WriteUSB(void* fp, u32 lba, u32 count, void *iobuf)
|
||||||
{
|
{
|
||||||
u32 cnt = 0;
|
u32 cnt = 0;
|
||||||
|
|
||||||
/* Do writes */
|
/* Do writes */
|
||||||
while (cnt < count)
|
while (cnt < count)
|
||||||
{
|
{
|
||||||
void *ptr = ((u8 *)iobuf) + (cnt * sector_size);
|
fp = ((u8 *)iobuf) + (cnt * sector_size);
|
||||||
u32 sectors = (count - cnt);
|
u32 sectors = (count - cnt);
|
||||||
|
|
||||||
/* Write sectors is too big */
|
/* Write sectors is too big */
|
||||||
@ -130,7 +132,7 @@ s32 __WBFS_WriteUSB(void *fp, u32 lba, u32 count, void *iobuf)
|
|||||||
sectors = MAX_NB_SECTORS;
|
sectors = MAX_NB_SECTORS;
|
||||||
|
|
||||||
/* USB write */
|
/* USB write */
|
||||||
s32 ret = USBStorage_WriteSectors(lba + cnt, sectors, ptr);
|
s32 ret = USBStorage_WriteSectors(lba + cnt, sectors, fp);
|
||||||
if (ret < 0) return ret;
|
if (ret < 0) return ret;
|
||||||
|
|
||||||
/* Increment counter */
|
/* Increment counter */
|
||||||
@ -140,14 +142,14 @@ s32 __WBFS_WriteUSB(void *fp, u32 lba, u32 count, void *iobuf)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 __WBFS_ReadSDHC(void *fp, u32 lba, u32 count, void *iobuf)
|
s32 __WBFS_ReadSDHC(void* fp, u32 lba, u32 count, void *iobuf)
|
||||||
{
|
{
|
||||||
u32 cnt = 0;
|
u32 cnt = 0;
|
||||||
|
|
||||||
/* Do reads */
|
/* Do reads */
|
||||||
while (cnt < count)
|
while (cnt < count)
|
||||||
{
|
{
|
||||||
void *ptr = ((u8 *)iobuf) + (cnt * sector_size);
|
fp = ((u8 *)iobuf) + (cnt * sector_size);
|
||||||
u32 sectors = (count - cnt);
|
u32 sectors = (count - cnt);
|
||||||
|
|
||||||
/* Read sectors is too big */
|
/* Read sectors is too big */
|
||||||
@ -155,7 +157,7 @@ s32 __WBFS_ReadSDHC(void *fp, u32 lba, u32 count, void *iobuf)
|
|||||||
sectors = MAX_NB_SECTORS;
|
sectors = MAX_NB_SECTORS;
|
||||||
|
|
||||||
/* SDHC read */
|
/* SDHC read */
|
||||||
s32 ret = SDHC_ReadSectors(lba + cnt, sectors, ptr);
|
s32 ret = SDHC_ReadSectors(lba + cnt, sectors, fp);
|
||||||
if (!ret) return -1;
|
if (!ret) return -1;
|
||||||
|
|
||||||
/* Increment counter */
|
/* Increment counter */
|
||||||
@ -165,7 +167,7 @@ s32 __WBFS_ReadSDHC(void *fp, u32 lba, u32 count, void *iobuf)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 __WBFS_WriteSDHC(void *fp, u32 lba, u32 count, void *iobuf)
|
s32 __WBFS_WriteSDHC(void* fp, u32 lba, u32 count, void *iobuf)
|
||||||
{
|
{
|
||||||
u32 cnt = 0;
|
u32 cnt = 0;
|
||||||
s32 ret;
|
s32 ret;
|
||||||
@ -173,7 +175,7 @@ s32 __WBFS_WriteSDHC(void *fp, u32 lba, u32 count, void *iobuf)
|
|||||||
/* Do writes */
|
/* Do writes */
|
||||||
while (cnt < count)
|
while (cnt < count)
|
||||||
{
|
{
|
||||||
void *ptr = ((u8 *)iobuf) + (cnt * sector_size);
|
fp = ((u8 *)iobuf) + (cnt * sector_size);
|
||||||
u32 sectors = (count - cnt);
|
u32 sectors = (count - cnt);
|
||||||
|
|
||||||
/* Write sectors is too big */
|
/* Write sectors is too big */
|
||||||
@ -181,7 +183,7 @@ s32 __WBFS_WriteSDHC(void *fp, u32 lba, u32 count, void *iobuf)
|
|||||||
sectors = MAX_NB_SECTORS;
|
sectors = MAX_NB_SECTORS;
|
||||||
|
|
||||||
/* SDHC write */
|
/* SDHC write */
|
||||||
ret = SDHC_WriteSectors(lba + cnt, sectors, ptr);
|
ret = SDHC_WriteSectors(lba + cnt, sectors, fp);
|
||||||
if (!ret) return -1;
|
if (!ret) return -1;
|
||||||
|
|
||||||
/* Increment counter */
|
/* Increment counter */
|
||||||
@ -361,11 +363,13 @@ wbfs_disc_t* WBFS_OpenDisc(u8 *discid, char *path)
|
|||||||
|
|
||||||
void WBFS_CloseDisc(wbfs_disc_t *disc)
|
void WBFS_CloseDisc(wbfs_disc_t *disc)
|
||||||
{
|
{
|
||||||
if (wbfs_part_fs)return WBFS_Ext_CloseDisc(disc);
|
if (wbfs_part_fs)
|
||||||
|
return WBFS_Ext_CloseDisc(disc);
|
||||||
|
|
||||||
/* No device open */
|
/* No device open */
|
||||||
if (!hdd || !disc) return;
|
if (!hdd || !disc)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Close disc */
|
/* Close disc */
|
||||||
wbfs_close_disc(disc);
|
wbfs_close_disc(disc);
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,6 @@ split_info_t split;
|
|||||||
|
|
||||||
struct statvfs wbfs_ext_vfs;
|
struct statvfs wbfs_ext_vfs;
|
||||||
|
|
||||||
s32 __WBFS_ReadDVD(void *fp, u32 lba, u32 len, void *iobuf);
|
|
||||||
|
|
||||||
#define STRCOPY(DEST,SRC) strcopy(DEST,SRC,sizeof(DEST))
|
#define STRCOPY(DEST,SRC) strcopy(DEST,SRC,sizeof(DEST))
|
||||||
char* strcopy(char *dest, const char *src, int size)
|
char* strcopy(char *dest, const char *src, int size)
|
||||||
{
|
{
|
||||||
@ -95,10 +93,10 @@ s32 WBFS_Ext_DiskSpace(f32 *used, f32 *free)
|
|||||||
*used = 0;
|
*used = 0;
|
||||||
*free = 0;
|
*free = 0;
|
||||||
|
|
||||||
static int wbfs_ext_vfs_have = 0, wbfs_ext_vfs_lba = 0, wbfs_ext_vfs_dev = 0;
|
static s32 wbfs_ext_vfs_have = 0, wbfs_ext_vfs_lba = 0, wbfs_ext_vfs_dev = 0;
|
||||||
|
|
||||||
// statvfs is slow, so cache values
|
// statvfs is slow, so cache values
|
||||||
if (!wbfs_ext_vfs_have || wbfs_ext_vfs_lba != wbfs_part_lba || wbfs_ext_vfs_dev != wbfsDev )
|
if (!wbfs_ext_vfs_have || wbfs_ext_vfs_lba != (s32)wbfs_part_lba || wbfs_ext_vfs_dev != wbfsDev )
|
||||||
{
|
{
|
||||||
if(statvfs(wbfs_fs_drive, &wbfs_ext_vfs))
|
if(statvfs(wbfs_fs_drive, &wbfs_ext_vfs))
|
||||||
return 0;
|
return 0;
|
||||||
@ -116,23 +114,13 @@ s32 WBFS_Ext_DiskSpace(f32 *used, f32 *free)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nop_read_sector(void *_fp,u32 lba,u32 count,void*buf)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int nop_write_sector(void *_fp,u32 lba,u32 count,void*buf)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
wbfs_t* WBFS_Ext_OpenPart(char *fname)
|
wbfs_t* WBFS_Ext_OpenPart(char *fname)
|
||||||
{
|
{
|
||||||
if(split_open(&split, fname) < 0)
|
if(split_open(&split, fname) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
wbfs_set_force_mode(1);
|
wbfs_set_force_mode(1);
|
||||||
wbfs_t *part = wbfs_open_partition(split_read_sector, nop_write_sector, //readonly //split_write_sector,
|
wbfs_t *part = wbfs_open_partition(split_read_sector, 0, //readonly //split_write_sector,
|
||||||
&split, sector_size, split.total_sec, 0, 0);
|
&split, sector_size, split.total_sec, 0, 0);
|
||||||
wbfs_set_force_mode(0);
|
wbfs_set_force_mode(0);
|
||||||
|
|
||||||
@ -243,7 +231,7 @@ s32 WBFS_Ext_DVD_Size(u64 *comp_size, u64 *real_size)
|
|||||||
// init a temporary dummy part
|
// init a temporary dummy part
|
||||||
// as a placeholder for wbfs_size_disc
|
// as a placeholder for wbfs_size_disc
|
||||||
wbfs_t *part = wbfs_open_partition(
|
wbfs_t *part = wbfs_open_partition(
|
||||||
nop_read_sector, nop_write_sector,
|
0, 0,
|
||||||
NULL, sector_size, n_sector, 0, 1);
|
NULL, sector_size, n_sector, 0, 1);
|
||||||
if (!part) return -1;
|
if (!part) return -1;
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@ void do_wip_code(u8 * dst, u32 len)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
u32 i = 0;
|
||||||
int n = 0;
|
s32 n = 0;
|
||||||
int offset = 0;
|
s32 offset = 0;
|
||||||
|
|
||||||
for(i = 0; i < CodesCount; i++)
|
for(i = 0; i < CodesCount; i++)
|
||||||
{
|
{
|
||||||
@ -38,13 +38,13 @@ void do_wip_code(u8 * dst, u32 len)
|
|||||||
{
|
{
|
||||||
offset = CodeList[i].offset+n-ProcessedLength;
|
offset = CodeList[i].offset+n-ProcessedLength;
|
||||||
|
|
||||||
if(offset < 0 || offset >= len)
|
if(offset < 0 || (u32)offset >= len)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(dst[offset] == ((u8 *)&CodeList[i].srcaddress)[n])
|
if(dst[offset] == ((u8 *)&CodeList[i].srcaddress)[n])
|
||||||
{
|
{
|
||||||
dst[offset] = ((u8 *)&CodeList[i].dstaddress)[n];
|
dst[offset] = ((u8 *)&CodeList[i].dstaddress)[n];
|
||||||
gprintf("WIP: %08X Address Patched.\n", CodeList[i].offset+n);
|
gprintf("WIP: %08X Address Patched.\n", CodeList[i].offset + n);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,23 +1,17 @@
|
|||||||
|
|
||||||
#include "mem2.hpp"
|
|
||||||
#include "mem2alloc.hpp"
|
|
||||||
#include "gecko.h"
|
|
||||||
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ogc/system.h>
|
#include <ogc/system.h>
|
||||||
|
|
||||||
#ifndef APPLOADER_START /* Also defined in disc.h */
|
#include "mem2.hpp"
|
||||||
#define APPLOADER_START (void *)0x81200000
|
#include "mem2alloc.hpp"
|
||||||
#endif
|
#include "gecko.h"
|
||||||
#ifndef APPLOADER_END /* Also defined in disc.h */
|
#include "disc.h"
|
||||||
#define APPLOADER_END (void *)0x81700000
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Forbid the use of MEM2 through malloc
|
// Forbid the use of MEM2 through malloc
|
||||||
u32 MALLOC_MEM2 = 0;
|
u32 MALLOC_MEM2 = 0;
|
||||||
|
|
||||||
static CMEM2Alloc g_mem2gp;
|
static CMEM2Alloc g_mem2gp;
|
||||||
extern int _end;
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
@ -52,9 +46,6 @@ void MEM1_free(void *p)
|
|||||||
|
|
||||||
void MEM2_init(unsigned int mem2Size)
|
void MEM2_init(unsigned int mem2Size)
|
||||||
{
|
{
|
||||||
if(&_end + 0x100 > APPLOADER_START)
|
|
||||||
gprintf("ZOMG MOVE THE ENTRYPOINT DOWN!\n");
|
|
||||||
|
|
||||||
g_mem2gp.init(mem2Size);
|
g_mem2gp.init(mem2Size);
|
||||||
g_mem2gp.clear();
|
g_mem2gp.clear();
|
||||||
|
|
||||||
|
@ -885,7 +885,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
|
|||||||
forwarder = m_gcfg2.getBool(id, "custom", forwarder) || strncmp(id.c_str(), "WIMC", 4) == 0;
|
forwarder = m_gcfg2.getBool(id, "custom", forwarder) || strncmp(id.c_str(), "WIMC", 4) == 0;
|
||||||
|
|
||||||
if(!forwarder)
|
if(!forwarder)
|
||||||
data = channel.Load(hdr->hdr.chantitle, (char *)id.c_str());
|
data = channel.Load(hdr->hdr.chantitle);
|
||||||
|
|
||||||
Nand::Instance()->Disable_Emu();
|
Nand::Instance()->Disable_Emu();
|
||||||
|
|
||||||
@ -939,8 +939,9 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
|
|||||||
|
|
||||||
SmartBuf cheatFile;
|
SmartBuf cheatFile;
|
||||||
u32 cheatSize = 0;
|
u32 cheatSize = 0;
|
||||||
if (cheat) _loadFile(cheatFile, cheatSize, m_cheatDir.c_str(), fmt("%s.gct", hdr->hdr.id));
|
if (cheat)
|
||||||
ocarina_load_code((u8 *) &hdr->hdr.id, cheatFile.get(), cheatSize);
|
_loadFile(cheatFile, cheatSize, m_cheatDir.c_str(), fmt("%s.gct", hdr->hdr.id));
|
||||||
|
ocarina_load_code(cheatFile.get(), cheatSize);
|
||||||
|
|
||||||
int result = _loadIOS(channel.GetRequestedIOS(hdr->hdr.chantitle), id);
|
int result = _loadIOS(channel.GetRequestedIOS(hdr->hdr.chantitle), id);
|
||||||
if (result == LOAD_IOS_FAILED)
|
if (result == LOAD_IOS_FAILED)
|
||||||
@ -1193,13 +1194,14 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
|||||||
|
|
||||||
setLanguage(language);
|
setLanguage(language);
|
||||||
|
|
||||||
if (cheat) _loadFile(cheatFile, cheatSize, m_cheatDir.c_str(), fmt("%s.gct", hdr->hdr.id));
|
if(cheat)
|
||||||
|
_loadFile(cheatFile, cheatSize, m_cheatDir.c_str(), fmt("%s.gct", hdr->hdr.id));
|
||||||
|
|
||||||
_loadFile(gameconfig, gameconfigSize, m_txtCheatDir.c_str(), "gameconfig.txt");
|
_loadFile(gameconfig, gameconfigSize, m_txtCheatDir.c_str(), "gameconfig.txt");
|
||||||
|
|
||||||
load_wip_patches((u8 *) m_wipDir.c_str(), (u8 *) &hdr->hdr.id);
|
load_wip_patches((u8 *) m_wipDir.c_str(), (u8 *) &hdr->hdr.id);
|
||||||
app_gameconfig_load((u8 *) &hdr->hdr.id, gameconfig.get(), gameconfigSize);
|
app_gameconfig_load((u8 *) &hdr->hdr.id, gameconfig.get(), gameconfigSize);
|
||||||
ocarina_load_code((u8 *) &hdr->hdr.id, cheatFile.get(), cheatSize);
|
ocarina_load_code(cheatFile.get(), cheatSize);
|
||||||
|
|
||||||
if (!using_wifi_gecko)
|
if (!using_wifi_gecko)
|
||||||
net_wc24cleanup();
|
net_wc24cleanup();
|
||||||
|
@ -23,10 +23,12 @@
|
|||||||
*
|
*
|
||||||
* for WiiXplorer 2010
|
* for WiiXplorer 2010
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <malloc.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "mem2.hpp"
|
||||||
#include "BNSDecoder.hpp"
|
#include "BNSDecoder.hpp"
|
||||||
|
|
||||||
BNSDecoder::BNSDecoder(const char * filepath)
|
BNSDecoder::BNSDecoder(const char * filepath)
|
||||||
@ -59,7 +61,7 @@ BNSDecoder::~BNSDecoder()
|
|||||||
while(Decoding)
|
while(Decoding)
|
||||||
usleep(100);
|
usleep(100);
|
||||||
|
|
||||||
SAFE_FREE(SoundData.buffer);
|
MEM2_free(SoundData.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BNSDecoder::OpenFile()
|
void BNSDecoder::OpenFile()
|
||||||
@ -262,7 +264,7 @@ static u8 * decodeBNS(u32 &size, const BNSInfo &bnsInfo, const BNSData &bnsData)
|
|||||||
int numBlocks = (bnsData.size - 8) / 8;
|
int numBlocks = (bnsData.size - 8) / 8;
|
||||||
int numSamples = numBlocks * 14;
|
int numSamples = numBlocks * 14;
|
||||||
const BNSADPCMBlock *inputBuf = (const BNSADPCMBlock *)&bnsData.data;
|
const BNSADPCMBlock *inputBuf = (const BNSADPCMBlock *)&bnsData.data;
|
||||||
u8 * buffer = (u8 *) malloc(numSamples * sizeof (s16));
|
u8 * buffer = (u8 *)MEM2_alloc(numSamples * sizeof (s16));
|
||||||
s16 *outputBuf;
|
s16 *outputBuf;
|
||||||
|
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
@ -342,7 +344,7 @@ SoundBlock DecodefromBNS(const u8 *buffer, u32 size)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OutBlock.buffer = (u8*) malloc(dataChunk.size);
|
OutBlock.buffer = (u8*)MEM2_alloc(dataChunk.size);
|
||||||
if (!OutBlock.buffer)
|
if (!OutBlock.buffer)
|
||||||
return OutBlock;
|
return OutBlock;
|
||||||
memcpy(OutBlock.buffer, &dataChunk.data, dataChunk.size);
|
memcpy(OutBlock.buffer, &dataChunk.data, dataChunk.size);
|
||||||
|
@ -104,7 +104,7 @@ GuiSound::GuiSound(GuiSound *g)
|
|||||||
|
|
||||||
if (g->sound != NULL)
|
if (g->sound != NULL)
|
||||||
{
|
{
|
||||||
u8 * snd = (u8 *) malloc(g->length);
|
u8 * snd = (u8 *)MEM2_alloc(g->length);
|
||||||
memcpy(snd, g->sound, length);
|
memcpy(snd, g->sound, length);
|
||||||
Load(snd, g->length, true);
|
Load(snd, g->length, true);
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ void GuiSound::FreeMemory()
|
|||||||
|
|
||||||
if(allocated)
|
if(allocated)
|
||||||
{
|
{
|
||||||
SAFE_FREE(sound);
|
MEM2_free(sound);
|
||||||
allocated = false;
|
allocated = false;
|
||||||
}
|
}
|
||||||
filepath = "";
|
filepath = "";
|
||||||
@ -237,12 +237,12 @@ bool GuiSound::LoadSoundEffect(const u8 * snd, u32 len)
|
|||||||
decoder.Rewind();
|
decoder.Rewind();
|
||||||
|
|
||||||
u32 done = 0;
|
u32 done = 0;
|
||||||
sound = (u8 *) malloc(4096);
|
sound = (u8 *)MEM2_alloc(4096);
|
||||||
memset(sound, 0, 4096);
|
memset(sound, 0, 4096);
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
u8 * tmpsnd = (u8 *) realloc(sound, done+4096);
|
u8 * tmpsnd = (u8 *)MEM2_realloc(sound, done+4096);
|
||||||
if(!tmpsnd)
|
if(!tmpsnd)
|
||||||
{
|
{
|
||||||
SAFE_FREE(sound);
|
SAFE_FREE(sound);
|
||||||
@ -258,7 +258,7 @@ bool GuiSound::LoadSoundEffect(const u8 * snd, u32 len)
|
|||||||
done += read;
|
done += read;
|
||||||
}
|
}
|
||||||
|
|
||||||
sound = (u8 *) realloc(sound, done);
|
sound = (u8 *)MEM2_realloc(sound, done);
|
||||||
SoundEffectLength = done;
|
SoundEffectLength = done;
|
||||||
allocated = true;
|
allocated = true;
|
||||||
|
|
||||||
@ -407,7 +407,7 @@ u8 * uncompressLZ77(const u8 *inBuf, u32 inLength, u32 * size)
|
|||||||
const u8 *inBufEnd = inBuf + inLength;
|
const u8 *inBufEnd = inBuf + inLength;
|
||||||
inBuf += 8;
|
inBuf += 8;
|
||||||
|
|
||||||
buffer = (u8 *) malloc(uncSize);
|
buffer = (u8 *)MEM2_alloc(uncSize);
|
||||||
|
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return buffer;
|
return buffer;
|
||||||
@ -468,7 +468,7 @@ void GuiSound::UncompressSoundbin(const u8 * snd, u32 len, bool isallocated)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sound = (u8 *) malloc(length);
|
sound = (u8 *)MEM2_alloc(length);
|
||||||
if (!sound)
|
if (!sound)
|
||||||
{
|
{
|
||||||
length = 0;
|
length = 0;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "dns.h"
|
#include "dns.h"
|
||||||
#include "utils.h"
|
#include "mem2.hpp"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves a domainname to an ip address
|
* Resolves a domainname to an ip address
|
||||||
@ -70,14 +70,14 @@ u32 getipbynamecached(char *domain)
|
|||||||
u32 ip = getipbyname(domain);
|
u32 ip = getipbyname(domain);
|
||||||
|
|
||||||
//No cache of this domain could be found, create a cache node and add it to the front of the cache
|
//No cache of this domain could be found, create a cache node and add it to the front of the cache
|
||||||
struct dnsentry *newnode = malloc(sizeof(struct dnsentry));
|
struct dnsentry *newnode = MEM2_alloc(sizeof(struct dnsentry));
|
||||||
if(newnode == NULL) return ip;
|
if(newnode == NULL) return ip;
|
||||||
|
|
||||||
newnode->ip = ip;
|
newnode->ip = ip;
|
||||||
newnode->domain = malloc(strlen(domain)+1);
|
newnode->domain = MEM2_alloc(strlen(domain)+1);
|
||||||
if(newnode->domain == NULL)
|
if(newnode->domain == NULL)
|
||||||
{
|
{
|
||||||
SAFE_FREE(newnode);
|
MEM2_free(newnode);
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
strcpy(newnode->domain, domain);
|
strcpy(newnode->domain, domain);
|
||||||
@ -110,8 +110,8 @@ u32 getipbynamecached(char *domain)
|
|||||||
previousnode->nextnode = NULL;
|
previousnode->nextnode = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SAFE_FREE(node->domain);
|
MEM2_free(node->domain);
|
||||||
SAFE_FREE(node);
|
MEM2_free(node);
|
||||||
dnsentrycount--;
|
dnsentrycount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
|
||||||
#include "gcard.h"
|
#include "gcard.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "gecko/gecko.h"
|
#include "gecko/gecko.h"
|
||||||
|
#include "mem2.hpp"
|
||||||
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define MAX_URL_SIZE 178 // 128 + 48 + 6
|
#define MAX_URL_SIZE 178 // 128 + 48 + 6
|
||||||
@ -44,7 +45,7 @@ void add_game_to_card(const char *gameid)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
char *url = (char *) malloc(MAX_URL_SIZE); // Too much memory, but only like 10 bytes
|
char *url = (char *)MEM2_alloc(MAX_URL_SIZE); // Too much memory, but only like 10 bytes
|
||||||
memset(url, 0, sizeof(url));
|
memset(url, 0, sizeof(url));
|
||||||
|
|
||||||
for (i = 0; i < amount_of_providers && providers != NULL; i++)
|
for (i = 0; i < amount_of_providers && providers != NULL; i++)
|
||||||
@ -56,5 +57,5 @@ void add_game_to_card(const char *gameid)
|
|||||||
gprintf("Gamertag URL:\n%s\n",(char*)url);
|
gprintf("Gamertag URL:\n%s\n",(char*)url);
|
||||||
downloadfile(NULL, 0, (char *) url, NULL, NULL);
|
downloadfile(NULL, 0, (char *) url, NULL, NULL);
|
||||||
}
|
}
|
||||||
SAFE_FREE(url);
|
MEM2_free(url);
|
||||||
}
|
}
|
@ -32,11 +32,11 @@
|
|||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Return the next byte in the pseudo-random sequence
|
* Return the next byte in the pseudo-random sequence
|
||||||
*/
|
*/
|
||||||
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) {
|
static int decrypt_byte(unsigned long* pkeys)
|
||||||
|
{
|
||||||
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
||||||
* unpredictable manner on 16-bit systems; not a problem
|
* unpredictable manner on 16-bit systems; not a problem
|
||||||
* with any known compiler so far, though */
|
* with any known compiler so far, though */
|
||||||
|
|
||||||
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
|
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
|
||||||
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
||||||
}
|
}
|
||||||
@ -71,10 +71,10 @@ static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned lon
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define zdecode(pkeys,pcrc_32_tab,c) \
|
#define zdecode(pkeys,pcrc_32_tab,c) \
|
||||||
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
|
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys)))
|
||||||
|
|
||||||
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
||||||
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
|
(t=decrypt_byte(pkeys), update_keys(pkeys,pcrc_32_tab,c), t^(c))
|
||||||
|
|
||||||
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
|
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
|
||||||
|
|
||||||
|
@ -30,43 +30,34 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
voidpf ZCALLBACK fopen_file_func OF((
|
voidpf ZCALLBACK fopen_file_func OF((
|
||||||
voidpf opaque,
|
|
||||||
const char* filename,
|
const char* filename,
|
||||||
int mode));
|
int mode));
|
||||||
|
|
||||||
uLong ZCALLBACK fread_file_func OF((
|
uLong ZCALLBACK fread_file_func OF((
|
||||||
voidpf opaque,
|
|
||||||
voidpf stream,
|
voidpf stream,
|
||||||
void* buf,
|
void* buf,
|
||||||
uLong size));
|
uLong size));
|
||||||
|
|
||||||
uLong ZCALLBACK fwrite_file_func OF((
|
uLong ZCALLBACK fwrite_file_func OF((
|
||||||
voidpf opaque,
|
|
||||||
voidpf stream,
|
voidpf stream,
|
||||||
const void* buf,
|
const void* buf,
|
||||||
uLong size));
|
uLong size));
|
||||||
|
|
||||||
long ZCALLBACK ftell_file_func OF((
|
long ZCALLBACK ftell_file_func OF((voidpf stream));
|
||||||
voidpf opaque,
|
|
||||||
voidpf stream));
|
|
||||||
|
|
||||||
long ZCALLBACK fseek_file_func OF((
|
long ZCALLBACK fseek_file_func OF((
|
||||||
voidpf opaque,
|
|
||||||
voidpf stream,
|
voidpf stream,
|
||||||
uLong offset,
|
uLong offset,
|
||||||
int origin));
|
int origin));
|
||||||
|
|
||||||
int ZCALLBACK fclose_file_func OF((
|
int ZCALLBACK fclose_file_func OF((
|
||||||
voidpf opaque,
|
|
||||||
voidpf stream));
|
voidpf stream));
|
||||||
|
|
||||||
int ZCALLBACK ferror_file_func OF((
|
int ZCALLBACK ferror_file_func OF((
|
||||||
voidpf opaque,
|
|
||||||
voidpf stream));
|
voidpf stream));
|
||||||
|
|
||||||
|
|
||||||
voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
|
voidpf ZCALLBACK fopen_file_func (filename, mode)
|
||||||
voidpf opaque;
|
|
||||||
const char* filename;
|
const char* filename;
|
||||||
int mode;
|
int mode;
|
||||||
{
|
{
|
||||||
@ -87,8 +78,7 @@ int mode;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
|
uLong ZCALLBACK fread_file_func (stream, buf, size)
|
||||||
voidpf opaque;
|
|
||||||
voidpf stream;
|
voidpf stream;
|
||||||
void* buf;
|
void* buf;
|
||||||
uLong size;
|
uLong size;
|
||||||
@ -99,8 +89,7 @@ uLong size;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
|
uLong ZCALLBACK fwrite_file_func (stream, buf, size)
|
||||||
voidpf opaque;
|
|
||||||
voidpf stream;
|
voidpf stream;
|
||||||
const void* buf;
|
const void* buf;
|
||||||
uLong size;
|
uLong size;
|
||||||
@ -110,8 +99,7 @@ uLong size;
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
long ZCALLBACK ftell_file_func (opaque, stream)
|
long ZCALLBACK ftell_file_func (stream)
|
||||||
voidpf opaque;
|
|
||||||
voidpf stream;
|
voidpf stream;
|
||||||
{
|
{
|
||||||
long ret;
|
long ret;
|
||||||
@ -119,8 +107,7 @@ voidpf stream;
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
|
long ZCALLBACK fseek_file_func (stream, offset, origin)
|
||||||
voidpf opaque;
|
|
||||||
voidpf stream;
|
voidpf stream;
|
||||||
uLong offset;
|
uLong offset;
|
||||||
int origin;
|
int origin;
|
||||||
@ -145,8 +132,7 @@ int origin;
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZCALLBACK fclose_file_func (opaque, stream)
|
int ZCALLBACK fclose_file_func(stream)
|
||||||
voidpf opaque;
|
|
||||||
voidpf stream;
|
voidpf stream;
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@ -154,8 +140,7 @@ voidpf stream;
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZCALLBACK ferror_file_func (opaque, stream)
|
int ZCALLBACK ferror_file_func(stream)
|
||||||
voidpf opaque;
|
|
||||||
voidpf stream;
|
voidpf stream;
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@ -173,5 +158,4 @@ zlib_filefunc_def* pzlib_filefunc_def;
|
|||||||
pzlib_filefunc_def->zseek_file = fseek_file_func;
|
pzlib_filefunc_def->zseek_file = fseek_file_func;
|
||||||
pzlib_filefunc_def->zclose_file = fclose_file_func;
|
pzlib_filefunc_def->zclose_file = fclose_file_func;
|
||||||
pzlib_filefunc_def->zerror_file = ferror_file_func;
|
pzlib_filefunc_def->zerror_file = ferror_file_func;
|
||||||
pzlib_filefunc_def->opaque = NULL;
|
|
||||||
}
|
}
|
||||||
|
@ -35,35 +35,34 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
|
typedef voidpf (ZCALLBACK *open_file_func) OF((const char* filename, int mode));
|
||||||
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf stream, void* buf, uLong size));
|
||||||
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
|
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf stream, const void* buf, uLong size));
|
||||||
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
|
typedef long (ZCALLBACK *tell_file_func) OF((voidpf stream));
|
||||||
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
|
typedef long (ZCALLBACK *seek_file_func) OF((voidpf stream, uLong offset, int origin));
|
||||||
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
|
typedef int (ZCALLBACK *close_file_func) OF((voidpf stream));
|
||||||
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
|
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf stream));
|
||||||
|
|
||||||
typedef struct zlib_filefunc_def_s {
|
typedef struct zlib_filefunc_def_s {
|
||||||
open_file_func zopen_file;
|
open_file_func zopen_file;
|
||||||
read_file_func zread_file;
|
read_file_func zread_file;
|
||||||
write_file_func zwrite_file;
|
write_file_func zwrite_file;
|
||||||
tell_file_func ztell_file;
|
tell_file_func ztell_file;
|
||||||
seek_file_func zseek_file;
|
seek_file_func zseek_file;
|
||||||
close_file_func zclose_file;
|
close_file_func zclose_file;
|
||||||
testerror_file_func zerror_file;
|
testerror_file_func zerror_file;
|
||||||
voidpf opaque;
|
} zlib_filefunc_def;
|
||||||
} zlib_filefunc_def;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
|
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
|
||||||
|
|
||||||
#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
|
#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))(filestream,buf,size))
|
||||||
#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
|
#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))(filestream,buf,size))
|
||||||
#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
|
#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))(filestream))
|
||||||
#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
|
#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))(filestream,pos,mode))
|
||||||
#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
|
#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))(filestream))
|
||||||
#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
|
#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))(filestream))
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -12,9 +12,10 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
# include <unistd.h>
|
#include <unistd.h>
|
||||||
# include <utime.h>
|
#include <utime.h>
|
||||||
|
|
||||||
|
#include "mem2.hpp"
|
||||||
#include "unzip.h"
|
#include "unzip.h"
|
||||||
|
|
||||||
#define CASESENSITIVITY (0)
|
#define CASESENSITIVITY (0)
|
||||||
@ -42,14 +43,14 @@ int makedir (char *newdir)
|
|||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
buffer = (char*)malloc(len+1);
|
buffer = (char*)MEM2_alloc(len+1);
|
||||||
strcpy(buffer,newdir);
|
strcpy(buffer,newdir);
|
||||||
|
|
||||||
if (buffer[len-1] == '/') {
|
if (buffer[len-1] == '/') {
|
||||||
buffer[len-1] = '\0';
|
buffer[len-1] = '\0';
|
||||||
}
|
}
|
||||||
if (mymkdir(buffer) == 0) {
|
if (mymkdir(buffer) == 0) {
|
||||||
SAFE_FREE(buffer);
|
MEM2_free(buffer);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,19 +64,19 @@ int makedir (char *newdir)
|
|||||||
*p = 0;
|
*p = 0;
|
||||||
if ((mymkdir(buffer) == -1) && (errno == ENOENT)) {
|
if ((mymkdir(buffer) == -1) && (errno == ENOENT)) {
|
||||||
// printf("couldn't create directory %s\n",buffer);
|
// printf("couldn't create directory %s\n",buffer);
|
||||||
SAFE_FREE(buffer);
|
MEM2_free(buffer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (hold == 0)
|
if (hold == 0)
|
||||||
break;
|
break;
|
||||||
*p++ = hold;
|
*p++ = hold;
|
||||||
}
|
}
|
||||||
SAFE_FREE(buffer);
|
MEM2_free(buffer);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *fullfilename(const char *basedir, char *filename) {
|
static char *fullfilename(const char *basedir, char *filename) {
|
||||||
char *file = (char *) malloc(strlen(basedir) + strlen(filename) + 1);
|
char *file = (char *)MEM2_alloc(strlen(basedir) + strlen(filename) + 1);
|
||||||
if (basedir == NULL) {
|
if (basedir == NULL) {
|
||||||
strcpy(file, filename);
|
strcpy(file, filename);
|
||||||
} else {
|
} else {
|
||||||
@ -107,7 +108,7 @@ static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_pat
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_buf = WRITEBUFFERSIZE;
|
size_buf = WRITEBUFFERSIZE;
|
||||||
buf = (void*)malloc(size_buf);
|
buf = (void*)MEM2_alloc(size_buf);
|
||||||
if (buf==NULL) {
|
if (buf==NULL) {
|
||||||
// printf("Error allocating memory\n");
|
// printf("Error allocating memory\n");
|
||||||
return UNZ_INTERNALERROR;
|
return UNZ_INTERNALERROR;
|
||||||
@ -125,7 +126,7 @@ static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_pat
|
|||||||
if ((*popt_extract_without_path)==0) {
|
if ((*popt_extract_without_path)==0) {
|
||||||
|
|
||||||
// Fix the path, this will fail if the directoryname is the same as the first filename in the zip
|
// Fix the path, this will fail if the directoryname is the same as the first filename in the zip
|
||||||
char *path = (char *) malloc(strlen(filename_withpath));
|
char *path = (char *)MEM2_alloc(strlen(filename_withpath));
|
||||||
strcpy(path, filename_withpath);
|
strcpy(path, filename_withpath);
|
||||||
char *ptr = strstr(path, filename_withoutpath);
|
char *ptr = strstr(path, filename_withoutpath);
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
@ -133,7 +134,7 @@ static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_pat
|
|||||||
// printf("creating directory: %s\n",path);
|
// printf("creating directory: %s\n",path);
|
||||||
mymkdir(path);
|
mymkdir(path);
|
||||||
|
|
||||||
SAFE_FREE(path);
|
MEM2_free(path);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
char* write_filename;
|
char* write_filename;
|
||||||
@ -187,12 +188,12 @@ static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_pat
|
|||||||
*(filename_withoutpath-1)='\0';
|
*(filename_withoutpath-1)='\0';
|
||||||
|
|
||||||
// Fix the path, this will fail if the directoryname is the same as the first filename in the zip
|
// Fix the path, this will fail if the directoryname is the same as the first filename in the zip
|
||||||
char *path = (char *) malloc(strlen(write_filename));
|
char *path = (char *)MEM2_alloc(strlen(write_filename));
|
||||||
strcpy(path, write_filename);
|
strcpy(path, write_filename);
|
||||||
char *ptr = strstr(path, filename_withoutpath);
|
char *ptr = strstr(path, filename_withoutpath);
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
makedir(path);
|
makedir(path);
|
||||||
SAFE_FREE(path);
|
MEM2_free(path);
|
||||||
|
|
||||||
*(filename_withoutpath-1)=c;
|
*(filename_withoutpath-1)=c;
|
||||||
fout=fopen(write_filename,"wb");
|
fout=fopen(write_filename,"wb");
|
||||||
@ -232,8 +233,8 @@ static int do_extract_currentfile(unzFile uf,const int* popt_extract_without_pat
|
|||||||
} else
|
} else
|
||||||
unzCloseCurrentFile(uf); /* don't lose the error */
|
unzCloseCurrentFile(uf); /* don't lose the error */
|
||||||
}
|
}
|
||||||
SAFE_FREE(filename_withpath);
|
MEM2_free(filename_withpath);
|
||||||
SAFE_FREE(buf);
|
MEM2_free(buf);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
#include "unzip.h"
|
#include "unzip.h"
|
||||||
|
#include "mem2.hpp"
|
||||||
|
|
||||||
#define READ_8(adr) ((unsigned char)*(adr))
|
#define READ_8(adr) ((unsigned char)*(adr))
|
||||||
#define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) )
|
#define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) )
|
||||||
@ -111,7 +113,7 @@ uLong* bytesRecovered;
|
|||||||
dataSize = uncpsize;
|
dataSize = uncpsize;
|
||||||
}
|
}
|
||||||
if (dataSize > 0) {
|
if (dataSize > 0) {
|
||||||
char* data = malloc(dataSize);
|
char* data = MEM2_alloc(dataSize);
|
||||||
if (data != NULL) {
|
if (data != NULL) {
|
||||||
if ((int)fread(data, 1, dataSize, fpZip) == dataSize) {
|
if ((int)fread(data, 1, dataSize, fpZip) == dataSize) {
|
||||||
if ((int)fwrite(data, 1, dataSize, fpOut) == dataSize) {
|
if ((int)fwrite(data, 1, dataSize, fpOut) == dataSize) {
|
||||||
@ -123,7 +125,7 @@ uLong* bytesRecovered;
|
|||||||
} else {
|
} else {
|
||||||
err = Z_ERRNO;
|
err = Z_ERRNO;
|
||||||
}
|
}
|
||||||
SAFE_FREE(data);
|
MEM2_free(data);
|
||||||
if (err != Z_OK) {
|
if (err != Z_OK) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ woven in by Terry Thorsen 1/2003.
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
#include "unzip.h"
|
#include "unzip.h"
|
||||||
|
#include "mem2.hpp"
|
||||||
|
|
||||||
#ifdef STDC
|
#ifdef STDC
|
||||||
# include <stddef.h>
|
# include <stddef.h>
|
||||||
@ -75,10 +76,10 @@ extern int errno;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ALLOC
|
#ifndef ALLOC
|
||||||
# define ALLOC(size) (malloc(size))
|
# define ALLOC(size) (MEM2_alloc(size))
|
||||||
#endif
|
#endif
|
||||||
#ifndef TRYFREE
|
#ifndef TRYFREE
|
||||||
# define TRYFREE(p) if(p) {free(p); p = NULL;}
|
# define TRYFREE(p) if(p) {MEM2_free(p); p = NULL;}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SIZECENTRALDIRITEM (0x2e)
|
#define SIZECENTRALDIRITEM (0x2e)
|
||||||
@ -171,11 +172,14 @@ voidpf filestream;
|
|||||||
int *pi;
|
int *pi;
|
||||||
{
|
{
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
|
int err = (int)ZREAD(*pzlib_filefunc_def, filestream, &c, 1);
|
||||||
if (err==1) {
|
if (err==1)
|
||||||
|
{
|
||||||
*pi = (int)c;
|
*pi = (int)c;
|
||||||
return UNZ_OK;
|
return UNZ_OK;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (ZERROR(*pzlib_filefunc_def,filestream))
|
if (ZERROR(*pzlib_filefunc_def,filestream))
|
||||||
return UNZ_ERRNO;
|
return UNZ_ERRNO;
|
||||||
else
|
else
|
||||||
@ -411,8 +415,7 @@ zlib_filefunc_def* pzlib_filefunc_def;
|
|||||||
else
|
else
|
||||||
us.z_filefunc = *pzlib_filefunc_def;
|
us.z_filefunc = *pzlib_filefunc_def;
|
||||||
|
|
||||||
us.filestream= (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque,
|
us.filestream= (*(us.z_filefunc.zopen_file))(path,
|
||||||
path,
|
|
||||||
ZLIB_FILEFUNC_MODE_READ |
|
ZLIB_FILEFUNC_MODE_READ |
|
||||||
ZLIB_FILEFUNC_MODE_EXISTING);
|
ZLIB_FILEFUNC_MODE_EXISTING);
|
||||||
if (us.filestream==NULL)
|
if (us.filestream==NULL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user