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.
Ir: the whole file, read withIr::from_json_str, written withIr::to_json_prettyand checked withIr::validate.FormatVersion: readers reject other major versions.Module: one image’s identity,TypeDefs,Functions,Globals andVtables.json_schema(): the file’s JSON Schema, with theschemafeature.
§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
Fieldwithin its backing storage. - Enum
Variant - A named constant of a
TypeKind::Enum. - Field
- A member of a
TypeKind::StructorTypeKind::Union. - Format
Version - 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.
- Module
Hash - A content hash of a module file.
- Parameter
- A function parameter.
- Pattern
- A byte pattern that finds a
Functionby 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.
- Validation
Errors - The problems found by
Ir::validate; never empty. - Vtable
- A virtual function table in a module.
- Vtable
Entry - One slot of a
Vtable.
Enums§
- Architecture
- A module’s instruction-set architecture.
- Calling
Convention - A function’s calling convention.
- Error
- An error reading or writing an IR file.
- Hash
Algorithm - A hash algorithm used by
ModuleHash. - Primitive
- A built-in primitive type.
- Storage
- Where a
Parameteris passed. - Type
Kind - A type’s kind and the data specific to it.
- Validation
Error - 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.