From 75e6abe9d58617bb8325cc93d4c4283994a9491c Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sat, 7 May 2022 18:31:47 +0200 Subject: [PATCH] Fix heap space issues --- src/driver/assembly.hpp | 1 - src/driver/ept.cpp | 9 ++++++++- src/driver/ept.hpp | 6 +++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/driver/assembly.hpp b/src/driver/assembly.hpp index 7b88417..f485381 100644 --- a/src/driver/assembly.hpp +++ b/src/driver/assembly.hpp @@ -1,5 +1,4 @@ #pragma once -#include "std_include.hpp" extern "C" { diff --git a/src/driver/ept.cpp b/src/driver/ept.cpp index f02562c..2d39b8a 100644 --- a/src/driver/ept.cpp +++ b/src/driver/ept.cpp @@ -76,7 +76,14 @@ namespace vmx } } - ept::ept() = default; + ept::ept() + { + // Directly initializing these fields kills the compiler ._. + // https://developercommunity.visualstudio.com/t/clexe-using-20gb-of-memory-compiling-small-file-in/407999 + memset(this->epml4, 0, sizeof(this->epml4)); + memset(this->epdpt, 0, sizeof(this->epdpt)); + memset(this->epde, 0, sizeof(this->epde)); + } ept::~ept() { diff --git a/src/driver/ept.hpp b/src/driver/ept.hpp index c369330..3c876cf 100644 --- a/src/driver/ept.hpp +++ b/src/driver/ept.hpp @@ -77,9 +77,9 @@ namespace vmx static void free_translation_hints(ept_translation_hint* hints); private: - DECLSPEC_PAGE_ALIGN pml4 epml4[EPT_PML4E_ENTRY_COUNT]{}; - DECLSPEC_PAGE_ALIGN pml3 epdpt[EPT_PDPTE_ENTRY_COUNT]{}; - DECLSPEC_PAGE_ALIGN pml2 epde[EPT_PDPTE_ENTRY_COUNT][EPT_PDE_ENTRY_COUNT]{}; + DECLSPEC_PAGE_ALIGN pml4 epml4[EPT_PML4E_ENTRY_COUNT]; + DECLSPEC_PAGE_ALIGN pml3 epdpt[EPT_PDPTE_ENTRY_COUNT]; + DECLSPEC_PAGE_ALIGN pml2 epde[EPT_PDPTE_ENTRY_COUNT][EPT_PDE_ENTRY_COUNT]; ept_split* ept_splits{nullptr}; ept_hook* ept_hooks{nullptr};