4 IMPLEMENT_THUNK( psapi
, WINDOWS
, BOOL
, WINAPI
, EnumProcesses
, ( LPDWORD lpProcesses
, DWORD cbSize
, LPDWORD lpcbCopied
) )
7 HANDLE hSnapshot
= CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
, 0 );
9 if ( IsValidHandle( hSnapshot
) )
16 pe
.dwSize
= sizeof(pe
);
17 if ( Process32First( hSnapshot
, &pe
) )
21 while ( cbSize
>= sizeof(*lpProcesses
) )
23 *(lpProcesses
++) = pe
.th32ProcessID
;
25 *lpcbCopied
+= sizeof(*lpProcesses
);
26 cbSize
-= sizeof(*lpProcesses
);
28 if ( !Process32Next( hSnapshot
, &pe
) )
33 CloseHandle( hSnapshot
);
36 SetLastError( ERROR_INVALID_HANDLE
);