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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
#include <chrono>
#include <thread>
#include "settings.hpp"
#include "hooks.hpp"
#include "ui.h"
#include "base_cheat.hpp"
#include "context.hpp"
#include "mem.hpp"
using namespace d3d;
float ui::get_csgo_frametime( ) {
return g_csgo.m_frametime;
}
float ui::anim_time;
void on_d3d( IDirect3DDevice9* device ) {
constexpr float step = 1.0f / 2.f;
constexpr float fade_step = 1.0f / 7.f;
static float anim_time{ };
static bool flip{ };
static int anim_progress{ };
static bool sprites_init{ };
if( !sprites_init ) {
ui::setup_sprites( device );
sprites_init = true;
}
if( g_settings.misc.hide_from_obs )
g_cheat.m_visuals( );
if( g_settings.menu.open ) {
if( anim_time >= 0.95f ) {
flip = true;
}
if( anim_time <= 0.05f ) {
flip = false;
}
if( flip )
anim_time -= fade_step * ui::ui_get_frametime( );
else
anim_time += fade_step * ui::ui_get_frametime( );
anim_time = std::clamp( anim_time, 0.f, 1.0f );
ui::set_animtime( anim_time );
anim_progress += ui::ui_get_frametime( ) * step * 255;
anim_progress = std::clamp( anim_progress, 0, 50 );
g_d3d.draw_filled_rect( clr_t( 0, 0, 0, anim_progress ),
0, 0, g_d3d.m_width, g_d3d.m_height );
ui::render( );
}
else {
anim_progress = 0;
}
}
long __stdcall hooks::d3d::draw( IDirect3DDevice9* device, D3DPRIMITIVETYPE type, int v_index, uint32_t min_index, uint32_t num_vert, uint32_t start_index, uint32_t prim_count ) {
return 0;
/*static auto draw_o = g_csgo.m_d3d->get_old_function< decltype( &hooks::d3d::draw ) >( 82 );
static auto ret_addr = pattern::first_code_match( GetModuleHandleA( xors( "studiorender.dll" ) ), xors( "EB 1F FF 75 F0" ), -8 );
std::function< void*( void** ) > find_ent;
find_ent = [ & ]( void** ebp ) -> void* {
if( !ebp )
return nullptr;
void** next = *( void*** )( ebp );
if( ( uintptr_t )( ebp[ 1 ] ) == ret_addr )
return next[ 4 ];
return find_ent( next );
};
c_base_player* ent = ( c_base_player* )( find_ent( ( void** )( get_baseptr( ) ) ) );
if( g_ctx.m_local && !!ent && ent->m_iHealth( ) > 0 && ent->m_iTeamNum( ) > 1 && g_settings.visuals.chams.enabled( ) && g_settings.misc.hide_from_obs ) {
g_cheat.m_chams.d3d_render_chams( ent, type, v_index, min_index, num_vert, start_index, prim_count );
return true;
}
auto result = draw_o( device, type, v_index, min_index, num_vert, start_index, prim_count );
return result;*/
}
long __stdcall hooks::d3d::end_scene( IDirect3DDevice9* device ) {
static auto end_scene_o = g_csgo.m_d3d->get_old_function< decltype( &hooks::d3d::end_scene ) >( 42 );
if ( g_csgo.m_panic ) return end_scene_o( device );
static uintptr_t return_address = 0;
static uintptr_t gameoverlay_return_address = 0;
g_csgo.m_d3d_thread = std::this_thread::get_id( );
if( !return_address ) {
return_address = ( uintptr_t )( _ReturnAddress( ) );
}
if( !gameoverlay_return_address ) {
MEMORY_BASIC_INFORMATION info;
VirtualQuery( _ReturnAddress( ), &info, sizeof( MEMORY_BASIC_INFORMATION ) );
char mod[ MAX_PATH ];
GetModuleFileNameA( ( HMODULE )info.AllocationBase, mod, MAX_PATH );
if( strstr( mod, xors( "gameoverlay" ) ) )
gameoverlay_return_address = ( uintptr_t )( _ReturnAddress( ) );
}
if( return_address != ( uintptr_t )( _ReturnAddress( ) ) && !g_settings.misc.hide_from_obs )
return end_scene_o( device );
if( gameoverlay_return_address != ( uintptr_t )( _ReturnAddress( ) ) && g_settings.misc.hide_from_obs )
return end_scene_o( device );
if( !g_csgo.m_panic && g_d3d.run_frame( device ) ) {
for( auto& it : ::d3d::sprites )
it->begin( device );
g_d3d.begin( );
//if( g_settings.misc.hide_from_obs )
//g_cheat.m_chams.d3d_render_textures( );
on_d3d( device );
std::chrono::high_resolution_clock timer;
static auto last = timer.now( );
auto now = timer.now( );
std::chrono::duration< double > delta = now - last;
last = timer.now( );
g_csgo.m_frametime = delta.count( );
if( !g_con->m_logs.empty( ) && g_settings.menu.logs_enable ) {
auto& logs = g_con->m_logs;
float time = ( float )GetTickCount( ) * 0.001f;
auto data = logs.data( );
int cur_pos = 2;
for( int i = logs.size( ) - 1; i >= 0; --i ) {
if( cur_pos > g_d3d.m_height - 200 ) {
cur_pos -= 8;
break;
}
float delta = time - data[ i ].m_time;
if( delta >= 5.0f ) {
break;
}
clr_t col( 255, 255, 255 );
if( delta > 4.f ) col.a( ) *= ( 6.f - delta );
g_d3d.draw_text< ALIGN_RIGHT >( fonts.f_con, col, g_d3d.m_width - 5, cur_pos, D3DFONTFLAG_DROPSHADOW, data[ i ].m_msg );
cur_pos += 10;
}
}
if( g_settings.menu.open || g_con->m_open ) {
ui::ui_draw_cursor( );
}
for( auto& it : ::d3d::sprites )
it->end( );
g_d3d.end( );
}
return end_scene_o( device );
}
long __stdcall hooks::d3d::present( IDirect3DDevice9* device, RECT* source, RECT* dest, HWND wnd_override, RGNDATA* reg ) {
static auto present_o = g_csgo.m_d3d->get_old_function< decltype( &hooks::d3d::present ) >( 17 );
static uintptr_t return_address = 0;
if( !return_address ) {
return_address = ( uintptr_t )( _ReturnAddress( ) );
}
if( return_address && return_address != ( uintptr_t )( _ReturnAddress( ) ) )
return present_o( device, source, dest, wnd_override, reg );
if( g_d3d.run_frame( device ) ) {
g_d3d.begin( );
if( g_settings.misc.watermark ) {
static std::string date;
std::string str;
static bool transformed = false;
if( !transformed ) {
date += __DATE__;
std::transform( date.begin( ), date.end( ), date.begin( ),
[ ]( char c ) { return ::tolower( c ); } );
transformed = true;
}
str = xors( "moneybot | " );
auto nci = g_csgo.m_engine( )->GetNetChannelInfo( );
if( nci ) {
char latency_str[ 32 ];
strenc::w_sprintf_s( latency_str, 32, xors( "lt: %1.2f + %1.2f | " ), nci->GetLatency( 0 ), nci->GetLatency( 1 ) );
str += latency_str;
}
else {
str += xors( "unconnected | " );
}
str += date;
g_d3d.draw_text< ALIGN_RIGHT >( ::d3d::fonts.f_menu,
ui::ui_get_text_col( ), g_d3d.m_width - 10, 8,
D3DFONTFLAG_DROPSHADOW, str.c_str( ) );
}
g_con->draw( );
if( ( g_settings.menu.open || g_con->m_open ) && !g_settings.misc.hide_from_obs ) {
ui::ui_draw_cursor( );
}
g_d3d.end( );
}
return present_o( device, source, dest, wnd_override, reg );
}
long __stdcall hooks::d3d::reset( IDirect3DDevice9* device, D3DPRESENT_PARAMETERS* params ) {
static auto reset_o = g_csgo.m_d3d->get_old_function< decltype( &hooks::d3d::reset ) >( 16 );
if ( g_csgo.m_panic ) {
return reset_o( device, params );
}
for( auto& sprite : ::d3d::sprites )
sprite->on_reset( );
g_d3d.on_device_lost( );
long result = reset_o( device, params );
g_d3d.on_device_reset( );
for( auto& sprite : ::d3d::sprites )
sprite->on_reset_end( );
return result;
}
|