diff --git a/src/bin/unpack.rs b/src/bin/unpack.rs index 9782255..301e345 100644 --- a/src/bin/unpack.rs +++ b/src/bin/unpack.rs @@ -6,13 +6,19 @@ fn main() -> anyhow::Result<()> { let package = Package::open(&std::env::args().nth(1).unwrap())?; std::fs::create_dir("./files/").ok(); + println!( + "PKG {:04x}_{}", + package.header.pkg_id, package.header.patch_id + ); for (i, e) in package.entries().enumerate() { + print!("{}/{} - ", e.file_type, e.file_subtype); if e.reference != u32::MAX { print!( - "{i} 0x{:x} - p={:x} f={} ", + "{i} 0x{:x} - p={:x} f={} / r=0x{:x} ", e.file_size, - (e.reference >> 13) & 0x3ff, - e.reference & 0x1fff + (e.reference & !0x80800000) >> 13, + e.reference & 0x1fff, + e.reference ); } else { print!("{i} 0x{:x} - ", e.file_size); @@ -20,7 +26,7 @@ fn main() -> anyhow::Result<()> { let ext = match (e.file_type, e.file_subtype) { (26, 6) => { println!("WWise WAVE Audio"); - "wav".to_string() + "wem".to_string() } (26, 7) => { println!("Havok File"); diff --git a/src/lib.rs b/src/lib.rs index bfa5bc1..121c54e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,3 +4,5 @@ mod crypto; mod oodle; pub mod package; pub mod structs; + +pub use package::Package; diff --git a/src/package.rs b/src/package.rs index a4cfc50..44bbefc 100644 --- a/src/package.rs +++ b/src/package.rs @@ -20,7 +20,7 @@ impl ReadSeek for R {} pub struct Package { gcm: RefCell, - header: PackageHeader, + pub header: PackageHeader, entries: Vec, blocks: Vec, @@ -147,7 +147,7 @@ impl Package { let block_data = self.get_block(current_block as usize)?; if current_block == entry.starting_block { - let block_start_offset = (entry.starting_block_offset * 16) as usize; + let block_start_offset = entry.starting_block_offset as usize; let block_remaining = block_data.len() - block_start_offset; let copy_size = if block_remaining < remaining_bytes { block_remaining diff --git a/src/structs.rs b/src/structs.rs index 685c1b1..5a417b9 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -51,7 +51,7 @@ pub struct EntryHeader { #[br(calc = _block_info as u32 & 0x3fff)] pub starting_block: u32, - #[br(calc = (_block_info >> 14) as u32 & 0x3FFF)] + #[br(calc = ((_block_info >> 14) as u32 & 0x3FFF) << 4)] pub starting_block_offset: u32, #[br(calc = (_block_info >> 28) as u32)]