72 if (moduleSize == 0) {
75 if (moduleSize == 0)
return 0;
78 std::set<ULONGLONG> relocs;
83 if (relocs.size() == 0) {
91 const ULONGLONG mask = ~ULONGLONG(0xFFFF);
92 std::map<ULONGLONG, size_t>base_candidates;
94 std::set<ULONGLONG>::iterator itr = relocs.begin();
96 for (itr = relocs.begin(); itr != relocs.end(); ++itr) {
97 const ULONGLONG guessed_base = (*itr) & mask;
98 std::map<ULONGLONG, size_t>::iterator found = base_candidates.find(guessed_base);
99 if (found == base_candidates.end()) {
100 base_candidates[guessed_base] = 0;
102 base_candidates[guessed_base]++;
104 ULONGLONG most_freqent = 0;
106 std::map<ULONGLONG, size_t>::iterator mapItr;
107 for (mapItr = base_candidates.begin(); mapItr != base_candidates.end(); ++mapItr) {
108 if (mapItr->second >= max_freq) {
109 most_freqent = mapItr->first;
110 max_freq = mapItr->second;
113 for (itr = relocs.begin(); itr != relocs.end(); ++itr) {
114 ULONGLONG first = *itr;
115 ULONGLONG first_base = first & mask;
116 if (first_base > most_freqent) {
119 ULONGLONG delta = most_freqent - first_base;
120 if (delta < moduleSize) {