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
| #include <stdio.h>
#include<cstdlib>
#include<Windows.h>
#include<iostream>
#include<cmath>
#include <GLFW/glfw3.h>
#include "imgui/imgui.h"
#include "imgui/imgui_impl_glfw.h"
#include "imgui/imgui_impl_opengl3.h"
#include "GetIMformation/GetIMformation.h"
//声明外部变量
extern DWORD g_process_id;
extern HANDLE g_process_handle;
extern UINT_PTR g_local_player;
extern UINT_PTR g_player_list_address;
extern UINT_PTR g_matrix_address;
extern UINT_PTR g_angle_address;
extern HWND g_game_hwnd;
extern module_information engine_module;
extern module_information client_module;
extern module_information server_module;
extern float g_client_width;
extern float g_client_height;
void DrawLine(Vec2& start, Vec2& end)
{
glLineWidth(1.2);
glBegin(GL_LINES);
glColor4f(255, 255, 255, 100);
glVertex2f(start.x, start.y);
glVertex2f(end.x, end.y);
glEnd();
}
void ShowMenu(GLFWwindow* Window)
{
glfwSetWindowAttrib(Window, GLFW_MOUSE_PASSTHROUGH, GLFW_FALSE);
}
void HideMenu(GLFWwindow* Window)
{
glfwSetWindowAttrib(Window, GLFW_MOUSE_PASSTHROUGH, GLFW_TRUE);
}
static void glfw_error_callback(int error, const char* description)
{
fprintf(stderr, "Glfw Error %d: %s\n", error, description);
}
void GetWindowSize()
{
HDC hdc = GetDC(nullptr);
g_client_width = GetDeviceCaps(hdc, DESKTOPHORZRES);
g_client_height = GetDeviceCaps(hdc, DESKTOPVERTRES);
ReleaseDC(nullptr, hdc);
}
int main(int, char**)
{
/////////////////////////功能性代码////////////////////////////////////////////////////////////////////////////////////////////
GetWindowSize();
init_address("csgo.exe");
UINT_PTR temp_address;
/////////////////////////功能性代码////////////////////////////////////////////////////////////////////////////////////////////
// Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
//###########################设置窗口###########################
auto glsl_version = "#version 130";
int Height = glfwGetVideoMode(monitor)->height;
int Width = glfwGetVideoMode(monitor)->width;
glfwWindowHint(GLFW_FLOATING, true);
glfwWindowHint(GLFW_RESIZABLE, false);
glfwWindowHint(GLFW_MAXIMIZED, true);
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, true);
//###########################设置窗口###########################
GLFWwindow* window = glfwCreateWindow(Width, Height, "titile", nullptr, nullptr);
if (window == nullptr)
return 1;
glfwSetWindowAttrib(window, GLFW_DECORATED, false); //设置没有标题栏
ShowWindow(GetConsoleWindow(), SW_HIDE);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
(void)io;
ImGui::StyleColorsDark();
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init(glsl_version);
bool bMenuVisible = true;
bool Dormant;
int EntityTeamNum;
int lifestate;
int blood;
int iTeamNum;
float temp_pos[3];
float Matrix[16];
Vec2 LineOrigin;
Vec2 ScreenCoord;
Vec3 EntityLocation;
LineOrigin.x = 0.0f;
LineOrigin.y = -1.0f;
UINT_PTR Entity;
while (!glfwWindowShouldClose(window))
{
glfwPollEvents();
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
if (GetAsyncKeyState(VK_F11) & 1)
{
bMenuVisible = !bMenuVisible;
if (bMenuVisible)
ShowMenu(window);
else
HideMenu(window);
}
//界面设计
if (bMenuVisible)
{
ImGui::Text("USE F11 TO Hiden/Show");
ImGui::Text("");
if (ImGui::Button("exit")) return 0;
}
ReadProcessMemory(g_process_handle, (LPVOID)(client_module.module_address + dwLocalPlayer),
&g_local_player, 4, nullptr);
if(g_local_player!=0)
{
ScreenCoord.x = 0.0f;
ScreenCoord.y = -1.0f;
g_angle_address = ReadMem<UINT_PTR>(g_process_handle, (engine_module.module_address + dwClientState), 4)+ dwClientState_ViewAngles;
ReadProcessMemory(g_process_handle, (LPCVOID)(client_module.module_address + dwViewMatrix), Matrix,
sizeof(float) * 16, nullptr);
for (short int i = 0; i < 64; ++i)
{
ReadProcessMemory(g_process_handle, (LPVOID)(client_module.module_address + dwLocalPlayer),
&g_local_player, 4, nullptr);
ReadProcessMemory(g_process_handle, (LPCVOID)(g_local_player + m_iTeamNum), &iTeamNum, 4, nullptr);
//获取敌人实体
ReadProcessMemory(g_process_handle, (LPCVOID)(client_module.module_address + dwEntityList + i * 0x10),
&Entity, sizeof(float), nullptr);
ReadProcessMemory(g_process_handle, (LPVOID)(Entity + m_bDormant), &Dormant, sizeof(bool), nullptr);
ReadProcessMemory(g_process_handle, (LPVOID)(Entity + m_lifeState), &lifestate, 4, nullptr);
ReadProcessMemory(g_process_handle, (LPCVOID)(Entity + m_iTeamNum), &EntityTeamNum, 4, nullptr);
ReadProcessMemory(g_process_handle, (LPCVOID)(Entity + m_iHealth), &blood, 4, nullptr);
if ((Entity == NULL) || (Entity == g_local_player) || (EntityTeamNum == iTeamNum) || (blood <= 0) ||
lifestate || Dormant)
continue;
ReadProcessMemory(g_process_handle, (LPVOID)(Entity + m_vecOrigin), &temp_pos, 12, nullptr);
EntityLocation.x = temp_pos[0], EntityLocation.y = temp_pos[1], EntityLocation.z = temp_pos[2];
if (!WorldToScreen(EntityLocation, ScreenCoord, Matrix))
continue;
if (true)
{
DrawLine(LineOrigin, ScreenCoord);
}
}
}
// Rendering
ImGui::Render();
int display_w, display_h;
glfwGetFramebufferSize(window, &display_w, &display_h);
glViewport(0, 0, display_w, display_h);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
glfwSwapBuffers(window);
}
// Cleanup
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
|