I'm getting started with the DIA SDK and have the following simple code:
#define PRINTIFHRIS(x) if (hr == x) printf(#x "\n");
int main()
{
HRESULT hr;
IDiaDataSource *ds = NULL;
wchar_t cwd[300];
GetCurrentDirectory(300, cwd);
printf("CWD: %S\n", cwd);
hr = CoInitialize(NULL);
assert(SUCCEEDED(hr));
hr = CoCreateInstance(
CLSID_DiaSource,
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(IDiaDataSource),
(void**)&ds
);
assert(SUCCEEDED(hr));
hr = ds->loadDataForExe(L"readpdb.exe", NULL, NULL);
PRINTIFHRIS(E_PDB_NOT_FOUND);
PRINTIFHRIS(E_PDB_FORMAT);
PRINTIFHRIS(E_PDB_INVALID_SIG);
PRINTIFHRIS(E_PDB_INVALID_AGE);
PRINTIFHRIS(E_INVALIDARG);
PRINTIFHRIS(E_UNEXPECTED);
PRINTIFHRIS(S_OK);
assert(SUCCEEDED(hr));
return 0;
}
If I start this from the Visual Studio IDE, it assert fails with E_PDB_NOT_FOUND, even if I start it without debugging. But if I start the very same program outside the IDE it works fine and returns S_OK. First I thought it's a working directory issue, so I put printf at the beginning to see if that's the problem, but it isn't the problem. The working directory is the same and PDB is there.
Does Visual Studio do something that affect the DIA SDK's behavior? I don't see anything in the documentation.