-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.cpp
More file actions
64 lines (50 loc) · 1.67 KB
/
main.cpp
File metadata and controls
64 lines (50 loc) · 1.67 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
60
61
62
63
64
#include <thread>
#include <chrono>
#include "ui.h"
#include "antidebug.h"
int main()
{
SetConsoleTitleA("AntiDebug");
std::thread ui_thread(UI::routine);
auto& options{ AntiDebug::getOptions() };
while (UI::running)
{
AntiDebug::options_mutex.lock();
for (auto& option : options)
{
if (option.enabled)
{
/* Handle delay for options with it */
if (option.delay != std::chrono::milliseconds(0))
{
auto now{ std::chrono::steady_clock::now() };
auto time_elapsed{ std::chrono::duration_cast<std::chrono::milliseconds>(now - option.time_start) };
if (time_elapsed < option.delay)
continue;
option.time_start = now;
}
bool was_detected{ option.detected };
option.callback(option);
bool is_detected{ option.detected };
if (is_detected && !was_detected || !is_detected && was_detected)
UI::triggerUpdate();
option.was_enabled = true;
}
else
{
/* Black magic to ensure UI update when disables */
if (option.was_enabled)
{
UI::triggerUpdate();
option.was_enabled = false;
}
option.detected = false;
}
}
AntiDebug::options_mutex.unlock();
std::this_thread::sleep_for(std::chrono::milliseconds(25));
}
if (ui_thread.joinable())
ui_thread.join();
return 0;
}