Skip to main content
The AddressValue object represents a memory address in the binary. It is used throughout VulHunt rules to reference specific locations in the binary, such as function addresses, call site addresses, and instruction addresses. AddressValue supports arithmetic (+, -), comparison (==, <, <=), and conversion to string and BitVec.

Functions

FunctionDescriptionParametersReturn Type
newConstructs a new AddressValue from an integer, string, BitVec, or another AddressValueinteger, string, BitVec or AddressValueAddressValue
from_integerCreates an AddressValue from an unsigned 64-bit integernumberAddressValue
from_stringParses an AddressValue from a hexadecimal stringstringAddressValue
from_bitvecConverts a BitVec to an AddressValueBitVecAddressValue

Methods

MethodDescriptionParametersReturn Type
to_bitvecConverts the address to a BitVec with specified bit sizenumberBitVec

Reference

new

Constructs a new AddressValue from an integer, string, BitVec, or another AddressValue.

from_integer

Creates an AddressValue from an unsigned 64-bit integer.

from_string

Parses an AddressValue from a hexadecimal string.

from_bitvec

Converts a BitVec to an AddressValue.

to_bitvec

Converts the address to a BitVec with specified bit size.

Example

-- Constructing addresses
local addr1 = AddressValue.new(0x401000)
local addr2 = AddressValue.from_string("0x401000")
local addr3 = AddressValue.from_integer(0x401000)

-- Arithmetic
local next_addr = addr1 + 0x10
local prev_addr = addr1 - 0x10

-- Comparison
if addr1 == addr2 then
  print("Addresses are equal")
end
if addr1 < next_addr then
  print("addr1 comes before next_addr")
end

-- Convert to BitVec for bitwise operations
local bv = addr1:to_bitvec(64)

-- Use with project:decompile
local decompiled = project:decompile(AddressValue.new(0x401000))