我正在通过连接内存 API 来实现内存管理工具,当我来到 NtAllocateVirtualMemoryEx 时,我试图在谷歌上找到它的定义,但什么也没找到,但是 NtAllocateVirtualMemory 在https://docs.microsoft.com/en-us中有明确定义/windows-hardware/drivers/ddi/ntifs/nf-ntifs-ntallocatevirtualmemory,有人知道它的详细信息吗?
1 回答
1
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
确实不是由kernel32.dllVirtualAlloc2导出的,也不是在kernel32.lib中定义的
需要使用从api-ms-win-core-memory-l1-1-6.dll导入此 api 的mincore.lib或mmos.lib(现在已解析为kernelbase.dll)
于 2020-09-27T11:36:36.490 回答