; // Lista Procesos de forma nativa con la API NtQuerySystemInformation
; // Escrito por Juan fary (mDrinky)
; // [email protected]
; // Ensamblador: Flat Assembler
include 'win32ax.inc'
entry start
.data
Buffer dd 0
len dd 0
nBytes dd ?
.code
start:
add [len],0x1000
cinvoke realloc,[Buffer],[len]
mov [Buffer],eax
invoke NtQuerySystemInformation,5,[Buffer],[len],addr nBytes
cmp eax,0xC0000004
je start
ListarProcesos:
mov eax,[Buffer]
mov eax,[eax+0x3C] ; Nombre del proceso
;mov eax,[eax+0x44] ; ID del proceso
test eax,eax
je SiguienteProceso
push eax
invoke MessageBoxW,0,eax,0,0
pop eax
mov eax,[Buffer] ; puntero a estructura
mov eax,[eax] ; Distancia que habria que recorrer hasta la siguiente estructura
cmp eax,0 ; Si es 0 no hay mas estructuras
je salir
SiguienteProceso:
mov eax,[Buffer]
mov edx,eax ; Puntero a estructura en EDX
mov eax,[eax] ; EAX = NextEntryDelta
add edx,eax ; Sumamos la distancia de la siguiente estructura
mov [Buffer],edx ; Siguiente Estructura
jmp ListarProcesos
salir:
ret
section '.idata' data readable import
library msvcrt,'msvcrt.dll',\
NTDLL,'NTDLL.DLL',\
USER32,'USER32.DLL'
import msvcrt,\
realloc,'realloc'
import NTDLL,\
NtQuerySystemInformation,'NtQuerySystemInformation'
import USER32,\
MessageBoxW,'MessageBoxW'
Me costo crear el código ya que hay poca documentación y mucha de la que hay es erronea, asique tuve que debuguear la API en un proceso externo y ver finalmente como eran las estructuras y en que posición estaba el ID del proceso y el nombre.