diff --git a/oodle_loader/src/lib.rs b/oodle_loader/src/lib.rs index 314848e..b9a9794 100644 --- a/oodle_loader/src/lib.rs +++ b/oodle_loader/src/lib.rs @@ -104,8 +104,6 @@ fn fetch_oodle() -> Result { mod windows_oodle { use super::*; - use anyhow::Context; - static DECOMPRESS: OnceLock<(OodleLZ_Decompress, libloading::Library)> = OnceLock::new(); pub fn decompress_wrapper_windows(comp_buf: &[u8], raw_buf: &mut [u8]) -> i32 { @@ -126,7 +124,6 @@ mod windows_oodle { mod linux_oodle { use super::*; - use anyhow::Result; use object::pe::{ ImageNtHeaders64, IMAGE_REL_BASED_DIR64, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE, diff --git a/repak/Cargo.toml b/repak/Cargo.toml index 38fce10..c9af637 100644 --- a/repak/Cargo.toml +++ b/repak/Cargo.toml @@ -11,6 +11,8 @@ default = ["compression", "encryption"] compression = ["dep:flate2", "dep:zstd"] oodle = [] oodle_loader = ["dep:oodle_loader"] +oodle_explicit = ["oodle"] +oodle_implicit_dynamic = ["dep:oodle_loader", "oodle"] encryption = ["dep:aes"] [dependencies] diff --git a/repak/src/pak.rs b/repak/src/pak.rs index d7fa80a..a4109af 100644 --- a/repak/src/pak.rs +++ b/repak/src/pak.rs @@ -7,7 +7,7 @@ use byteorder::{ReadBytesExt, WriteBytesExt, LE}; use std::collections::BTreeMap; use std::io::{self, Read, Seek, Write}; -#[derive(Debug, Default)] +#[derive(Debug)] pub struct PakBuilder { key: super::Key, oodle: super::Oodle, @@ -16,14 +16,21 @@ pub struct PakBuilder { impl PakBuilder { pub fn new() -> Self { - Self::default() + Self { + key: Default::default(), + #[cfg(not(feature = "oodle_implicit_dynamic"))] + oodle: super::Oodle::None, + #[cfg(feature = "oodle_implicit_dynamic")] + oodle: super::Oodle::Some(oodle_loader::decompress), + allowed_compression: Default::default(), + } } #[cfg(feature = "encryption")] pub fn key(mut self, key: aes::Aes256) -> Self { self.key = super::Key::Some(key); self } - #[cfg(feature = "oodle")] + #[cfg(feature = "oodle_explicit")] pub fn oodle(mut self, oodle_getter: super::oodle::OodleGetter) -> Self { self.oodle = super::Oodle::Some(oodle_getter); self diff --git a/repak_cli/Cargo.toml b/repak_cli/Cargo.toml index 792d723..18818bd 100644 --- a/repak_cli/Cargo.toml +++ b/repak_cli/Cargo.toml @@ -17,9 +17,12 @@ eula = false name = "repak" path = "src/main.rs" +[features] +default = ["oodle"] +oodle = ["repak/oodle_implicit_dynamic"] + [dependencies] -oodle_loader = { path = "../oodle_loader" } -repak = { path = "../repak", features = ["oodle"] } +repak = { path = "../repak" } aes = { workspace = true } base64 = { workspace = true } clap = { version = "4.1.4", features = ["derive"] } diff --git a/repak_cli/src/main.rs b/repak_cli/src/main.rs index 5e0b83e..d66767c 100644 --- a/repak_cli/src/main.rs +++ b/repak_cli/src/main.rs @@ -238,7 +238,7 @@ fn list(aes_key: Option, action: ActionList) -> Result<(), repak::E } fn hash_list(aes_key: Option, action: ActionHashList) -> Result<(), repak::Error> { - let mut builder = repak::PakBuilder::new().oodle(oodle_loader::decompress); + let mut builder = repak::PakBuilder::new(); if let Some(aes_key) = aes_key { builder = builder.key(aes_key); } @@ -311,7 +311,7 @@ impl Output { fn unpack(aes_key: Option, action: ActionUnpack) -> Result<(), repak::Error> { for input in &action.input { - let mut builder = repak::PakBuilder::new().oodle(oodle_loader::decompress); + let mut builder = repak::PakBuilder::new(); if let Some(aes_key) = aes_key.clone() { builder = builder.key(aes_key); } @@ -506,7 +506,7 @@ fn pack(args: ActionPack) -> Result<(), repak::Error> { fn get(aes_key: Option, args: ActionGet) -> Result<(), repak::Error> { let mut reader = BufReader::new(File::open(&args.input)?); - let mut builder = repak::PakBuilder::new().oodle(oodle_loader::decompress); + let mut builder = repak::PakBuilder::new(); if let Some(aes_key) = aes_key { builder = builder.key(aes_key); }