mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
Work around pre 19041 SDK definition
SDK definition of WER_RUNTIME_EXCEPTION_INFORMATION changed in SDK 19041 to add the bIsFatal field which we use. This adds a local definition of the newer structure to allow the WER handler to build on earlier SDKs. Bug: crashpad:423 Change-Id: I23bb69cc002ac8d469227e549f29b0af4849c893 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3880663 Reviewed-by: Mark Mentovai <mark@chromium.org> Commit-Queue: Alex Gough <ajgo@chromium.org>
This commit is contained in:
parent
833219f1ad
commit
ca928c8d6b
@ -43,5 +43,6 @@ source_set("crashpad_wer_test") {
|
||||
"../../../client:client",
|
||||
"../../../test:test",
|
||||
"../../../third_party/googletest:googletest",
|
||||
"../../../util:util_registration_protocol",
|
||||
]
|
||||
}
|
||||
|
@ -27,6 +27,18 @@ namespace crashpad::wer {
|
||||
namespace {
|
||||
using crashpad::WerRegistration;
|
||||
|
||||
// bIsFatal and dwReserved fields are not present in SDK < 19041.
|
||||
struct WER_RUNTIME_EXCEPTION_INFORMATION_19041 {
|
||||
DWORD dwSize;
|
||||
HANDLE hProcess;
|
||||
HANDLE hThread;
|
||||
EXCEPTION_RECORD exceptionRecord;
|
||||
CONTEXT context;
|
||||
PCWSTR pwszReportId;
|
||||
BOOL bIsFatal;
|
||||
DWORD dwReserved;
|
||||
};
|
||||
|
||||
// We have our own version of this to avoid pulling in //base.
|
||||
class ScopedHandle {
|
||||
public:
|
||||
@ -69,8 +81,18 @@ bool ProcessException(DWORD* handled_exceptions,
|
||||
if (!pContext)
|
||||
return false;
|
||||
|
||||
if (!e_info->bIsFatal)
|
||||
// Older OSes might provide a smaller structure than SDK 19041 defines.
|
||||
if (e_info->dwSize <=
|
||||
offsetof(WER_RUNTIME_EXCEPTION_INFORMATION_19041, bIsFatal)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If building with SDK < 19041 then the bIsFatal field isn't defined, so
|
||||
// use our internal definition here.
|
||||
if (!reinterpret_cast<const WER_RUNTIME_EXCEPTION_INFORMATION_19041*>(e_info)
|
||||
->bIsFatal) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only deal with exceptions that crashpad would not have handled.
|
||||
bool found = false;
|
||||
|
@ -56,8 +56,8 @@ TEST(CrashpadWerModule, Basic) {
|
||||
ASSERT_EQ(res, E_FAIL);
|
||||
|
||||
// Dummy args for OutOfProcessExceptionEventCallback.
|
||||
crashpad::WerRegistration registration;
|
||||
WER_RUNTIME_EXCEPTION_INFORMATION wer_ex;
|
||||
wer_ex.dwSize = sizeof(WER_RUNTIME_EXCEPTION_INFORMATION);
|
||||
BOOL bClaimed = FALSE;
|
||||
|
||||
// No context => skip.
|
||||
@ -65,6 +65,10 @@ TEST(CrashpadWerModule, Basic) {
|
||||
ASSERT_EQ(res, S_OK);
|
||||
ASSERT_EQ(bClaimed, FALSE);
|
||||
|
||||
// Following tests only make sense if building on SDK >= 19041 as
|
||||
// bIsFatalField only exists after that.
|
||||
#if defined(NTDDI_WIN10_VB) && (WDK_NTDDI_VERSION >= NTDDI_WIN10_VB)
|
||||
crashpad::WerRegistration registration;
|
||||
// Non-fatal exceptions are skipped.
|
||||
wer_ex.bIsFatal = FALSE;
|
||||
res = wref(®istration, &wer_ex, &bClaimed, nullptr, nullptr, nullptr);
|
||||
@ -77,7 +81,7 @@ TEST(CrashpadWerModule, Basic) {
|
||||
res = wref(®istration, &wer_ex, &bClaimed, nullptr, nullptr, nullptr);
|
||||
ASSERT_EQ(res, S_OK);
|
||||
ASSERT_EQ(bClaimed, FALSE);
|
||||
|
||||
#endif // defined(NTDDI_WIN10_VB) && WDK_NTDDI_VERSION >= NTDDI_WIN10_VB
|
||||
FreeLibrary(hMod);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user