忘记了一个很简单问题的答案

阿呆_ 2014-10-16 09:32:14
呃, 谁记得 VirtualProtect(...)传入的lpAddress是否要4096对齐的? 还是任何地址?

...全文
204 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
shen_wei 2014-10-17
  • 打赏
  • 举报
回复
引用 1 楼 happyparrot 的回复:
你这也太懒了吧......好像两者都不是吧
他这是散粉。。MSDN看看都可以了。。
oyljerry 2014-10-17
  • 打赏
  • 举报
回复
lpAddress [in] A pointer an address that describes the starting page of the region of pages whose access protection attributes are to be changed. All pages in the specified region must be within the same reserved region allocated when calling the VirtualAlloc or VirtualAllocEx function using MEM_RESERVE. The pages cannot span adjacent reserved regions that were allocated by separate calls to VirtualAlloc or VirtualAllocEx using MEM_RESERVE.
快乐鹦鹉 2014-10-17
  • 打赏
  • 举报
回复
你这也太懒了吧......好像两者都不是吧
阿呆_ 2014-10-17
  • 打赏
  • 举报
回复
引用 3 楼 shen_wei 的回复:
[quote=引用 1 楼 happyparrot 的回复:] 你这也太懒了吧......好像两者都不是吧
他这是散粉。。MSDN看看都可以了。。[/quote] 这就被看穿了? 看MSDN可不够,文档描述并不清楚:比如VirtualProtect中有关lpAddress参数的描述: lpAddress [in] A pointer an address that describes the starting page of the region of pages whose access protection attributes are to be changed. 那么这个pointer究竟是在这个starting page中的“任意地址”还是“首地址(4906边界)”? 再看看VirtualQuery: lpAddress [in, optional] A pointer to the base address of the region of pages to be queried. This value is rounded down to the next page boundary. 它明确表示了你传入的地址会自动转换成该页的边界地址。所以你可以传入任意地址而不必手工转换成4096对齐的地址再调用。 但是VirtualProtect中的描述没有说是不是需要手工转换成4096边界地址才能操作。 印象中不用,任意地址都可以,但是确实忘了究竟是不是可以, 虽然证实很容易, 写一小片段代码就行了。 但是 ---- 懒惰,是人类文明不断发展的原因。 就当散分了。

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧