forked from BloodSharp/sxe-base-v8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
snapshot.cpp
70 lines (62 loc) · 1.65 KB
/
snapshot.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
#include "client.h"
bool ScreenFirst = true, bAntiSSTemp = true, DrawVisuals, FirstFrame = true;
PBYTE BufferScreen;
int temp;
DWORD dwSize, time_scr;
void __stdcall m_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
{
if (ScreenFirst || !cvar.misc_snapshot)
{
dwSize = (width * height) * 3;
BufferScreen = (PBYTE)malloc(dwSize);
gl_ReadPixels(x, y, width, height, format, type, pixels);
__try
{
memcpy(BufferScreen, pixels, dwSize);
}
__except (EXCEPTION_EXECUTE_HANDLER) {};
DrawVisuals = true;
ScreenFirst = false;
return;
}
__try
{
memcpy(pixels, BufferScreen, dwSize);
}
__except (EXCEPTION_EXECUTE_HANDLER) {};
}
void Snapshot()
{
if (cvar.misc_snapshot)
{
if (bAntiSSTemp)
{
time_scr = GetTickCount();
temp = 0;
bAntiSSTemp = false;
}
if (GetTickCount() - time_scr > cvar.misc_snapshot_time * 1000)
{
DrawVisuals = false;
temp++;
if (temp > 10)
{
bAntiSSTemp = true;
ScreenFirst = true;
DWORD sz = ImGui::GetIO().DisplaySize.x * ImGui::GetIO().DisplaySize.y * 3;
free((PBYTE)BufferScreen);
PBYTE buf = (PBYTE)malloc(sz);
glReadPixels(0, 0, ImGui::GetIO().DisplaySize.x, ImGui::GetIO().DisplaySize.y, GL_RGB, GL_UNSIGNED_BYTE, buf);
free((PBYTE)buf);
}
}
}
if (FirstFrame)
{
DWORD sz = ImGui::GetIO().DisplaySize.x * ImGui::GetIO().DisplaySize.y * 3;
PBYTE buf = (PBYTE)malloc(sz);
glReadPixels(0, 0, ImGui::GetIO().DisplaySize.x, ImGui::GetIO().DisplaySize.y, GL_RGB, GL_UNSIGNED_BYTE, buf);
free((PBYTE)buf);
FirstFrame = false;
}
}