NtAllocateVirtualMemoryEx定义

问题描述

我正在通过连接到内存API来实现内存管理工具,当我来到NtAllocateVirtualMemoryEx时,我试图在google上找到其定义,但未找到任何内容,但是NtAllocateVirtualMemory明确定义为https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-ntallocatevirtualmemory,有人知道吗?详细信息?

解决方法

ntifs.h 中定义的

ZwAllocateVirtualMemoryEx

#if (NTDDI_VERSION >= NTDDI_WIN10_RS5)
_Must_inspect_result_
_IRQL_requires_max_(PASSIVE_LEVEL)
_When_(return==0,__drv_allocatesMem(Region))
NTSYSAPI
NTSTATUS
NTAPI
ZwAllocateVirtualMemoryEx(
    _In_ HANDLE ProcessHandle,_Inout_ _At_ (*BaseAddress,_Readable_bytes_ (*RegionSize) _Writable_bytes_ (*RegionSize) _Post_readable_byte_size_ (*RegionSize)) PVOID* BaseAddress,_Inout_ PSIZE_T RegionSize,_In_ ULONG AllocationType,_In_ ULONG PageProtection,_Inout_updates_opt_(ExtendedParameterCount) PMEM_EXTENDED_PARAMETER ExtendedParameters,_In_ ULONG ExtendedParameterCount
    );
#endif

MEM_EXTENDED_PARAMETER和所有api实际上具有与VirtualAlloc2相同的用法。 VirtualAlloc2只是ZwAllocateVirtualMemoryEx上的薄壳

有趣的是,VirtualAlloc2在条件下memoryapi.h中定义了

#if (NTDDI_VERSION >= NTDDI_WIN10_RS4)

ZwAllocateVirtualMemoryEx已声明为条件

#if (NTDDI_VERSION >= NTDDI_WIN10_RS5)

这种情况的最小错误是错误的-因为VirtualAlloc2呼叫ZwAllocateVirtualMemoryEx-如果VirtualAlloc2可用-ZwAllocateVirtualMemoryEx也可用。

msdn中也是错误的:

  • 库Kernel32.lib
  • DLL Kernel32.dll

确实VirtualAlloc2未被 kernel32.dll 导出,也未在 kernel32.lib

中定义

需要使用从api-ms-win-core-memory-l1-1-6.dll导入此api的 mincore.lib mmos.lib (现在已解析为 kernelbase.dll