Updated README.

This commit is contained in:
jonomango
2024-06-04 00:39:04 -07:00
parent 23d1471ed6
commit 07a14950bc
2 changed files with 41 additions and 1 deletions
+40 -1
View File
@@ -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)
```
+1
View File
@@ -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;
}