diff options
-rw-r--r-- | src/client/windows/handler/exception_handler.cc | 30 | ||||
-rw-r--r-- | src/client/windows/handler/exception_handler.h | 12 | ||||
-rw-r--r-- | src/processor/testdata/test_app.cc | 3 |
3 files changed, 33 insertions, 12 deletions
diff --git a/src/client/windows/handler/exception_handler.cc b/src/client/windows/handler/exception_handler.cc index 0e6c43c9..cd1d7f26 100644 --- a/src/client/windows/handler/exception_handler.cc +++ b/src/client/windows/handler/exception_handler.cc @@ -62,6 +62,8 @@ ExceptionHandler::ExceptionHandler(const wstring &dump_path, next_minidump_path_c_(NULL), dbghelp_module_(NULL), minidump_write_dump_(NULL), + rpcrt4_module_(NULL), + uuid_create_(NULL), handler_types_(handler_types), previous_filter_(NULL), previous_pch_(NULL), @@ -78,10 +80,6 @@ ExceptionHandler::ExceptionHandler(const wstring &dump_path, previous_iph_ = NULL; #endif // _MSC_VER >= 1400 - // set_dump_path calls UpdateNextID. This sets up all of the path and id - // strings, and their equivalent c_str pointers. - set_dump_path(dump_path); - // Set synchronization primitives and the handler thread. Each // ExceptionHandler object gets its own handler thread because that's the // only way to reliably guarantee sufficient stack space in an exception, @@ -105,6 +103,19 @@ ExceptionHandler::ExceptionHandler(const wstring &dump_path, GetProcAddress(dbghelp_module_, "MiniDumpWriteDump")); } + // Load this library dynamically to not affect existing projects. Most + // projects don't link against this directly, it's usually dynamically + // loaded by dependent code. + rpcrt4_module_ = LoadLibrary(L"rpcrt4.dll"); + if (rpcrt4_module_) { + uuid_create_ = reinterpret_cast<UuidCreate_type>( + GetProcAddress(rpcrt4_module_, "UuidCreate")); + } + + // set_dump_path calls UpdateNextID. This sets up all of the path and id + // strings, and their equivalent c_str pointers. + set_dump_path(dump_path); + if (handler_types != HANDLER_NONE) { if (!handler_stack_critical_section_initialized_) { InitializeCriticalSection(&handler_stack_critical_section_); @@ -140,6 +151,10 @@ ExceptionHandler::~ExceptionHandler() { FreeLibrary(dbghelp_module_); } + if (rpcrt4_module_) { + FreeLibrary(rpcrt4_module_); + } + if (handler_types_ != HANDLER_NONE) { EnterCriticalSection(&handler_stack_critical_section_); @@ -518,8 +533,11 @@ bool ExceptionHandler::WriteMinidumpWithException( } void ExceptionHandler::UpdateNextID() { - GUID id; - CoCreateGuid(&id); + assert(uuid_create_); + UUID id = {0}; + if (uuid_create_) { + uuid_create_(&id); + } next_minidump_id_ = GUIDString::GUIDToWString(&id); next_minidump_id_c_ = next_minidump_id_.c_str(); diff --git a/src/client/windows/handler/exception_handler.h b/src/client/windows/handler/exception_handler.h index 7d82564c..fc9af326 100644 --- a/src/client/windows/handler/exception_handler.h +++ b/src/client/windows/handler/exception_handler.h @@ -52,9 +52,6 @@ // ExceptionHandler *f = new ExceptionHandler(...); // delete e; // This will put the exception filter stack into an inconsistent state. -// -// To use this library in your project, you will need to link against -// ole32.lib. #ifndef CLIENT_WINDOWS_HANDLER_EXCEPTION_HANDLER_H__ #define CLIENT_WINDOWS_HANDLER_EXCEPTION_HANDLER_H__ @@ -62,10 +59,11 @@ #include <stdlib.h> #include <Windows.h> #include <DbgHelp.h> +#include <rpc.h> #pragma warning( push ) // Disable exception handler warnings. -#pragma warning( disable : 4530 ) +#pragma warning( disable : 4530 ) #include <string> #include <vector> @@ -195,6 +193,9 @@ class ExceptionHandler { CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam); + // Function pointer type for UuidCreate, which is looked up dynamically. + typedef RPC_STATUS (RPC_ENTRY *UuidCreate_type)(UUID *Uuid); + // Runs the main loop for the exception handler thread. static DWORD WINAPI ExceptionHandlerThreadMain(void *lpParameter); @@ -272,6 +273,9 @@ class ExceptionHandler { HMODULE dbghelp_module_; MiniDumpWriteDump_type minidump_write_dump_; + HMODULE rpcrt4_module_; + UuidCreate_type uuid_create_; + // Tracks the handler types that were installed according to the // handler_types constructor argument. int handler_types_; diff --git a/src/processor/testdata/test_app.cc b/src/processor/testdata/test_app.cc index e2b9c3a9..f230ef3f 100644 --- a/src/processor/testdata/test_app.cc +++ b/src/processor/testdata/test_app.cc @@ -29,8 +29,7 @@ // This file is used to generate minidump2.dmp and minidump2.sym. // cl /Zi test_app.cc /Fetest_app.exe /I google_breakpad/src \ -// google_breakpad/src/client/windows/releasestaticcrt/exception_handler.lib \ -// ole32.lib +// google_breakpad/src/client/windows/releasestaticcrt/exception_handler.lib // Then run test_app to generate a dump, and dump_syms to create the .sym file. #include <cstdio> |