-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRegHacks.cpp
240 lines (206 loc) · 6.44 KB
/
RegHacks.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#include <cstdio>
#include <string>
#include <thread>
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include "hacks/all.h"
#include "HCl/All.hpp"
using namespace std::literals;
namespace fs = std::filesystem;
HTextArea logs;
const char* reghacks_ascii_art = "\r\n"
" WELCOME TO REG HACKS v1.2\r\n"
" Use the Provided Buttons to Enable/Disable Hacks.\r\n";
void clear()
{
logs.setText("");
}
void print(const auto& ...args)
{
std::stringstream ss;
(ss << ... << args);
logs.setText(logs.getText()+ss.str());
}
void println(const auto& ...args)
{
std::stringstream ss;
(ss << ... << args) << "\r\n";
logs.setText(logs.getText()+ss.str());
};
enum class result : uint8_t
{
FALIURE = 0,
SUCCESS = 1
};
void playSound(result r)
{
if (r == result::SUCCESS)
PlaySoundA("C:/Windows/Media/chimes.wav", NULL, SND_ASYNC | SND_FILENAME | SND_NODEFAULT);
else
PlaySoundA("C:/Windows/Media/chord.wav" , NULL, SND_ASYNC | SND_FILENAME | SND_NODEFAULT);
}
void cwd2ExePath()
{
char buffer[MAX_PATH];
GetModuleFileNameA(NULL, buffer, MAX_PATH);
auto exepath = std::string(buffer);
auto dirpath = exepath.substr(0, exepath.find_last_of("\\/"));
SetCurrentDirectoryA(dirpath.c_str());
}
void cwd2TempPath()
{
SetCurrentDirectoryW(fs::temp_directory_path().wstring().c_str());
}
bool iAmAdmin()
{
bool IsElevated = false;
HANDLE hToken = NULL;
TOKEN_ELEVATION elevation;
DWORD dwSize;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
goto Cleanup; // if Failed, we treat as False
if (!GetTokenInformation(hToken, TokenElevation, &elevation, sizeof(elevation), &dwSize))
goto Cleanup; // if Failed, we treat as False
IsElevated = elevation.TokenIsElevated;
Cleanup:
if (hToken)
{
CloseHandle(hToken);
hToken = NULL;
}
return IsElevated;
}
bool use_hack_file(uint8_t id)
{
auto filename = std::to_string(id) + ".reg";
FILE* f = fopen(filename.c_str(), "wb");
if (!f) return false;
fwrite(rhe_map[id].data, 1, rhe_map[id].size, f);
fclose(f);
system(("reg import "+filename).c_str());
DeleteFileA(filename.c_str());
return true;
}
void button_boilerplate(uint8_t id, const char* desc, bool reboot_required=true)
{
clear(); println(); print(desc);
if (use_hack_file(id))
{
println("Done!"); println();
if (reboot_required)
print("Changes will take Effect after a Reboot!");
playSound(result::SUCCESS);
}
else
{
println("Error!");
playSound(result::FALIURE);
}
}
void disable_windows_defender()
{
HKEY key, new_key;
DWORD disable = 1;
if (ERROR_SUCCESS == RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Policies\\Microsoft\\Windows Defender", 0, KEY_ALL_ACCESS, &key))
{
RegSetValueExA(key, "DisableAntiSpyware", 0, REG_DWORD, (const BYTE*)&disable, sizeof(disable));
RegCreateKeyExA(key, "Real-Time Protection", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &new_key, 0);
RegSetValueExA(new_key, "DisableRealtimeMonitoring", 0, REG_DWORD, (const BYTE*)&disable, sizeof(disable));
RegSetValueExA(new_key, "DisableBehaviorMonitoring", 0, REG_DWORD, (const BYTE*)&disable, sizeof(disable));
RegSetValueExA(new_key, "DisableScanOnRealtimeEnable", 0, REG_DWORD, (const BYTE*)&disable, sizeof(disable));
RegSetValueExA(new_key, "DisableOnAccessProtection", 0, REG_DWORD, (const BYTE*)&disable, sizeof(disable));
RegSetValueExA(new_key, "DisableIOAVProtection", 0, REG_DWORD, (const BYTE*)&disable, sizeof(disable));
RegCloseKey(key);
RegCloseKey(new_key);
}
}
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)
{
cwd2TempPath();
ReportHINSTANCE(hInstance);
if (!iAmAdmin())
{
MessageBox(NULL, L"Please run this program as Administrator.", L"Runtime Error", MB_OK);
return 1;
}
HFrame frame = HFrame("RegHacks v1.2 for Windows 10/11");
frame.setSize(610, 450);
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
logs = HTextArea("logs");
logs.setSize(480, 100);
logs.setLocation(60, 10);
logs.setText(reghacks_ascii_art);
HButton b1("Enable Windows Photo Viewer");
b1.setSize(240, 70);
b1.setLocation(50, 120);
b1.addActionListener([](ActionEvent) -> int
{
button_boilerplate(1, "Enabling Windows Photo Viewer...");
return 0;
});
HButton b2("Disable Bing in Search Bar");
b2.setSize(240, 70);
b2.setLocation(310, 120);
b2.addActionListener([](ActionEvent) -> int
{
button_boilerplate(2, "Disabling Bing in Search Bar...");
return 0;
});
HButton b3("Enable Direct Sign In Screen");
b3.setSize(240, 70);
b3.setLocation(50, 210);
b3.addActionListener([](ActionEvent) -> int
{
button_boilerplate(3, "Enabling Direct Sign In Screen...");
return 0;
});
HButton b4("Disable Ads and Telemetery");
b4.setSize(240, 70);
b4.setLocation(310, 210);
b4.addActionListener([](ActionEvent) -> int
{
button_boilerplate(4, "Disabling Ads and Telemetery...");
return 0;
});
HButton b5("Disable Cortana and OneDrive");
b5.setSize(240, 70);
b5.setLocation(50, 300);
b5.addActionListener([](ActionEvent) -> int
{
button_boilerplate(5, "Disabling Cortana and OneDrive...");
return 0;
});
HButton b6("Disable Windows Defender");
b6.setSize(240, 70);
b6.setLocation(310, 300);
b6.addActionListener([](ActionEvent) -> int
{
clear(); println();
print("Disabling Windows Defender...");
disable_windows_defender();
println("Done!"); println();
print("Changes will take Effect after a Reboot!");
playSound(result::SUCCESS);
return 0;
});
frame.add(&logs);
frame.add(&b1);
frame.add(&b2);
frame.add(&b3);
frame.add(&b4);
frame.add(&b5);
frame.add(&b6);
frame.setVisible(true);
HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(0));
SendMessage(frame.hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
SendMessage(frame.hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
std::thread([]()
{
std::this_thread::sleep_for(30s);
logs.setText(reghacks_ascii_art);
})
.detach();
WaitAll();
return 0;
}