Assigning a value to `PointerBuilder.offset`has no effect
Version and Platform (required):
- Binary Ninja Version: 4.3.6541-dev (2a7e8df1)
- OS: macOS
- OS Version: 15.1.1
- CPU Architecture: M1
Bug Description:
The offset value of pointers cannot be set when building a pointer type. The idea is to create an offset pointer to a struct but the offset value does not change when using the PointerBuilder type via the Python API.
Steps To Reproduce:
The following python code creates a PointerBuilder for a pointer type that points to void (the type it points to doesn't matter AFAICT). It changes the offset to 0x10 and then prints the offset. This can be copied, pasted and run in the integrated python terminal in the BN UI.
foo = binaryninja.PointerBuilder.create(binaryninja.Type.void())
foo.offset = 0x10
print(f"Offset = {foo.offset}")
Expected Behavior: The offset value should change to the assigned value.
Additional Information:
Pointers with non-zero offsets can be created using any API that parses C source strings like bv.platform.parse_types_from_source.
There is clearly a documentation issue here. The offset is actually only used for StructureMember offsets. Not for generalized pointer offsets. What you want here is pointer_base_offset
>>> foo = binaryninja.PointerBuilder.create(Type.int(4))
>>> foo.pointer_base_offset
0
>>> foo.pointer_base_offset = 0x100
>>> foo.pointer_base_offset
256
Looks like there is no public API for creating pointer to structure member types. This only exists inside the core. This is only part of the interface and the other part is not exposed so this property is effectively useless. I'm going to change this issue title to actually track the creation of structure member pointers.