Python memory map API is kinda awkward

オープン
#7,359 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python

調査の方向性

Start with the Python MemoryMap API entry point and review how regions, iteration, and flags are currently exposed. Done means the API provides an object or equivalent access for regions, supports iterating all regions, and accepts the flag representation needed to copy flags between regions.

索引モデルが issue の本文から書いたものです。

説明

Component: Python API Effort: Low Impact: Low

Version and Platform (required):

  • Binary Ninja Version: 5.2.8236-dev Ultimate, d8af0ff0
  • OS: macos
  • OS Version: 26.0
  • CPU Architecture: arm64

Bug Description:
I used the MemoryMap API for the first time today and found it a bit awkward to use. I was writing a small script to extract the flags for each memory region into a dictionary so they could be used to copy the same flags to an existing database (to help recover from #7354).

I ended up with:

import functools
{ bv.memory_map.get_active_memory_region_at(s.start): 
    functools.reduce(lambda a, b: a | b, bv.memory_map.get_memory_region_flags(bv.memory_map.get_active_memory_region_at(s.start)), 0)
    for s in bv.segments
}

I had expected it to look more like:

{ region.name: region.flags for region in bv.memory_map }

Specifically:

  • There's no object to represent a memory region.

    Looking up a region by address gives you back a name. To query properties of that region you pass the name to functions on MemoryMap.

  • There's no way to iterate all memory regions.

    MemoryMap implements __len__, but not __getitem__ or __iter__.

  • get_memory_region_flags returns a set containing zero or more SegmentFlag, but set_memory_region_flags accepts a SegmentFlag.

    In order to take the flags from one memory region and apply them to another, you have to do something like reduce(lambda a, b: a | b, flags, 0) to convert from the set to SegmentFlag. set_memory_region_flags should probably accept both a set or SegmentFlag.

主要言語
C++
スター
1.3k
フォーク
298
平均マージ
5日 5時間
マージ済み PR(30日)
19

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Vector35/binaryninja-api のほかの issue

Vector35/binaryninja-api の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。