C# 任何 CPU 选项和 VirtualQueryEx

标签 c# .net

我发现了一种我无法解释的行为,我希望有人向我解释为什么会发生这种情况。

为了恢复我的情况,我正在尝试使用 VirtualQueryEx 将内存区域读取到 64 位程序 (notepad.exe)

我已经弄清楚了:

  • 从 32 位进程中,我只能使用 MEMORY_BASIC_INFORMATION32 结构读取 32 位进程 msdn doc
  • 从 64 位进程中,我可以使用 MEMORY_BASIC_INFORMATION64 结构读取 64 位和 32 位进程 msdn doc
  • “任何 CPU” 配置中,我获得的行为与将程序作为 x86 32 位程序运行时完全相同。

那么我的问题是:为什么? 我的意思是,我检查了 msdn 文档,他们说它通常应该在 64 位模式下运行,因为我的计算机是 64 位操作系统。那么为什么它的行为像一个 32 位进程呢?

非常感谢您 future 的回答。我真的很好奇。

最佳答案

感谢@hans-passant的回答:

The solution platform name is irrelevant in C# projects, it only matters to C++ projects. The kind of projects where using different build tools is important. The only settings that matters are the ones on your EXE project, the ones that force a particular jitter to get used. Project > Properties > Build tab > Prefer 32-bit and Platform target. They tried to change this in VS2010 btw, giving C# projects a solution platform name of "x86". Big fail whale, back to AnyCPU in VS2012

然后对我有用的解决方案就是取消选中“首选 32 位”以查看视觉选择 64 位程序作为调试和 Release模式的解决方案。

再次感谢您。

关于C# 任何 CPU 选项和 VirtualQueryEx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53788811/

相关文章:

c# - 粗圆检测

c# - "Membership.Provider must be an instance of ExtendedMembershipProvider"

.net - Microsoft ACE 驱动程序更改了程序其余部分中的浮点精度

c# - Azure VM 上 FtpWebRequest 处于事件模式 (UsePassive = False) 时为 "500 Syntax error, command unrecognized"

c# - 存储库模式、POCO 和业务实体

c# - 在 Azure Durable Functions 中,我如何适本地确定大量并行事件的进程?

c# - Newtonsoft Json.NET ReferenceLoopHandling 和 JavascriptDateTimeConverter

c# - 如何创建用于访问 XNA 内容项目中文件的强类型结构?

c# - 安装项目在安装过程中不创建文件系统文件夹

c# - 如何通过图形 API 将带有地点(位置)的帖子添加到用户的墙上?