我是通过连接到内存API来实现内存管理工具的,当我访问NtAllocateVirtualMemoryEx时,我试图在谷歌上找到它的定义,但是没有发现任何东西,但是NtAllocateVirtualMemory在https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-ntallocatevirtualmemory中有明确的定义,有人知道它的细节吗?
发布于 2020-09-27 11:36:36
在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.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 )
https://stackoverflow.com/questions/64084729
复制相似问题