forked from NoMod-Programming/DyKnow-Bypass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDyKnowSupport.c
58 lines (55 loc) · 1.62 KB
/
DyKnowSupport.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <windows.h>
#include <process.h>
#include <Tlhelp32.h>
#include <winbase.h>
#include <string.h>
#include <stdio.h>
int killProcessByName(char* filename)
{
int ret = 1;
HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
PROCESSENTRY32 pEntry;
pEntry.dwSize = sizeof (pEntry);
BOOL hRes = Process32First(hSnapShot, &pEntry);
while (hRes)
{
//printf("%s\n", pEntry.szExeFile);
if (strcmp(pEntry.szExeFile, filename) == 0)
{
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, 0,
(DWORD) pEntry.th32ProcessID);
if (hProcess != NULL)
{
TerminateProcess(hProcess, 9);
CloseHandle(hProcess);
ret = 0;
} else {
return GetLastError();
}
}
hRes = Process32Next(hSnapShot, &pEntry);
}
CloseHandle(hSnapShot);
return ret;
}
void getProcesses(char arr[255][255])
{
HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
PROCESSENTRY32 pEntry;
pEntry.dwSize = sizeof (pEntry);
BOOL hRes = Process32First(hSnapShot, &pEntry);
int reti = 0;
while (hRes)
{
//printf("%s\n", pEntry.szExeFile);
// pEntry.szExeFile - Is it a pointer? Nope!
// arr[255] - array of char arrays
snprintf((char*)&arr[reti], 255, "%s", pEntry.szExeFile);
hRes = Process32Next(hSnapShot, &pEntry);
reti++;
}
CloseHandle(hSnapShot);
}
void test() {
killProcessByName("chrome.exe");
}