FunctionContext object provides access to information and utilities related to a specific function in the binary.
It is used in VulHunt rules to inspect function properties, search for patterns, and analyze function calls.
Fields
Methods
Reference
name
The name field contains the name of the function.address
The address field contains the address of the function in the binary.total_bytes
The total_bytes field returns the function length in bytes, calculated as the sum of the sizes of all its code blocks.calls
The calls method returns a table of addresses where the current function calls the specified function(s). Accepts a string (function name),AddressValue (function address), or CallsToQuery for pattern matching.
Returns an empty table when the specified function is not found.
has_call
The has_call method returns true if the function contains a call to the specified function(s). Accepts a string (function name),AddressValue (function address), or CallsToQuery for pattern matching.
has_reference
The has_reference method returns true if the function contains a cross-reference to the specified address. Accepts anAddressValue.
named
The named method returns true if the function name matches the provided name.find
The find method searches for a pattern in the function’s code and returns the address of the match, if found.matches
The matches method returns true if the function’s code matches the given pattern.blocks
The blocks method returns every basic block in the function asIRTerm objects. Each item can be traversed to inspect instructions, operands, or metadata.
prototype
The prototype method returns the inferred prototype as anIRTerm for the function entry if one is available, otherwise nil.
is_reachable
The is_reachable method takes twoAddressValue objects and reports whether execution can flow from the first address to the second inside the current function.
dominates
The dominates method returns true when the basic block that contains the firstAddressValue dominates the block that contains the second address.