Python memory map API is kinda awkward

Đang mở
#7,359 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
api, reverse-engineering

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C++
Star
1.3k
Fork
298
Merge trung bình
5 ngày 5 giờ
Pull request đã merge (30 ngày)
19

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Vector35/binaryninja-api

Tất cả issue của Vector35/binaryninja-api

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.