微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

NtAllocateVirtualMemoryEx定义

如何解决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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。