-
Notifications
You must be signed in to change notification settings - Fork 18
/
Main.cpp
137 lines (118 loc) · 3.19 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include <Windows.h>
#include "CheatManager.h"
#include "Globals.h"
#include "System.h"
#include "cexception.h"
#include "StealthOverlay.h"
#include "XorString.hpp"
#include "Menu.h"
#include "EntityUpdator.h"
#include <dwmapi.h>
#pragma comment(lib, "Cheat-Template.lib")
void RunCheat();
#ifdef _MakeAsDLL
DWORD WINAPI ThreadProc(
_In_ LPVOID lpParameter
) {
RunCheat();
TerminateProcess(GetCurrentProcess(), 0);
return 0;
}
BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved) {
if (fdwReason == DLL_PROCESS_ATTACH) {
auto result = CreateThread(
NULL,
0,
ThreadProc,
(LPVOID)hinstDLL,
0,
NULL
);
if (result == NULL) {
MessageBoxW(NULL, L"Can not Create thread", L"ERROR", 0);
return false;
}
}
return TRUE;
}
#else
int CALLBACK WinMain(
_In_ HINSTANCE hInstance,
_In_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow
) {
RunCheat();
return 0;
}
#endif
HWND MakeOverlay()
{
WNDCLASSEXW window_class;
window_class.cbSize = sizeof(WNDCLASSEXW);
window_class.style = 0;
window_class.lpfnWndProc = DefWindowProcW;
window_class.cbClsExtra = 0;
window_class.cbWndExtra = 0;
window_class.hInstance = GetModuleHandleW(NULL);
window_class.hIcon = NULL;
window_class.hCursor = NULL;
window_class.hbrBackground = NULL; // for testing
window_class.lpszMenuName = NULL;
window_class.lpszClassName = L"3A09FB91-B7FE-4cf5-91F1-20D3832C6EB6";
window_class.hIconSm = NULL;
RegisterClassExW(&window_class);
HWND hWnd = CreateWindowExW(
WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_LAYERED | WS_EX_NOACTIVATE,
L"3A09FB91-B7FE-4cf5-91F1-20D3832C6EB6",
NULL,
WS_POPUP | WS_VISIBLE,
Rust::Globals::system_data.GameWindowRect.left,
Rust::Globals::system_data.GameWindowRect.top,
Rust::Globals::system_data.width,
Rust::Globals::system_data.height,
NULL,
NULL,
(HINSTANCE)GetModuleHandleW(NULL),
NULL
);
return hWnd;
}
void RunCheat() {
try {
AllocConsole();
Rust::Globals::Init();
Rust::Globals::system_data.hOverlay = MakeOverlay();
MARGINS margin = { 0,0,0,1440 };
DwmExtendFrameIntoClientArea(Rust::Globals::system_data.hOverlay, &margin);
SetLayeredWindowAttributes(Rust::Globals::system_data.hOverlay, 0, 0, 0);
ShowWindow(Rust::Globals::system_data.hOverlay, SW_SHOW);
Rust::CheatManager manager;
bool CreateThread = true;
while (Rust::Globals::CheatRunning) {
manager.exec();
MSG msg;
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
Rust::Globals::CheatRunning = false;
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
if (CreateThread)
{
std::thread TaggedObjectAdder(Rust::EntityUpdator::AddNewTaggedObjects);
std::thread ActiveObjectAdder(Rust::EntityUpdator::AddNewActiveObjects);
std::thread UpdateThread(Rust::EntityUpdator::UpdateThread);
TaggedObjectAdder.detach();
ActiveObjectAdder.detach();
UpdateThread.detach();
CreateThread = false;
}
}
}
catch (std::exception& ex) {
MessageBoxA(NULL, ex.what(), "Exception", 0);
return;
}
}