Skip to main content

Crate imping_ir

Crate imping_ir 

Source
Expand description

Intermediate representation (IR) types and JSON Schema for the imping toolkit.

One IR file describes one build of a target. Addresses are relative to each module’s image base and written as 0x hex strings; types are referenced by TypeId into the module’s type table.

§Examples

use imping_ir::{Architecture, Ir};

let json = r#"{
  "format_version": { "major": 1, "minor": 2 },
  "modules": [ { "name": "target.exe", "architecture": "x64",
    "image_base": "0x140000000", "timestamp": "0x64b8f2a1",
    "image_size": "0xa2b000" } ]
}"#;

let ir = Ir::from_json_str(json)?;
assert_eq!(ir.modules[0].architecture, Architecture::X64);
assert_eq!(ir.modules[0].image_base, 0x1_4000_0000);

let written = ir.to_json_pretty()?;
assert_eq!(Ir::from_json_str(&written)?, ir);

Structs§

BitField
The bit placement of a bitfield Field within its backing storage.
EnumVariant
A named constant of a TypeKind::Enum.
Field
A member of a TypeKind::Struct or TypeKind::Union.
FormatVersion
The format version of an IR file.
Function
A function in a module.
Global
A global variable in a module.
Ir
A complete IR file: a format version and the modules of one target build.
Module
One module (image) of a target build: an executable or a shared library.
ModuleHash
A content hash of a module file.
Parameter
A function parameter.
Pattern
A byte pattern that finds a Function by its code instead of its address.
Rtti
Which vtable this is, by the class’s MSVC run-time type information.
TypeDef
A named type definition in a module’s type table.
TypeId
A stable id for a type in its module’s type table.
ValidationErrors
The problems found by Ir::validate; never empty.
Vtable
A virtual function table in a module.
VtableEntry
One slot of a Vtable.

Enums§

Architecture
A module’s instruction-set architecture.
CallingConvention
A function’s calling convention.
Error
An error reading or writing an IR file.
HashAlgorithm
A hash algorithm used by ModuleHash.
Primitive
A built-in primitive type.
Storage
Where a Parameter is passed.
TypeKind
A type’s kind and the data specific to it.
ValidationError
A single problem found by Ir::validate.

Constants§

CURRENT_MINOR
The minor format version this crate writes.
SUPPORTED_MAJOR
The major format version this crate reads and writes.

Functions§

json_schema
Returns the JSON Schema of the IR file format.

Type Aliases§

Result
A Result with this crate’s Error.