aboutsummaryrefslogtreecommitdiff
path: root/src/client/windows
diff options
context:
space:
mode:
authorted.mielczarek <ted.mielczarek@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-08-02 13:56:29 +0000
committerted.mielczarek <ted.mielczarek@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-08-02 13:56:29 +0000
commit0fdc829d3233917185e179c62a12ecd6d3df9e42 (patch)
tree364bdd0cc61eb532fc7aeaac6152060ae7dc5971 /src/client/windows
parentreview: http://breakpad.appspot.com/139001 (diff)
downloadbreakpad-0fdc829d3233917185e179c62a12ecd6d3df9e42.tar.xz
Fix HandleInvalidParameter/HandlePureVirtualCall to dynamically lookup the RtlCaptureContext symbol so the Windows exception handler will continue to work on Windows 2000. Patch by Jim Mathies <jmathies@mozilla.com> and Timothy Nikkel <tnikkel@gmail.com>. r=ted
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@637 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/windows')
-rw-r--r--src/client/windows/handler/exception_handler.cc78
1 files changed, 50 insertions, 28 deletions
diff --git a/src/client/windows/handler/exception_handler.cc b/src/client/windows/handler/exception_handler.cc
index 27c28e76..7af20ce7 100644
--- a/src/client/windows/handler/exception_handler.cc
+++ b/src/client/windows/handler/exception_handler.cc
@@ -37,6 +37,8 @@
#include "client/windows/handler/exception_handler.h"
#include "common/windows/guid_string.h"
+typedef VOID (WINAPI *RtlCaptureContextPtr) (PCONTEXT pContextRecord);
+
namespace google_breakpad {
static const int kWaitForHandlerThreadMs = 60000;
@@ -486,18 +488,28 @@ void ExceptionHandler::HandleInvalidParameter(const wchar_t* expression,
EXCEPTION_RECORD exception_record = {};
CONTEXT exception_context = {};
EXCEPTION_POINTERS exception_ptrs = { &exception_record, &exception_context };
- RtlCaptureContext(&exception_context);
- exception_record.ExceptionCode = STATUS_NONCONTINUABLE_EXCEPTION;
-
- // We store pointers to the the expression and function strings,
- // and the line as exception parameters to make them easy to
- // access by the developer on the far side.
- exception_record.NumberParameters = 3;
- exception_record.ExceptionInformation[0] =
- reinterpret_cast<ULONG_PTR>(&assertion.expression);
- exception_record.ExceptionInformation[1] =
- reinterpret_cast<ULONG_PTR>(&assertion.file);
- exception_record.ExceptionInformation[2] = assertion.line;
+
+ EXCEPTION_POINTERS* exinfo = NULL;
+
+ RtlCaptureContextPtr fnRtlCaptureContext = (RtlCaptureContextPtr)
+ GetProcAddress(GetModuleHandleW(L"kernel32"), "RtlCaptureContext");
+ if (fnRtlCaptureContext) {
+ fnRtlCaptureContext(&exception_context);
+
+ exception_record.ExceptionCode = STATUS_NONCONTINUABLE_EXCEPTION;
+
+ // We store pointers to the the expression and function strings,
+ // and the line as exception parameters to make them easy to
+ // access by the developer on the far side.
+ exception_record.NumberParameters = 3;
+ exception_record.ExceptionInformation[0] =
+ reinterpret_cast<ULONG_PTR>(&assertion.expression);
+ exception_record.ExceptionInformation[1] =
+ reinterpret_cast<ULONG_PTR>(&assertion.file);
+ exception_record.ExceptionInformation[2] = assertion.line;
+
+ exinfo = &exception_ptrs;
+ }
bool success = false;
// In case of out-of-process dump generation, directly call
@@ -505,10 +517,10 @@ void ExceptionHandler::HandleInvalidParameter(const wchar_t* expression,
if (current_handler->IsOutOfProcess()) {
success = current_handler->WriteMinidumpWithException(
GetCurrentThreadId(),
- &exception_ptrs,
+ exinfo,
&assertion);
} else {
- success = current_handler->WriteMinidumpOnHandlerThread(&exception_ptrs,
+ success = current_handler->WriteMinidumpOnHandlerThread(exinfo,
&assertion);
}
@@ -564,18 +576,28 @@ void ExceptionHandler::HandlePureVirtualCall() {
EXCEPTION_RECORD exception_record = {};
CONTEXT exception_context = {};
EXCEPTION_POINTERS exception_ptrs = { &exception_record, &exception_context };
- RtlCaptureContext(&exception_context);
- exception_record.ExceptionCode = STATUS_NONCONTINUABLE_EXCEPTION;
-
- // We store pointers to the the expression and function strings,
- // and the line as exception parameters to make them easy to
- // access by the developer on the far side.
- exception_record.NumberParameters = 3;
- exception_record.ExceptionInformation[0] =
- reinterpret_cast<ULONG_PTR>(&assertion.expression);
- exception_record.ExceptionInformation[1] =
- reinterpret_cast<ULONG_PTR>(&assertion.file);
- exception_record.ExceptionInformation[2] = assertion.line;
+
+ EXCEPTION_POINTERS* exinfo = NULL;
+
+ RtlCaptureContextPtr fnRtlCaptureContext = (RtlCaptureContextPtr)
+ GetProcAddress(GetModuleHandleW(L"kernel32"), "RtlCaptureContext");
+ if (fnRtlCaptureContext) {
+ fnRtlCaptureContext(&exception_context);
+
+ exception_record.ExceptionCode = STATUS_NONCONTINUABLE_EXCEPTION;
+
+ // We store pointers to the the expression and function strings,
+ // and the line as exception parameters to make them easy to
+ // access by the developer on the far side.
+ exception_record.NumberParameters = 3;
+ exception_record.ExceptionInformation[0] =
+ reinterpret_cast<ULONG_PTR>(&assertion.expression);
+ exception_record.ExceptionInformation[1] =
+ reinterpret_cast<ULONG_PTR>(&assertion.file);
+ exception_record.ExceptionInformation[2] = assertion.line;
+
+ exinfo = &exception_ptrs;
+ }
bool success = false;
// In case of out-of-process dump generation, directly call
@@ -584,10 +606,10 @@ void ExceptionHandler::HandlePureVirtualCall() {
if (current_handler->IsOutOfProcess()) {
success = current_handler->WriteMinidumpWithException(
GetCurrentThreadId(),
- &exception_ptrs,
+ exinfo,
&assertion);
} else {
- success = current_handler->WriteMinidumpOnHandlerThread(&exception_ptrs,
+ success = current_handler->WriteMinidumpOnHandlerThread(exinfo,
&assertion);
}