Skip to main content

Crate fNET

Crate fNET 

Source
Expand description

An iced-style decoder for raw .NET CIL method code, including Mono extensions.

The default build uses only core: decoding, prefix grouping, switch target iteration, and formatting require no allocator. Instructions borrow their original bytes, so an arbitrarily large switch remains a Copy value.

use fNET::{BufSink, Code, Decoder, DecoderOptions, FmtFormatter, Formatter};

let bytes = [0x1f, 42, 0x2b, 0xfc, 0x2a];
let mut decoder = Decoder::new(&bytes, 0x1000, DecoderOptions::NONE);
let instruction = decoder.decode();
assert_eq!(instruction.code(), Code::LdcI4S);
assert_eq!(instruction.immediate_i32(), Some(42));
let branch = decoder.decode();
assert_eq!(branch.near_branch_target(), Some(0x1000));
let mut buffer = [0; 64];
let mut text = BufSink::new(&mut buffer);
FmtFormatter::new().format(&branch, &mut text).unwrap();
assert_eq!(text.as_str(), "br.s IL_1000");

This crate disassembles opcode streams. It does not parse PE files, resolve metadata signatures, or verify stack types. Structural prefix validation is available separately from permissive byte decoding.

Re-exports§

pub use decoder::Decoder;
pub use decoder::DecoderOptions;
pub use decoder::FeatureSet;
pub use decoder::MonoDialect;
pub use decoder::PrefixedIter;
pub use error::DecodeError;
pub use extensions::ExtensionError;
pub use extensions::ExtensionTable;
pub use format::format_to_string;
pub use format::BufSink;
pub use format::FmtFormatter;
pub use format::Formatter;
pub use format::FormatterOptions;
pub use format::SymbolResolver;
pub use instruction::Instruction;
pub use instruction::PrefixedInstruction;
pub use op_code::FlowControl;
pub use op_code::OpCodeInfo;
pub use op_code::OpCodeKind;
pub use op_code::OperandKind;
pub use op_code::StackBehaviourPop;
pub use op_code::StackBehaviourPush;
pub use operand::MetadataToken;
pub use operand::Operand;
pub use operand::SwitchTargets;
pub use operand::TokenKind;
pub use prefix::PrefixMetadataResolver;
pub use prefix::PrefixValidationError;
pub use prefix::PrefixValidationOptions;

Modules§

decoder
error
extensions
format
instruction
op_code
operand
prefix
Optional structural prefix checks (ECMA-335 III.2). These checks do not perform signature, stack, exception-region, or branch-entry verification.

Enums§

Code
Exact operation identity. Historical-only identities use internal E100 IDs.
Mnemonic
Canonical operation, with macro and short forms normalized.

Constants§

ALL_CODES
All operation identities across dialects, including reserved marker descriptors.
EARLY_MONO_OPCODES
Audited historical Mono map/overrides; select the corresponding decoder dialect.
JULY2002_MONO_OPCODES
Audited historical Mono map/overrides; select the corresponding decoder dialect.
LEGACY_MONO_OVERRIDES
Audited historical Mono map/overrides; select the corresponding decoder dialect.
MAY2004_MONO_OPCODES
Audited historical Mono map/overrides; select the corresponding decoder dialect.
OPCODE_COUNT