• R/O
  • SSH
  • HTTPS

peframework: Commit


Commit MetaInfo

Revision15 (tree)
Time2017-08-03 00:59:52
Authorquiret

Log Message

- added more helper routines regarding exports

Change Summary

Incremental Difference

--- include/peloader.h (revision 14)
+++ include/peloader.h (revision 15)
@@ -1466,6 +1466,8 @@
14661466 void MapName( std::uint32_t ordinal, const char *name );
14671467 void RemoveExport( std::uint32_t ordinal );
14681468
1469+ func* ResolveExport( bool isOrdinal, std::uint32_t ordinal, const std::string& name );
1470+
14691471 PESectionAllocation funcAddressAllocEntry;
14701472 PESectionAllocation funcNamesAllocEntry;
14711473 PESectionAllocation funcOrdinalsAllocEntry;
--- src/peloader.exports.cpp (revision 14)
+++ src/peloader.exports.cpp (revision 15)
@@ -57,4 +57,43 @@
5757 }
5858 }
5959 }
60+}
61+
62+static inline std::uint32_t ResolveExportOrdinal( const PEFile::PEExportDir& expDir, bool isOrdinal, std::uint32_t ordinal, const std::string& name, bool& hasOrdinal )
63+{
64+ if ( isOrdinal )
65+ {
66+ hasOrdinal = true;
67+ // Need to subtract the ordinal base.
68+ return ( ordinal - expDir.ordinalBase );
69+ }
70+
71+ auto findIter = expDir.funcNameMap.find( name );
72+
73+ if ( findIter != expDir.funcNameMap.end() )
74+ {
75+ hasOrdinal = true;
76+ // Internally we do not store with ordinal base offset.
77+ return ( findIter->second );
78+ }
79+
80+ return false;
81+}
82+
83+PEFile::PEExportDir::func* PEFile::PEExportDir::ResolveExport( bool isOrdinal, std::uint32_t ordinal, const std::string& name )
84+{
85+ bool hasImportOrdinal = false;
86+ size_t impOrdinal = ResolveExportOrdinal( *this, isOrdinal, ordinal, name, hasImportOrdinal );
87+
88+ if ( hasImportOrdinal && impOrdinal < this->functions.size() )
89+ {
90+ PEFile::PEExportDir::func& expFunc = this->functions[ impOrdinal ];
91+
92+ if ( expFunc.isForwarder == false )
93+ {
94+ return &expFunc;
95+ }
96+ }
97+
98+ return NULL;
6099 }
\ No newline at end of file
Show on old repository browser