; // 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.
un saludo!
Gran codigo mDrinky :)
Gracias, Saludos.
Dejo la estructura Correcta, en C (El código de las estructuras no es mio lo saque de por ahí.)
typedef struct {
USHORT Length;
USHORT MaxLen;
USHORT *Buffer;
}UNICODE_STRING;
struct process_info {
ULONG NextEntryDelta;
ULONG ThreadCount;
ULONG Reserved1[6];
LARGE_INTEGER CreateTime;
LARGE_INTEGER UserTime;
LARGE_INTEGER KernelTime;
UNICODE_STRING ProcessName;
ULONG BasePriority;
ULONG ProcessId;
};
un saludo!
HOLA!!!
Felicitaciones Lo LOGRASTE!
GRACIAS POR LEER!!!
Aquí está el código en VB6 por si a alguien le interesa ;D
http://foro.elhacker.net/programacion_visual_basic/ntdll_systemprocessesandthreadsinformation-t303891.0.html
Gracias mDrinky muy bonito código a estudiar un ratito ;D