Last active
May 4, 2017 02:22
-
-
Save the-nose-knows/b1ec3f2697e4bf4d8ab8dd1fc6cec4b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Windows.h" | |
#include "tchar.h" | |
#include "stdio.h" | |
#include "stdlib.h" | |
#include <string> | |
int _tmain(int argc, _TCHAR* argv[]) | |
{ | |
STARTUPINFOA startup_info = { 0 }; | |
LPSTARTUPINFOA p_startup_info = &startup_info; | |
PROCESS_INFORMATION proc_info = { 0 }; | |
LPPROCESS_INFORMATION p_proc_info = &proc_info; | |
if (!CreateProcess(("C:\\WINDOWS\\system32\\calc.exe"), | |
NULL, | |
NULL, | |
NULL, | |
FALSE, | |
0, | |
NULL, | |
"C:\\WINDOWS\\system32", | |
p_startup_info, | |
p_proc_info)) | |
{ | |
printf("Doh!\n"); | |
} | |
else | |
{ | |
DWORD PID = GetProcessId(p_proc_info->hProcess); | |
printf("PID: %u\n", PID); | |
std::string task_killer = std::string("taskkill /F /T /PID ") + std::to_string(PID); | |
int result = system(task_killer.c_str()); | |
return result; | |
} | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment