diff options
author | Rainer Schuetze <r.sagitario@gmx.de> | 2020-03-26 21:40:24 (GMT) |
---|---|---|
committer | Rainer Schuetze <r.sagitario@gmx.de> | 2020-03-26 21:40:24 (GMT) |
commit | 243f8daa3289f205bad5dd73e425fea9c6761236 (patch) | |
tree | 83f9388e22151b69d698de876d131490f7b1ca9c /src/PEImage.cpp | |
parent | 191f0a0b1131e5d095637a9381787f7779766ec5 (diff) | |
download | cv2pdb-243f8daa3289f205bad5dd73e425fea9c6761236.zip cv2pdb-243f8daa3289f205bad5dd73e425fea9c6761236.tar.gz cv2pdb-243f8daa3289f205bad5dd73e425fea9c6761236.tar.bz2 |
fix issue #59: add DWARF support for symbol to imported data
Diffstat (limited to 'src/PEImage.cpp')
-rw-r--r-- | src/PEImage.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/PEImage.cpp b/src/PEImage.cpp index 5808cf9..1f916c2 100644 --- a/src/PEImage.cpp +++ b/src/PEImage.cpp @@ -783,14 +783,33 @@ const char* PEImage::findSectionSymbolName(int s) const return t_findSectionSymbolName<IMAGE_SYMBOL> (s);
}
-int PEImage::findSymbol(const char* name, unsigned long& off) const
+bool symbolMatches(const char* name, const char* symname, bool& dllimport)
+{
+ if (strcmp(symname, name) == 0)
+ return true;
+ if (symname[0] != '_')
+ return false;
+ if (strcmp(symname + 1, name) == 0)
+ return true;
+
+ if (strncmp(symname + 1, "_imp_", 5) == 0)
+ symname += 6;
+ else
+ return false;
+ if (strcmp(symname, name) != 0 && (symname[0] != '_' || strcmp(symname + 1, name) != 0))
+ return false;
+ dllimport = true;
+ return true;
+}
+
+int PEImage::findSymbol(const char* name, unsigned long& off, bool& dllimport) const
{
int sizeof_sym = bigobj ? sizeof(IMAGE_SYMBOL_EX) : IMAGE_SIZEOF_SYMBOL;
for(int i = 0; i < nsym; i++)
{
IMAGE_SYMBOL* sym = (IMAGE_SYMBOL*) (symtable + i * sizeof_sym);
const char* symname = sym->N.Name.Short == 0 ? strtable + sym->N.Name.Long : (char*)sym->N.ShortName;
- if(strcmp(symname, name) == 0 || (symname[0] == '_' && strcmp(symname + 1, name) == 0))
+ if(symbolMatches(name, symname, dllimport))
{
off = sym->Value;
return bigobj ? ((IMAGE_SYMBOL_EX*)sym)->SectionNumber : sym->SectionNumber;
|