vtil::instruction + operands
vtil::instruction is the IR node stored by each basic block. It carries opcode metadata, operands, original VIP, and stack state metadata.
Core fields
| Field | Type | Description |
|---|---|---|
base | instruction_desc* | Instruction descriptor (ADD, JMP, VEXIT, ...). |
operands | std::vector<operand> | Instruction operands in descriptor order. |
vip | vip_t | Source instruction address (if mapped). |
explicit_volatile | bool | Force volatility and restrict optimization. |
Inspecting instructions
for (auto& ins : *bb) {
if (!ins.is_valid()) continue;
vtil::logger::log("%s\n", ins.to_string().c_str());
for (auto&& [op, op_type] : ins.enum_operands()) {
(void)op_type;
if (op.is_immediate()) {
// Handle literal operands.
}
}
}Building instructions directly
auto t0 = bb->tmp(64);
vtil::instruction custom(&vtil::ins::add, t0, 0x10);
bb->push_back(custom);
bb->mov(t0, vtil::make_imm<uint32_t>(0xDEADBEEF));