forked from ZEROWyt/Overwatch-2-TOPE-EXTERNAL-CHEAT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
includes.hpp
231 lines (201 loc) · 5.84 KB
/
includes.hpp
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#pragma once
#define DEG2RAD(x) x * M_PI / 180.0
#define M_PI 3.14159265358979323846
#define DIRECTINPUT_VERSION 0x0800
/* WinApi C++ 17 */
#include <Windows.h>
#include <iostream>
#include <filesystem>
#include <fstream>
#include <string>
#include <direct.h>
#include <TlHelp32.h>
#include <vector>
#include <process.h>
#include <thread>
#include <bitset>
#include <mutex>
#include <array>
#include <dwmapi.h>
/* D3D SDK */
#include <d3d11.h>
#include <DirectXMath.h>
#include <d3d9types.h>
/* Overlay & Imgui */
#include "imgai/imgui.h"
#include "imgai/imgui_impl_dx11.h"
#include "imgai/imgui_impl_win32.h"
#include "imgai/imgui_internal.h"
#include "SDK.hpp"
/* String Encrypted */
//#include "Xor.hpp"
/* Offset & Address */
#include "Offsets.hpp"
/* Config */
#include "Config.hpp"
/* Render */
#include "Renderer.hpp"
#include "Vector.hpp"
/* Lib */
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dwmapi.lib")
#pragma warning(disable : 4996)
bool windows11yes = false;
namespace fs = std::filesystem;
using namespace DirectX;
typedef int (FAR WINAPI* pDD_btn)(int btn);
typedef int (FAR WINAPI* pDD_key)(int keycode, int flag);
typedef int (FAR WINAPI* pDD_movR)(int dx, int dy);
// Forward declare message handler from imgui_impl_win32.cpp
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
struct CurrentProcess {
DWORD ID;
HANDLE Handle;
HWND Hwnd;
WNDPROC WndProc;
int WindowWidth;
int WindowHeight;
int WindowLeft;
int WindowRight;
int WindowTop;
int WindowBottom;
LPCSTR Title;
LPCSTR ClassName;
LPCSTR Path;
}Process;
class Rect {
public:
float x;
float y;
float width;
float height;
Rect() {
this->x = 0;
this->y = 0;
this->width = 0;
this->height = 0;
}
Rect(float x, float y, float width, float height) {
this->x = x;
this->y = y;
this->width = width;
this->height = height;
}
bool operator==(const Rect& src) const {
return (src.x == this->x && src.y == this->y && src.height == this->height && src.width == this->width);
}
bool operator!=(const Rect& src) const {
return (src.x != this->x && src.y != this->y && src.height != this->height && src.width != this->width);
}
};
bool IsCorrectTargetArchitecture(HANDLE hProc) {
BOOL bTarget = FALSE;
if (!IsWow64Process(hProc, &bTarget)) {
printf("Can't confirm target process architecture: 0x%X\n", GetLastError());
return false;
}
BOOL bHost = FALSE;
IsWow64Process(GetCurrentProcess(), &bHost);
return (bTarget == bHost);
}
namespace OW {
struct Entity
{
Vector3 Loc;
Vector3 foot;
float health;
Vector3 savedVelocity;
Vector3 Velocity;
clock_t lastVelocityUpdate;
Vector3 lastPos;
Vector3 predict;
Vector3 head;
Vector3 base;
Vector3 headbase;
Vector3 center;
Vector3 head2;
bool Live;
bool Team;
};
inline UINT g_Width{}, g_Height{};
inline std::vector<uint64_t> Entity_t{};
inline Entity Entitys[20] = {};
inline Matrix viewMatrix{};
inline uint64_t viewMatrixPtr{};
// Data
static ID3D11Device* g_pd3dDevice = NULL;
static ID3D11DeviceContext* g_pd3dDeviceContext = NULL;
static IDXGISwapChain* g_pSwapChain = NULL;
static ID3D11RenderTargetView* g_mainRenderTargetView = NULL;
inline void CleanupRenderTarget()
{
if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = NULL; }
}
inline void CleanupDeviceD3D()
{
CleanupRenderTarget();
if (g_pSwapChain) { g_pSwapChain->Release(); g_pSwapChain = NULL; }
if (g_pd3dDeviceContext) { g_pd3dDeviceContext->Release(); g_pd3dDeviceContext = NULL; }
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
}
inline void CreateRenderTarget()
{
ID3D11Texture2D* pBackBuffer;
g_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &g_mainRenderTargetView);
pBackBuffer->Release();
}
inline bool CreateDeviceD3D(HWND hWnd)
{
// Setup swap chain
DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd));
sd.BufferCount = 2;
sd.BufferDesc.Width = 0;
sd.BufferDesc.Height = 0;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = hWnd;
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.Windowed = TRUE;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
UINT createDeviceFlags = 0;
//createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
D3D_FEATURE_LEVEL featureLevel;
const D3D_FEATURE_LEVEL featureLevelArray[2] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_0, };
if (D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext) != S_OK)
return false;
CreateRenderTarget();
return true;
}
// Win32 message handler
inline LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
return true;
switch (msg)
{
case WM_SIZE:
if (g_pd3dDevice != NULL && wParam != SIZE_MINIMIZED)
{
CleanupRenderTarget();
g_pSwapChain->ResizeBuffers(0, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam), DXGI_FORMAT_UNKNOWN, 0);
CreateRenderTarget();
}
return 0;
case WM_SYSCOMMAND:
if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu
return 0;
break;
case WM_DESTROY:
::PostQuitMessage(0);
return 0;
}
return ::DefWindowProc(hWnd, msg, wParam, lParam);
}
}