mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Try to catch low space on game crypto and CIA build operations
This commit is contained in:
parent
28ba5a85b3
commit
b5a0f6cfcf
@ -756,6 +756,17 @@ u32 CryptNcchNcsdBossFirmFile(const char* orig, const char* dest, u32 mode, u16
|
||||
if (fsize < offset) return 1;
|
||||
if (!size) size = fsize - offset;
|
||||
|
||||
// ensure free space in destination
|
||||
if (!inplace) {
|
||||
if ((fvx_lseek(dfp, offset + size) != FR_OK) ||
|
||||
(fvx_tell(dfp) != offset + size) ||
|
||||
(fvx_lseek(dfp, offset) != FR_OK)) {
|
||||
fvx_close(ofp);
|
||||
fvx_close(dfp);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
u32 ret = 0;
|
||||
if (!ShowProgress(offset, fsize, dest)) ret = 1;
|
||||
if (mode & (GAME_NCCH|GAME_NCSD|GAME_BOSS|SYS_FIRM|GAME_NDS)) { // for NCCH / NCSD / BOSS / FIRM files
|
||||
@ -1048,6 +1059,16 @@ u32 InsertCiaContent(const char* path_cia, const char* path_content, u32 offset,
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ensure free space for destination file
|
||||
UINT offset_dest = fvx_tell(&dfile);
|
||||
if ((fvx_lseek(&dfile, offset_dest + fsize) != FR_OK) ||
|
||||
(fvx_tell(&dfile) != offset_dest + fsize) ||
|
||||
(fvx_lseek(&dfile, offset_dest) != FR_OK)) {
|
||||
fvx_close(&ofile);
|
||||
fvx_close(&dfile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// check if NCCH crypto is available
|
||||
if (ncch_decrypt) {
|
||||
NcchHeader ncch;
|
||||
@ -1404,8 +1425,10 @@ u32 DumpCxiSrlFromTmdFile(const char* path) {
|
||||
(GetTmdContentPath(path_cxi, path) != 0) ||
|
||||
(!((filetype = IdentifyFileType(path_cxi)) & (GAME_NCCH|GAME_NDS))) ||
|
||||
(GetGoodName(dname, path_cxi, false) != 0) ||
|
||||
(CryptNcchNcsdBossFirmFile(path_cxi, dest, filetype, CRYPTO_DECRYPT, 0, 0, NULL, NULL) != 0))
|
||||
(CryptNcchNcsdBossFirmFile(path_cxi, dest, filetype, CRYPTO_DECRYPT, 0, 0, NULL, NULL) != 0)) {
|
||||
if (*dname) fvx_unlink(dest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user