mirror of
https://github.com/xavo95/repak.git
synced 2025-01-18 19:04:07 +00:00
Add implicit oodle feature
This commit is contained in:
parent
abda6dae9f
commit
96410d664a
5 changed files with 20 additions and 11 deletions
|
@ -104,8 +104,6 @@ fn fetch_oodle() -> Result<std::path::PathBuf> {
|
||||||
mod windows_oodle {
|
mod windows_oodle {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use anyhow::Context;
|
|
||||||
|
|
||||||
static DECOMPRESS: OnceLock<(OodleLZ_Decompress, libloading::Library)> = OnceLock::new();
|
static DECOMPRESS: OnceLock<(OodleLZ_Decompress, libloading::Library)> = OnceLock::new();
|
||||||
|
|
||||||
pub fn decompress_wrapper_windows(comp_buf: &[u8], raw_buf: &mut [u8]) -> i32 {
|
pub fn decompress_wrapper_windows(comp_buf: &[u8], raw_buf: &mut [u8]) -> i32 {
|
||||||
|
@ -126,7 +124,6 @@ mod windows_oodle {
|
||||||
mod linux_oodle {
|
mod linux_oodle {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use anyhow::Result;
|
|
||||||
use object::pe::{
|
use object::pe::{
|
||||||
ImageNtHeaders64, IMAGE_REL_BASED_DIR64, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ,
|
ImageNtHeaders64, IMAGE_REL_BASED_DIR64, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ,
|
||||||
IMAGE_SCN_MEM_WRITE,
|
IMAGE_SCN_MEM_WRITE,
|
||||||
|
|
|
@ -11,6 +11,8 @@ default = ["compression", "encryption"]
|
||||||
compression = ["dep:flate2", "dep:zstd"]
|
compression = ["dep:flate2", "dep:zstd"]
|
||||||
oodle = []
|
oodle = []
|
||||||
oodle_loader = ["dep:oodle_loader"]
|
oodle_loader = ["dep:oodle_loader"]
|
||||||
|
oodle_explicit = ["oodle"]
|
||||||
|
oodle_implicit_dynamic = ["dep:oodle_loader", "oodle"]
|
||||||
encryption = ["dep:aes"]
|
encryption = ["dep:aes"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
|
@ -7,7 +7,7 @@ use byteorder::{ReadBytesExt, WriteBytesExt, LE};
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::io::{self, Read, Seek, Write};
|
use std::io::{self, Read, Seek, Write};
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug)]
|
||||||
pub struct PakBuilder {
|
pub struct PakBuilder {
|
||||||
key: super::Key,
|
key: super::Key,
|
||||||
oodle: super::Oodle,
|
oodle: super::Oodle,
|
||||||
|
@ -16,14 +16,21 @@ pub struct PakBuilder {
|
||||||
|
|
||||||
impl PakBuilder {
|
impl PakBuilder {
|
||||||
pub fn new() -> Self {
|
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")]
|
#[cfg(feature = "encryption")]
|
||||||
pub fn key(mut self, key: aes::Aes256) -> Self {
|
pub fn key(mut self, key: aes::Aes256) -> Self {
|
||||||
self.key = super::Key::Some(key);
|
self.key = super::Key::Some(key);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
#[cfg(feature = "oodle")]
|
#[cfg(feature = "oodle_explicit")]
|
||||||
pub fn oodle(mut self, oodle_getter: super::oodle::OodleGetter) -> Self {
|
pub fn oodle(mut self, oodle_getter: super::oodle::OodleGetter) -> Self {
|
||||||
self.oodle = super::Oodle::Some(oodle_getter);
|
self.oodle = super::Oodle::Some(oodle_getter);
|
||||||
self
|
self
|
||||||
|
|
|
@ -17,9 +17,12 @@ eula = false
|
||||||
name = "repak"
|
name = "repak"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["oodle"]
|
||||||
|
oodle = ["repak/oodle_implicit_dynamic"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
oodle_loader = { path = "../oodle_loader" }
|
repak = { path = "../repak" }
|
||||||
repak = { path = "../repak", features = ["oodle"] }
|
|
||||||
aes = { workspace = true }
|
aes = { workspace = true }
|
||||||
base64 = { workspace = true }
|
base64 = { workspace = true }
|
||||||
clap = { version = "4.1.4", features = ["derive"] }
|
clap = { version = "4.1.4", features = ["derive"] }
|
||||||
|
|
|
@ -238,7 +238,7 @@ fn list(aes_key: Option<aes::Aes256>, action: ActionList) -> Result<(), repak::E
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hash_list(aes_key: Option<aes::Aes256>, action: ActionHashList) -> Result<(), repak::Error> {
|
fn hash_list(aes_key: Option<aes::Aes256>, 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 {
|
if let Some(aes_key) = aes_key {
|
||||||
builder = builder.key(aes_key);
|
builder = builder.key(aes_key);
|
||||||
}
|
}
|
||||||
|
@ -311,7 +311,7 @@ impl Output {
|
||||||
|
|
||||||
fn unpack(aes_key: Option<aes::Aes256>, action: ActionUnpack) -> Result<(), repak::Error> {
|
fn unpack(aes_key: Option<aes::Aes256>, action: ActionUnpack) -> Result<(), repak::Error> {
|
||||||
for input in &action.input {
|
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() {
|
if let Some(aes_key) = aes_key.clone() {
|
||||||
builder = builder.key(aes_key);
|
builder = builder.key(aes_key);
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ fn pack(args: ActionPack) -> Result<(), repak::Error> {
|
||||||
|
|
||||||
fn get(aes_key: Option<aes::Aes256>, args: ActionGet) -> Result<(), repak::Error> {
|
fn get(aes_key: Option<aes::Aes256>, args: ActionGet) -> Result<(), repak::Error> {
|
||||||
let mut reader = BufReader::new(File::open(&args.input)?);
|
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 {
|
if let Some(aes_key) = aes_key {
|
||||||
builder = builder.key(aes_key);
|
builder = builder.key(aes_key);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue