void ncsd_process(ncsd_context* ctx, u32 actions) { fseeko64(ctx->file, ctx->offset, SEEK_SET); fread(&ctx->header, 1, 0x200, ctx->file); if (getle32(ctx->header.magic) != MAGIC_NCSD) { fprintf(stdout, "Error, NCSD segment corrupted\n"); return; } if (actions & VerifyFlag) { if (ctx->usersettings) ctx->headersigcheck = ncsd_signature_verify(&ctx->header, &ctx->usersettings->keys.ncsdrsakey); } if (actions & InfoFlag) ncsd_print(ctx); if(ctx->ncch_index > 7 || ctx->header.partitiongeometry[ctx->ncch_index].size == 0) { fprintf(stderr," ERROR NCSD partition %d, does not exist\n",ctx->ncch_index); return; } ncch_set_file(&ctx->ncch, ctx->file); ncch_set_offset(&ctx->ncch, ctx->header.partitiongeometry[ctx->ncch_index].offset * ncsd_get_mediaunit_size(ctx)); ncch_set_size(&ctx->ncch, ctx->header.partitiongeometry[ctx->ncch_index].size * ncsd_get_mediaunit_size(ctx)); ncch_set_usersettings(&ctx->ncch, ctx->usersettings); ncch_process(&ctx->ncch, actions); }
void ncsd_process(ncsd_context* ctx, u32 actions) { fseek(ctx->file, ctx->offset, SEEK_SET); fread(&ctx->header, 1, 0x200, ctx->file); if (getle32(ctx->header.magic) != MAGIC_NCSD) { fprintf(stdout, "Error, NCSD segment corrupted\n"); return; } if (actions & VerifyFlag) { if (ctx->usersettings) ctx->headersigcheck = ncsd_signature_verify(&ctx->header, &ctx->usersettings->keys.ncsdrsakey); } if (actions & InfoFlag) ncsd_print(ctx); ncch_set_file(&ctx->ncch, ctx->file); ncch_set_offset(&ctx->ncch, 0x4000); ncch_set_size(&ctx->ncch, ctx->size - 0x4000); ncch_set_usersettings(&ctx->ncch, ctx->usersettings); ncch_process(&ctx->ncch, actions); }