gpt4 book ai didi

c++ - 虚拟分配地址

转载 作者:搜寻专家 更新时间:2023-10-31 00:43:47 24 4
gpt4 key购买 nike

我写了下面的代码

 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com