mirror of
https://github.com/DarkStore-3DS/Project_CTR.git
synced 2026-07-05 16:59:02 +00:00
Fix verifying incomplete DLC CIAs. (#76)
This commit is contained in:
+8
-3
@@ -251,6 +251,7 @@ clean:
|
|||||||
void cia_verify_contents(cia_context *ctx, u32 actions)
|
void cia_verify_contents(cia_context *ctx, u32 actions)
|
||||||
{
|
{
|
||||||
u16 contentflags;
|
u16 contentflags;
|
||||||
|
u16 contentindex;
|
||||||
ctr_tmd_body *body;
|
ctr_tmd_body *body;
|
||||||
ctr_tmd_contentchunk *chunk;
|
ctr_tmd_contentchunk *chunk;
|
||||||
u8 *verify_buf;
|
u8 *verify_buf;
|
||||||
@@ -263,6 +264,10 @@ void cia_verify_contents(cia_context *ctx, u32 actions)
|
|||||||
|
|
||||||
fseeko64(ctx->file, ctx->offset + ctx->offsetcontent, SEEK_SET);
|
fseeko64(ctx->file, ctx->offset + ctx->offsetcontent, SEEK_SET);
|
||||||
for(i = 0; i < getbe16(body->contentcount); i++)
|
for(i = 0; i < getbe16(body->contentcount); i++)
|
||||||
|
{
|
||||||
|
contentindex = getbe16(chunk->index);
|
||||||
|
|
||||||
|
if(ctx->header.contentindex[contentindex >> 3] & (0x80 >> (contentindex & 7)))
|
||||||
{
|
{
|
||||||
content_size = getbe64(chunk->size) & 0xffffffff;
|
content_size = getbe64(chunk->size) & 0xffffffff;
|
||||||
|
|
||||||
@@ -273,8 +278,8 @@ void cia_verify_contents(cia_context *ctx, u32 actions)
|
|||||||
|
|
||||||
if(contentflags & 1 && !(actions & PlainFlag)) // Decrypt if needed
|
if(contentflags & 1 && !(actions & PlainFlag)) // Decrypt if needed
|
||||||
{
|
{
|
||||||
ctx->iv[0] = (getbe16(chunk->index) >> 8) & 0xff;
|
ctx->iv[0] = (contentindex >> 8) & 0xff;
|
||||||
ctx->iv[1] = getbe16(chunk->index) & 0xff;
|
ctx->iv[1] = contentindex & 0xff;
|
||||||
|
|
||||||
ctr_init_cbc_decrypt(&ctx->aes, ctx->titlekey, ctx->iv);
|
ctr_init_cbc_decrypt(&ctx->aes, ctx->titlekey, ctx->iv);
|
||||||
|
|
||||||
@@ -287,7 +292,7 @@ void cia_verify_contents(cia_context *ctx, u32 actions)
|
|||||||
ctx->tmd.content_hash_stat[i] = 2;
|
ctx->tmd.content_hash_stat[i] = 2;
|
||||||
|
|
||||||
free(verify_buf);
|
free(verify_buf);
|
||||||
|
}
|
||||||
chunk++;
|
chunk++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user