-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdecompile_binary.rs
More file actions
39 lines (31 loc) · 1.19 KB
/
decompile_binary.rs
File metadata and controls
39 lines (31 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use rust_file_explorer::decompiler;
use std::fs;
use std::path::Path;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let binary_path = std::env::args()
.nth(1)
.unwrap_or_else(|| "notepad.exe".to_string());
if !Path::new(&binary_path).exists() {
eprintln!("Error: Binary not found: {}", binary_path);
return Err("File not found".into());
}
println!("Loading {}...", binary_path);
let binary = fs::read(&binary_path)?;
println!("Decompiling...");
let result = decompiler::decompile(&binary)?;
println!("\n{:─^60}", " DECOMPILATION RESULTS ");
println!("Functions detected: {}", result.functions.len());
println!("API calls found: {}", result.api_calls.len());
println!("Image base: 0x{:X}", result.image_base);
println!("Entry point: 0x{:X}\n", result.entry_point);
println!("{:─^60}", " PSEUDO-CODE ");
println!("{}\n", result.pseudocode);
println!("{:─^60}", " ASSEMBLY ");
for line in result.assembly.lines().take(50) {
println!("{}", line);
}
if result.assembly.lines().count() > 50 {
println!("... ({} more lines)", result.assembly.lines().count() - 50);
}
Ok(())
}