Files
mirror-processhacker/trunk/NProcessHacker/Test/test.c
T
wj32 c3625ea5fc * changed error when terminating self to STATUS_CANT_TERMINATE_SELF
* 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
2009-05-19 08:25:38 +00:00

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;
}