VirtualAlloc位于0x000’00000000。

huangapple go评论67阅读模式
英文:

VirtualAlloc at 0x000'00000000

问题

当将0x000'00000000NULL)作为VirtualAlloc的第一个参数传递时,系统确定在哪里分配该区域,如果函数失败,返回值是NULL0x000'00000000)。

对于64位Windows上的64位进程,虚拟地址空间范围从0x000'000000000x7FFF'FFFFFFFF

那么如何在0x000'00000000处保留一个页面,以避免函数失败并使系统确定在哪里分配该区域?

英文:

When passing 0x000'00000000 (NULL) as the first parameter of VirtualAlloc the system determines where to allocate the region, or if the function fails, the return value is NULL (0x000'00000000).

For a 64-bit process on 64-bit Windows, the virtual address space ranges from 0x000'00000000 through 0x7FFF'FFFFFFFF.

So how do I reserve a page starting at 0x000'00000000 without the function failing and system determining where to allocate the region?

答案1

得分: 1

以下是已翻译的内容:

如果按照字面意思理解你的问题,你要求“保留”一个页面而不提交它。这很容易;操作系统在进程启动时已经为你执行此操作,以防止不小心提交该页面并与使用这些65536地址作为特殊值的所有函数(如NULL指针或伪装为字符串指针的整数,如MAKEINTRESOURCE,或者正如Hans Passant在评论中提到的,通过将该页面中的每个访问冲突视为空指针异常来破坏CLR的空指针检测)造成混乱。

然而,从Windows 8开始,你无法再取消保留该页面

英文:

Taking your question literally, you asked to reserve a page and not commit it. That's easy; the operating system already does it for you on process startup to prevent that page being committed by accident and causing havoc with all the functions that use those 65536 addresses as special values, like the NULL pointer or integers disguised as string pointers like MAKEINTRESOURCE, or, as Hans Passant has mentioned in the comments, breaking the CLR's null pointer detection by treating every access violation in that page as a null pointer exception.

However, starting with Windows 8, you cannot unreserve that page anymore.

huangapple
  • 本文由 发表于 2023年6月9日 02:34:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76434777.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定