Merge pull request #15 from sbJFn5r/master

merge sbJFn5r additions
This commit is contained in:
applestash
2014-09-07 19:23:19 +08:00
4 changed files with 27 additions and 3 deletions
+1
View File
@@ -26,6 +26,7 @@ typedef enum
FILETYPE_LZSS, FILETYPE_LZSS,
FILETYPE_FIRM, FILETYPE_FIRM,
FILETYPE_CWAV, FILETYPE_CWAV,
FILETYPE_EXEFS,
FILETYPE_ROMFS FILETYPE_ROMFS
} ctr_filetypes; } ctr_filetypes;
+3 -1
View File
@@ -129,7 +129,7 @@ void exefs_save(exefs_context* ctx, u32 index, u32 flags)
ctr_init_counter(&ctx->aes, ctx->key, ctx->counter); ctr_init_counter(&ctx->aes, ctx->key, ctx->counter);
ctr_add_counter(&ctx->aes, offset / 0x10); ctr_add_counter(&ctx->aes, offset / 0x10);
if (index == 0 && ctx->compressedflag && ((flags & RawFlag) == 0)) if (index == 0 && (ctx->compressedflag || (flags & DecompressCodeFlag)) && ((flags & RawFlag) == 0))
{ {
fprintf(stdout, "Decompressing section %s to %s...\n", name, outfname); fprintf(stdout, "Decompressing section %s to %s...\n", name, outfname);
@@ -200,6 +200,8 @@ void exefs_save(exefs_context* ctx, u32 index, u32 flags)
} }
clean: clean:
if (fout)
fclose(fout);
free(compressedbuffer); free(compressedbuffer);
free(decompressedbuffer); free(decompressedbuffer);
return; return;
+21 -1
View File
@@ -57,7 +57,7 @@ static void usage(const char *argv0)
" --ncchsyskey=key Set ncch fixed system key.\n" " --ncchsyskey=key Set ncch fixed system key.\n"
" --showkeys Show the keys being used.\n" " --showkeys Show the keys being used.\n"
" -t, --intype=type Specify input file type [ncsd, ncch, exheader, cia, tmd, lzss,\n" " -t, --intype=type Specify input file type [ncsd, ncch, exheader, cia, tmd, lzss,\n"
" firm, cwav, romfs]\n" " firm, cwav, exefs, romfs]\n"
"LZSS options:\n" "LZSS options:\n"
" --lzssout=file Specify lzss output file\n" " --lzssout=file Specify lzss output file\n"
"CXI/CCI options:\n" "CXI/CCI options:\n"
@@ -78,6 +78,9 @@ static void usage(const char *argv0)
"CWAV options:\n" "CWAV options:\n"
" --wav=file Specify wav output file.\n" " --wav=file Specify wav output file.\n"
" --wavloops=count Specify wav loop count, default 0.\n" " --wavloops=count Specify wav loop count, default 0.\n"
"EXEFS options:\n"
" --decompresscode Decompress .code section\n"
" (only needed when using raw EXEFS file)\n"
"ROMFS options:\n" "ROMFS options:\n"
" --romfsdir=dir Specify RomFS directory path.\n" " --romfsdir=dir Specify RomFS directory path.\n"
" --listromfs List files in RomFS.\n" " --listromfs List files in RomFS.\n"
@@ -142,6 +145,7 @@ int main(int argc, char* argv[])
{"listromfs", 0, NULL, 18}, {"listromfs", 0, NULL, 18},
{"wavloops", 1, NULL, 19}, {"wavloops", 1, NULL, 19},
{"logo", 1, NULL, 20}, {"logo", 1, NULL, 20},
{"decompresscode", 0, NULL, 21},
{NULL}, {NULL},
}; };
@@ -201,6 +205,8 @@ int main(int argc, char* argv[])
ctx.filetype = FILETYPE_FIRM; ctx.filetype = FILETYPE_FIRM;
else if (!strcmp(optarg, "cwav")) else if (!strcmp(optarg, "cwav"))
ctx.filetype = FILETYPE_CWAV; ctx.filetype = FILETYPE_CWAV;
else if (!strcmp(optarg, "exefs"))
ctx.filetype = FILETYPE_EXEFS;
else if (!strcmp(optarg, "romfs")) else if (!strcmp(optarg, "romfs"))
ctx.filetype = FILETYPE_ROMFS; ctx.filetype = FILETYPE_ROMFS;
break; break;
@@ -226,6 +232,7 @@ int main(int argc, char* argv[])
case 18: settings_set_list_romfs_files(&ctx.usersettings, 1); break; case 18: settings_set_list_romfs_files(&ctx.usersettings, 1); break;
case 19: settings_set_cwav_loopcount(&ctx.usersettings, strtoul(optarg, 0, 0)); break; case 19: settings_set_cwav_loopcount(&ctx.usersettings, strtoul(optarg, 0, 0)); break;
case 20: settings_set_logo_path(&ctx.usersettings, optarg); break; case 20: settings_set_logo_path(&ctx.usersettings, optarg); break;
case 21: ctx.actions |= DecompressCodeFlag; break;
default: default:
usage(argv[0]); usage(argv[0]);
@@ -424,6 +431,19 @@ int main(int argc, char* argv[])
break; break;
} }
case FILETYPE_EXEFS:
{
exefs_context exefsctx;
exefs_init(&exefsctx);
exefs_set_file(&exefsctx, ctx.infile);
exefs_set_size(&exefsctx, ctx.infilesize);
exefs_set_usersettings(&exefsctx, &ctx.usersettings);
exefs_process(&exefsctx, ctx.actions);
break;
}
case FILETYPE_ROMFS: case FILETYPE_ROMFS:
{ {
+2 -1
View File
@@ -21,7 +21,8 @@ enum flags
VerboseFlag = (1<<3), VerboseFlag = (1<<3),
VerifyFlag = (1<<4), VerifyFlag = (1<<4),
RawFlag = (1<<5), RawFlag = (1<<5),
ShowKeysFlag = (1<<6) ShowKeysFlag = (1<<6),
DecompressCodeFlag = (1<<7)
}; };
enum validstate enum validstate