summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsagitario <sagitario@fc51e93f-b9fe-4711-8d8d-3ae870c5f7d8>2013-11-25 08:34:17 (GMT)
committersagitario <sagitario@fc51e93f-b9fe-4711-8d8d-3ae870c5f7d8>2013-11-25 08:34:17 (GMT)
commitd37bb77e8afe142177e726212da13ba0a3630d12 (patch)
treeeb146c400f6d2ee3c8dabe177359e8d905c23dd7 /src
parentddef976e546d947c6b47cb058af86a9bd759d1e3 (diff)
downloadcv2pdb-d37bb77e8afe142177e726212da13ba0a3630d12.zip
cv2pdb-d37bb77e8afe142177e726212da13ba0a3630d12.tar.gz
cv2pdb-d37bb77e8afe142177e726212da13ba0a3630d12.tar.bz2
2013-11-16 Version 0.28
* added searching mspdb120.dll for VS 2013 * changed search order for mspdb*.dll: trying to load through PATH first newest VS versions preferred, then trying through installation paths for VS 2013-2005 * dviewhelper.dll now avoids being reloaded for every expression
Diffstat (limited to 'src')
-rw-r--r--src/cv2pdb.cpp1
-rw-r--r--src/dviewhelper/dviewhelper.cpp13
-rw-r--r--src/mspdb.cpp90
3 files changed, 84 insertions, 20 deletions
diff --git a/src/cv2pdb.cpp b/src/cv2pdb.cpp
index 1bbff16..2388844 100644
--- a/src/cv2pdb.cpp
+++ b/src/cv2pdb.cpp
@@ -3048,6 +3048,7 @@ bool CV2PDB::writeSymbols(mspdb::Mod* mod, DWORD* data, int databytes, int prefi
return setError(
mspdb::vsVersion == 10 ? "cannot add symbols to module, probably msobj100.dll missing"
: mspdb::vsVersion == 11 ? "cannot add symbols to module, probably msobj110.dll missing"
+ : mspdb::vsVersion == 12 ? "cannot add symbols to module, probably msobj120.dll missing"
: "cannot add symbols to module, probably msobj80.dll missing");
return true;
}
diff --git a/src/dviewhelper/dviewhelper.cpp b/src/dviewhelper/dviewhelper.cpp
index f777e20..350c3a2 100644
--- a/src/dviewhelper/dviewhelper.cpp
+++ b/src/dviewhelper/dviewhelper.cpp
@@ -212,4 +212,17 @@ HRESULT WINAPI DObjectView(DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOO
return S_OK;
}
+// avoid unloading the DLL with every expression
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ if(fdwReason == DLL_PROCESS_ATTACH)
+ {
+ TCHAR moduleName[1024];
+
+ if(GetModuleFileName(hinstDLL, moduleName, sizeof(moduleName)/ sizeof(TCHAR)))
+ LoadLibrary(moduleName);
+ }
+ return TRUE;
+}
+
} // extern "C"
diff --git a/src/mspdb.cpp b/src/mspdb.cpp
index fc1cdec..d4b01d8 100644
--- a/src/mspdb.cpp
+++ b/src/mspdb.cpp
@@ -16,10 +16,34 @@ mspdb::fnPDBOpen2W *pPDBOpen2W;
char* mspdb80_dll = "mspdb80.dll";
char* mspdb100_dll = "mspdb100.dll";
char* mspdb110_dll = "mspdb110.dll";
+char* mspdb120_dll = "mspdb120.dll";
// char* mspdb110shell_dll = "mspdbst.dll"; // the VS 2012 Shell uses this file instead of mspdb110.dll, but is missing mspdbsrv.exe
int mspdb::vsVersion = 8;
+// verify mspdbsrv.exe is found in the same path
+void tryLoadLibrary(const char* mspdb)
+{
+ if (modMsPdb)
+ return;
+ modMsPdb = LoadLibraryA(mspdb);
+ if (!modMsPdb)
+ return;
+
+ char modpath[260];
+ if(GetModuleFileNameA(modMsPdb, modpath, 260) < 260)
+ {
+ char* p = modpath + strlen(modpath);
+ while(p > modpath && p[-1] != '\\')
+ p--;
+ strcpy(p, "mspdbsrv.exe");
+ if(GetFileAttributesA(modpath) != INVALID_FILE_ATTRIBUTES)
+ return;
+ }
+ FreeLibrary(modMsPdb);
+ modMsPdb = NULL;
+}
+
bool getInstallDir(const char* version, char* installDir, DWORD size)
{
char key[260] = "SOFTWARE\\Microsoft\\";
@@ -34,7 +58,7 @@ bool getInstallDir(const char* version, char* installDir, DWORD size)
return rc;
}
-bool tryLoadMsPdb(const char* version, const char* mspdb)
+bool tryLoadMsPdb(const char* version, const char* mspdb, const char* path = 0)
{
char installDir[260];
if (!getInstallDir(version, installDir, sizeof(installDir)))
@@ -42,55 +66,74 @@ bool tryLoadMsPdb(const char* version, const char* mspdb)
char* p = installDir + strlen(installDir);
if (p[-1] != '\\' && p[-1] != '/')
*p++ = '\\';
+ if(path)
+ p += strlen(strcpy(p, path));
strcpy(p, mspdb);
- modMsPdb = LoadLibraryA(installDir);
+ tryLoadLibrary(installDir);
return modMsPdb != 0;
}
-void tryLoadMsPdb80()
+void tryLoadMsPdb80(bool throughPath)
{
- if (!modMsPdb)
- modMsPdb = LoadLibraryA(mspdb80_dll);
+ if (!modMsPdb && throughPath)
+ tryLoadLibrary(mspdb80_dll);
- if (!modMsPdb)
+ if (!modMsPdb && !throughPath)
tryLoadMsPdb("VisualStudio\\9.0", mspdb80_dll);
- if (!modMsPdb)
+ if (!modMsPdb && !throughPath)
tryLoadMsPdb("VisualStudio\\8.0", mspdb80_dll);
- if (!modMsPdb)
+ if (!modMsPdb && !throughPath)
tryLoadMsPdb("VCExpress\\9.0", mspdb80_dll);
- if (!modMsPdb)
+ if (!modMsPdb && !throughPath)
tryLoadMsPdb("VCExpress\\8.0", mspdb80_dll);
}
-void tryLoadMsPdb100()
+void tryLoadMsPdb100(bool throughPath)
{
if (!modMsPdb)
{
- modMsPdb = LoadLibraryA(mspdb100_dll);
- if (!modMsPdb)
+ if(throughPath)
+ modMsPdb = LoadLibraryA(mspdb100_dll);
+ if (!modMsPdb && !throughPath)
tryLoadMsPdb("VisualStudio\\10.0", mspdb100_dll);
- if (!modMsPdb)
+ if (!modMsPdb && !throughPath)
tryLoadMsPdb("VCExpress\\10.0", mspdb100_dll);
if (modMsPdb)
mspdb::vsVersion = 10;
}
}
-void tryLoadMsPdb110()
+void tryLoadMsPdb110(bool throughPath)
{
if (!modMsPdb)
{
- modMsPdb = LoadLibraryA(mspdb110_dll);
- if (!modMsPdb)
+ if (throughPath)
+ modMsPdb = LoadLibraryA(mspdb110_dll);
+ if (!modMsPdb && !throughPath)
tryLoadMsPdb("VisualStudio\\11.0", mspdb110_dll);
- if (!modMsPdb)
+ if (!modMsPdb && !throughPath)
tryLoadMsPdb("VSWinExpress\\11.0", mspdb110_dll);
if (modMsPdb)
mspdb::vsVersion = 11;
}
}
+void tryLoadMsPdb120(bool throughPath)
+{
+ if (!modMsPdb)
+ {
+ if(throughPath)
+ modMsPdb = LoadLibraryA(mspdb120_dll);
+ if (!modMsPdb && !throughPath)
+ tryLoadMsPdb("VisualStudio\\12.0", mspdb120_dll, "..\\..\\VC\\bin\\");
+ if (!modMsPdb && !throughPath)
+ tryLoadMsPdb("VSWinExpress\\12.0", mspdb120_dll, "..\\..\\VC\\bin\\");
+ if (modMsPdb)
+ mspdb::vsVersion = 12;
+ }
+}
+
bool initMsPdb()
{
#if 0 // might cause problems when combining VS Shell 2010 with VS 2008 or similar
@@ -105,9 +148,16 @@ bool initMsPdb()
}
#endif
- tryLoadMsPdb80();
- tryLoadMsPdb100();
- tryLoadMsPdb110();
+ // try loading through the PATH first to best match current setup
+ tryLoadMsPdb120(true);
+ tryLoadMsPdb110(true);
+ tryLoadMsPdb100(true);
+ tryLoadMsPdb80(true);
+
+ tryLoadMsPdb120(false);
+ tryLoadMsPdb110(false);
+ tryLoadMsPdb100(false);
+ tryLoadMsPdb80(false);
if (!modMsPdb)
return false;