-
Notifications
You must be signed in to change notification settings - Fork 19
/
main.cpp
175 lines (149 loc) · 5.95 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
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
#include <Windows.h>
#include "fmath.hpp"
#include <thread>
#include <chrono>
#include <iostream>
#include "Esp.hpp"
#include "sdk.hpp"
#include <fstream>
#include "vmthook.hpp"
#include "drawmanager.hpp"
#include "pattern.hpp"
#include "PaintTraverse.hpp"
#include "EndScene.hpp"
#include "Reset.hpp"
#include "CreateMove.hpp"
#include "SceneEnd.hpp"
vfunc_hook ppanel;
vfunc_hook renderview;
vfunc_hook d3d;
vfunc_hook client;
uint64_t FindSignature(const char* szModule, const char* szSignature)
{
MODULEINFO modInfo;
GetModuleInformation(GetCurrentProcess(), GetModuleHandleA(szModule), &modInfo, sizeof(MODULEINFO));
DWORD startAddress = (DWORD)modInfo.lpBaseOfDll;
DWORD endAddress = startAddress + modInfo.SizeOfImage;
const char* pat = szSignature;
DWORD firstMatch = 0;
for (DWORD pCur = startAddress; pCur < endAddress; pCur++) {
if (!*pat) return firstMatch;
if (*(PBYTE)pat == '\?' || *(BYTE*)pCur == getByte(pat)) {
if (!firstMatch) firstMatch = pCur;
if (!pat[2]) return firstMatch;
if (*(PWORD)pat == '\?\?' || *(PBYTE)pat != '\?') pat += 3;
else pat += 2; //one ?
}
else {
pat = szSignature;
firstMatch = 0;
}
}
return NULL;
}
DWORD FindPattern(DWORD start_offset, DWORD size, BYTE* pattern, char mask[])
{
DWORD pos = 0;
int searchLen = strlen(mask) - 1;
for (DWORD retAddress = start_offset; retAddress < start_offset + size; retAddress++)
{
if (*(BYTE*)retAddress == pattern[pos] || mask[pos] == '?') {
if (mask[pos + 1] == '\0')
return (retAddress - searchLen);
pos++;
}
else
pos = 0;
}
return NULL;
}
using color_t = uint8_t[4];
void(__cdecl* datapaths)(void) = nullptr;
unsigned long __stdcall init(void* dll)
{
AllocConsole();
freopen("conin$", "r", stdin);
freopen("conout$", "w", stdout);
freopen("conout$", "w", stderr);
globals::engine = interface::get<Engine>(GetModuleHandleW(L"engine.dll"), "VEngineClient");
globals::entitylist = interface::get<EntityList>(GetModuleHandleW(L"client.dll"), "VClientEntityList");
globals::surface = interface::get<ISurface>(GetModuleHandleW(L"vguimatsurface.dll"), "VGUI_Surface030");
globals::panel = interface::get<IPanel>(GetModuleHandleW(L"vgui2.dll"), "VGUI_Panel009");
globals::lua = interface::get<lua::Shared>(GetModuleHandleW(L"lua_shared.dll"), "LUASHARED");
globals::client = interface::get<IBaseClientDLL>(GetModuleHandleW(L"client.dll"), "VClient017");
globals::trace = interface::get<IEngineTrace>(GetModuleHandleW(L"engine.dll"), "EngineTraceClient003");
globals::modelinfo = interface::get<IVModelInfo>(GetModuleHandleW(L"engine.dll"), "VModelInfoClient006");
globals::renderview = interface::get<RenderView>(GetModuleHandleW(L"engine.dll"), "VEngineRenderView014");
globals::pDevice = **(IDirect3DDevice9***)(FindSignature("shaderapidx9.dll", "A1 ? ? ? ? 50 8B 08 FF 51 0C") + 1);
printf("globals::engine: 0x%X\n", (DWORD)globals::engine);
printf("globals::entitylist: 0x%X\n", (DWORD)globals::entitylist);
printf("globals::panel: 0x%X\n", (DWORD)globals::panel);
printf("globals::lua: 0x%X\n", (DWORD)globals::lua);
printf("globals::client: 0x%X\n", (DWORD)globals::client);
printf("globals::trace: 0x%X\n", (DWORD)globals::trace);
printf("globals::modelinfo: 0x%X\n", (DWORD)globals::modelinfo);
printf("globals::renderview: 0x%X\n", (DWORD)globals::renderview);
printf("globals::pDevice: 0x%X\n", (DWORD)globals::pDevice);
globals::engine->get_screen_size(globals::screenweight, globals::screenheight);
using datapack_paths_t = void(__cdecl*)();
datapaths = reinterpret_cast<datapack_paths_t>(signature::search(GetModuleHandleW(L"client.dll"), signature::detail::convert("55 8B EC 8B 0D ?? ?? ?? ?? 83 EC 7C")));
// datapaths();
auto chl = interface::get<void>(GetModuleHandleW(L"client.dll"), "VClient");
auto classes = method<get_all_classes_t>(8, chl)(chl);
for (; classes; classes = classes->next)
netvars::store(classes->table->table, classes->table);
// PaintTraverse Hook
if (ppanel.setup(globals::panel)) {
original::PaintTraverse = ppanel.get_original<tPaintTraverse>(41);
printf("Original PaintTraverse founded \n");
ppanel.hook_index(41, hkPaintTraverse);
printf("PaintTraverse founded \n");
}
// EndScene & Reset Hook
if (d3d.setup(globals::pDevice)) {
original::endscene = d3d.get_original<EndSceneFn>(42);
printf("Original EndScene founded \n");
d3d.hook_index(42, hkEndScene);
printf("EndScene hooked \n");
original::reset = d3d.get_original<ResetFn>(16);
printf("Original Reset founded \n");
d3d.hook_index(16, hkReset);
printf("Reset hooked \n");
}
// SceneEnd hook
if (renderview.setup(globals::renderview)) {
original::sceneend = renderview.get_original<tSceneEnd>(9);
printf("Original SceneEnd founded \n");
renderview.hook_index(9, hkSceneEnd);
printf("SceneEnd hooked \n");
}
// CreateMove Hook
if (client.setup(globals::client)) {
original::CreateMove = client.get_original<tCreateMove>(21);
DWORD dwInputPointer = FindPattern((DWORD)original::CreateMove, 0x100, (byte*)"\x8B\x0D", "xx");
if (dwInputPointer != NULL)
{
dwInputPointer += 0x2;
globals::input = **(CInput***)dwInputPointer;
printf("globals::input: 0x%X\n", (DWORD)globals::input);
}
client.hook_index(21, hkCreateMove);
}
Particles = new particle_network(globals::screenweight, globals::screenheight, 60);
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));
d3d.unhook_all();
ppanel.unhook_all();
client.unhook_all();
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;
}