forked from Giteob/Fortnite-External-Cheat-WinSense-Leak
/
utility.h
142 lines (89 loc) · 3.13 KB
/
utility.h
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
#pragma once
#include <windows.h>
#include <winternl.h>
#include <process.h>
#include <tlhelp32.h>
#include <inttypes.h>
#include <iostream>
#include <stdexcept>
#include <vector>
#include <algorithm>
#include <chrono>
#include <sstream>
#include <d3d9.h>
#pragma comment (lib, "d3d9.lib")
HANDLE DriverHandle;
uint64_t base_address;
HWND hwnd = NULL;
DWORD processID;
int Width;
int Height;
int Depth;
#define M_PI 3.14159265358979323846264338327950288419716939937510
#define ctl_write CTL_CODE(FILE_DEVICE_UNKNOWN, 0x0569, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
#define ctl_read CTL_CODE(FILE_DEVICE_UNKNOWN, 0x0567, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
#define ctl_base CTL_CODE(FILE_DEVICE_UNKNOWN, 0x0568, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
typedef struct info_t {
int pid = 0;
DWORD_PTR address;
void* value;
SIZE_T size;
void* data;
} info, * p_info;
template <typename Type>
Type read(void* DriverHandle, unsigned long int Process_Identifier, unsigned long long int Address)
{
info_t Input_Output_Data;
Input_Output_Data.pid = Process_Identifier;
Input_Output_Data.address = Address;
Type Return_Value;
Input_Output_Data.value = &Return_Value;
Input_Output_Data.size = sizeof(Type);
unsigned long int Readed_Bytes_Amount;
DeviceIoControl(DriverHandle, ctl_read, &Input_Output_Data, sizeof Input_Output_Data, &Input_Output_Data, sizeof Input_Output_Data, &Readed_Bytes_Amount, nullptr);
return *(Type*)&Return_Value;
}
void writefloat(unsigned long long int Address, float stuff)
{
info_t Input_Output_Data;
Input_Output_Data.pid = processID;
Input_Output_Data.address = Address;
Input_Output_Data.value = &stuff;
Input_Output_Data.size = sizeof(float);
unsigned long int Readed_Bytes_Amount;
DeviceIoControl(DriverHandle, ctl_write, &Input_Output_Data, sizeof Input_Output_Data, &Input_Output_Data, sizeof Input_Output_Data, &Readed_Bytes_Amount, nullptr);
}
void writedouble(unsigned long long int Address, double stuff)
{
info_t Input_Output_Data;
Input_Output_Data.pid = processID;
Input_Output_Data.address = Address;
Input_Output_Data.value = &stuff;
Input_Output_Data.size = sizeof(double);
unsigned long int Readed_Bytes_Amount;
DeviceIoControl(DriverHandle, ctl_write, &Input_Output_Data, sizeof Input_Output_Data, &Input_Output_Data, sizeof Input_Output_Data, &Readed_Bytes_Amount, nullptr);
}
struct FQuat
{
float x;
float y;
float z;
float w;
};
std::string string_To_UTF8(const std::string& str)
{
int nwLen = ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0);
wchar_t* pwBuf = new wchar_t[nwLen + 1];
ZeroMemory(pwBuf, nwLen * 2 + 2);
::MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length(), pwBuf, nwLen);
int nLen = ::WideCharToMultiByte(CP_UTF8, 0, pwBuf, -1, NULL, NULL, NULL, NULL);
char* pBuf = new char[nLen + 1];
ZeroMemory(pBuf, nLen + 1);
::WideCharToMultiByte(CP_UTF8, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL);
std::string retStr(pBuf);
delete[]pwBuf;
delete[]pBuf;
pwBuf = NULL;
pBuf = NULL;
return retStr;
}