mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
c3625ea5fc
* fixed some outdated comments * added lots of defs to NProcessHacker KPH * added test program git-svn-id: svn://svn.code.sf.net/p/processhacker/code@1297 21ef857c-d57f-4fe0-8362-d861dc6d29cd
52 lines
1.1 KiB
C
52 lines
1.1 KiB
C
#ifndef UNICODE
|
|
#define UNICODE
|
|
#endif
|
|
|
|
#include <windows.h>
|
|
#include <stdio.h>
|
|
#include "../kph.h"
|
|
|
|
int wmain(int argc, WCHAR *argv[])
|
|
{
|
|
NTSTATUS status;
|
|
ULONG pid;
|
|
HANDLE kphHandle, processHandle;
|
|
|
|
if (argc < 2)
|
|
{
|
|
printf("Usage: test [pid to kill]\n");
|
|
return 1;
|
|
}
|
|
|
|
pid = _wtoi(argv[1]);
|
|
|
|
status = KphConnect(&kphHandle);
|
|
|
|
if (!NT_SUCCESS(status))
|
|
{
|
|
printf("Could not connect to KProcessHacker (0x%08x).\n", status);
|
|
return status;
|
|
}
|
|
|
|
status = KphOpenProcess(kphHandle, &processHandle, pid, PROCESS_TERMINATE);
|
|
|
|
if (!NT_SUCCESS(status))
|
|
{
|
|
printf("Could not open process with PID %d (0x%08x).\n", pid, status);
|
|
return status;
|
|
}
|
|
|
|
status = KphTerminateProcess(kphHandle, processHandle, 0);
|
|
|
|
if (!NT_SUCCESS(status))
|
|
{
|
|
printf("Could not terminate process (0x%08x).\n", status);
|
|
return status;
|
|
}
|
|
|
|
CloseHandle(processHandle);
|
|
KphDisconnect(kphHandle);
|
|
|
|
return 0;
|
|
}
|