1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| #include <stdio.h>
#include <windows.h>
#include <tlhelp32.h>
int main(void)
{
HANDLE hSnapshot;
PROCESSENTRY32 pe;
MODULEENTRY32 me;
pe.dwSize = sizeof(pe);
me.dwSize = sizeof(me);
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,NULL);
if(Process32First(hSnapshot,&pe))
{
do {
HANDLE hSnapshot2;
printf("%s : ",pe.szExeFile);
hSnapshot2 = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,pe.th32ProcessID);
if(hSnapshot2 == INVALID_HANDLE_VALUE)
{
char buf[80];
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM,NULL,GetLastError(),0,buf,80,NULL);
CharToOemA(buf, buf);
printf("- ERREUR Snapshot: %s",buf);
continue;
}
if(Module32First(hSnapshot2, &me))
{
do {
#ifdef EXE_UNIQUEMENT
if(strstr(me.szModule,".exe") || strstr(me.szModule,".EXE"))
{
printf(" %s\n",me.szExePath);
}//if exe
#else
printf("%s\n",me.szExePath);
#endif
} while(Module32Next(hSnapshot2,&me));
}
else//Pas de module du tout/Erreur Module32First
{
char buf[80];
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,GetLastError(),0,buf,80,NULL);
printf("- %s",buf);
}//if Module32First
puts(" ");
CloseHandle(hSnapshot2);
} while(Process32Next(hSnapshot,&pe));
}//if Process32First
CloseHandle(hSnapshot);
return 0;
} |
Partager