Fix installing bogus wads

This commit is contained in:
Juan de la Cruz Caravaca Guerrero 2024-07-13 16:48:31 +02:00
parent d9ba968f90
commit ed2c3b83d7
2 changed files with 59 additions and 58 deletions

View File

@ -239,7 +239,6 @@ s32 Sys_GetSharedContents(SharedContent** out, u32* count)
{ {
if (!out || !count) return false; if (!out || !count) return false;
int ret = 0;
u32 size; u32 size;
SharedContent* buf = (SharedContent*)NANDLoadFile("/shared1/content.map", &size); SharedContent* buf = (SharedContent*)NANDLoadFile("/shared1/content.map", &size);
@ -276,7 +275,6 @@ bool Sys_SharedContentPresent(tmd_content* content, SharedContent shared[], u32
bool Sys_GetcIOSInfo(int IOS, cIOSInfo* out) bool Sys_GetcIOSInfo(int IOS, cIOSInfo* out)
{ {
int ret;
u64 titleID = 0x0000000100000000ULL | IOS; u64 titleID = 0x0000000100000000ULL | IOS;
ATTRIBUTE_ALIGN(0x20) char path[ISFS_MAXPATH]; ATTRIBUTE_ALIGN(0x20) char path[ISFS_MAXPATH];
u32 size; u32 size;

View File

@ -965,73 +965,76 @@ skipChecks:
if (ret < 0) if (ret < 0)
goto err; goto err;
/* Get list of currently installed shared contents */ if (header->data_len) // Bogus WADs have no contents
Sys_GetSharedContents(&sharedContents, &sharedContentsCount);
/* Install contents */
for (cnt = 0; cnt < tmd_data->num_contents; cnt++)
{ {
tmd_content *content = &tmd_data->contents[cnt]; /* Get list of currently installed shared contents */
Sys_GetSharedContents(&sharedContents, &sharedContentsCount);
u32 idx = 0, len; /* Install contents */
s32 cfd; for (cnt = 0; cnt < tmd_data->num_contents; cnt++)
/* Encrypted content size */
len = round_up(content->size, 64);
if (Sys_SharedContentPresent(content, sharedContents, sharedContentsCount))
{ {
offset += len; tmd_content *content = &tmd_data->contents[cnt];
continue;
}
Con_ClearLine(); u32 idx = 0, len;
printf("\r\t\t>> Installing content #%02d...", content->cid); s32 cfd;
fflush(stdout);
/* Install content */ /* Encrypted content size */
cfd = ES_AddContentStart(tmd_data->title_id, content->cid); len = round_up(content->size, 64);
if (cfd < 0)
{
ret = cfd;
goto err;
}
/* Install content data */ if (Sys_SharedContentPresent(content, sharedContents, sharedContentsCount))
while (idx < len)
{
u32 size;
/* Data length */
size = (len - idx);
if (size > BLOCK_SIZE)
size = BLOCK_SIZE;
/* Read data */
ret = FSOPReadOpenFile(fp, &wadBuffer, offset, size);
if (ret != 1)
{ {
ES_AddContentFinish(cfd); offset += len;
continue;
}
Con_ClearLine();
printf("\r\t\t>> Installing content #%02d...", content->cid);
fflush(stdout);
/* Install content */
cfd = ES_AddContentStart(tmd_data->title_id, content->cid);
if (cfd < 0)
{
ret = cfd;
goto err; goto err;
} }
/* Install data */ /* Install content data */
ret = ES_AddContentData(cfd, wadBuffer, size); while (idx < len)
{
u32 size;
/* Data length */
size = (len - idx);
if (size > BLOCK_SIZE)
size = BLOCK_SIZE;
/* Read data */
ret = FSOPReadOpenFile(fp, &wadBuffer, offset, size);
if (ret != 1)
{
ES_AddContentFinish(cfd);
goto err;
}
/* Install data */
ret = ES_AddContentData(cfd, wadBuffer, size);
if (ret < 0)
{
ret = ES_AddContentFinish(cfd);
goto err;
}
/* Increase variables */
idx += size;
offset += size;
}
/* Finish content installation */
ret = ES_AddContentFinish(cfd);
if (ret < 0) if (ret < 0)
{
ret = ES_AddContentFinish(cfd);
goto err; goto err;
}
/* Increase variables */
idx += size;
offset += size;
} }
/* Finish content installation */
ret = ES_AddContentFinish(cfd);
if (ret < 0)
goto err;
} }
Con_ClearLine(); Con_ClearLine();