#include <stdexcept>\r
#include <list>\r
#include <map>\r
+#include <vector>\r
#include <iomanip>\r
#include <fstream>\r
#include <sstream>\r
}\r
}\r
\r
+CFvMapFile::~CFvMapFile(void)\r
+{\r
+ Cleanup();\r
+}\r
+\r
void CFvMapFile::Cleanup(void)\r
{\r
for (iterator i = begin(); i != end(); i++)\r
delete i->second;\r
}\r
\r
+static bool map_less(const CFvMapFile::const_iterator& l, const CFvMapFile::const_iterator& r)\r
+{\r
+ return l->second->m_ullLoadAddr < r->second->m_ullLoadAddr;\r
+}\r
+\r
ostream& operator << (ostream& os, const CFvMapFile& fvMap)\r
{\r
- for (CFvMapFile::const_iterator i = fvMap.begin(); !!os && i != fvMap.end(); i++)\r
+ vector<CFvMapFile::const_iterator> rgIter;\r
+ rgIter.reserve(fvMap.size());\r
+ for (CFvMapFile::const_iterator i = fvMap.begin(); i != fvMap.end(); i++)\r
+ rgIter.push_back(i);\r
+ sort(rgIter.begin(), rgIter.end(), map_less);\r
+\r
+ for (vector<CFvMapFile::const_iterator>::const_iterator i = rgIter.begin(); i != rgIter.end(); i++)\r
{\r
- CMapFile::const_iterator j = i->second->begin();\r
- while (j != i->second->end() && j->m_strAddress != i->second->m_strEntryPoint) j++;\r
- if (j == i->second->end())\r
+ CMapFile::const_iterator j = (*i)->second->begin();\r
+ while (j != (*i)->second->end() && j->m_strAddress != (*i)->second->m_strEntryPoint) j++;\r
+ if (j == (*i)->second->end())\r
throw runtime_error(\r
__FUNCTION__ ":Entry point not found for module " +\r
- i->second->m_strModuleName);\r
+ (*i)->second->m_strModuleName);\r
\r
os << hex\r
- << i->second->m_strModuleName\r
- << " (EP=" << j->m_ullRva\r
- << ", BA=" << i->second->m_ullLoadAddr\r
- << ", GUID=" << i->first\r
+ << (*i)->second->m_strModuleName\r
+ << " (EntryPoint=" << j->m_ullRva\r
+ << ", BaseAddress=" << (*i)->second->m_ullLoadAddr\r
+ << ", GUID=" << (*i)->first\r
<< ")" << endl << endl;\r
\r
- for (j = i->second->begin(); j != i->second->end(); j++)\r
+ for (j = (*i)->second->begin(); j != (*i)->second->end(); j++)\r
os << " " << *j << endl;\r
\r
os << endl << endl;\r
return os;\r
}\r
\r
-CFvMapFile::~CFvMapFile(void)\r
-{\r
- Cleanup();\r
-}\r
-\r
class CGenFvMapUsage : public invalid_argument\r
{\r
public:\r