diff options
| author | DrChat <arkolbed@gmail.com> | 2018-02-10 21:58:44 -0600 |
|---|---|---|
| committer | DrChat <arkolbed@gmail.com> | 2018-02-10 21:58:44 -0600 |
| commit | d0460122f4a6d04b22455cccac9eadf8078d332f (patch) | |
| tree | 5ba9c7d78c6b9fc3cee0d189f644cecab4f95957 /src | |
| parent | 44e03762f661595985ef3979d1f651111849befb (diff) | |
[Core] BaseHeap::QueryBaseAndSize
Diffstat (limited to 'src')
| -rw-r--r-- | src/xenia/memory.cc | 14 | ||||
| -rw-r--r-- | src/xenia/memory.h | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/xenia/memory.cc b/src/xenia/memory.cc index 9636b38e7..2c30041eb 100644 --- a/src/xenia/memory.cc +++ b/src/xenia/memory.cc @@ -1147,6 +1147,20 @@ bool BaseHeap::QuerySize(uint32_t address, uint32_t* out_size) { return true; } +bool BaseHeap::QueryBaseAndSize(uint32_t* in_out_address, uint32_t* out_size) { + uint32_t page_number = (*in_out_address - heap_base_) / page_size_; + if (page_number > page_table_.size()) { + XELOGE("BaseHeap::QuerySize base page out of range"); + *out_size = 0; + return false; + } + auto global_lock = global_critical_region_.Acquire(); + auto page_entry = page_table_[page_number]; + *in_out_address = (page_entry.base_address * page_size_); + *out_size = (page_entry.region_page_count * page_size_); + return true; +} + bool BaseHeap::QueryProtect(uint32_t address, uint32_t* out_protect) { uint32_t page_number = (address - heap_base_) / page_size_; if (page_number > page_table_.size()) { diff --git a/src/xenia/memory.h b/src/xenia/memory.h index 64f8c57e9..4309ded05 100644 --- a/src/xenia/memory.h +++ b/src/xenia/memory.h @@ -144,6 +144,9 @@ class BaseHeap { // Queries the size of the region containing the given address. bool QuerySize(uint32_t address, uint32_t* out_size); + // Queries the base and size of a region containing the given address. + bool QueryBaseAndSize(uint32_t* in_out_address, uint32_t* out_size); + // Queries the current protection mode of the region containing the given // address. bool QueryProtect(uint32_t address, uint32_t* out_protect); |
