diff --git a/README.md b/README.md index f4faef3..cc4a821 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ Options: ## Panasonic Blu-Ray (PANA_DVD.FRM, PANA_ESD.FRM, PANAEUSB.FRM) **Used in:** Panasonic Blu-Ray Players and Recorders -**Notes:** **Depends on keys** - see keys.rs (Included keys should work for 99% of players released in and before 2014, and some released in 2018), Note that there is currently an issue with MAIN in some very ancient files not extracting correctly. +**Notes:** **Depends on keys** - see keys.rs (Included keys should work for 99% of players released in and before 2014, and some released in 2018), Note that there is currently an issue with MAIN in some very ancient files not extracting correctly. **Options:** `pana_dvd:split_main` - Automatically split the MAIN module into seperate partitions. diff --git a/src/formats/pana_dvd/mod.rs b/src/formats/pana_dvd/mod.rs index 4330810..a509b99 100644 --- a/src/formats/pana_dvd/mod.rs +++ b/src/formats/pana_dvd/mod.rs @@ -13,7 +13,7 @@ use binrw::BinReaderExt; use crate::keys; use crate::utils::common; use crate::utils::aes::{decrypt_aes128_cbc_nopad}; -use crate::utils::compression::{decompress_gzip}; +use crate::utils::compression::{decompress_gzip_get_filename}; use pana_dvd_crypto::{decrypt_data}; use lzss::{decompress_lzss}; use include::*; @@ -233,8 +233,10 @@ fn decompress_data(data: &[u8]) -> Result, Box> { if header.compression_type == 1 { //gzip + optionally lzss println!("- Decompressing GZIP..."); - let decompressed_gzip = decompress_gzip(&compressed_data)?; - + let (decompressed_gzip, gzip_filename) = decompress_gzip_get_filename(&compressed_data)?; + if let Some(gzip_filename) = gzip_filename { + println!("- GZIP filename: {}", gzip_filename); + } // the decompressed data can have another header if decompressed_gzip.starts_with(COMPRESSED_FILE_MAGIC) { decompressed_data = decompress_data(&decompressed_gzip)?; diff --git a/src/utils/compression.rs b/src/utils/compression.rs index f63df17..3e5fbe9 100644 --- a/src/utils/compression.rs +++ b/src/utils/compression.rs @@ -7,6 +7,8 @@ use lz4::block::decompress; use bzip2::read::BzDecoder; use liblzma::read::XzDecoder; +use crate::utils::common; + pub fn decompress_zlib(data: &[u8]) -> io::Result> { let mut decoder = ZlibDecoder::new(data); let mut decompressed = Vec::new(); @@ -22,6 +24,20 @@ pub fn decompress_gzip(compressed_data: &[u8]) -> Result, Box Result<(Vec, Option), Box> { + let mut decoder = GzDecoder::new(compressed_data); + + let mut filename: Option = None; + if let Some(filename_bytes) = decoder.header().unwrap().filename() { + filename = Some(common::string_from_bytes(filename_bytes)); + } + + let mut decompressed = Vec::new(); + decoder.read_to_end(&mut decompressed)?; + + Ok((decompressed, filename)) +} + pub fn decompress_lzma(compressed_data: &[u8]) -> Result, Box> { let mut input = Cursor::new(compressed_data); let mut output = Vec::new();