-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinject.cpp
More file actions
59 lines (44 loc) · 1.02 KB
/
inject.cpp
File metadata and controls
59 lines (44 loc) · 1.02 KB
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
59
#include "injection.h"
const char szDllFile[] = "File DLL path";
const char szProc[] = "File exe path";
int main(void)
{
PROCESSENTRY32 PE32{ 0 };
PE32.dwSize = sizeof(PE32);
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnap == INVALID_HANDLE_VALUE)
{
DWORD Err = GetLastError();
printf("CreateToolhelp32Snapshot failed: 0x%X\n", Err);
system("PAUSE");
return 0;
}
DWORD PID = 0;
BOOL bRet = Process32First(hSnap, &PE32);
while (bRet)
{
if (!strcmp(szProc, PE32.szExeFile))
{
PID = PE32.th32ProcessID;
break;
}
bRet = Process32Next(hSnap, &PE32);
}
CloseHandle(hSnap);
HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, PID);
if (!hProc)
{
DWORD Err = GetLastError();
printf("OpenProcess failed: 0x%X\n", Err);
system("PAUSE");
return 0;
}
if (!ManualMap(hProc, szDllFile))
{
printf("Something went wrong FeelsBadMan\n");
system("PAUSE");
return 0;
}
CloseHandle(hProc);
return 0;
}