gpt4 book ai didi

c++ - VirtualProtect 是否需要页面开头的地址?

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

我需要使用 VirtualProtect,我的问题是关于传递给函数的区域地址。它说(在 MSDN 上)“描述起始页的地址”,它必须是页面开头的地址还是可以是该页面中的任何地址?也就是说,是不是应该先用VirtualQuery来确定页面的起始地址呢?

最佳答案

不需要传入页面的基地址。 VirtualProtect 将接受页面内的任何地址。 description of the dwSize parameter说得很清楚:

The region of affected pages includes all pages containing one or more bytes in the range from the lpAddress parameter to (lpAddress+dwSize). This means that a 2-byte range straddling a page boundary causes the protection attributes of both pages to be changed.

如果您能够拥有跨越页面边界的两字节范围,那么 lpAddress 一定有可能只是页面末尾之前的一个字节。页面不能只有一个字节长,因此它不在页面的开头。

关于c++ - VirtualProtect 是否需要页面开头的地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10838902/

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