Skip to main content

iptr_edge_analyzer/
error.rs

1//! This module contains definition of errors made when analyzing with [`EdgeAnalyzer`][crate::EdgeAnalyzer].
2
3use perfect_derive::perfect_derive;
4use thiserror::Error;
5
6use crate::{HandleControlFlow, ReadMemory};
7
8/// Error for edge analysis
9#[derive(Error)]
10#[perfect_derive(Debug)]
11#[non_exhaustive]
12pub enum AnalyzerError<H: HandleControlFlow, R: ReadMemory> {
13    /// Control flow handler error
14    #[error("Control flow handler error")]
15    ControlFlowHandler(#[source] H::Error),
16    /// Memory reader error
17    #[error("Memory reader error")]
18    MemoryReader(#[source] R::Error),
19    /// Instructions non-decodable by iced-x86
20    #[error("Invalid instruction")]
21    InvalidInstruction,
22    /// Corrupted callstack, will affect the behavior
23    /// of return compression
24    #[error("The self-maintained callstack is corrupted")]
25    CorruptedCallstack,
26    /// Semantic-level invalid packet
27    #[error("Invalid packet")]
28    InvalidPacket,
29    /// Return compression is not supported since we need to maintain
30    /// the callstack in the cache, which is very hard to design a efficient way
31    #[error("Return compression is not supported")]
32    UnsupportedReturnCompression,
33    /// TNT buffer exceeded.
34    ///
35    /// This is unexpected, and may occur when we re-inject TNT buffers
36    /// into manager when a deferred TIP is detected
37    #[error("Unexpected! TNT buffer exceeded!")]
38    ExceededTntBuffer,
39    /// Unexpected edge analyzer error
40    #[error("Unexpected edge analyzer error")]
41    Unexpected,
42}
43
44pub(crate) type AnalyzerResult<T, H, R> = core::result::Result<T, AnalyzerError<H, R>>;