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
This commit is contained in:
parent
7b25f70813
commit
25f913e981
1 changed files with 36 additions and 4 deletions
|
@ -33,6 +33,7 @@
|
||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
#include <atlbase.h>
|
#include <atlbase.h>
|
||||||
#include <dia2.h>
|
#include <dia2.h>
|
||||||
|
#include <diacreate.h>
|
||||||
#include <ImageHlp.h>
|
#include <ImageHlp.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -121,6 +122,40 @@ class AutoImage {
|
||||||
PLOADED_IMAGE img_;
|
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
|
} // namespace
|
||||||
|
|
||||||
PDBSourceLineWriter::PDBSourceLineWriter() : output_(NULL) {
|
PDBSourceLineWriter::PDBSourceLineWriter() : output_(NULL) {
|
||||||
|
@ -149,13 +184,10 @@ bool PDBSourceLineWriter::Open(const wstring &file, FileFormat format) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CComPtr<IDiaDataSource> data_source;
|
CComPtr<IDiaDataSource> data_source;
|
||||||
if (FAILED(data_source.CoCreateInstance(CLSID_DiaSource))) {
|
if (!CreateDiaDataSourceInstance(data_source)) {
|
||||||
const int kGuidSize = 64;
|
const int kGuidSize = 64;
|
||||||
wchar_t classid[kGuidSize] = {0};
|
wchar_t classid[kGuidSize] = {0};
|
||||||
StringFromGUID2(CLSID_DiaSource, classid, kGuidSize);
|
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 "
|
fprintf(stderr, "CoCreateInstance CLSID_DiaSource %S failed "
|
||||||
"(msdia*.dll unregistered?)\n", classid);
|
"(msdia*.dll unregistered?)\n", classid);
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue