+ cleanup

This commit is contained in:
Pari Malam
2026-06-05 21:02:40 +08:00
parent 612ba74bc8
commit c1f5b7961d
65 changed files with 670 additions and 641 deletions
+5 -4
View File
@@ -5,6 +5,7 @@ use crate::AppContext;
use crate::utils::common;
use crate::utils::aes::decrypt_aes_ecb_auto;
use crate::formats;
use log::info;
pub struct EpkContext {
epk_version: u8,
@@ -55,21 +56,21 @@ fn match_with_pattern(data: &[u8], pattern: &str) -> bool {
pub fn extract_epk(app_ctx: &AppContext, ctx: Box<dyn Any>) -> Result<(), Box<dyn std::error::Error>> {
let mut file = app_ctx.file().ok_or("Extractor expected file")?;
let ctx = ctx.downcast::<EpkContext>().expect("Missing context");
let ctx = ctx.downcast::<EpkContext>().map_err(|_| "Invalid context type")?;
let versions = common::read_file(&file, 1712, 36)?;
let platform_version = common::string_from_bytes(&versions[4..20]);
let sdk_version = common::string_from_bytes(&versions[20..36]);
println!("Platform version: {}\nSDK version: {}", platform_version, sdk_version);
info!("Platform version: {}\nSDK version: {}", platform_version, sdk_version);
file.seek(std::io::SeekFrom::Start(0))?;
if ctx.epk_version == 2 {
println!("EPK2 detected!\n");
info!("EPK2 detected!\n");
formats::epk2::extract_epk2(app_ctx, Box::new(()))?;
} else if ctx.epk_version == 3 {
println!("EPK3 detected!\n");
info!("EPK3 detected!\n");
formats::epk3::extract_epk3(app_ctx, Box::new(()))?;
}