Small tweak to process enumeration on Windows.

develop
Petr Mrázek 2011-05-23 03:24:16 +02:00
parent b7aef4d84c
commit c6b749e7e5
1 changed files with 6 additions and 3 deletions

@ -248,15 +248,18 @@ void ProcessEnumerator::Private::EnumPIDs (vector <ProcessID> &PIDs)
// Get the list of process identifiers. // Get the list of process identifiers.
DWORD ProcArray[2048], memoryNeeded, numProccesses; DWORD ProcArray[2048], memoryNeeded, numProccesses;
//EnableDebugPriv(); if(!EnableDebugPriv())
{
cerr << "Failed to acquire debug privileges." << endl;
}
if ( !EnumProcesses( ProcArray, sizeof(ProcArray), &memoryNeeded ) ) if ( !EnumProcesses( ProcArray, sizeof(ProcArray), &memoryNeeded ) )
{ {
cout << "EnumProcesses fail'd" << endl; cerr << "EnumProcesses fail'd" << endl;
return; return;
} }
// Calculate how many process identifiers were returned. // Calculate how many process identifiers were returned.
numProccesses = memoryNeeded / sizeof(DWORD); numProccesses = memoryNeeded / sizeof(DWORD);
EnableDebugPriv(); //EnableDebugPriv();
// iterate through processes // iterate through processes
for ( int i = 0; i < (int)numProccesses; i++ ) for ( int i = 0; i < (int)numProccesses; i++ )
{ {