-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdllMain.cpp
79 lines (58 loc) · 2.26 KB
/
dllMain.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
#include "Windows.h"
#include "source/me/sleepyfish/autoclicker/Utils.h"
#include "source/me/sleepyfish/autoclicker/ClickUtils.h"
ClickUtils* rightClickUtils{};
ClickUtils* leftClickUtils{};
bool running = false;
void Init(HMODULE mod) {
// initialize click utils for left and right clicks
{
rightClickUtils = new ClickUtils(1);
leftClickUtils = new ClickUtils(0);
rightClickUtils->init();
leftClickUtils->init();
}
// print that the dll is injected if console mode is enabled
Utils::messageBox(std::string("AutoClicker Injected\n\n\nHold Left -> Left AutoClick\nHold Right -> Right AutoClick\n"
"\nHold backspace to Detach\n\n\nInjected into: " + Utils::getCurrentProcessPathName()).c_str());
running = true;
// main loop
while (running) {
// check if ingame focus
if (Utils::hasIngameFocus()) {
// update click utils if ur holding right mouse button down
if (Utils::holdingMouseRight())
rightClickUtils->update(15, 18);
// update click utils if ur holding left mouse button down
if (Utils::holdingMouseLeft())
leftClickUtils->update(10, 14);
// exit the whole main loop if ur holding backspace
if (GetAsyncKeyState(VK_BACK) & 0x8000) {
running = false;
continue;
}
}
// sleep for 0.20 seconds
Sleep(20L);
}
Utils::messageBox("AutoClicker Detached");
// free click utils for memory management
delete rightClickUtils;
delete leftClickUtils;
// free the dll / like detaching
FreeLibrary(mod);
}
BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) {
// checks if the dll action is attach
if (dwReason == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(hModule);
// create thread for the main loop passing argument hModule to the init function
HANDLE hThread = CreateThread (
nullptr, 0, (LPTHREAD_START_ROUTINE) (Init), hModule, 0, nullptr
);
// close the thread
if (hThread != nullptr)
CloseHandle(hThread);
}
return true;
}