-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.cpp
187 lines (155 loc) · 4.43 KB
/
script.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
176
177
178
179
180
181
182
183
184
185
186
187
/*
ViewportEditor
RAGE GTA 5 b1290 CViewportGame Editor
Transmet 2018
*/
#include "script.h"
#include "keyboard.h"
#include <string>
#include <Psapi.h>
#pragma warning(disable : 4244 4305) // double <-> float conversions
void DrawTextShadow(char* caption, float x, float y, int r, int g, int b, int a, int font = 0, float text_scale = 0.35)
{
UI::SET_TEXT_FONT(font);
UI::SET_TEXT_SCALE(0.0, text_scale);
UI::SET_TEXT_COLOUR(r, g, b, a);
UI::SET_TEXT_CENTRE(0);
UI::SET_TEXT_DROPSHADOW(5, 0, 0, 0, 255);
UI::SET_TEXT_EDGE(0, 0, 0, 0, 0);
UI::BEGIN_TEXT_COMMAND_DISPLAY_TEXT("STRING");
UI::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(caption);
UI::END_TEXT_COMMAND_DISPLAY_TEXT(x, y);
UI::SET_TEXT_FONT(font);
UI::SET_TEXT_SCALE(0.0, text_scale);
UI::SET_TEXT_COLOUR(r, g, b, a);
UI::SET_TEXT_CENTRE(0);
UI::SET_TEXT_DROPSHADOW(5, 0, 0, 0, 255);
UI::SET_TEXT_EDGE(0, 0, 0, 0, 0);
UI::_BEGIN_TEXT_COMMAND_LINE_COUNT("STRING");
UI::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(caption);
UI::_GET_TEXT_SCREEN_LINE_COUNT(x, y);
}
typedef unsigned int long long QWORD;
static QWORD PatternSearch(const char* pattern, const char* mask, const int length)
{
QWORD base = (QWORD)GetModuleHandle(nullptr);
MODULEINFO modinfo;
GetModuleInformation(GetCurrentProcess(), (HMODULE)base, &modinfo, sizeof(MODULEINFO));
QWORD sizeImage = modinfo.SizeOfImage;
for (QWORD i = base; i < base + sizeImage; i++)
{
bool bypass = true;
for (unsigned short it = 0; it < length; it++)
{
if (mask[it] == '1')
if (pattern[it] != *((char*)(i + it)))
{
bypass = false;
break;
}
}
if (bypass)
return i;
}
return 0;
}
struct {
unsigned short offset;
const char* name;
} properties[] = {
{ 0x0420, "SceneX" },
{ 0x0424, "SceneY" },
{ 0x0428, "SceneWidth" },
{ 0x042C, "SceneHeight" },
{ 0x0460, "ScaleX" },
{ 0x0464, "ScaleY" },
{ 0x0468, "Val1_0" },
{ 0x046C, "Val1_1" },
{ 0x0430, "Val2_0" },
{ 0x0434, "Val2_1" },
};
unsigned short countProps = sizeof(properties) / sizeof(properties[0]);
void ScriptMain()
{
// E8????????488B??????????488D??????????488BCDE8????????80??????????01751A
QWORD CViewportGamePat = PatternSearch(
"\xE8\x00\x00\x00\x00\x48\x8B\x00\x00\x00\x00\x00\x48\x8D\x00\x00\x00\x00\x00\x48\x8B\xCD\xE8\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x01\x75\x1A",
"100001100000110000011110000100000111",
36
);
if (!CViewportGamePat)
{
MessageBoxA(0, "Pattern not found !", "ViewportEditor", 0);
return;
}
CViewportGamePat += 8;
DWORD offsetPtr = *(DWORD*)(CViewportGamePat);
CViewportGamePat += offsetPtr + 4;
CViewportGamePat = *(QWORD*)(CViewportGamePat);
char bufOut[128];
bool renderSelector = false;
unsigned short index = 0;
DWORD ticktick = 0;
for (;;)
{
if (renderSelector)
{
GRAPHICS::DRAW_RECT(0.075f, 0.042f, 0.135f, 0.05f, 0, 155, 255, 200);
DrawTextShadow("ViewportEditor 0.1", 0.02f, 0.024f, 255, 255, 255, 255, 6, 0.5f);
for (unsigned short i = 0; i < countProps; i++)
{
sprintf_s(
bufOut,
"[%.3f] %s",
*(float*)(CViewportGamePat + properties[i].offset),
properties[i].name
);
if (i == index)
{
GRAPHICS::DRAW_RECT(0.075f, 0.1f + (i * 0.043f), 0.135f, 0.04f, 0, 155, 255, 200);
DrawTextShadow(bufOut, 0.02f, 0.083f + (i * 0.043f), 255, 255, 255, 255, 6, 0.5f);
}
else
{
GRAPHICS::DRAW_RECT(0.075f, 0.1f + (i * 0.043f), 0.135f, 0.04f, 255, 255, 255, 170);
DrawTextShadow(bufOut, 0.02f, 0.083f + (i * 0.043f), 0, 155, 255, 255, 6, 0.5f);
}
}
float eom = 0.153f + ((countProps - 1) * 0.043f);
GRAPHICS::DRAW_RECT(0.075f, eom, 0.135f, 0.05f, 0, 155, 255, 200);
DrawTextShadow("Numpad 4/6 to increment/decrement\nNumpad 8/2 to up/down in menu", 0.02f, eom - 0.022f, 255, 255, 255, 255, 6, 0.35f);
if (IsKeyJustUp(VK_NUMPAD8))
{
if (index - 1 < 0)
index = countProps - 1;
else
index--;
}
else if (IsKeyJustUp(VK_NUMPAD2))
{
if (index + 1 >= countProps)
index = 0;
else
index++;
}
}
DWORD curTick = GetTickCount();
if (ticktick < curTick)
{
if (renderSelector)
{
if (IsKeyDown(VK_NUMPAD4))
*(float*)(CViewportGamePat + properties[index].offset) -= 0.003f;
else if (IsKeyDown(VK_NUMPAD6))
*(float*)(CViewportGamePat + properties[index].offset) += 0.003f;
ticktick = curTick + 5;
}
if (IsKeyDown(VK_CONTROL) && IsKeyDown(0x43))
{
renderSelector = !renderSelector;
ticktick = curTick + 300;
}
}
WAIT(0);
}
}