-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
86 lines (71 loc) · 2.29 KB
/
main.cpp
File metadata and controls
86 lines (71 loc) · 2.29 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <iostream>
#include <stdexcept>
#include <csignal>
#include <Windows.h>
#include "config.h"
#include "process.h"
#include "memory.h"
#include "mouse.h"
static bool g_running = true;
static bool g_buttonHeld = false;
void OnSignal(int) {
g_running = false;
}
int main() {
std::signal(SIGINT, OnSignal);
std::cout << "Coded by CirqueiraDev\n";
std::cout << "[*] Connecting to process: " << PROCESS_NAME << "\n";
DWORD pid = FindProcessId(PROCESS_NAME);
if (!pid) {
std::cerr << "[!] Process not found.\n";
return 1;
}
std::cout << "[+] Connected! PID: " << pid << "\n";
HANDLE hProcess;
try {
hProcess = OpenProcessFull(pid);
} catch (const std::exception& e) {
std::cerr << "[!] " << e.what() << "\n";
return 1;
}
uintptr_t moduleBase;
try {
moduleBase = GetModuleBase(hProcess, pid, MODULE_NAME);
} catch (const std::exception& e) {
std::cerr << "[!] " << e.what() << "\n";
CloseHandle(hProcess);
return 1;
}
std::cout << "[+] Module base " << MODULE_NAME << ": 0x" << std::hex << moduleBase << "\n";
uintptr_t baseAddress = moduleBase + BASE_OFFSET;
std::cout << "[+] Base address: 0x" << baseAddress << std::dec << "\n";
std::cout << "[*] Press Ctrl+C to stop.\n\n";
while (g_running) {
try {
uintptr_t finalAddress = ResolvePointerChain(hProcess, baseAddress, OFFSETS);
int32_t value = ReadMemory<int32_t>(hProcess, finalAddress);
if (value != 0 && !g_buttonHeld) {
std::cout << "[+] Value=" << value << " | Holding click...\n";
MouseDown();
g_buttonHeld = true;
} else if (value == 0 && g_buttonHeld) {
std::cout << "[-] Value=0 | Releasing click...\n";
MouseUp();
g_buttonHeld = false;
}
} catch (const std::exception& e) {
if (g_buttonHeld) {
MouseUp();
g_buttonHeld = false;
}
std::cerr << "[!] Error: " << e.what() << "\n";
Sleep(1000);
}
Sleep(POLL_INTERVAL_MS);
}
if (g_buttonHeld)
MouseUp();
CloseHandle(hProcess);
std::cout << "[*] Stopped.\n";
return 0;
}