Código
#include <Windows.h> #include <winternl.h> #include <stdio.h> #pragma comment(lib, "ntdll.lib") typedef struct _CLIENT_ID { PVOID UniqueProcess; PVOID UniqueThread; } CLIENT_ID, *PCLIENT_ID; EXTERN_C NTSTATUS NTAPI NtOpenProcess(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, PCLIENT_ID); EXTERN_C NTSTATUS NTAPI NtTerminateProcess(HANDLE, NTSTATUS); void main() { OBJECT_ATTRIBUTES oa; HANDLE hProc; ULONG pid; CLIENT_ID cid; printf("\n introduce pid-> "); scanf("%ld", &pid); cid.UniqueProcess = (HANDLE)pid; cid.UniqueThread = 0; InitializeObjectAttributes(&oa, NULL, 0, NULL, NULL); if(NT_SUCCESS(NtOpenProcess(&hProc, PROCESS_TERMINATE, &oa, &cid))) { NTSTATUS status = NtTerminateProcess(hProc, 1); if(NT_SUCCESS(status)) { MessageBoxW(0, TEXT("proceso terminado"), TEXT("test"), MB_ICONINFORMATION); } } NtClose(hProc); }