首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NtAllocateVirtualMemoryEx定义

NtAllocateVirtualMemoryEx定义
EN

Stack Overflow用户
提问于 2020-09-27 04:13:10
回答 1查看 1.1K关注 0票数 0

我是通过连接到内存API来实现内存管理工具的,当我访问NtAllocateVirtualMemoryEx时,我试图在谷歌上找到它的定义,但是没有发现任何东西,但是NtAllocateVirtualMemory在https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-ntallocatevirtualmemory中有明确的定义,有人知道它的细节吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-09-27 11:36:36

在ntifs.h中定义的ZwAllocateVirtualMemoryEx

代码语言:javascript
复制
#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上的薄外壳

有趣的是在条件下VirtualAlloc2memoryapi.h中定义

代码语言:javascript
复制
#if (NTDDI_VERSION >= NTDDI_WIN10_RS4)

但是ZwAllocateVirtualMemoryEx声明有条件

代码语言:javascript
复制
#if (NTDDI_VERSION >= NTDDI_WIN10_RS5)

然而,最起码的一个条件是错误的-因为VirtualAlloc2调用ZwAllocateVirtualMemoryEx -如果VirtualAlloc2可用- ZwAllocateVirtualMemoryEx也可用。

msdn中也有错误

  • 库Kernel32.lib
  • DLL Kernel32.dll

未由kernel32.dll导出且未在kernel32.lib中定义的VirtualAlloc2

需要使用mincore.lib或mmos.lib从https://learn.microsoft.com/en-us/uwp/win32-and-com/win32-apis#apis-from-api-ms-win-core-memory-l1-1-6dll导入此api (现在已解析为kernelbase.dll )

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64084729

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档