Error Handling & Global Variables
Error Handling
The Styx API uses the vmxroot_error_t
enumeration for error codes. Here are some common error codes defined as macros:
STY_SUCCESS
STY_PML4E_NOT_PRESENT
STY_PDPTE_NOT_PRESENT
STY_PDE_NOT_PRESENT
STY_PTE_NOT_PRESENT
STY_TRANSLATE_FAILURE
STY_INVALID_SELF_REF_PML4E
STY_INVALID_MAPPING_PML4E
STY_INVALID_HOST_VIRTUAL
STY_INVALID_GUEST_PHYSICAL
STY_INVALID_GUEST_VIRTUAL
STY_PAGE_TABLE_INIT_FAILED
These error codes can be used to handle specific error conditions in your code. For example:
ScyHV::vmxroot_error_t result = ScyHV::some_function();
if (result != SCY_SUCCESS) {
switch(result) {
case SCY_PML4E_NOT_PRESENT:
std::cerr << "PML4E not present" << std::endl;
break;
case SCY_TRANSLATE_FAILURE:
std::cerr << "Address translation failed" << std::endl;
break;
// Handle other error codes...
default:
std::cerr << "Unknown error occurred" << std::endl;
}
}
Global Variables
pmem_ranges
A map of physical memory ranges.
Type: std::map<std::uintptr_t, std::uintptr_t>
Description: This map contains information about the physical memory ranges available in the system. The key represents the start address of a range, and the value represents the size of the range.
Example:
for (const auto& range : Styx::pmem_ranges) {
std::cout << "Range start: 0x" << std::hex << range.first
<< ", size: 0x" << range.second << std::endl;
}
This global variable can be useful for:
Iterating through available physical memory ranges
Checking if a physical address falls within a valid range
Determining the total amount of physical memory available
Last updated