Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <stdio.h>
- #include <psapi.h>
- void PrintMemoryInfo( DWORD processID )
- {
- HANDLE hProcess;
- PROCESS_MEMORY_COUNTERS_EX pmc;
- printf( "\nProcess ID: %u\n", processID );
- hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID );
- if (NULL == hProcess) return;
- ZeroMemory(&pmc,sizeof(pmc));
- if ( GetProcessMemoryInfo( hProcess, (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc)) )
- {
- printf( "\tPageFaultCount: 0x%08X\n", pmc.PageFaultCount );
- printf( "\tPeakWorkingSetSize: 0x%08X\n", pmc.PeakWorkingSetSize );
- printf( "\tWorkingSetSize: 0x%08X\n", pmc.WorkingSetSize );
- printf( "\tQuotaPeakPagedPoolUsage: 0x%08X\n", pmc.QuotaPeakPagedPoolUsage );
- printf( "\tQuotaPagedPoolUsage: 0x%08X\n", pmc.QuotaPagedPoolUsage );
- printf( "\tQuotaPeakNonPagedPoolUsage: 0x%08X\n", pmc.QuotaPeakNonPagedPoolUsage );
- printf( "\tQuotaNonPagedPoolUsage: 0x%08X\n", pmc.QuotaNonPagedPoolUsage );
- printf( "\tPagefileUsage: 0x%08X\n", pmc.PagefileUsage );
- printf( "\tPeakPagefileUsage: 0x%08X\n", pmc.PeakPagefileUsage );
- printf( "\tPrivateUsage: 0x%08X\n", pmc.PrivateUsage );
- }
- CloseHandle( hProcess );
- }
- int main( )
- {
- DWORD aProcesses[1024], cbNeeded, cProcesses;
- unsigned int i;
- if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
- return 1;
- cProcesses = cbNeeded / sizeof(DWORD);
- for ( i = 0; i < cProcesses; i++ )
- PrintMemoryInfo( aProcesses[i] );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement