-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.cpp
80 lines (60 loc) · 2.58 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
#include <Windows.h>
#include "fmath.hpp"
#include <thread>
#include <chrono>
#include <iostream>
#include "utils.hpp"
#include "Entities.hpp"
#include "lua.hpp"
#include "Net.hpp"
#include "Engine.hpp"
#include "Esp.hpp"
#include <fstream>
using color_t = uint8_t[4];
void(__cdecl* datapaths)(void) = nullptr;
unsigned long __stdcall init(void* dll)
{
void(__cdecl* print)(const color_t&, const char*, ...) = nullptr;
auto tier0 = GetModuleHandleW(L"tier0.dll");
print = reinterpret_cast<decltype(print)>(GetProcAddress(tier0, "?ConColorMsg@@YAXABVColor@@PBDZZ"));
auto handle = GetModuleHandleW(L"engine.dll");
auto client = GetModuleHandleW(L"client.dll");
globals::engine = interface::get<Engine>(handle, "VEngineClient");
globals::entities = interface::get<Entities>(client, "VClientEntityList");
// Credits to Copypaste
using datapack_paths_t = void(__cdecl*)();
datapaths = reinterpret_cast<datapack_paths_t>(signature::search(client, signature::detail::convert("55 8B EC 8B 0D ?? ?? ?? ?? 83 EC 7C")));
// datapaths();
globals::lua = interface::get<lua::Shared>(GetModuleHandleW(L"lua_shared.dll"), "LUASHARED");
auto chl = interface::get<void>(client, "VClient");
auto classes = method<get_all_classes_t>(8, chl)(chl);
for (; classes; classes = classes->next)
netvars::store(classes->table->table, classes->table);
// Credits to Aixxe for the pattern and the render prototype
auto overlay = GetModuleHandleW(L"gameoverlayrenderer.dll");
void*& present = **reinterpret_cast<void***>(
signature::search(overlay, signature::detail::convert("8B F8 85 DB")) - 4
);
void*& reset = **reinterpret_cast<void***>(
signature::search(overlay, signature::detail::convert("C7 45 ?? ?? ?? ?? ?? FF 15 ?? ?? ?? ?? 8B F8")) + 9
);
original::present = *reinterpret_cast<decltype(&original::present)>(&present);
original::reset = *reinterpret_cast<decltype(&original::reset)>(&reset);
present = reinterpret_cast<void*>(&detours::present);
reset = reinterpret_cast<void*>(&detours::reset);
for (; !(GetAsyncKeyState(VK_HOME) & 1); std::this_thread::sleep_for(std::chrono::milliseconds(25)));
SetWindowLongPtrW(FindWindowW(L"Valve001", nullptr), GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(original::proc));
present = *reinterpret_cast<void**>(&original::present);
reset = *reinterpret_cast<void**>(&original::reset);
ImGui_ImplDX9_Shutdown();
FreeLibraryAndExitThread(HMODULE(dll), 0);
}
int __stdcall DllMain(HINSTANCE dll, DWORD reason, LPVOID)
{
DisableThreadLibraryCalls(dll);
if (reason == DLL_PROCESS_ATTACH)
{
CreateThread(nullptr, 0, init, dll, 0, nullptr);
}
return 1;
}