如何预约底部4GB虚拟机在基于x64的C ++应用程序 [英] How to reserve bottom 4GB VM in an x64 C++ app

查看:133
本文介绍了如何预约底部4GB虚拟机在基于x64的C ++应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

工作在32位Windows的C ++应用程序到64位移植。不幸的是,code使用频繁的铸造DWORD和指针值之间的两个方向。

Working on porting a 32bit Windows C++ app to 64 bit. Unfortunately, the code uses frequent casting in both directions between DWORD and pointer values.

其中一个想法是保留的虚拟进程空间中第一4GB尽早在过程的启动,使所有后续调用保留存储器将是从虚拟地址大于4GB的。这会导致访问冲突错误的任何不安全的指针转换为DWORD,然后回指针,并会帮助及时捕获错误。

One of the ideas is to reserve the first 4GB of virtual process space as early as possible during process startup so that all subsequent calls to reserve memory will be from virtual addresses greater than 4 GB. This would cause an access violation error any unsafe cast from pointer to DWORD and then back to pointer and would help catch errors early.

当我看到一个非常简单的线C ++程序的内存映射,也有在底部装4GB许多图书馆?有没有一种方法,以确保所有的图书馆,等得到加载只有4GB以上?

When I look at the memory map of a very simple one line C++ program, there are many libraries loaded within bottom 4GB? Is there a way to make sure that all libraries, etc get loaded only above 4GB?

感谢

推荐答案

编译与 / Wp64 项目开关(检测64位可移植性问题),并修复所有的警告。

Compile your project with /Wp64 switch (Detect 64-bit Portability Issues) and fix all warnings.

这篇关于如何预约底部4GB虚拟机在基于x64的C ++应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆