c++ - 虚拟分配地址

标签 c++ c winapi virtualalloc

我编写了下面的代码

 void * ptr1 = VirtualAlloc((void*)0x70000000, 32*1024*1024, MEM_RESERVE, PAGE_READWRITE);
 void * ptr2 = VirtualAlloc((void*)0x80000000, 4*1024*1024, MEM_RESERVE, PAGE_READWRITE);

但是 VirtualAlloc 失败并且 ptr1,ptr2 的值始终为 NULL。 我想使用地址0x70000000,0x80000000。 有谁知道我如何使用这些地址?

最佳答案

用户模式应用程序无法访问这部分内存。来自以下MSDN page :

User applications cannot call VirtualAlloc with shared heap address range (0x70000000 to 0x7fffffff) because this is read-only for user applications and read/write for kernel mode.

关于c++ - 虚拟分配地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10080083/

相关文章:

c++ - EXE 和 DLL 依赖 - 何时重新编译 EXE?

c - 如何禁用 Windows 7 上的开始按钮(而不是任务栏)?

c++ - 如何为 WinApi ldap_search_s 初始化 PZPWSTR (wchar_t**) 参数?

c++ - DialogBoxParam 和 GetOpenFileName

c++ - Windows 7 和 Windows 8 进程 "ring"控件

c++ - 创建样本库

C++ 同时写入 std::out 和 std:clog

c++ - 在多线程环境中什么会导致 "bad file descriptor"?

c - 通过c中的libcurl使用POST请求将文件上传到http(s)服务器

c - 我怎么知道II和&&之间的顺序?