Enum Error
pub enum Error {
Show 18 variants
InvalidOffset,
Malformed {
message: String,
file: &'static str,
line: u32,
},
OutOfBounds,
NotSupported,
Empty,
FileError(Error),
Error(String),
GoblinErr(Error),
TypeInsert(Token),
TypeNotFound(Token),
TypeError(String),
TypeMissingParent,
TypeNotPrimitive,
TypeNotConst(u8),
TypeConversionInvalid,
RecursionLimit(usize),
LockError,
GraphError(String),
}Expand description
dotscope Error type.
The main error type for all operations in this crate. Provides detailed error information for file parsing, metadata validation, and disassembly operations.
§Usage Examples
use dotscope::{Error, CilObject};
match CilObject::from_file(std::path::Path::new("tests/samples/crafted_2.exe")) {
Ok(assembly) => println!("Loaded successfully"),
Err(Error::NotSupported) => println!("File format not supported"),
Err(Error::Malformed { message, .. }) => println!("Malformed: {}", message),
Err(e) => println!("Error: {}", e),
}The generic Error type, which provides coverage for all errors this library can potentially return.
This enum covers all possible error conditions that can occur during .NET assembly parsing, metadata analysis, and disassembly operations. Each variant provides specific context about the failure mode to enable appropriate error handling.
§Error Categories
§File Parsing Errors
crate::Error::InvalidOffset- Invalid file offset during parsingcrate::Error::Malformed- Corrupted or invalid file structurecrate::Error::OutOfBounds- Attempted to read beyond file boundariescrate::Error::NotSupported- Unsupported file format or featurecrate::Error::Empty- Empty input provided
§I/O and External Errors
crate::Error::FileError- Filesystem I/O errorscrate::Error::GoblinErr- PE/ELF parsing errors from goblin crate
§Type System Errors
crate::Error::TypeInsert- Failed to register new type in type systemcrate::Error::TypeNotFound- Requested type not found in type systemcrate::Error::TypeError- General type system operation errorcrate::Error::TypeMissingParent- Type inheritance chain brokencrate::Error::TypeNotPrimitive- Expected primitive typecrate::Error::TypeNotConst- Cannot convert to constant typecrate::Error::TypeConversionInvalid- Invalid type conversion requested
§Analysis Errors
crate::Error::RecursionLimit- Maximum recursion depth exceededcrate::Error::LockError- Thread synchronization failurecrate::Error::GraphError- Dependency graph analysis error
Variants§
InvalidOffset
Encountered an invalid offset while parsing file structures.
This error occurs when the parser encounters an offset that is invalid for the current file context, such as negative offsets or offsets that would point outside the valid file structure.
Malformed
The file is damaged and could not be parsed.
This error indicates that the file structure is corrupted or doesn’t conform to the expected .NET PE format. The error includes the source location where the malformation was detected for debugging purposes.
§Fields
message- Detailed description of what was malformedfile- Source file where the error was detectedline- Source line where the error was detected
Fields
OutOfBounds
An out of bound access was attempted while parsing the file.
This error occurs when trying to read data beyond the end of the file or stream. It’s a safety check to prevent buffer overruns during parsing.
NotSupported
This file type is not supported.
Indicates that the input file is not a supported .NET PE executable, or uses features that are not yet implemented in this library.
Empty
Provided input was empty.
This error occurs when an empty file or buffer is provided where actual .NET assembly data was expected.
FileError(Error)
File I/O error.
Wraps standard I/O errors that can occur during file operations such as reading from disk, permission issues, or filesystem errors.
Error(String)
Generic error for miscellaneous failures.
Used for errors that don’t fit into other categories or for wrapping external library errors with additional context.
GoblinErr(Error)
Error from the goblin crate during PE/ELF parsing.
The goblin crate is used for low-level PE format parsing. This error wraps any failures from that parsing layer.
TypeInsert(Token)
Failed to insert new type into TypeSystem.
This error occurs when attempting to register a new type in the type system fails, typically due to conflicting metadata tokens or invalid type definitions.
The associated crate::metadata::token::Token identifies which type caused the failure.
TypeNotFound(Token)
Failed to find type in TypeSystem.
This error occurs when looking up a type by token that doesn’t exist in the loaded metadata or type system registry.
The associated crate::metadata::token::Token identifies which type was not found.
TypeError(String)
General error during TypeSystem usage.
Covers various type system operations that can fail, such as type resolution, inheritance chain analysis, or generic instantiation.
TypeMissingParent
The parent of the current type is missing.
This error occurs when analyzing type inheritance and the parent type referenced by a type definition cannot be found or resolved.
TypeNotPrimitive
This type can not be converted to a primitive.
Occurs when attempting to convert a complex type to a primitive type representation, but the type is not compatible with primitive type semantics.
TypeNotConst(u8)
This type can not be converted to a ConstType.
Indicates that a type cannot be represented as a compile-time constant value. The associated value indicates the type code that failed conversion.
TypeConversionInvalid
The requested type conversion is not possible.
This error occurs when attempting type conversions that are semantically invalid in the .NET type system.
RecursionLimit(usize)
Recursion limit reached.
To prevent stack overflow during recursive operations like type resolution or dependency analysis, a maximum recursion depth is enforced. This error indicates that limit was exceeded.
The associated value shows the recursion limit that was reached.
LockError
Failed to lock target.
This error occurs when thread synchronization fails, typically when trying to acquire a mutex or rwlock that is in an invalid state.
GraphError(String)
LoaderGraph error.
Errors related to dependency graph analysis and metadata loading order resolution. This can occur when circular dependencies are detected or when the dependency graph cannot be properly constructed.
Trait Implementations§
§impl Error for Error
impl Error for Error
§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more