forked from v3ctra/load-lib-injector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
89 lines (72 loc) · 1.71 KB
/
main.cpp
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <Windows.h>
#include <iostream>
#include "memory.hpp"
#include "ifexist.hpp"
using namespace std;
Injector inj;
DWORD pid;
//now it's global
LPVOID ntOpenFile = GetProcAddress(LoadLibraryW(L"ntdll"), "NtOpenFile");
void bypass()
{
// Restore original NtOpenFile from external process
//credits: Daniel Krupiñski(pozdro dla ciebie byczku <3)
if (ntOpenFile) {
char originalBytes[5];
memcpy(originalBytes, ntOpenFile, 5);
WriteProcessMemory(inj.process, ntOpenFile, originalBytes, 5, NULL);
}
else
{
cout << "Unable to bypass :(\n";
Sleep(2000);
exit(-1);
}
}
void Backup()
{
if (ntOpenFile) {
//So, when I patching first 5 bytes I need to backup them to 0? (I think)
char originalBytes[5];
memcpy(originalBytes, ntOpenFile, 5);
WriteProcessMemory(inj.process, ntOpenFile, originalBytes, 0, NULL);
}
else
{
cout << "Unable to backup :(\n";
Sleep(2000);
exit(-1);
}
}
int main()
{
SetConsoleTitle("totally not pasted injector :)");
cout << "Credits:\n Daniel Krupinski\n online-9\n Hitchance\n\n" << endl;
inj.hwndproc = FindWindowA(0, "Counter-Strike: Global Offensive");
GetWindowThreadProcessId(inj.hwndproc, &pid);
inj.process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
inj.clientDLL = inj.GetModule(pid, "client.dll");
if (DoesFileExist("cheat.dll")) {
bypass();
if (inj.inject(pid, "cheat.dll")) {
cout << "module injected!\n\n" << endl;
Backup();
Sleep(2000);
exit(0);
}
else
{
cout << "Injection failed!\n\n" << endl;
Backup();
Sleep(2000);
exit(-1);
}
}
else
{
cout << "cannot find cheat.dll\n\n";
Sleep(2000);
exit(-1);
}
return 0;
}