Crate aegis_vm

Crate aegis_vm 

Source
Expand description

§RustAegis VM

Custom Virtual Machine for code virtualization and protection.

This VM converts critical Rust code to custom bytecode that is interpreted at runtime, making static analysis and patching extremely difficult.

§Features

  • Hybrid Architecture: Stack + Register based for flexibility
  • 60+ Opcodes: Complete instruction set for complex logic
  • Anti-Analysis: Opaque predicates, timing checks, integrity verification
  • Cross-Platform: Works on iOS and Android
  • OLLVM Compatible: Uses fastrand instead of rand crate

§Example

use aegis_vm::{execute, build_config::opcodes::{stack, arithmetic, exec}};

// Simple bytecode: 40 + 2 = 42
let bytecode = [
    stack::PUSH_IMM8, 40,
    stack::PUSH_IMM8, 2,
    arithmetic::ADD,
    exec::HALT,
];

let result = execute(&bytecode, &[]).unwrap();
assert_eq!(result, 42);

Re-exports§

pub use error::VmError;
pub use error::VmResult;
pub use state::VmState;
pub use engine::execute;
pub use engine::execute_with_state;
pub use engine::execute_with_natives;
pub use engine::execute_with_native_table;
pub use engine::run;
pub use engine::run_with_natives;
pub use engine::run_with_native_table;
pub use bytecode::BytecodeHeader;
pub use bytecode::BytecodePackage;
pub use bytecode::ProtectionLevel;
pub use bytecode::BuildInfo;
pub use crypto::CryptoContext;
pub use native::NativeRegistry;
pub use native::NativeRegistryBuilder;
pub use native::NativeFunction;
pub use native::standard_ids;
pub use integrity::IntegrityTable;
pub use integrity::IntegrityError;
pub use integrity::compute_hash;
pub use integrity::verify_hash;
pub use smc::SmcConfig;
pub use smc::execute_smc;
pub use smc::execute_smc_with_natives;
pub use smc::encrypt_bytecode;
pub use smc::decrypt_bytecode;

Modules§

build_config
Build-time generated configuration
bytecode
Encrypted bytecode format with header
crypto
Cryptographic operations for bytecode encryption
engine
VM Execution Engine
error
VM Error types
handlers
VM Opcode Handlers
integrity
Region-based Integrity Checking
native
Native Function Registry
opcodes
Opcode definitions for the VM
smc
Self-Modifying Code (SMC) Engine
state
VM State management
string_obfuscation
Runtime string decryption for obfuscated strings
whitebox

Macros§

aegis_str

Structs§

StdVec
A contiguous growable array type, written as Vec<T>, short for ‘vector’.

Constants§

VERSION
VM version

Functions§

fnv1a_hash
FNV-1a hash for bytecode integrity (randomized constants per build)
fnv1a_hash32
FNV-1a 32-bit hash (for smaller checksums, randomized constants per build)

Type Aliases§

SpinOnce
A primitive that provides lazy one-time initialization. See once::Once for documentation.

Attribute Macros§

obfuscate_strings
String obfuscation attribute macro
vm_protect
VM protection attribute macro