mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Fixed inability to install a larger/smaller ticket when a smaller/large one is installed (#733)
* Fixed inability to install a larger ticket when a smaller one is installed * improved AddBDRIEntry checks, formatting and added define for REPLACE_SIZE_MISMATCH
This commit is contained in:
parent
0dbe70928f
commit
55385a5502
@ -2,6 +2,7 @@
|
|||||||
#include "vff.h"
|
#include "vff.h"
|
||||||
|
|
||||||
#define FAT_ENTRY_SIZE 2 * sizeof(u32)
|
#define FAT_ENTRY_SIZE 2 * sizeof(u32)
|
||||||
|
#define REPLACE_SIZE_MISMATCH 2
|
||||||
|
|
||||||
#define getfatflag(uv) (((uv) & 0x80000000UL) != 0)
|
#define getfatflag(uv) (((uv) & 0x80000000UL) != 0)
|
||||||
#define getfatindex(uv) ((uv) & 0x7FFFFFFFUL)
|
#define getfatindex(uv) ((uv) & 0x7FFFFFFFUL)
|
||||||
@ -369,7 +370,8 @@ static u32 AddBDRIEntry(const BDRIFsHeader* fs_header, const u32 fs_header_offse
|
|||||||
|
|
||||||
// If an entry for the tid already existed that is already the specified size and replace was specified, just replace the existing entry
|
// If an entry for the tid already existed that is already the specified size and replace was specified, just replace the existing entry
|
||||||
if (memcmp(title_id_be, file_entry.title_id, 8) == 0) {
|
if (memcmp(title_id_be, file_entry.title_id, 8) == 0) {
|
||||||
if (!replace || (file_entry.size != size)) return 1;
|
if (!replace) return 1;
|
||||||
|
else if (file_entry.size != size) return REPLACE_SIZE_MISMATCH;
|
||||||
else {
|
else {
|
||||||
do_replace = true;
|
do_replace = true;
|
||||||
break;
|
break;
|
||||||
@ -864,10 +866,15 @@ u32 AddTicketToDB(const char* path, const u8* title_id, const Ticket* ticket, bo
|
|||||||
|
|
||||||
bdrifp = &file;
|
bdrifp = &file;
|
||||||
|
|
||||||
|
u32 add_bdri_res = 0;
|
||||||
|
|
||||||
if ((BDRIRead(0, sizeof(TickDBPreHeader), &pre_header) != FR_OK) ||
|
if ((BDRIRead(0, sizeof(TickDBPreHeader), &pre_header) != FR_OK) ||
|
||||||
!CheckDBMagic((u8*) &pre_header, true) ||
|
!CheckDBMagic((u8*) &pre_header, true) ||
|
||||||
|
((add_bdri_res = AddBDRIEntry(&(pre_header.fs_header), sizeof(TickDBPreHeader) - sizeof(BDRIFsHeader), title_id,
|
||||||
|
(const u8*) te, entry_size, replace)) == 1) ||
|
||||||
|
(add_bdri_res == REPLACE_SIZE_MISMATCH && ((RemoveBDRIEntry(&(pre_header.fs_header), sizeof(TickDBPreHeader) - sizeof(BDRIFsHeader), title_id) != 0) ||
|
||||||
(AddBDRIEntry(&(pre_header.fs_header), sizeof(TickDBPreHeader) - sizeof(BDRIFsHeader), title_id,
|
(AddBDRIEntry(&(pre_header.fs_header), sizeof(TickDBPreHeader) - sizeof(BDRIFsHeader), title_id,
|
||||||
(const u8*) te, entry_size, replace) != 0)) {
|
(const u8*) te, entry_size, replace) != 0)))) {
|
||||||
free(te);
|
free(te);
|
||||||
fvx_close(bdrifp);
|
fvx_close(bdrifp);
|
||||||
bdrifp = NULL;
|
bdrifp = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user