diff options
| author | boris <wzn@moneybot.cc> | 2018-11-28 16:00:02 +1300 |
|---|---|---|
| committer | boris <wzn@moneybot.cc> | 2018-11-28 16:00:02 +1300 |
| commit | 3d412a4b30a9f7c7f51ea6562e694315948bd3da (patch) | |
| tree | 26d67dfd1f3e5fd12903ad13e85d0cb8bcf8f21c /tf2/directx.cpp | |
| parent | e4729e4393d90271a3814c7a79950a660c48325a (diff) | |
cleaned up
in short, the cheat and loader are now separate solutions. unused stuff was moved into the legacy solution in case anyone wants to compile it or whatever.
i can change this back if you want to. also, i configured the loader to compile in x64, and have separate build types for linux and win64
Diffstat (limited to 'tf2/directx.cpp')
| -rw-r--r-- | tf2/directx.cpp | 233 |
1 files changed, 0 insertions, 233 deletions
diff --git a/tf2/directx.cpp b/tf2/directx.cpp deleted file mode 100644 index db2d62f..0000000 --- a/tf2/directx.cpp +++ /dev/null @@ -1,233 +0,0 @@ -#include <chrono>
-
-#include "settings.h"
-#include "hooks.h"
-#include "ui.h"
-#include "base_cheat.h"
-#include "ctx.hpp"
-#include "mem.hpp"
-
-//this shit prolly barely working rn like a toddler trying to walk but hes actually mentally slow and 25
-
-using namespace d3d;
-
-float ui::get_tf2_frametime( ) {
- return cl.m_frametime;
-}
-
-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.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 ) {
- static auto draw_o = cl.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.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 = cl.m_d3d->get_old_function< decltype( &hooks::d3d::end_scene ) >( 42 );
- if( cl.m_panic ) return end_scene_o( device );
-
- static uintptr_t return_address = 0;
- static uintptr_t gameoverlay_return_address = 0;
-
- 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( !cl.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( );
-
- cl.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 = cl.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 str( xors( "moneybot | " ) );
- static bool transform = false;
- if( !transform ) {
- str += __DATE__;
- str += ", ";
- str += __TIME__;
-
- std::transform( str.begin( ), str.end( ), str.begin( ),
- [ ]( char c ) { return ::tolower( c ); } );
- transform = true;
- }
-
- 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 = cl.m_d3d->get_old_function< decltype( &hooks::d3d::reset ) >( 16 );
- if( cl.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;
-}
\ No newline at end of file |
