diff --git a/sdk/xtdk/mmtypes.h b/sdk/xtdk/mmtypes.h index f1e4199..ba118ca 100644 --- a/sdk/xtdk/mmtypes.h +++ b/sdk/xtdk/mmtypes.h @@ -41,6 +41,19 @@ /* Number of reserved zeroed PTEs */ #define MM_RESERVED_ZERO_PTES 32 +/* Memory Manager Protection Bits */ +#define MM_ZERO_ACCESS 0 +#define MM_READONLY 1 +#define MM_EXECUTE 2 +#define MM_EXECUTE_READ 3 +#define MM_READWRITE 4 +#define MM_WRITECOPY 5 +#define MM_EXECUTE_READWRITE 6 +#define MM_EXECUTE_WRITECOPY 7 +#define MM_PROTECT_ACCESS 7 + +/* Protection field shift */ +#define MM_PROTECT_FIELD_SHIFT 5 /* Memory manager page lists */ typedef enum _MMPAGELISTS diff --git a/xtoskrnl/mm/alloc.cc b/xtoskrnl/mm/alloc.cc index 37bc957..59c8b82 100644 --- a/xtoskrnl/mm/alloc.cc +++ b/xtoskrnl/mm/alloc.cc @@ -151,11 +151,12 @@ MM::Allocator::AllocateNonPagedPoolPages(IN PFN_COUNT Pages, /* Initialize the PFN entry for the allocated physical page */ Pfn = MM::Pfn::GetPfnEntry(PageFrameNumber); + MM::Paging::SetPte(&Pfn->OriginalPte, 0, MM_READWRITE << MM_PROTECT_FIELD_SHIFT); Pfn->PteAddress = CurrentPte; Pfn->u2.ShareCount = 1; Pfn->u3.e1.PageLocation = ActiveAndValid; Pfn->u3.e2.ReferenceCount = 1; - Pfn->u4.VerifierAllocation = 0; + Pfn->u4.PteFrame = MM::Paging::GetPageFrameNumber(MM::Paging::GetPteAddress(CurrentPte)); /* Build a valid PTE pointing to the allocated page frame */ MM::Paging::SetPte(ValidPte, PageFrameNumber, 0);