异常被Win32消息分派器捕获的问题 [英] Issue with exceptions being caught by Win32 message dispatcher

查看:129
本文介绍了异常被Win32消息分派器捕获的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个非常低级的类型问题,但也许有人在这里有一些洞察...

This is kinda a very low-level type question, but maybe someone here has some insight...

我有一个问题,其中未处理的SEH异常如Access Violations)似乎被捕获在Win32消息分派级别,而不是终止程序。我发现以下参考博客,解释了问题,但在WM_TIMER消息的上下文: http://bugswar.blogspot.com/2010/07/why-its-not-crashing.html

I'm having an issue where unhandled SEH exceptions (such as Access Violations) are seemingly being caught at the Win32 message dispatch level, rather than terminating the program. I found the following reference blog, which explains the problem, but in the context of WM_TIMER messages only: http://bugswar.blogspot.com/2010/07/why-its-not-crashing.html

我'遇到Win 2008R2的问题,以及正常消息(例如:WM_COMMAND等)。我怀疑它可能是Windows试图帮助通过屏蔽异常,但我想它的错误出来; 继续和忽略行为一般导致应用程序的问题。我意识到我可以尝试包装每个函数在try / catch,并使用编译器选项/ EHa将SEH异常转换为C ++异常(这本身是非常不鼓励和危险),但这显然是次优的。

I'm experiencing the issue with Win 2008R2, and on "normal" messages (eg: WM_COMMAND, etc.). I suspect it might be Windows trying to "help" by masking exceptions, but I want it to error out; the "continue and ignore" behavior is causing problems with the application in general. I realize I could try to wrap every function in a try/catch, and use the compiler option /EHa to convert SEH exceptions into C++ exceptions (which is itself very discouraged and dangerous), but this is obviously sub-optimal.

根据引用的博客,AppCompatFlags2中的TIB结构中有一个标志(http://en.wikipedia.org/wiki/Win32_Thread_Information_Block),它可能导致Win32处理程序不捕获/丢弃SEH异常,但我不知道如何设置/启用它。任何人都有这方面的见解?有没有一个AppCompat设置我可以让Windows不捕获和忽略异常?

According to the referenced blog, there's a flag in the AppCompatFlags2 in the TIB structure (http://en.wikipedia.org/wiki/Win32_Thread_Information_Block) which can cause the Win32 handler to not catch/discard the SEH exception, but I have no idea how to set/enable it. Anyone have any insight on this? Is there an AppCompat setting I can enable to have Windows not catch and ignore exceptions?

推荐答案

我认为它是设计,它不被认为足够仔细。

I think it's by design, but obviously it was not considered carefully enough. Perhaps ill-advised attempt to make some legacy application "behave".

您可以在Windows 7 SP1中覆盖此行为;我在此此堆栈回答中写了更多信息。

You can override this behaviour in Windows 7 SP1; I wrote more on this in this stackoverflow answer.

这篇关于异常被Win32消息分派器捕获的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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