use std::collections::HashMap;
use crate::{constants, definitions::Definition};
use serde::{Deserialize, Serialize};
#[derive(Clone, Serialize, Deserialize)]
pub struct Config {
pub filename: String, pub trace_mem: bool, pub trace_calls: bool, pub trace_regs: bool, pub trace_reg: bool, pub trace_filename: Option<String>,
pub trace_start: u64,
pub trace_string: bool,
pub trace_flags: bool,
pub reg_names: Vec<String>, pub verbose: u32, pub console: bool, pub console_num: u64, pub loops: bool, pub nocolors: bool, pub string_addr: u64,
pub inspect: bool,
pub inspect_seq: String,
pub endpoint: bool,
pub maps_folder: String,
pub console2: bool,
pub console_addr: u64,
pub entry_point: u64,
pub exit_position: u64,
pub dump_on_exit: bool,
pub dump_filename: Option<String>,
pub code_base_addr: u64,
pub is_64bits: bool, pub stack_trace: bool,
pub test_mode: bool,
pub console_enabled: bool,
pub skip_unimplemented: bool,
pub stack_addr: u64,
pub arguments: String,
pub enable_threading: bool, pub verbose_at: Option<u64>,
pub command: Option<String>,
pub definitions: HashMap<u64, Definition>,
pub entropy: bool,
pub shellcode: bool,
pub emulate_winapi: bool,
pub max_alloc_size: u64,
pub module_name: String,
pub exe_name: String,
pub user_name: String,
pub host_name: String,
pub temp_path: String,
pub cwd_path: String,
pub windows_directory: String,
pub system_directory: String,
pub max_instructions: Option<u64>, pub timeout_secs: Option<f64>,
pub max_faults: Option<u32>,
pub short_circuit_sleep: bool,
pub heap_alloc_min_size: u64,
pub heap_free_soft: bool,
pub allow_empty_code_blocks: bool,
}
impl Default for Config {
fn default() -> Self {
Self::new()
}
}
impl Config {
pub fn new() -> Config {
Config {
filename: String::new(),
trace_mem: false,
trace_calls: false,
trace_regs: false,
trace_reg: false,
trace_filename: None,
trace_start: 0,
trace_string: false,
trace_flags: false,
reg_names: Vec::new(),
verbose: 0,
console: false,
console_num: 0,
loops: false,
nocolors: false,
string_addr: 0,
inspect: false,
inspect_seq: "".to_string(),
endpoint: false,
maps_folder: "".to_string(),
console2: false,
console_addr: 0,
entry_point: constants::CFG_DEFAULT_BASE,
exit_position: 0,
dump_on_exit: false, dump_filename: Some("dumps/emu.bin".to_string()), code_base_addr: constants::CFG_DEFAULT_BASE,
is_64bits: false,
stack_trace: false,
test_mode: false,
console_enabled: false,
skip_unimplemented: false,
stack_addr: 0,
arguments: "".to_string(),
enable_threading: false, verbose_at: None,
command: None,
definitions: HashMap::new(),
entropy: false,
shellcode: false,
emulate_winapi: false,
max_alloc_size: 0xffffff, module_name: constants::MODULE_NAME.to_string(),
exe_name: constants::EXE_NAME.to_string(),
user_name: constants::USER_NAME.to_string(),
host_name: constants::HOST_NAME.to_string(),
temp_path: constants::TEMP_PATH.to_string(),
cwd_path: constants::CWD_PATH.to_string(),
windows_directory: constants::WINDOWS_DIRECTORY.to_string(),
system_directory: constants::SYSTEM_DIRECTORY.to_string(),
max_instructions: None,
timeout_secs: None,
max_faults: None,
short_circuit_sleep: false,
heap_alloc_min_size: 0,
heap_free_soft: false,
allow_empty_code_blocks: false,
}
}
pub fn get_maps_folder(&self, filename: &str) -> String {
let mut path = self.maps_folder.clone();
if !path.ends_with('/') {
path.push('/');
}
path.push_str(&filename);
path
}
}