bring back samsung_old - by adding InputTarget system

This commit is contained in:
theubusu
2026-02-06 15:08:38 +01:00
parent 43128ca117
commit 9b059c67ab
32 changed files with 291 additions and 224 deletions
+9 -6
View File
@@ -1,5 +1,5 @@
use std::any::Any;
use crate::{AppContext, formats::Format};
use crate::{InputTarget, AppContext, formats::Format};
pub fn format() -> Format {
Format { name: "roku", detector_func: is_roku_file, extractor_func: extract_roku }
}
@@ -62,7 +62,9 @@ impl ImageHeader {
}
pub fn is_roku_file(app_ctx: &AppContext) -> Result<Option<Box<dyn Any>>, Box<dyn std::error::Error>> {
let header = common::read_file(app_ctx.file, 0, 32)?;
let file = match &app_ctx.input {InputTarget::File(f) => f, InputTarget::Directory(_) => return Ok(None)};
let header = common::read_file(&file, 0, 32)?;
let try_decrypt_header = decrypt_aes128_cbc_nopad(&header, &FILE_KEY, &FILE_IV)?;
if try_decrypt_header.starts_with(b"manifest\x00\x00\x00\x00\x00\x00\x00\x00") {
@@ -73,7 +75,8 @@ pub fn is_roku_file(app_ctx: &AppContext) -> Result<Option<Box<dyn Any>>, Box<dy
}
pub fn extract_roku(app_ctx: &AppContext, _ctx: Option<Box<dyn Any>>) -> Result<(), Box<dyn std::error::Error>> {
let mut file = app_ctx.file;
let mut file = match &app_ctx.input {InputTarget::File(f) => f, InputTarget::Directory(_) => return Err("Extractor expected file, not directory".into())};
let mut encrypted_data = Vec::new();
file.read_to_end(&mut encrypted_data)?;
@@ -116,7 +119,7 @@ pub fn extract_roku(app_ctx: &AppContext, _ctx: Option<Box<dyn Any>>) -> Result<
common::read_exact(&mut image_reader, image.size1 as usize - image.data_start_offset as usize)?
};
let folder_path = Path::new(app_ctx.output_dir).join(&path);
let folder_path = Path::new(&app_ctx.output_dir).join(&path);
let output_path = Path::new(&folder_path).join(format!("{}_{}.bin", i, image.type_string()));
fs::create_dir_all(&folder_path)?;
@@ -130,9 +133,9 @@ pub fn extract_roku(app_ctx: &AppContext, _ctx: Option<Box<dyn Any>>) -> Result<
} else {
println!("\nOther/Unknown file: {:?}", path);
let output_path = Path::new(app_ctx.output_dir).join(&path);
let output_path = Path::new(&app_ctx.output_dir).join(&path);
fs::create_dir_all(app_ctx.output_dir)?;
fs::create_dir_all(&app_ctx.output_dir)?;
let mut out_file = OpenOptions::new().write(true).create(true).open(output_path)?;
out_file.write_all(&contents)?;