- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
_EXCEPTION_RECORD
的documentation说明了其中一个成员struct _EXCEPTION_RECORD *ExceptionRecord
A pointer to an associated EXCEPTION_RECORD structure. Exception records can be chained together to provide additional information when nested exceptions occur.
#include <iostream>
#include <windows.h>
void Handle0(LPEXCEPTION_POINTERS pex) {
std::cout << "chain0 = " << pex->ExceptionRecord->ExceptionRecord << std::endl;
}
void Handle1(LPEXCEPTION_POINTERS pex) {
std::cout << "chain1 = " << pex->ExceptionRecord->ExceptionRecord << std::endl;
__try {
throw 3;
} __except( Handle0(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER ) {}
}
int main() {
__try {
throw 3;
} __except( Handle1(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER ) {}
return 0;
}
pex->ExceptionRecord->ExceptionRecord
始终是
nullptr
。在什么情况下我可以在那里找到嵌套的
_EXCEPTION_RECORD
的链接?
最佳答案
根据MSDN:
When an exception is raised during the processing of an exceptionfilter within ... native code ... a nested exception is raised, the
ExceptionRecord
field in theEXCEPTION_RECORD
structure (as returnedbyGetExceptionInformation
) is set, and theExceptionFlags
field setsthe0x10
bit. The following example illustrates this difference inbehavior:
#include <windows.h>
#include <stdio.h>
#include <assert.h>
#ifndef false
#define false 0
#endif
int *p;
int filter(PEXCEPTION_POINTERS ExceptionPointers) {
PEXCEPTION_RECORD ExceptionRecord =
ExceptionPointers->ExceptionRecord;
if ((ExceptionRecord->ExceptionFlags & 0x10) == 0) {
// not a nested exception, throw one
*p = 0; // throw another AV
}
else {
printf("Caught a nested exception\n");
return 1;
}
assert(false);
return 0;
}
void f(void) {
__try {
*p = 0; // throw an AV
}
__except(filter(GetExceptionInformation())) {
printf_s("We should execute this handler if "
"compiled to native\n");
}
}
int main() {
__try {
f();
}
__except(1) {
printf_s("The handler in main caught the "
"exception\n");
}
}
我相信如果您尝试继续不可延续的异常,它也会被设置。在这种情况下,
EXCEPTION_RECORD
将表示
EXCEPTION_NONCONTINUABLE_EXCEPTION
,而其
ExceptionRecord
将指向原始异常。
关于c++ - 在什么情况下EXCEPTION_RECORD链接到另一个嵌套异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51764125/
我正在开发一个 voip 调用应用程序。我需要做的是在接到来电时将 Activity 带到前台。我在应用程序中使用 Twilio,并在收到推送消息时开始调用。 问题是我试图在接到任何电话时显示 Act
我是一名优秀的程序员,十分优秀!