windows – MEMORY_BASIC_INFORMATION结构中的BaseAddress和Allo
发布时间:2020-12-14 04:11:01 所属栏目:Windows 来源:网络整理
导读:在MSDN中,我发现以下` BaseAddress – 指向页面区域的基址的指针. AllocationBase – 指向VirtualAlloc函数分配的一系列页面的基址的指针. BaseAddress成员指向的页面包含在此分配范围内. 但我真的不明白有什么区别.谁能告诉我区别? (不像在MSDN :)) Window
在MSDN中,我发现以下`
BaseAddress – 指向页面区域的基址的指针. AllocationBase – 指向VirtualAlloc函数分配的一系列页面的基址的指针. BaseAddress成员指向的页面包含在此分配范围内. 但我真的不明白有什么区别.谁能告诉我区别? (不像在MSDN :))
Windows上的虚拟内存分配的粒度为64千字节,即SYSTEM_INFO.dwAllocationGranularity的值.但虚拟内存页面为4096字节,SYSTEM_INFO.dwPageSize的值.
使用VirtualAlloc分配虚拟内存时,您将始终获得一个BaseAddress等于AllocationBase的块.但是,如果您随后更改了此块中一个或多个页面的页面保护,那么您可以观察到此块被细分为不同的BaseAddress.使用示例程序最佳显示,在MSVC上运行: #include "stdafx.h" #include <Windows.h> #include <stdio.h> #include <conio.h> void showmem(void* mem) { MEMORY_BASIC_INFORMATION info = {}; VirtualQuery(mem,&info,sizeof info); printf("Alloc = %p,base = %p,size = %d,protect = %dn",info.AllocationBase,info.BaseAddress,info.RegionSize,info.Protect); } int main() { BYTE* mem = (BYTE*)VirtualAlloc(0,65536,MEM_COMMIT,PAGE_READWRITE); printf("%s","Initial allocation:n"); showmem(mem); DWORD oldprotect; BOOL ok = VirtualProtect(mem + 4096,4096,PAGE_NOACCESS,&oldprotect); printf("%s","nAfter protection changes:n"); showmem(mem); showmem(mem + 4096); showmem(mem + 4096 + 4096); _getch(); return 0; } 该程序的示例输出: Initial allocation: Alloc = 00ED0000,base = 00ED0000,size = 65536,protect = 4 After protection changes: Alloc = 00ED0000,size = 4096,protect = 4 Alloc = 00ED0000,base = 00ED1000,protect = 1 Alloc = 00ED0000,base = 00ED2000,size = 57344,protect = 4 并注意VirtualProtect()调用如何要求原始块在具有不同BaseAddress但具有相同AllocationBase的3个区域中分割. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows – 更新批处理文件中的命令行参数
- windows-phone-7 – MvvmCross – 为多个视图共享视图模型
- windows-server-2008 – 为什么我不能在外部访问Tomcat?
- iis – 如何查看详细的500错误?
- 如何在Windows上更改全局广播地址(255.255.255.255)的行为?
- windows – 在批处理文件中捕获错误(7-zip)
- 在Windows窗体中嵌入Selenium ChromeDriver
- windows-server-2008 – 在ISAPI筛选器上调用LoadLibraryEx
- api – 还有可能让Skype的用户在线状态?
- windows-7 – 如何在Windows 7上使用带有Powershell 3.0的n
推荐文章
站长推荐
- .NET中分离的项目/ DLL的缺点和优点?他们中有多
- windows – 窗口消息“可靠”吗?
- 利用开机账户登录“轻松访问”创建Windows后门
- windows-phone-7 – 在Windows Phone 7应用程序中
- 如何在Windows操作系统中从R调用Python?
- $(window).scroll in vanilla JavaScript
- microsoft-graph – 无法访问Microsoft Graph AP
- 二十三种设计模式[18] - 备忘录模式(Memento Pa
- microsoft-metro – 使用Windbg调试Metro应用程序
- windows-server-2008 – Windows远程访问服务器(
热点阅读