20 moduleData = peconv::alloc_unaligned(_moduleSize);
39 std::cout <<
"Deleting cached module...\n";
61 std::cout <<
"Cache initialized\n";
70 BYTE*
loadCached(LPSTR szModName,
size_t& original_size);
77 std::map<std::string, CachedModule*>::iterator itr =
cachedModules.find(modName);
80 if (!cached)
return nullptr;
106 DWORD lTimestamp = 0;
107 DWORD gTimestamp = 0;
108 std::map<std::string, CachedModule*>::iterator foundItr =
cachedModules.end();
110 std::map<std::string, CachedModule*>::iterator itr;
115 if ((lTimestamp == 0) || (mod->
lastUsage < lTimestamp)) {
120 if ((gTimestamp == 0) || (mod->
lastUsage > gTimestamp)) {
125 if ((gTimestamp == lTimestamp) || (foundItr ==
cachedModules.end())) {
129 std::cout <<
"Deleting the least recent module: " << foundItr->first <<
" timestamp: " << lTimestamp <<
"\n";
143 std::map<std::string, CachedModule*>::iterator itr;
149 std::cout <<
"[" << i++ <<
"] Deleting cached module: " << itr->first <<
"\n";
157 std::cout <<
"Cache deleted. Total: " << i <<
" modules.\n";
BYTE * getMappedCached(const std::string &modName, size_t &mappedSize)
bool isCacheAvailable(const size_t neededSize)
BYTE * loadCached(LPSTR szModName, size_t &original_size)
bool _deleteLeastRecent()
std::map< std::string, CachedModule * > cachedModules
the list of all the cached modules
static const size_t MinUsageCntr
how many times loading of the module must be requested before the module is added to cache
std::map< std::string, size_t > usageBeforeCounter
how many times loading of the same module was requested before it was cached
bool prepareCacheSpace(const size_t neededSize, bool force_free)
CachedModule(BYTE *_moduleData, size_t _moduleSize)
BYTE * mapFromCached(size_t &mappedSize) const