pana_dvd: clear up some structs and add final key for 2012_2

This commit is contained in:
theubusu
2026-02-19 17:20:29 +01:00
parent f4a146a389
commit 070a4f37c9
3 changed files with 36 additions and 28 deletions
+16 -14
View File
@@ -104,25 +104,27 @@ pub const COMPRESSED_FILE_MAGIC: &[u8; 8] = b"EXTRHEAD";
#[derive(BinRead)]
pub struct CompressedFileHeader {
_header_string: [u8; 14], //EXTRHEADDRV \x01\x00
pub compression_type_byte: u16,
pub decompressed_size: u32,
_destination_address: u32,
pub compressed_size: u32,
_magic_bytes: [u8; 8], // EXTRHEAD
_unk_string: [u8; 4], // DRV\x20 ?
_compressed_flag: u16, // checks for 1 here, else -> "Error! Not compress"
pub compression_type: u16, // 0 - not compressed, 1 - GZIP , 2 - LZSS
pub dest_size: u32, // decompressed size
_dest_address: u32,
pub src_size: u32, // compressed size
_src_address: u32,
_footer_offset: u32, // offset to EXTRFOOT
_unk: u32,
_footer_offset: u32,
_base_address: u32,
_checksum: u32, //unknown type of checksum
_checksum_flag: u8,
_unused: [u8; 19],
_checksum: u32, // adler32 calculated every checksum_skip bytes of decompressed data
_checksum_skip: u32,
_unused: [u8; 16],
}
impl CompressedFileHeader {
pub fn compression_type(&self) -> &str {
if self.compression_type_byte == 0 {
pub fn compression_type_str(&self) -> &str {
if self.compression_type == 0 {
return "Uncompressed"
} else if self.compression_type_byte == 1 {
} else if self.compression_type == 1 {
return "GZIP"
} else if self.compression_type_byte == 2 {
} else if self.compression_type == 2 {
return "LZSS"
} else {
return "Unknown"
+6 -6
View File
@@ -226,12 +226,12 @@ fn decompress_data(data: &[u8]) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
let mut data_reader = Cursor::new(data);
let header: CompressedFileHeader = data_reader.read_le()?;
println!("Compressed size: {}, Decompressed size: {}, Compression type: {}({})",
header.compressed_size, header.decompressed_size, header.compression_type_byte, header.compression_type());
header.src_size, header.dest_size, header.compression_type, header.compression_type_str());
let compressed_data = common::read_exact(&mut data_reader, header.compressed_size as usize)?;
let compressed_data = common::read_exact(&mut data_reader, header.src_size as usize)?;
let decompressed_data;
if header.compression_type_byte == 1 { //gzip + optionally lzss
if header.compression_type == 1 { //gzip + optionally lzss
println!("- Decompressing GZIP...");
let decompressed_gzip = decompress_gzip(&compressed_data)?;
@@ -241,13 +241,13 @@ fn decompress_data(data: &[u8]) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
} else {
decompressed_data = decompressed_gzip;
}
} else if header.compression_type_byte == 2 { //only lzss
} else if header.compression_type == 2 { //only lzss
println!("- Decompressing LZSS...");
decompressed_data = decompress_lzss(&compressed_data);
if decompressed_data.len() != header.decompressed_size as usize {
if decompressed_data.len() != header.dest_size as usize {
return Err("Decompressed size does not match size in header, decompression failed!".into());
}
} else if header.compression_type_byte == 0 { //no compression. havent encountered one yet
} else if header.compression_type == 0 { //no compression. havent encountered one yet
decompressed_data = compressed_data;
} else {