This project demonstrates how to securely create and map memory sections using native Windows APIs. The provided code showcases techniques for handling memory securely, verifying system library integrity, and modifying memory sections safely. These practices are essential for applications that interact with system internals, ensuring both security and efficiency. 🛡️
-
Dynamic Section Creation
- Utilizes
NtCreateSection
to allocate a secure 2MB section of memory. 🧠
- Utilizes
-
Memory Mapping
- Maps the created section into the process' virtual address space using
NtMapViewOfSection
. 📦
- Maps the created section into the process' virtual address space using
-
Memory Integrity Check
- Compares the first 0x1000 bytes of the original
ntdll.dll
with the newly mapped section to ensure the code is untampered. 🔍
- Compares the first 0x1000 bytes of the original
-
Safe Memory Modifications
- Demonstrates secure modification by zeroing out the first 0x1000 bytes of the mapped section. 🔧
-
API Resolution from Trusted Sources
- All APIs (
NtCreateSection
,NtMapViewOfSection
,NtClose
) are dynamically resolved fromntdll.dll
, ensuring that the functions used are the ones provided by the trusted system library. 📜
- All APIs (
-
Memory Integrity Validation
- The program verifies the integrity of the memory by comparing the first page of
ntdll.dll
before and after mapping, preventing malicious alterations. 🛡️
- The program verifies the integrity of the memory by comparing the first page of
-
Memory Section Isolation
- The created section is isolated and modified securely in a way that doesn't impact the original
ntdll.dll
in memory, ensuring safe modifications without system instability. ⚡
- The created section is isolated and modified securely in a way that doesn't impact the original
- Compile the code with any C++ compiler that supports Windows system calls.
- Run the executable.
- The code will:
- Load
ntdll.dll
- Create and map a secure memory section
- Compare the original and mapped
ntdll.dll
for integrity - Perform secure memory modification
- Load
This code is provided under the MIT License. See the LICENSE
file for more information.