Новичок
Профиль
Группа: Участник
Сообщений: 35
Регистрация: 11.7.2011
Репутация: 1 Всего: 1
|
Полазил в сети нашел один пример на основе его написал код: | Код | use Win32::API; use Data::Dumper; use constant TH32CS_SNAPPROCESS => 0x00000002; use constant DWORD_SIZE => 4; use constant LONG_SIZE => 4; use constant MAX_PATH_SIZE => 260;
my @pList; my $process; my $pe32; my $CreateToolhelp32Snapshot = Win32::API->new('kernel32','CreateToolhelp32Snapshot', 'NN', 'I' ); my $Process32First = Win32::API->new('kernel32','Process32First','IP','I'); my $Process32Next = Win32::API->new('kernel32','Process32Next','IP','I');
$hSnap = $CreateToolhelp32Snapshot->Call(TH32CS_SNAPPROCESS,0); $pe32 = " " x (DWORD_SIZE*8+LONG_SIZE+MAX_PATH_SIZE); if ( $Process32First->Call($hSnap,$pe32) ) { do { # Empty hash $process={};
# Unpack structure to hash ($process->{dwSize}, $process->{cntUsage}, $process->{th32ProcessID}, $process->{th32DefaultHeapID}, $process->{th32ModuleID}, $process->{cntThreads}, $process->{th32ParentProcessID}, $process->{pcPriClassBase}, $process->{dwFlags}, $process->{szExeFile}) = unpack("LLLLLLLlLA*",$pe32);
# Push process to list push(@pList,$process);
# Fill in the size of the structure again with blanks. $pe32 = " " x (DWORD_SIZE*8+LONG_SIZE+MAX_PATH_SIZE);
} while ($Process32Next->Call($hSnap, $pe32)); } print Dumper @pList;
|
Код выводит список процессов: | Цитата | $VAR19 = { 'szExeFile' => 'nvsvc32.exe', 'cntThreads' => 4, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 1992, 'th32ParentProcessID' => 724, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR20 = { 'szExeFile' => 'daemonu.exe', 'cntThreads' => 7, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 168, 'th32ParentProcessID' => 724, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR21 = { 'szExeFile' => 'SPIDERNT.EXE', 'cntThreads' => 6, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 248, 'th32ParentProcessID' => 724, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR22 = { 'szExeFile' => 'soundman.exe', 'cntThreads' => 2, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 1516, 'th32ParentProcessID' => 1696, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR23 = { 'szExeFile' => 'rundll32.exe', 'cntThreads' => 2, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 1716, 'th32ParentProcessID' => 1696, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR24 = { 'szExeFile' => 'jusched.exe', 'cntThreads' => 1, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 884, 'th32ParentProcessID' => 1696, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR25 = { 'szExeFile' => 'drwagnui.exe', 'cntThreads' => 4, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 976, 'th32ParentProcessID' => 1696, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR26 = { 'szExeFile' => 'drwagntd.exe', 'cntThreads' => 17, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 1100, 'th32ParentProcessID' => 724, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR27 = { 'szExeFile' => 'SPIDERUI.EXE', 'cntThreads' => 4, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 548, 'th32ParentProcessID' => 1696, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR28 = { 'szExeFile' => 'alg.exe', 'cntThreads' => 5, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 2240, 'th32ParentProcessID' => 724, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR29 = { 'szExeFile' => 'ctfmon.exe', 'cntThreads' => 1, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 2284, 'th32ParentProcessID' => 1696, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR30 = { 'szExeFile' => 'googletalk.exe', 'cntThreads' => 18, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 2400, 'th32ParentProcessID' => 1696, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR31 = { 'szExeFile' => 'ExpanDrive.exe', 'cntThreads' => 9, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 2540, 'th32ParentProcessID' => 1696, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR32 = { 'szExeFile' => 'Skype.exe', 'cntThreads' => 36, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 2676, 'th32ParentProcessID' => 1696, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR33 = { 'szExeFile' => 'putty.exe', 'cntThreads' => 2, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 3672, 'th32ParentProcessID' => 1696, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR34 = { 'szExeFile' => 'firefox.exe', 'cntThreads' => 35, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 1084, 'th32ParentProcessID' => 1696, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR35 = { 'szExeFile' => 'thunderbird.exe', 'cntThreads' => 27, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 3948, 'th32ParentProcessID' => 1696, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR36 = { 'szExeFile' => 'komodo.exe', 'cntThreads' => 20, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 3944, 'th32ParentProcessID' => 2236, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR37 = { 'szExeFile' => 'jucheck.exe', 'cntThreads' => 4, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 2640, 'th32ParentProcessID' => 884, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR38 = { 'szExeFile' => 'plugin-container.e 'cntThreads' => 25, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 3728, 'th32ParentProcessID' => 1084, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR39 = { 'szExeFile' => 'Geany.exe', 'cntThreads' => 5, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 2600, 'th32ParentProcessID' => 1696, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR40 = { 'szExeFile' => 'calc.exe', 'cntThreads' => 2, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 2560, 'th32ParentProcessID' => 1696, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR41 = { 'szExeFile' => 'cmd.exe', 'cntThreads' => 1, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 632, 'th32ParentProcessID' => 3460, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; $VAR42 = { 'szExeFile' => 'perl.exe', 'cntThreads' => 1, 'th32ModuleID' => 0, 'cntUsage' => 0, 'pcPriClassBase' => 8, 'dwSize' => 538976288, 'th32ProcessID' => 584, 'th32ParentProcessID' => 632, 'th32DefaultHeapID' => 0, 'dwFlags' => 0 }; Для продолжения нажмите любую клавишу . . .
|
В общем работает, пример на основе которого я написал код можете посмотреть тут
|