You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug Description: Offset pointers do not maintain their offsets when stored in a type library. If I define a pointer type that has an offset and then store that type in a type library, when the type is loaded from the type library, its offset is 0. Its not obvious if this is because the offset is not being written into the type library or not being loaded from the library.
Steps To Reproduce:
The following python code will define an offset pointer and store it in a type library and then import it from the type library. It prints the offset on the pointer when its first defined and then again once it has been imported from the type library. This can be copied, pasted and run in the integrated python terminal in the BN UI.
# Define a 256 byte struct and an offset pointer to that structparsed_types=bv.platform.parse_types_from_source("struct Foo { char Bar[0x100]; }; typedef void* __offset(Foo, 0x10) Baz;").types# Print the actual offset of the pointerprint(f"Original offset = {parsed_types['Baz'].offset}")
# Create the type librarytypelib=binaryninja.TypeLibrary.new(bv.arch, f"test")
typelib.add_platform(bv.platform)
# Add the struct definition to the type librarytypelib.add_named_type("Foo", parsed_types["Foo"])
# Add the offset pointer to the struct to the type librarytypelib.add_named_type("Baz", parsed_types["Baz"])
# Import the type library into BNbv.add_type_library(typelib)
# Import the types from the type librarybv.import_library_type("Foo")
bv.import_library_type("Baz")
# Print the offset of the offset pointerprint(f"Offset after type library = {bv.get_type_by_name('Baz').offset}")
Expected Behavior:
The offset for the pointer should be maintained across storing and loading from a type library.
The text was updated successfully, but these errors were encountered:
Version and Platform (required):
Bug Description:
Offset pointers do not maintain their offsets when stored in a type library. If I define a pointer type that has an offset and then store that type in a type library, when the type is loaded from the type library, its offset is
0
. Its not obvious if this is because the offset is not being written into the type library or not being loaded from the library.Steps To Reproduce:
The following python code will define an offset pointer and store it in a type library and then import it from the type library. It prints the offset on the pointer when its first defined and then again once it has been imported from the type library. This can be copied, pasted and run in the integrated python terminal in the BN UI.
Expected Behavior:
The offset for the pointer should be maintained across storing and loading from a type library.
The text was updated successfully, but these errors were encountered: