summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsagitario <sagitario@fc51e93f-b9fe-4711-8d8d-3ae870c5f7d8>2012-06-18 17:53:58 (GMT)
committersagitario <sagitario@fc51e93f-b9fe-4711-8d8d-3ae870c5f7d8>2012-06-18 17:53:58 (GMT)
commitdd2882c90682885dea946a6e527645b4b237da99 (patch)
tree1fae6ef2e186224752e7f5bc6faffbfc67cd8372 /src
parentdd308fa75adfe87dbff2201f60972ecadfe14e68 (diff)
downloadcv2pdb-dd2882c90682885dea946a6e527645b4b237da99.zip
cv2pdb-dd2882c90682885dea946a6e527645b4b237da99.tar.gz
cv2pdb-dd2882c90682885dea946a6e527645b4b237da99.tar.bz2
v0.25
* new option -p allows to specify the embedded PDB reference in the binary * added support for VS2012
Diffstat (limited to 'src')
-rw-r--r--src/cv2pdb.cpp13
-rw-r--r--src/cv2pdb.h2
-rw-r--r--src/main.cpp7
-rw-r--r--src/mspdb.cpp20
-rw-r--r--src/mspdb.h108
5 files changed, 107 insertions, 43 deletions
diff --git a/src/cv2pdb.cpp b/src/cv2pdb.cpp
index 86e0409..1bbff16 100644
--- a/src/cv2pdb.cpp
+++ b/src/cv2pdb.cpp
@@ -125,15 +125,15 @@ bool CV2PDB::cleanup(bool commit)
return true;
}
-bool CV2PDB::openPDB(const TCHAR* pdbname)
+bool CV2PDB::openPDB(const TCHAR* pdbname, const TCHAR* pdbref)
{
#ifdef UNICODE
const wchar_t* pdbnameW = pdbname;
char pdbnameA[260]; // = L"c:\\tmp\\aa\\ddoc4.pdb";
- WideCharToMultiByte(CP_UTF8, 0, pdbname, -1, pdbnameA, 260, 0, 0);
+ WideCharToMultiByte(CP_UTF8, 0, pdbref ? pdbref : pdbname, -1, pdbnameA, 260, 0, 0);
// wcstombs (pdbnameA, pdbname, 260);
#else
- const char* pdbnameA = pdbname;
+ const char* pdbnameA = pdbref ? pdbref : pdbname;
wchar_t pdbnameW[260]; // = L"c:\\tmp\\aa\\ddoc4.pdb";
mbstowcs (pdbnameW, pdbname, 260);
#endif
@@ -3045,9 +3045,10 @@ bool CV2PDB::writeSymbols(mspdb::Mod* mod, DWORD* data, int databytes, int prefi
data[3] = 1;
int rc = mod->AddSymbols((BYTE*) data, ((databytes + 3) / 4 + prefix) * 4);
if (rc <= 0)
- return setError(mspdb::DBI::isVS10
- ? "cannot add symbols to module, probably msobj100.dll missing"
- : "cannot add symbols to module, probably msobj80.dll missing");
+ 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"
+ : "cannot add symbols to module, probably msobj80.dll missing");
return true;
}
diff --git a/src/cv2pdb.h b/src/cv2pdb.h
index 03e0b5e..efdf4fc 100644
--- a/src/cv2pdb.h
+++ b/src/cv2pdb.h
@@ -28,7 +28,7 @@ public:
~CV2PDB();
bool cleanup(bool commit);
- bool openPDB(const TCHAR* pdbname);
+ bool openPDB(const TCHAR* pdbname, const TCHAR* pdbref);
bool setError(const char* msg);
bool createModules();
diff --git a/src/main.cpp b/src/main.cpp
index 110589d..8c23cf3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -107,6 +107,7 @@ int T_main(int argc, TCHAR* argv[])
{
PEImage img;
double Dversion = 2.043;
+ const TCHAR* pdbref = 0;
while (argc > 1 && argv[1][0] == '-')
{
@@ -124,6 +125,8 @@ int T_main(int argc, TCHAR* argv[])
useTypedefEnum = true;
else if (argv[0][1] == 's' && argv[0][2])
dotReplacementChar = (char)argv[0][2];
+ else if (argv[0][1] == 'p' && argv[0][2])
+ pdbref = argv[0] + 2;
else
fatal("unknown option: " SARG, argv[0]);
}
@@ -136,7 +139,7 @@ int T_main(int argc, TCHAR* argv[])
printf("License for redistribution is given by the Artistic License 2.0\n");
printf("see file LICENSE for further details\n");
printf("\n");
- printf("usage: " SARG " [-Dversion|-C|-n|-sC] <exe-file> [new-exe-file] [pdb-file]\n", argv[0]);
+ printf("usage: " SARG " [-Dversion|-C|-n|-e|-sC|-pembedded-pdb] <exe-file> [new-exe-file] [pdb-file]\n", argv[0]);
return -1;
}
@@ -169,7 +172,7 @@ int T_main(int argc, TCHAR* argv[])
T_unlink(pdbname);
- if(!cv2pdb.openPDB(pdbname))
+ if(!cv2pdb.openPDB(pdbname, pdbref))
fatal(SARG ": %s", pdbname, cv2pdb.getLastError());
if(img.hasDWARF())
diff --git a/src/mspdb.cpp b/src/mspdb.cpp
index ee30833..3602ccd 100644
--- a/src/mspdb.cpp
+++ b/src/mspdb.cpp
@@ -15,8 +15,9 @@ mspdb::fnPDBOpen2W *pPDBOpen2W;
char* mspdb80_dll = "mspdb80.dll";
char* mspdb100_dll = "mspdb100.dll";
+char* mspdb110_dll = "mspdb110.dll";
-bool mspdb::DBI::isVS10 = false;
+int mspdb::vsVersion = 8;
bool getInstallDir(const char* version, char* installDir, DWORD size)
{
@@ -51,6 +52,7 @@ bool initMsPdb()
if (!modMsPdb)
modMsPdb = LoadLibraryA(mspdb80_dll);
+#if 1
if (!modMsPdb)
tryLoadMsPdb("VisualStudio\\9.0", mspdb80_dll);
if (!modMsPdb)
@@ -59,6 +61,7 @@ bool initMsPdb()
tryLoadMsPdb("VCExpress\\9.0", mspdb80_dll);
if (!modMsPdb)
tryLoadMsPdb("VCExpress\\8.0", mspdb80_dll);
+#endif
#if 1
if (!modMsPdb)
@@ -69,7 +72,20 @@ bool initMsPdb()
if (!modMsPdb)
tryLoadMsPdb("VCExpress\\10.0", mspdb100_dll);
if (modMsPdb)
- mspdb::DBI::isVS10 = true;
+ mspdb::vsVersion = 10;
+ }
+#endif
+
+#if 1
+ if (!modMsPdb)
+ {
+ modMsPdb = LoadLibraryA(mspdb110_dll);
+ if (!modMsPdb)
+ tryLoadMsPdb("VisualStudio\\11.0", mspdb110_dll);
+ if (!modMsPdb)
+ tryLoadMsPdb("VCExpress\\11.0", mspdb110_dll);
+ if (modMsPdb)
+ mspdb::vsVersion = 11;
}
#endif
diff --git a/src/mspdb.h b/src/mspdb.h
index a0abf78..9c48342 100644
--- a/src/mspdb.h
+++ b/src/mspdb.h
@@ -33,6 +33,7 @@ struct Mod;
struct StreamCached;
struct GSI;
struct TPI;
+struct IPI;
struct NameMap;
struct EnumNameMap;
@@ -51,6 +52,9 @@ struct EnumNameMap;
#define EnumNameMap2 EnumNameMap
struct DBI;
+
+extern int vsVersion;
+
/*
#define DBICommon DBI
#define DBI2 DBI
@@ -198,35 +202,76 @@ public: virtual void MRECmp::structIsBoring(unsigned long);
typedef int __cdecl fnPDBOpen2W(unsigned short const *path,char const *mode,long *p,
unsigned short *ext,unsigned int flags,struct PDB **pPDB);
-struct PDB {
-public: static int __cdecl PDBCommon::Open2W(unsigned short const *path,char const *mode,long *p,unsigned short *ext,unsigned int flags,struct PDB **pPDB);
-
-public: virtual unsigned long PDB::QueryInterfaceVersion(void);
-public: virtual unsigned long PDB::QueryImplementationVersion(void);
-public: virtual long PDBCommon::QueryLastError(char * const);
-public: virtual char * PDB::QueryPDBName(char * const);
-public: virtual unsigned long PDB::QuerySignature(void);
-public: virtual unsigned long PDB::QueryAge(void);
-public: virtual int PDB::CreateDBI(char const *,struct DBI * *);
-public: virtual int PDB::OpenDBI(char const *,char const *,struct DBI * *);
-public: virtual int PDB::OpenTpi(char const *,struct TPI * *);
-public: virtual int PDB::Commit(void);
-public: virtual int PDB::Close(void);
-public: virtual int PDBCommon::OpenStreamW(unsigned short const *,struct Stream * *);
-public: virtual int PDB::GetEnumStreamNameMap(struct Enum * *);
-public: virtual int PDB::GetRawBytes(int (__cdecl*)(void const *,long));
-public: virtual unsigned long PDB::QueryPdbImplementationVersion(void);
-public: virtual int PDB::OpenDBIEx(char const *,char const *,struct DBI * *,int (__stdcall*)(struct _tagSEARCHDEBUGINFO *));
-public: virtual int PDBCommon::CopyTo(char const *,unsigned long,unsigned long);
-public: virtual int PDB::OpenSrc(struct Src * *);
-public: virtual long PDB::QueryLastErrorExW(unsigned short *,unsigned int);
-public: virtual unsigned short * PDB::QueryPDBNameExW(unsigned short *,unsigned int);
-public: virtual int PDB::QuerySignature2(struct _GUID *);
-public: virtual int PDBCommon::CopyToW(unsigned short const *,unsigned long,unsigned long);
-public: virtual int PDB::fIsSZPDB(void)const ;
-public: virtual int PDB::containsW(unsigned short const *,unsigned long *);
-public: virtual int PDB::CopyToW2(unsigned short const *,unsigned long,int (__cdecl*(__cdecl*)(void *,enum PCC))(void),void *);
-public: virtual int PDB::OpenStreamEx(char const *,char const *,struct Stream * *);
+struct PDB_part1 {
+public: virtual unsigned long QueryInterfaceVersion(void);
+public: virtual unsigned long QueryImplementationVersion(void);
+public: virtual long QueryLastError(char * const);
+public: virtual char * QueryPDBName(char * const);
+public: virtual unsigned long QuerySignature(void);
+public: virtual unsigned long QueryAge(void);
+public: virtual int CreateDBI(char const *,struct DBI * *);
+public: virtual int OpenDBI(char const *,char const *,struct DBI * *);
+public: virtual int OpenTpi(char const *,struct TPI * *);
+};
+
+struct PDB_part_vs11 : public PDB_part1 {
+public: virtual int OpenIpi(char const *,struct IPI * *); // VS11
+};
+
+template<class BASE>
+struct PDB_part2 : public BASE {
+public: virtual int Commit(void);
+public: virtual int Close(void);
+public: virtual int OpenStreamW(unsigned short const *,struct Stream * *);
+public: virtual int GetEnumStreamNameMap(struct Enum * *);
+public: virtual int GetRawBytes(int (__cdecl*)(void const *,long));
+public: virtual unsigned long QueryPdbImplementationVersion(void);
+public: virtual int OpenDBIEx(char const *,char const *,struct DBI * *,int (__stdcall*)(struct _tagSEARCHDEBUGINFO *));
+public: virtual int CopyTo(char const *,unsigned long,unsigned long);
+public: virtual int OpenSrc(struct Src * *);
+public: virtual long QueryLastErrorExW(unsigned short *,unsigned int);
+public: virtual unsigned short * QueryPDBNameExW(unsigned short *,unsigned int);
+public: virtual int QuerySignature2(struct _GUID *);
+public: virtual int CopyToW(unsigned short const *,unsigned long,unsigned long);
+public: virtual int fIsSZPDB(void)const ;
+public: virtual int containsW(unsigned short const *,unsigned long *);
+public: virtual int CopyToW2(unsigned short const *,unsigned long,int (__cdecl*(__cdecl*)(void *,enum PCC))(void),void *);
+public: virtual int OpenStreamEx(char const *,char const *,struct Stream * *);
+};
+
+struct PDB_VS10 : public PDB_part2<PDB_part1> {};
+struct PDB_VS11 : public PDB_part2<PDB_part_vs11> {};
+
+struct PDB
+{
+ PDB_VS10 vs10;
+
+public:
+ static int __cdecl Open2W(unsigned short const *path,char const *mode,long *p,unsigned short *ext,unsigned int flags,struct PDB **pPDB);
+
+ unsigned long QueryAge() { return vs10.QueryAge(); }
+ int CreateDBI(char const *n,struct DBI * *pdbi) { return vs10.CreateDBI(n, pdbi); }
+ int OpenTpi(char const *n,struct TPI * *ptpi) { return vs10.OpenTpi(n, ptpi); }
+ long QueryLastError(char * const lastErr) { return vs10.QueryLastError(lastErr); }
+
+ int Commit()
+ {
+ if(vsVersion >= 11)
+ return ((PDB_VS11*)&vs10)->Commit();
+ return vs10.Commit();
+ }
+ int Close()
+ {
+ if(vsVersion >= 11)
+ return ((PDB_VS11*)&vs10)->Close();
+ return vs10.Close();
+ }
+ int QuerySignature2(struct _GUID *guid)
+ {
+ if(vsVersion >= 11)
+ return ((PDB_VS11*)&vs10)->QuerySignature2(guid);
+ return vs10.QuerySignature2(guid);
+ }
};
struct Src {
@@ -414,7 +459,6 @@ struct DBI_VS10 : public DBI_BASE<DBI_part2> {};
struct DBI
{
- static bool isVS10;
DBI_VS9 vs9;
unsigned long QueryImplementationVersion() { return vs9.QueryImplementationVersion(); }
@@ -425,13 +469,13 @@ struct DBI
int AddPublic2(char const *name,unsigned short sec,long off,unsigned long type)
{
- if(isVS10)
+ if(vsVersion >= 10)
return ((DBI_VS10*) &vs9)->AddPublic2(name, sec, off, type);
return vs9.AddPublic2(name, sec, off, type);
}
void SetMachineType(unsigned short type)
{
- if(isVS10)
+ if(vsVersion >= 10)
return ((DBI_VS10*) &vs9)->SetMachineType(type);
return vs9.SetMachineType(type);
}