binaryninja-api icon indicating copy to clipboard operation
binaryninja-api copied to clipboard

Offset types

Open fabianfreyer opened this issue 3 years ago • 2 comments

I'm working with a binary that has many self-relative offsets, e.g.

0001000    int64_t data_1000 = 0x234 // references 0x1234

I'd like to be able to set the type of this to be an offset and have it rendered as it would a pointer, i.e.

0001000    offset data_1000 = data_1234

An additional improvement over this would be to enable arbitrary base offsets, i.e. have pointers be offset to a constant, or to a binary base relative offset.

fabianfreyer avatar Dec 16 '21 22:12 fabianfreyer

So this is a feature I'd love. There is a way to implement this currently using a DataRenderer The problem in implementing this would be that you'd have to have types which are relocation-aware but that seems tricky :)

plafosse avatar Feb 09 '22 20:02 plafosse

This came up again, so to offer an example, you can see how the Objective-C workflow renders relative pointers using a custom DataRenderer here: https://github.com/Vector35/workflow_objc/blob/a0ab6b1859a2c9046751e50e0ebd70a843bdb5e7/DataRenderers.cpp#L143

jonpalmisc avatar Jan 01 '23 11:01 jonpalmisc

These are now implemented as of >= 4.1.5339-dev. You can create them using void* __based(start) and various other forms as documented in the new type annotations docs.

CouleeApps avatar May 23 '24 22:05 CouleeApps

and various other forms as documented in the new type annotations docs.

@CouleeApps Are those docs online? And if so, can we link to them from here for continuity?

0xdevalias avatar May 24 '24 01:05 0xdevalias

Sure. See https://dev-docs.binary.ninja/guide/types/attributes.html#based-pointers

CouleeApps avatar May 24 '24 01:05 CouleeApps

@CouleeApps Thanks :)

0xdevalias avatar May 24 '24 01:05 0xdevalias