Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: src/common/windows/pdb_source_line_writer.cc

Issue 1601513002: Try loading msdiaNNN.dll if CoCreateInstance(CLSID_DiaSource) fails Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/common/windows/pdb_source_line_writer.cc
diff --git a/src/common/windows/pdb_source_line_writer.cc b/src/common/windows/pdb_source_line_writer.cc
index 3c3401d281ec816b775645437b558c3fcbb06d39..f0edb721c07e86bd9658a984be55e6bf23749dbe 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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698