11 BYTE* raw_buf = peconv::load_file(szModName, raw_size);
16 bool force_free_cache =
false;
24 bool is_cached =
false;
31 std::cout <<
"Added to cache: " << szModName <<
" Total cached: " << cachedModulesCntr <<
"\n";
38 force_free_cache =
true;
47 mapped_pe = peconv::load_pe_module(raw_buf, raw_size, module_size,
false,
false);
48 peconv::free_file(raw_buf);
59 if (!GetProcessWorkingSetSizeEx(GetCurrentProcess(), &minSize, &maxSize, &
info)) {
61 std::cout <<
"GetProcessWorkingSetSizeEx failed!\n";
66 MEMORYSTATUSEX memStatus = { 0 };
67 memStatus.dwLength =
sizeof(MEMORYSTATUSEX);
69 if ((
info & QUOTA_LIMITS_HARDWS_MAX_DISABLE) == QUOTA_LIMITS_HARDWS_MAX_DISABLE) {
70 if (GlobalMemoryStatusEx(&memStatus)) {
71 if (memStatus.ullAvailVirtual > ((DWORDLONG)neededSize * 2) && (memStatus.dwMemoryLoad < 50)) {
77 PROCESS_MEMORY_COUNTERS ppsmemCounter = { 0 };
78 ppsmemCounter.cb =
sizeof(PROCESS_MEMORY_COUNTERS);
79 GetProcessMemoryInfo(GetCurrentProcess(), &ppsmemCounter,
sizeof(PROCESS_MEMORY_COUNTERS));
82 if (maxSize > ppsmemCounter.PeakWorkingSetSize) {
83 size_t freeMem = maxSize - ppsmemCounter.WorkingSetSize;
84 size_t percW1 = size_t(((
double)ppsmemCounter.WorkingSetSize / (
double)maxSize) * 100.0);
85 if (freeMem > (neededSize * 2) && (percW1 < 60)) {
89 size_t freeMemP = ppsmemCounter.PeakWorkingSetSize - ppsmemCounter.WorkingSetSize;
90 size_t percPeak = size_t(((
double)ppsmemCounter.WorkingSetSize / (
double)ppsmemCounter.PeakWorkingSetSize) * 100.0);
92 if (freeMemP > (neededSize * 2) && (percPeak < 70)) {
98 std::cout <<
"C: " << std::hex << ppsmemCounter.WorkingSetSize
99 <<
"\tP: " << std::hex << ppsmemCounter.PeakWorkingSetSize
100 <<
"\tMin: " << minSize
101 <<
"\tMax: " << maxSize
102 <<
"\tGlobalMem Av Virt: " << std::hex << memStatus.ullAvailVirtual
103 << std::dec <<
"\tPerc: " << memStatus.dwMemoryLoad
104 << std::dec <<
" PercPeak: " << percPeak
105 <<
" HasFree: " << hasFree
106 <<
" modulesCount: " << cachedModules.size()