float SystemLinux::GetPercentageOfUsedPhysicalMemory() const { MemoryInformation sMemoryInformation; if (GetMemoryInformation(sMemoryInformation)) return (static_cast<float>(sMemoryInformation.nTotalPhysicalMemory-sMemoryInformation.nFreePhysicalMemory)/sMemoryInformation.nTotalPhysicalMemory)*100.0f; else return 0.0f; }
void test(void) { std::list<PROCESSENTRY32> lProcess; std::list<MODULEENTRY32> lModules; DWORD dwPid = 0; std::list<MEMORY_BASIC_INFORMATION> lMemBI; std::list<THREADENTRY32> lThreads; std::list<LPCVOID> lAddress; DWORD dwBaseAddress = 0; IMAGE_DOS_HEADER DosHeader; IMAGE_NT_HEADERS NTHeader; lProcess = GetProcessList(); PrintProcessList(lProcess); dwPid = GetPidProcess("notepad++.exe"); PrintPidProcess("notepad++.exe", dwPid); lModules = GetModuleList(dwPid); PrintModulesList(lModules); lMemBI = GetMemoryInformation(dwPid); PrintMemoryInfo(lMemBI); lThreads = GetThreadsList(dwPid); PrintThreadsInfo(lThreads); SuspendAllThread(dwPid); Sleep(1000); ResumeAllThread(dwPid); lAddress = ScanPattern("\x42\x42\x42", 3, dwPid); PrintPatternMatch(lAddress); dwBaseAddress = GetRemoteBaseAddress(dwPid); printf("BaseAddress = %08X\n", dwBaseAddress); DosHeader = GetDosHeader(dwPid); PrintDosHeader(&DosHeader); NTHeader = GetNTHeader(dwPid); PrintNTHeader(&NTHeader); }
uint64 SystemLinux::GetFreeVirtualMemory() const { MemoryInformation sMemoryInformation; return GetMemoryInformation(sMemoryInformation) ? sMemoryInformation.nFreeSwapMemory : 0; }
uint64 SystemLinux::GetTotalVirtualMemory() const { MemoryInformation sMemoryInformation; return GetMemoryInformation(sMemoryInformation) ? sMemoryInformation.nTotalSwapMemory : 0; }
uint64 SystemLinux::GetFreePhysicalMemory() const { MemoryInformation sMemoryInformation; return GetMemoryInformation(sMemoryInformation) ? sMemoryInformation.nFreePhysicalMemory : 0; }