From 3289b2a3aad71c4b157e0211a82dcffa94a4337c Mon Sep 17 00:00:00 2001 From: Luke Street Date: Mon, 10 Jun 2024 00:40:37 -0600 Subject: [PATCH] Ignore invalid instructions This could be a bad idea, but it's unclear how to properly handle these cases. Resolves #55 --- src/analysis/slices.rs | 9 +++++++-- src/analysis/tracker.rs | 15 +++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/analysis/slices.rs b/src/analysis/slices.rs index ce121fa..685ce90 100644 --- a/src/analysis/slices.rs +++ b/src/analysis/slices.rs @@ -266,8 +266,13 @@ impl FunctionSlices { } } StepResult::Illegal => { - log::debug!("Illegal instruction @ {:#010X}", ins_addr); - Ok(ExecCbResult::End(false)) + if ins.code == 0 { + log::debug!("Hit zeroed padding @ {:#010X}", ins_addr); + Ok(ExecCbResult::End(false)) + } else { + log::debug!("Illegal instruction @ {:#010X}", ins_addr); + Ok(ExecCbResult::Continue) + } } StepResult::Jump(target) => match target { BranchTarget::Unknown diff --git a/src/analysis/tracker.rs b/src/analysis/tracker.rs index 24bb321..af4cc5f 100644 --- a/src/analysis/tracker.rs +++ b/src/analysis/tracker.rs @@ -348,12 +348,15 @@ impl Tracker { } Ok(ExecCbResult::Continue) } - StepResult::Illegal => bail!( - "Illegal instruction hit @ {:#010X} (function {:#010X}-{:#010X})", - ins_addr, - function_start, - function_end - ), + StepResult::Illegal => { + log::debug!( + "Illegal instruction hit @ {:#010X} (function {:#010X}-{:#010X})", + ins_addr, + function_start, + function_end + ); + Ok(ExecCbResult::Continue) + } StepResult::Jump(target) => match target { BranchTarget::Unknown | BranchTarget::Return