如何使我的程序与 DEP 兼容? [英] How to make my program DEP-compatible?

查看:21
本文介绍了如何使我的程序与 DEP 兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Windows 窗体 (.net 3.0) 项目,由于 DEP 错误,该项目无法在我客户的 vista 计算机上运行.它在我的 vista 机器上运行,并在虚拟机中运行 vista sp1 的干净版本.我无法找到使我的程序 DEP、数据执行保护兼容的方法.我真的不能对最终用户机器做任何事情,它只能运行.有没有办法摆脱这个最新的vista开发噩梦?我的程序使用 devexpress 控件、sql express 和 .net ie web 浏览器控件.我已经跳出 ie 控件,但无济于事.我有其他程序在同一台机器上使用 devexpress 和 sql express,它们运行正常.我不知道在用户的计算机上调试这个.

I have a windows forms (.net 3.0) project that won't run on my customer's vista computer due to a DEP error. It runs on my vista machine, and in a clean version of vista sp1 in a virtual machine. I am having trouble tracking down ways to make my program DEP, Data Execution Prevention compatible. I really can't do anything to end user machines, it just has to run. Is there any way out of this latest vista development nightmare? My program uses devexpress controls, sql express, and the .net ie web browser control. I've already jumpered out the ie control, but to no avail. I have other program that use devexpress and sql express on that same machine and they run ok. I am at a loss to debug this on the user's computer.

推荐答案

DEP 以两种模式之一运行:

DEP runs in one of two modes:

1) 硬件 DEP 适用于可以将内存页标记为不可执行的 CPU.这有助于防止某些漏洞,例如缓冲区溢出.

1) Hardware DEP is for CPUs that can mark memory pages as non-executable. This helps to prevent certain exploits such as buffer overflows.

2) 软件 DEP 适用于不支持硬件 DEP 的 CPU.它不会阻止执行数据页中的代码,而是阻止 SEH 覆盖(另一种类型的攻击).

2) Software DEP is for CPUs that do not have hardware DEP support. It doesn't prevent execution of code in data pages, but instead stops SEH overwrite (another type of attack).

在 CPU 支持的 Windows XP 上,默认情况下仅对某些 Windows 系统二进制文件以及选择选择加入"的程序启用硬件 DEP.

On Windows XP with CPUs that support it, hardware DEP is enabled by default only for certain Windows system binaries, and also for programs that choose to "opt-in".

在具有支持它的 CPU 的 Vista 上,默认情况下几乎所有进程都启用了硬件 DEP.这偶尔会出现问题,通常对于较旧的程序和驱动程序,以及未进行任何 Vista 测试的 ISV.

On Vista with CPUs that support it, hardware DEP is enabled by default for nearly all processes. This can occasionally be problematic, usually for older programs and drivers, and for ISVs that haven't done any Vista testing.

所以我怀疑第一步是确定您是在处理软件还是硬件 DEP.另外,您使用的是 C#/VB 还是托管 C++?您是否使用任何本机代码或组件?如果您的应用程序使用本机组件或使用旧 ATL 框架构建的 ActiveX 控件,那么您的应用程序很可能会因硬件 DEP 而失败.

So I suspect that the first step is to discover whether you're dealing with software or hardware DEP. Also, are you using C#/VB or Managed C++? And are you using any native code or components? If your application uses a native component or an ActiveX control that was built using the old ATL framework, then it's quite possible that your application will fail with hardware DEP.

从 .NET Framework 2.0 SP1 开始,我相信 C# 编译器会发出与 DEP 兼容的托管代码.但是,如果您的应用程序正在生成 DEP 异常,那么您可以尝试清除可执行文件的 IMAGE_DLLCHARACTERISTICS_NX_COMPAT 标志.为此,您可以使用 VC 工具集中的 EDITBIN.EXE,如下所示:

Since .NET Framework 2.0 SP1, I believe that the C# compiler emits managed code which is DEP-compatible. But if your application is generating DEP exceptions, then you can try clearing the IMAGE_DLLCHARACTERISTICS_NX_COMPAT flag for your executable. To do this you use EDITBIN.EXE from the VC toolset like so:

editbin.exe /NXCOMPAT:NO <your binary>

如果您使用的是 Visual Studio,则可以向可执行文件的项目添加构建后步骤.您需要设置环境,以便可以解决 EDITBIN 的依赖项.当我在应用程序中使用本机代码时,构建后步骤如下所示:

If you're using Visual Studio, you can add a post-build step to your executable's project. You'll need to setup the environment so that EDITBIN's dependencies can be resolved. When I'm using native code as part of my app, the post-build step looks like this:

call $(DevEnvDir)..\tools\vsvars32.bat
editbin.exe /NXCOMPAT:NO $(TargetPath)  

这篇关于如何使我的程序与 DEP 兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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