Retrieving the current process's Directory Table Base (DTB/CR3)
Loading necessary Kernel Module Addresses
Getting the Process ID (PID) of a target process
Retrieving the base address of the target process
Reading from and writing to process memory
Important: Before calling ScyHV::init(), you must define SECRET_KEY. Failure to do so may result in initialization errors and can lead to a BSOD. Set the key first, then initialize Styx!
Code example:
#include <iostream>
#include <iomanip>
#include <Windows.h>
#include "Styx.h"
int main()
{
//Make sure you set your SECRET KEY first!
Styx::set_secret_key("INSERT-SECRET-KEY-HERE");
// Initialize the hyper-v communication
//if it doesnt is called you will get instant BSOD
if (!Styx::init()) {
std::cout << "Initialization failed. Exiting." << std::endl;
return 1;
}
// Get our own Directory Table Base (DTB/CR3)
Styx::guest_phys_t my_cr3 = Styx::my_dtb();
if (my_cr3 == 0) {
std::cout << "Failed obtaining My DTB!\n";
return 1;
}
std::cout << "[+] Retrieved My CR3: 0x" << std::hex << my_cr3 << std::endl;
// Load necessary Kernel Module Addresses
bool kmodule_init = Styx::get_kmodule_address();
if (!kmodule_init) {
std::cout << "[-] Failed to load Kernel Module Addresses!\n";
return 1;
}
std::cout << "[+] All necessary Kernel Module Addresses retrieved!\n";
// Get target process ID (PID)
const wchar_t* target_process = L"explorer.exe";
std::uint32_t pid = Styx::get_pid(target_process);
if (pid == 0) {
std::cout << "Failed obtaining Process ID!\n";
return 1;
}
std::cout << "[+] Retrieved Target Process ID: " << pid << std::endl;
// Get process module Base address
std::uint32_t image_base = Styx::get_proc_base(pid);
if (image_base == 0) {
std::cout << "Failed to get Process Base Address!\n";
return 1;
}
std::cout << "[+] Retrieved Target Base Address: 0x" << std::hex << image_base << std::endl;
// Example of reading memory (assuming we have a valid address to read from)
Styx::guest_virt_t address_to_read = image_base + 0x1000; // Example offset
int value = ScyHV::read<int>(address_to_read);
std::cout << "[+] Read value at 0x" << std::hex << address_to_read << ": " << std::dec << value << std::endl;
// Example of writing memory
int new_value = 42;
Styx::write<int>(address_to_read, new_value);
std::cout << "[+] Wrote value " << new_value << " to address 0x" << std::hex << address_to_read << std::endl;
std::cout << "Example completed successfully!\n";
return 0;
}
For more detailed information on each function, please refer to the API Documentation section.