Initial revision
authorSteven Edwards <winehacker@gmail.com>
Tue, 27 Nov 2001 14:24:14 +0000 (14:24 +0000)
committerSteven Edwards <winehacker@gmail.com>
Tue, 27 Nov 2001 14:24:14 +0000 (14:24 +0000)
svn path=/trunk/; revision=2397

reactos/apps/tests/kill/kill.cpp [new file with mode: 0644]
reactos/apps/tests/kill/makefile [new file with mode: 0644]

diff --git a/reactos/apps/tests/kill/kill.cpp b/reactos/apps/tests/kill/kill.cpp
new file mode 100644 (file)
index 0000000..d0251e6
--- /dev/null
@@ -0,0 +1,58 @@
+/* Kill for Win32 by chris@dbn.lia.net
+ * http://users.lia.net/chris/win32/
+ * Public domain 
+ */
+
+
+#include <windows.h>
+
+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 (file)
index 0000000..06bd923
--- /dev/null
@@ -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