mirror of
https://github.com/jonomango/superfetch
synced 2026-08-09 12:43:33 +00:00
Updated README.
This commit is contained in:
@@ -1,2 +1,41 @@
|
||||
# superfetch
|
||||
Translate virtual addresses to physical addresses from usermode.
|
||||
Simple library for translating virtual addresses to physical addresses from usermode.
|
||||
|
||||
## Example usage
|
||||
|
||||
```cpp
|
||||
#include <superfetch/superfetch.h>
|
||||
|
||||
int main() {
|
||||
auto const mm = spf::init_memory_map();
|
||||
if (!mm) {
|
||||
// Do something with mm.error()
|
||||
}
|
||||
|
||||
// Any kernel virtual address.
|
||||
void const* const virt = ...;
|
||||
|
||||
std::uint64_t const phys = spf::translate(mm.value(), virt);
|
||||
if (!phys) {
|
||||
// Do something...
|
||||
}
|
||||
|
||||
std::printf("%p -> %zX\n", virt, phys);
|
||||
}
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
To use `superfetch`, simply add the `include` directory to your project and include
|
||||
`superfetch/superfetch.h`.
|
||||
|
||||
### CMake
|
||||
|
||||
If you are using [CMake](https://cmake.org/), add this repository as a
|
||||
subdirectory and link to the `superfetch` target library.
|
||||
|
||||
```cmake
|
||||
add_subdirectory(path/to/superfetch/repo/dir)
|
||||
target_link_libraries(my_project_target superfetch)
|
||||
```
|
||||
|
||||
|
||||
@@ -149,6 +149,7 @@ inline std::expected<memory_map, init_error> init_memory_map() {
|
||||
return std::unexpected(init_error::query_pfn);
|
||||
|
||||
for (std::uint64_t i = 0; i < page_count; ++i) {
|
||||
// Cache the translation for this page.
|
||||
if (void const* const virt = request->PageData[i].u2.VirtualAddress)
|
||||
mm.translations[virt] = (base_pfn + i) << 12;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user