#ifndef _NTMMAPI_H
#if (PHNT_MODE != PHNT_MODE_KERNEL)
/**
* Locks the specified region of the process's virtual address space into physical memory, ensuring that subsequent access to the region will not incur a page fault.
*
* \param ProcessHandle A handle to the process whose virtual address space is to be locked.
* \param BaseAddress A pointer to the base address of the region of pages to be locked.
* \param RegionSize The size of the region to be locked, in bytes. The size is rounded up to the nearest multiple of PAGE_SIZE.
* \param MapType A bitmask containing one or more flags that specify the type of operations to be performed.
* \return NTSTATUS Successful or errant status.
* \sa https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtuallock
*/
NTSYSCALLAPI
NTSTATUS
NTAPI
NtLockVirtualMemory(
_In_ HANDLE ProcessHandle,
_Inout_ PVOID *BaseAddress,
_Inout_ PSIZE_T RegionSize,
_In_ ULONG MapType
);
View code on GitHub
#ifndef _NTZWAPI_H
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwLockVirtualMemory(
_In_ HANDLE ProcessHandle,
_Inout_ PVOID *BaseAddress,
_Inout_ PSIZE_T RegionSize,
_In_ ULONG MapType
);
View code on GitHub
Can be one or both of following values:
#define VM_LOCK_1 0x0001 // This is used, when calling KERNEL32.DLL VirtualLock routine
#define VM_LOCK_2 0x0002 // This require SE_LOCK_MEMORY_NAME privilege
Privilege: SE_LOCK_MEMORY_NAME