diff --git a/reactos/apps/tests/kill/kill.cpp b/reactos/apps/tests/kill/kill.cpp new file mode 100644 index 00000000000..d0251e6fe63 --- /dev/null +++ b/reactos/apps/tests/kill/kill.cpp @@ -0,0 +1,58 @@ +/* Kill for Win32 by chris@dbn.lia.net + * http://users.lia.net/chris/win32/ + * Public domain + */ + + +#include + +inline int h2i(char x) +{ + return (x + ((x & 0x40) >> 6) | ((x & 0x40) >> 3)) & 0x0f; +} + +void msg(HANDLE out, LPCTSTR fmt...) +{ + char tmp[256]; + wvsprintf(tmp,fmt,(char*)&fmt+sizeof(fmt)); + DWORD w; + WriteFile(out,tmp,lstrlen(tmp),&w,NULL); +} + +void main(void) +{ + HANDLE stdout = GetStdHandle(STD_OUTPUT_HANDLE); + HANDLE stderr = GetStdHandle(STD_ERROR_HANDLE); + + LPTSTR cmdline = GetCommandLine(); + + //Scan command line to end of program name + while(*cmdline && *cmdline != ' ') + if(*cmdline++ == '"') + while(*cmdline && *cmdline++ != '"'); + + // Loop while we have parameters. + while(*cmdline) + { + //scan past spaces.. + while(*cmdline == ' ') + cmdline++; + + //read in pid + int pid = 0; + while(*cmdline) + pid = (pid << 4) + h2i(*cmdline++); + + HANDLE p = OpenProcess(PROCESS_ALL_ACCESS,FALSE,pid); + if(p) + { + if(TerminateProcess(p,(unsigned int)-9)) + msg(stdout,"Terminated PID: %08X\n",pid); + else + msg(stdout,"Couldn't kill PID: %08X, error=%d\n",pid,GetLastError()); + CloseHandle(p); + } + else + msg(stderr,"No such PID: %08X, error=%d\n",pid,GetLastError()); + } +} \ No newline at end of file diff --git a/reactos/apps/tests/kill/makefile b/reactos/apps/tests/kill/makefile new file mode 100644 index 00000000000..06bd923e5bf --- /dev/null +++ b/reactos/apps/tests/kill/makefile @@ -0,0 +1,21 @@ +# + +PATH_TO_TOP = ../.. + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = kill + +TARGET_SDKLIBS = + +TARGET_OBJECTS = $(TARGET_NAME).o + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF