Skip to content

Pointer Interpretation

Olexa Bilaniuk requested to merge obilaniu/okteta:pointer into 0.26

This PR introduces the ability to customize the interpretation of pointers beyond strict byte offsets.

  • The pointer() constructor can receive an optional 3rd and 4th arguments: A scale and an interpreter function respectively.
  • A pointer has new .scale and .interpretFunc members in Javascript.
  • If scale is set to an integer N, the pointer is interpreted as a multiple of N bytes, rather than the default 1.
  • If interpreterFunc is set to a function, the function is invoked to interpret the pointer, and must return an absolute byte offset. The scaling factor is not applied automatically, but is available inside the interpreter function as this.scale.

Custom pointer interpretations such as pointer(uint64(), uint8(), 512) are particularly useful when dealing with filesystems, which sometimes specify offsets in units of 512- or 4096-byte sectors, and stuff the pointers with other bits.

Edited by Olexa Bilaniuk

Merge request reports

Loading