Bug 1236343 - Cherry-pick upstream Breakpad commit "Try loading msdiaNNN.dll if CoCreateInstance(CLSID_DiaSource) fails". r=ted

1e24e66fbb

DONTBUILD because we don't build pdb_source_line_writer.cc yet.
This commit is contained in:
Birunthan Mohanathas 2016-02-17 11:36:19 -05:00
Родитель 2e94e291fd
Коммит a22220e378
1 изменённых файлов: 36 добавлений и 4 удалений

Просмотреть файл

@ -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;