aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirunthan Mohanathas <birunthan@mohanathas.com>2016-02-17 11:36:19 -0500
committerTed Mielczarek <ted@mielczarek.org>2016-02-17 11:36:19 -0500
commit25f913e98115ccfa39b03791de1945434b536c90 (patch)
treea9ac9670679b62ed67e83afb23b3fa5ec1388827
parentFix buffer overrun in MinidumpModule::debug_identifier with MDCVInfoELF (diff)
downloadbreakpad-25f913e98115ccfa39b03791de1945434b536c90.tar.xz
Try loading msdiaNNN.dll if CoCreateInstance(CLSID_DiaSource) fails
Because tools/windows/symupload/symupload.cc uses `nullptr` (which requires VS2010), the CLSID comparison is only performed for msdia100.dll and later. When compiling with an older (or future) CLSID_DiaSource, we retain the existing behaviour (i.e. fail if CoCreateInstance fails). R=ivanpe@chromium.org BUG=https://bugzilla.mozilla.org/show_bug.cgi?id=1236343
-rw-r--r--src/common/windows/pdb_source_line_writer.cc40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/common/windows/pdb_source_line_writer.cc b/src/common/windows/pdb_source_line_writer.cc
index 3c3401d2..f0edb721 100644
--- a/src/common/windows/pdb_source_line_writer.cc
+++ b/src/common/windows/pdb_source_line_writer.cc
@@ -33,6 +33,7 @@
#include <winnt.h>
#include <atlbase.h>
#include <dia2.h>
+#include <diacreate.h>
#include <ImageHlp.h>
#include <stdio.h>
@@ -121,6 +122,40 @@ class AutoImage {
PLOADED_IMAGE img_;
};
+bool CreateDiaDataSourceInstance(CComPtr<IDiaDataSource> &data_source) {
+ if (SUCCEEDED(data_source.CoCreateInstance(CLSID_DiaSource))) {
+ return true;
+ }
+
+ class DECLSPEC_UUID("B86AE24D-BF2F-4ac9-B5A2-34B14E4CE11D") DiaSource100;
+ class DECLSPEC_UUID("761D3BCD-1304-41D5-94E8-EAC54E4AC172") DiaSource110;
+ class DECLSPEC_UUID("3BFCEA48-620F-4B6B-81F7-B9AF75454C7D") DiaSource120;
+ class DECLSPEC_UUID("E6756135-1E65-4D17-8576-610761398C3C") DiaSource140;
+
+ // If the CoCreateInstance call above failed, msdia*.dll is not registered.
+ // We can try loading the DLL corresponding to the #included DIA SDK, but
+ // the DIA headers don't provide a version. Lets try to figure out which DIA
+ // version we're compiling against by comparing CLSIDs.
+ const wchar_t *msdia_dll = nullptr;
+ if (CLSID_DiaSource == _uuidof(DiaSource100)) {
+ msdia_dll = L"msdia100.dll";
+ } else if (CLSID_DiaSource == _uuidof(DiaSource110)) {
+ msdia_dll = L"msdia110.dll";
+ } else if (CLSID_DiaSource == _uuidof(DiaSource120)) {
+ msdia_dll = L"msdia120.dll";
+ } else if (CLSID_DiaSource == _uuidof(DiaSource140)) {
+ msdia_dll = L"msdia140.dll";
+ }
+
+ if (msdia_dll &&
+ SUCCEEDED(NoRegCoCreate(msdia_dll, CLSID_DiaSource, IID_IDiaDataSource,
+ reinterpret_cast<void **>(&data_source)))) {
+ return true;
+ }
+
+ return false;
+}
+
} // namespace
PDBSourceLineWriter::PDBSourceLineWriter() : output_(NULL) {
@@ -149,13 +184,10 @@ bool PDBSourceLineWriter::Open(const wstring &file, FileFormat format) {
}
CComPtr<IDiaDataSource> data_source;
- if (FAILED(data_source.CoCreateInstance(CLSID_DiaSource))) {
+ if (!CreateDiaDataSourceInstance(data_source)) {
const int kGuidSize = 64;
wchar_t classid[kGuidSize] = {0};
StringFromGUID2(CLSID_DiaSource, classid, kGuidSize);
- // vc80 uses bce36434-2c24-499e-bf49-8bd99b0eeb68.
- // vc90 uses 4C41678E-887B-4365-A09E-925D28DB33C2.
- // vc100 uses B86AE24D-BF2F-4AC9-B5A2-34B14E4CE11D.
fprintf(stderr, "CoCreateInstance CLSID_DiaSource %S failed "
"(msdia*.dll unregistered?)\n", classid);
return false;