diff --git a/PSKDM/mapper_ctx/mapper_ctx.cpp b/PSKDM/mapper_ctx/mapper_ctx.cpp index d9c12bc..d6784f3 100644 --- a/PSKDM/mapper_ctx/mapper_ctx.cpp +++ b/PSKDM/mapper_ctx/mapper_ctx.cpp @@ -17,7 +17,7 @@ namespace nasa map_into->set_page(map_into->dirbase)); // look for an empty pml4e... - for (auto idx = 0u; idx < 256; ++idx) + for (auto idx = 100u; idx < 255; ++idx) { if (!map_into_pml4[idx].value) { @@ -38,6 +38,7 @@ namespace nasa drv_pml4e.nx = false; drv_pml4e.user_supervisor = false; + drv_pml4e.write = true; // ensure we insert the pml4e... while (!map_into->write_phys( @@ -68,7 +69,8 @@ namespace nasa if (!process_handle) return { {}, {} }; - drv_image.fix_imports([&](const char* module_name, const char* export_name) + drv_image.fix_imports( + [&](const char* module_name, const char* export_name) { return reinterpret_cast( util::get_kmodule_export( @@ -137,6 +139,7 @@ namespace nasa { pdpt_mapping[pdpt_idx].user_supervisor = false; pdpt_mapping[pdpt_idx].nx = false; + pdpt_mapping[pdpt_idx].write = true; auto pd_mapping = reinterpret_cast( map_from->set_page(reinterpret_cast( @@ -149,6 +152,7 @@ namespace nasa { pd_mapping[pd_idx].user_supervisor = false; pd_mapping[pd_idx].nx = false; + pd_mapping[pd_idx].write = true; auto pt_mapping = reinterpret_cast( map_from->set_page(reinterpret_cast( @@ -161,6 +165,7 @@ namespace nasa { pt_mapping[pt_idx].user_supervisor = false; pt_mapping[pt_idx].nx = false; + pt_mapping[pt_idx].write = true; } } diff --git a/PSKDM/mem_ctx/mem_ctx.cpp b/PSKDM/mem_ctx/mem_ctx.cpp index 1e487f7..89fe3b2 100644 --- a/PSKDM/mem_ctx/mem_ctx.cpp +++ b/PSKDM/mem_ctx/mem_ctx.cpp @@ -116,7 +116,7 @@ namespace nasa pdpte new_pdpte = { NULL }; new_pdpte.present = true; - new_pdpte.rw = true; + new_pdpte.write = true; new_pdpte.pfn = reinterpret_cast(new_pd.first) >> 12; new_pdpte.user_supervisor = true; @@ -125,7 +125,7 @@ namespace nasa pde new_pde = { NULL }; new_pde.present = true; - new_pde.rw = true; + new_pde.write = true; new_pde.pfn = reinterpret_cast(new_pt.first) >> 12; new_pde.user_supervisor = true; @@ -134,7 +134,7 @@ namespace nasa pte new_pte = { NULL }; new_pte.present = true; - new_pte.rw = true; + new_pte.write = true; new_pte.pfn = reinterpret_cast(addr) >> 12; new_pte.user_supervisor = true; diff --git a/PSKDM/util/nt.hpp b/PSKDM/util/nt.hpp index 3a4c26e..078d7a8 100644 --- a/PSKDM/util/nt.hpp +++ b/PSKDM/util/nt.hpp @@ -97,7 +97,7 @@ typedef union _pml4e struct { std::uint64_t present : 1; // Must be 1, region invalid if 0. - std::uint64_t ReadWrite : 1; // If 0, writes not allowed. + std::uint64_t write : 1; // If 0, writes not allowed. std::uint64_t user_supervisor : 1; // If 0, user-mode accesses not allowed. std::uint64_t PageWriteThrough : 1; // Determines the memory type used to access PDPT. std::uint64_t page_cache : 1; // Determines the memory type used to access PDPT. @@ -119,7 +119,7 @@ typedef union _pdpte struct { std::uint64_t present : 1; // Must be 1, region invalid if 0. - std::uint64_t rw : 1; // If 0, writes not allowed. + std::uint64_t write : 1; // If 0, writes not allowed. std::uint64_t user_supervisor : 1; // If 0, user-mode accesses not allowed. std::uint64_t PageWriteThrough : 1; // Determines the memory type used to access PD. std::uint64_t page_cache : 1; // Determines the memory type used to access PD. @@ -141,7 +141,7 @@ typedef union _pde struct { std::uint64_t present : 1; // Must be 1, region invalid if 0. - std::uint64_t rw : 1; // If 0, writes not allowed. + std::uint64_t write : 1; // If 0, writes not allowed. std::uint64_t user_supervisor : 1; // If 0, user-mode accesses not allowed. std::uint64_t PageWriteThrough : 1; // Determines the memory type used to access PT. std::uint64_t page_cache : 1; // Determines the memory type used to access PT. @@ -163,7 +163,7 @@ typedef union _pte struct { std::uint64_t present : 1; // Must be 1, region invalid if 0. - std::uint64_t rw : 1; // If 0, writes not allowed. + std::uint64_t write : 1; // If 0, writes not allowed. std::uint64_t user_supervisor : 1; // If 0, user-mode accesses not allowed. std::uint64_t PageWriteThrough : 1; // Determines the memory type used to access the memory. std::uint64_t page_cache : 1; // Determines the memory type used to access the memory. @@ -175,7 +175,7 @@ typedef union _pte std::uint64_t pfn : 36; // The page frame number of the backing physical page. std::uint64_t reserved : 4; std::uint64_t Ignored3 : 7; - std::uint64_t ProtectionKey : 4; // If the PKE bit of CR4 is set, determines the protection key. + std::uint64_t pk : 4; // If the PKE bit of CR4 is set, determines the protection key. std::uint64_t nx : 1; // If 1, instruction fetches not allowed. }; } pte, * ppte; diff --git a/um-example/PSKDM.lib b/um-example/PSKDM.lib index 9f4f293..fdae025 100644 Binary files a/um-example/PSKDM.lib and b/um-example/PSKDM.lib differ