darfink / region-rs

A cross-platform virtual memory API written in Rust
https://darfink.github.io/region-rs/
MIT License
119 stars 23 forks source link

fix querying of regions with submaps on macos and add max_protection field #17

Closed fry closed 2 years ago

fry commented 3 years ago

submaps were being ignored, region::query returned the topmost page. switch to using mach_vm_region_recurse with a max depth

particularly, mach_vm_region returns the top level map, not that of a potential submap at a queried address, while mach_vm_region_recurse can return the details of the lowest map

the old functionality might be wanted at times, too, perhaps a macos specific query parameter makes sense?

additionally add a max_protection field to the Region structure

darfink commented 2 years ago

Thank you for your PR, and sorry for the delay. I believe submaps are more compatible with the cross-platform definition of a virtual memory page, so I view this as an improvement.

As for max_protection, I've never had a use case for it myself, but I'll revise it and add platform-specific integrations where applicable.