News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

List of running processes

Started by Vortex, August 21, 2012, 06:18:47 PM

Previous topic - Next topic

Vortex

Here is an example listing running processes :

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

TouEnMasm

Hello,
Thelp32 provide also:
Quote
Heap32ListFirst PROTO :DWORD ,:DWORD
Heap32ListNext PROTO :DWORD ,:DWORD
;-----------------------------------------------------
Heap32First PROTO :DWORD ,:DWORD ,:DWORD
Heap32Next PROTO :DWORD
;-----------------------------------------------------------------------
Toolhelp32ReadProcessMemory PROTO :DWORD ,:DWORD ,:DWORD ,:DWORD ,:DWORD
;------------------------------------
Module32First PROTO :DWORD ,:DWORD
Module32Next PROTO :DWORD ,:DWORD
;----------------------------------
Fa is a musical note to play with CL