#include "hyper_ctx.hpp" namespace hyperspace { hyper_ctx::hyper_ctx(ptm::ptm_ctx* target_ctx) : target_ctx(target_ctx), v_ctx(target_ctx->v_ctx) { orig_context.first = v_ctx->get_virtual( reinterpret_cast(target_ctx->dirbase)); orig_context.second = reinterpret_cast(target_ctx->dirbase); // make a new context 1:1 with the target process... hyperspace_context.first = v_ctx->kalloc(PAGE_4KB); hyperspace_context.second = v_ctx->get_physical(this->hyperspace_context.first); v_ctx->wkm(reinterpret_cast(this->hyperspace_context.first), reinterpret_cast(this->orig_context.first), PAGE_4KB); // make a new kprocess 1:1 with the target process... orig_peproc = v_ctx->get_peprocess(target_ctx->pid); clone_peproc = reinterpret_cast(v_ctx->kalloc(PAGE_4KB)); v_ctx->wkm(clone_peproc, orig_peproc, PAGE_4KB); // 1: kd > dt !_KPROCESS // nt!_KPROCESS // + 0x000 Header : _DISPATCHER_HEADER // + 0x018 ProfileListHead : _LIST_ENTRY // + 0x028 DirectoryTableBase : Uint8B <=== swap this with new pml4... const auto dirbase_ptr = reinterpret_cast(clone_peproc) + KPROCESS_DIRBASE_OFFSET; v_ctx->wkm(dirbase_ptr, hyperspace_context.second); } auto hyper_ctx::hyper_jmp(std::uint32_t tid) -> void { const auto current_thread = reinterpret_cast( v_ctx->get_current_thread()); v_ctx->wkm( current_thread + KTHREAD_PKPROCESS_OFFSET, clone_peproc); } auto hyper_ctx::hyper_ret(std::uint32_t tid) -> void { const auto current_thread = reinterpret_cast( v_ctx->get_current_thread()); v_ctx->wkm( current_thread + KTHREAD_PKPROCESS_OFFSET, orig_peproc); } }