mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-24 15:00:11 +01:00
Fix some encrypted FSB .bank
This commit is contained in:
parent
948c55f4f9
commit
242e10f80c
@ -3,7 +3,7 @@
|
||||
#include "../util/chunks.h"
|
||||
|
||||
|
||||
static int get_subsongs(STREAMFILE* sf, off_t fsb5_offset, size_t fsb5_size);
|
||||
static int get_subsongs(STREAMFILE* sf, uint32_t fsb5_offset, uint32_t fsb5_size);
|
||||
|
||||
/* FEV+FSB5 container [Just Cause 3 (PC), Shantae: Half-Genie Hero (Switch)] */
|
||||
VGMSTREAM* init_vgmstream_fsb5_fev_bank(STREAMFILE* sf) {
|
||||
@ -88,7 +88,7 @@ VGMSTREAM* init_vgmstream_fsb5_fev_bank(STREAMFILE* sf) {
|
||||
|
||||
/* 0x00: unknown (chunk version? ex LE: 0x00080003, 0x00080005) */
|
||||
banks = (bank_size - 0x04) / entry_size;
|
||||
|
||||
|
||||
/* multiple banks is possible but rare [Hades (Switch), Guacamelee 2 (Switch)],
|
||||
* must map bank (global) subsong to FSB (internal) subsong */
|
||||
|
||||
@ -99,11 +99,11 @@ VGMSTREAM* init_vgmstream_fsb5_fev_bank(STREAMFILE* sf) {
|
||||
total_subsongs = 0;
|
||||
for (i = 0; i < banks; i++) {
|
||||
//TODO: fsb5_size fails for v0x28< + encrypted, but only used with multibanks = unlikely
|
||||
off_t fsb5_offset = read_u32le(bank_offset + 0x04 + entry_size*i + 0x00,sf);
|
||||
size_t fsb5_size = read_u32le(bank_offset+0x08 + entry_size*i,sf);
|
||||
uint32_t fsb5_offset = read_u32le(bank_offset + 0x04 + entry_size*i + 0x00,sf);
|
||||
uint32_t fsb5_size = read_u32le(bank_offset + 0x08 + entry_size*i,sf);
|
||||
int fsb5_subsongs = get_subsongs(sf, fsb5_offset, fsb5_size);
|
||||
if (!fsb5_subsongs) {
|
||||
vgm_logi("FSB: couldn't load bank (encrypted?)\n");
|
||||
vgm_logi("FSB: couldn't load bank %i at %x (encrypted?)\n", i, fsb5_offset);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -159,14 +159,13 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int get_subsongs(STREAMFILE* sf, off_t fsb5_offset, size_t fsb5_size) {
|
||||
static int get_subsongs(STREAMFILE* sf, uint32_t fsb5_offset, uint32_t fsb5_size) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
STREAMFILE* temp_sf = NULL;
|
||||
int subsongs = 0;
|
||||
|
||||
|
||||
/* standard */
|
||||
if (read_u32be(fsb5_offset, sf) == 0x46534235) { /* FSB5 */
|
||||
if (is_id32be(fsb5_offset, sf, "FSB5")) {
|
||||
return read_s32le(fsb5_offset + 0x08,sf);
|
||||
}
|
||||
|
||||
@ -174,6 +173,7 @@ static int get_subsongs(STREAMFILE* sf, off_t fsb5_offset, size_t fsb5_size) {
|
||||
temp_sf = setup_subfile_streamfile(sf, fsb5_offset, fsb5_size, "fsb");
|
||||
if (!temp_sf) goto end;
|
||||
|
||||
temp_sf->stream_index = 0;
|
||||
vgmstream = init_vgmstream_fsb_encrypted(temp_sf);
|
||||
if (!vgmstream) goto end;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _FSB_ENCRYPTED_STREAMFILE_H_
|
||||
#define _FSB_ENCRYPTED_STREAMFILE_H_
|
||||
|
||||
#define FSB_KEY_MAX 0x10000 //0x168
|
||||
#define FSB_KEY_MAX 0x80 /* known max ~0x33 */
|
||||
|
||||
|
||||
typedef struct {
|
||||
@ -57,7 +57,7 @@ static STREAMFILE* setup_fsb_streamfile(STREAMFILE* sf, const uint8_t* key, size
|
||||
size_t io_data_size = sizeof(fsb_decryption_data);
|
||||
|
||||
/* setup decryption with key (external) */
|
||||
if (!key_size || key_size > FSB_KEY_MAX)
|
||||
if (!key_size || key_size >= FSB_KEY_MAX)
|
||||
return NULL;
|
||||
|
||||
memcpy(io_data.key, key, key_size);
|
||||
|
Loading…
Reference in New Issue
Block a user