NO

Author Topic: Listing processes  (Read 4116 times)

Offline Vortex

  • Member
  • *
  • Posts: 865
    • http://www.vortex.masmcode.com
Listing processes
« on: August 21, 2012, 10:16:14 AM »
Here is a quick example to list running processes :

Code: [Select]
include     Process.inc

.data

text1       db 'Process name: %s',9,9,'Process ID: %d',9,9,'Parent process: %d',13,10,0

.code

start:

    call    main
    invoke  ExitProcess,0

main PROC USES esi

LOCAL pe32:PROCESSENTRY32
LOCAL hProcessSnap:DWORD

    lea     esi,pe32
    invoke  CreateToolhelp32Snapshot,TH32CS_SNAPPROCESS,0
    mov     hProcessSnap,eax

    mov     pe32.dwSize,SIZEOF PROCESSENTRY32
    invoke  Process32First,eax,esi

@@:
    invoke  printf,ADDR text1,ADDR PROCESSENTRY32.szExeFile[esi],\
            PROCESSENTRY32.th32ProcessID[esi],\
            PROCESSENTRY32.th32ParentProcessID[esi]

    invoke  Process32Next,hProcessSnap,esi
    test    eax,eax
    jnz     @b
   
    invoke  CloseHandle,hProcessSnap
    ret

main ENDP

END start
Code it... That's all...