Vector35 / Vector35/binaryninja-api
RVA magic variable
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.3k
- Forks
- 298
- Avg merge
- 5d 5h
- Merged PRs (30d)
- 19
Description
What is the feature you'd like to have?
In the same manner as current_offset / here, it would be helpful to have current_rva / rva magic variable. There is already current_file_offset however it works only within the file-backed ranges, thus it won't work for __bss section or some other dynamic sections.
Is your feature request related to a problem?
not at all
Are any alternative solutions acceptable?
I've actually already implemented this, however i think it can be nice addition to the built-in features of BN
Additional Information:
from binaryninja import *
from typing import Any
def _get_rva(instance: PythonScriptingInstance) -> int | None:
if not instance.interpreter.active_view:
return None
binary_view = instance.interpreter.active_view
return binary_view.offset - binary_view.start
def _set_rva(instance: PythonScriptingInstance, old_value: int | None, new_value: Any):
if instance.interpreter.active_view is None:
return
if isinstance(new_value, str):
raise NotImplementedError
# new_value = instance.interpreter.active_view.parse_expression(
# new_value,
# instance.interpreter.active_addr
# )
if (vt := type(new_value)) is not int:
raise TypeError(f"RVA can't be assigned with value of type: {vt.__qualname__}")
if not instance.interpreter.active_view.file.navigate(
instance.interpreter.active_view.file.view,
instance.interpreter.active_view.start + new_value,
):
mainthread.execute_on_main_thread(
lambda: instance.interpreter.locals["current_ui_context"].navigateForBinaryView(
instance.interpreter.active_view,
instance.interpreter.active_view.start + new_value,
)
)
PythonScriptingProvider.register_magic_variable(
"rva",
get_value=_get_rva,
set_value=_set_rva,
depends_on=["current_ui_context"],
)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the PythonScriptingProvider.register_magic_variable path alongside the existing current_offset, here, and current_file_offset magic variables. Use the provided _get_rva and _set_rva behavior as the specification, ensuring RVA navigation also works for dynamic sections such as __bss; the feature is done when rva can be read and assigned consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- reverse-engineering
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100