我发现了一种我无法解释的行为,我希望有人向我解释为什么会发生这种情况。
为了恢复我的情况,我正在尝试使用 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/