From 65ce24409cbb7a4da18751e5043978ded5090fac Mon Sep 17 00:00:00 2001 From: boris Date: Wed, 5 Dec 2018 18:11:08 +1300 Subject: im a retard double events still happen :| --- cheat/internal_rewrite/create_move.cpp | 12 ++-- cheat/internal_rewrite/extra.cpp | 57 ++++++++++------ cheat/internal_rewrite/extra.hpp | 13 +++- cheat/internal_rewrite/hooks.cpp | 6 +- cheat/internal_rewrite/hooks.hpp | 3 + cheat/internal_rewrite/internal_rewrite.vcxproj | 1 + .../internal_rewrite.vcxproj.filters | 3 + cheat/internal_rewrite/net_showfragments.cpp | 78 +++++++++++----------- cheat/internal_rewrite/packet_start.cpp | 12 ++-- cheat/internal_rewrite/process_packet.cpp | 39 +++++++++++ cheat/internal_rewrite/send_datagram.cpp | 15 +++-- cheat/internal_rewrite/ui.h | 2 +- 12 files changed, 161 insertions(+), 80 deletions(-) create mode 100644 cheat/internal_rewrite/process_packet.cpp (limited to 'cheat/internal_rewrite') diff --git a/cheat/internal_rewrite/create_move.cpp b/cheat/internal_rewrite/create_move.cpp index 54c393e..2d2d548 100644 --- a/cheat/internal_rewrite/create_move.cpp +++ b/cheat/internal_rewrite/create_move.cpp @@ -106,23 +106,21 @@ bool __fastcall hooks::create_move( void* ecx_, void* edx_, float input_sample_f else { int choked = cl->m_netchannel->m_nChokedPackets; //printf( "choked: %d\n", choked ); - + cl->m_netchannel->m_nChokedPackets = 0; - + int in_seq = cl->m_netchannel->m_nInSequenceNr; - + g_cheat.m_extra.add_latency( cl->m_netchannel ); send_datagram_o( cl->m_netchannel, 0, 0 ); - + cl->m_netchannel->m_nInSequenceNr = in_seq; - + cl->m_netchannel->m_nOutSequenceNr--; cl->m_netchannel->m_nChokedPackets = choked; } g_cheat.m_ragebot.m_antiaim->on_runcommand( ); - - } else { g_ctx.reset_shot_queue( ); diff --git a/cheat/internal_rewrite/extra.cpp b/cheat/internal_rewrite/extra.cpp index e95a840..07a8aaf 100644 --- a/cheat/internal_rewrite/extra.cpp +++ b/cheat/internal_rewrite/extra.cpp @@ -79,22 +79,51 @@ namespace features } void c_extra::update_netchannel( ) { + // fuck u bithc + auto *netchan = g_csgo.m_global_state->get_client_state()->m_netchannel; + + if (netchan->m_nInSequenceNr != m_last_sequence) { + m_last_sequence = netchan->m_nInSequenceNr; + + // emplace new record + netchan_record_t record{ + g_csgo.m_globals->m_realtime, + netchan->m_nInReliableState, + netchan->m_nInSequenceNr + }; + m_net_records.emplace_back(record); + } + + // clear outdated records + for (auto &it = m_net_records.begin(); it != m_net_records.end(); ++it) { + const float delta = g_csgo.m_globals->m_realtime - it->m_realtime; + // 200ms is the max we can fake anyway.. + // hnn this might be why it's so fucked :/ + if (delta > 0.4f) + m_net_records.erase(it); + } } void c_extra::add_latency( INetChannel* channel ) { - // todo @boris: - // replace this with sharklazer's method + auto nci = g_csgo.m_engine()->GetNetChannelInfo(); + float in_latency = nci->GetLatency(0); + + // amount of latency we want to achieve + float latency = 0.15f - (in_latency + g_csgo.m_globals->m_frametime) - TICK_INTERVAL(); if ( g_ctx.m_local && g_ctx.m_local->is_valid( ) ) { - - auto nci = g_csgo.m_engine( )->GetNetChannelInfo( ); - float in_latency = nci->GetLatency( 0 ); + // god this is autistic + for (auto &it = m_net_records.begin(); it != m_net_records.end(); ++it) { + const float delta = g_csgo.m_globals->m_realtime - it->m_realtime; - float latency = 0.15f - ( in_latency + g_csgo.m_globals->m_frametime ) - TICK_INTERVAL( ); + if (delta >= latency) { + // apply latency + channel->m_nInReliableState = it->m_reliable; + channel->m_nInSequenceNr = it->m_sequence; - if( g_settings.misc.net_fakelag && latency > 0.f ) { - channel->m_nInSequenceNr += 2 * 64 - ( 63 * latency ); + break; + } } } } @@ -122,12 +151,6 @@ namespace features // I am so, so, so, so sorry. void c_extra::money_talk( IGameEvent *evt ) { - static float last_time = 0.0f; - - if( !g_csgo.m_engine( )->IsConnected( ) || !g_csgo.m_engine( )->IsInGame( ) ) { - last_time = 0.0f; - } - if( !g_settings.misc.money_talk( ) ) return; @@ -135,11 +158,7 @@ namespace features const int player = g_csgo.m_engine( )->GetPlayerForUserID( evt->GetInt( xors( "attacker" ) ) ); if( player == g_csgo.m_engine( )->GetLocalPlayer( ) ) { - if( last_time <= g_csgo.m_globals->m_curtime ) { - g_csgo.m_engine( )->ClientCmd( xors( "say god i wish i had moneybot" ) ); - - last_time = g_csgo.m_globals->m_curtime + 0.1f; - } + g_csgo.m_engine( )->ClientCmd( xors( "say god i wish i had moneybot" ) ); } } } diff --git a/cheat/internal_rewrite/extra.hpp b/cheat/internal_rewrite/extra.hpp index 7f0ac98..5c7d5f4 100644 --- a/cheat/internal_rewrite/extra.hpp +++ b/cheat/internal_rewrite/extra.hpp @@ -7,6 +7,17 @@ namespace features class c_extra { bool m_fire_next{ }; + // i'm gay + struct netchan_record_t { + float m_realtime; + int32_t m_reliable; + int32_t m_sequence; + }; + + std::vector< netchan_record_t > m_net_records; + + int32_t m_last_sequence; + public: void rank_reveal( user_cmd_t* ucmd ); void thirdperson( ); @@ -36,6 +47,6 @@ namespace features private: using grenade_trace_t = std::vector< vec3_t >; - + }; } \ No newline at end of file diff --git a/cheat/internal_rewrite/hooks.cpp b/cheat/internal_rewrite/hooks.cpp index 685d7ea..d6e598c 100644 --- a/cheat/internal_rewrite/hooks.cpp +++ b/cheat/internal_rewrite/hooks.cpp @@ -34,6 +34,7 @@ namespace hooks { decltype( &convar_getint ) convar_getint_o; decltype( &packet_start ) packet_start_o; decltype(&emit_sound) emit_sound_o; + decltype(&process_packet) process_packet_o; } hooks::c_netvar_proxy hooks::lby_proxy; @@ -96,7 +97,10 @@ bool hooks::commit( factory::c_csgo* instance ) { end_lock_o = d->create_hook( &hooks::end_lock, instance->m_mdl_cache->get_old_function< void* >( 34 ) ); auto packet_start = pattern::first_code_match< void* >( instance->m_engine.dll( ), xors( "55 8B EC 8B 45 08 89 81 ? ? ? ? 8B 45 0C 89 81 ? ? ? ? 5D C2 08 00 ? ? ? ? ? ? ? 56" ) ); - packet_start_o = d->create_hook( &::hooks::packet_start, packet_start ); + packet_start_o = d->create_hook( &hooks::packet_start, packet_start ); + + auto process_packet = pattern::first_code_match< void * >(instance->m_engine.dll(), xors("55 8B EC 83 E4 C0 81 EC ? ? ? ? 53 56 57 8B 7D 08 8B D9")); + process_packet_o = d->create_hook(&hooks::process_packet, process_packet); auto update_clientside_anim = pattern::first_code_match< void* >( instance->m_chl.dll( ), xors( "55 8B EC 51 56 8B F1 80 BE ? ? ? ? ? 74 36" ) ); update_clientside_animation_o = d->create_hook( &hooks::update_clientside_animation, update_clientside_anim ); diff --git a/cheat/internal_rewrite/hooks.hpp b/cheat/internal_rewrite/hooks.hpp index dc23672..2304c08 100644 --- a/cheat/internal_rewrite/hooks.hpp +++ b/cheat/internal_rewrite/hooks.hpp @@ -103,6 +103,9 @@ namespace hooks void __fastcall packet_start( void* ecx, void* edx, int in_seq, int out_ack ); extern decltype( &packet_start ) packet_start_o; + + bool __fastcall process_packet(void *ecx, void *, void *packet, bool has_header); + extern decltype(&process_packet) process_packet_o; int __fastcall cl_csm_shadows_get_int( void* ecx_, void* edx_ ); int __fastcall debug_show_spread_get_int( void* ecx_, void* edx_ ); diff --git a/cheat/internal_rewrite/internal_rewrite.vcxproj b/cheat/internal_rewrite/internal_rewrite.vcxproj index 5381eb2..f75393b 100644 --- a/cheat/internal_rewrite/internal_rewrite.vcxproj +++ b/cheat/internal_rewrite/internal_rewrite.vcxproj @@ -438,6 +438,7 @@ + diff --git a/cheat/internal_rewrite/internal_rewrite.vcxproj.filters b/cheat/internal_rewrite/internal_rewrite.vcxproj.filters index a871845..0e555ea 100644 --- a/cheat/internal_rewrite/internal_rewrite.vcxproj.filters +++ b/cheat/internal_rewrite/internal_rewrite.vcxproj.filters @@ -268,6 +268,9 @@ hooks + + hooks + diff --git a/cheat/internal_rewrite/net_showfragments.cpp b/cheat/internal_rewrite/net_showfragments.cpp index 93e5db0..e2885c9 100644 --- a/cheat/internal_rewrite/net_showfragments.cpp +++ b/cheat/internal_rewrite/net_showfragments.cpp @@ -6,45 +6,45 @@ int __fastcall hooks::net_showfragments_get_int( void* ecx_, void* edx_ ) { static auto old_fn = g_csgo.m_netshowfragments->get_old_function< decltype( &net_showfragments_get_int ) >( 13 ); - static auto ret_checkreceivinglist = pattern::first_code_match( g_csgo.m_engine.dll( ), xors( "FF 50 34 8B 1D ? ? ? ? 85 C0 74 16 FF B6" ), 0x3 ); - static auto ret_readsubchanneldata = pattern::first_code_match( g_csgo.m_engine.dll( ), xors( "FF 50 34 85 C0 74 12 53 FF 75 0C" ), 0x3 ); - - static auto last_fragment = 0; - static auto last_time = 0.f; - - stack_t stack( get_baseptr( ) ); - auto cl = g_csgo.m_global_state->get_client_state( ); - auto nc = cl->m_netchannel; - - auto nci = g_csgo.m_engine( )->GetNetChannelInfo( ); - - if ( nci && ( nci->GetLatency( 1 ) > 0.06f ) && g_ctx.m_local ) { - if ( stack.return_address( ) == ret_readsubchanneldata ) { - auto e = ( uint32_t* ) ( nc ); - auto data = &e [ 0x54 ]; - - auto fragment = data [ 0x43 ]; - - if ( fragment == last_fragment ) { - float delta = GetTickCount( ) * 0.001f - last_time; - - if ( delta <= std::max( nci->GetLatency( 1 ), 0.3f ) ) { - ( ( uint32_t* ) data ) [ 0x42 ] = 0; - last_time = GetTickCount( ) * 0.001f; - } - } - } - - if ( stack.return_address( ) == ret_checkreceivinglist ) { - auto e = ( uint32_t* ) ( nc ); - auto data = &e [ 0x54 ]; - - auto fragment = data [ 0x43 ]; - - last_fragment = fragment; - last_time = GetTickCount( ) * 0.001f; - } - } + //static auto ret_checkreceivinglist = pattern::first_code_match( g_csgo.m_engine.dll( ), xors( "FF 50 34 8B 1D ? ? ? ? 85 C0 74 16 FF B6" ), 0x3 ); + //static auto ret_readsubchanneldata = pattern::first_code_match( g_csgo.m_engine.dll( ), xors( "FF 50 34 85 C0 74 12 53 FF 75 0C" ), 0x3 ); + // + //static auto last_fragment = 0; + //static auto last_time = 0.f; + // + //stack_t stack( get_baseptr( ) ); + //auto cl = g_csgo.m_global_state->get_client_state( ); + //auto nc = cl->m_netchannel; + // + //auto nci = g_csgo.m_engine( )->GetNetChannelInfo( ); + // + //if ( nci && ( nci->GetLatency( 1 ) > 0.06f ) && g_ctx.m_local ) { + // if ( stack.return_address( ) == ret_readsubchanneldata ) { + // auto e = ( uint32_t* ) ( nc ); + // auto data = &e [ 0x54 ]; + // + // auto fragment = data [ 0x43 ]; + // + // if ( fragment == last_fragment ) { + // float delta = GetTickCount( ) * 0.001f - last_time; + // + // if ( delta <= std::max( nci->GetLatency( 1 ), 0.3f ) ) { + // ( ( uint32_t* ) data ) [ 0x42 ] = 0; + // last_time = GetTickCount( ) * 0.001f; + // } + // } + // } + // + // if ( stack.return_address( ) == ret_checkreceivinglist ) { + // auto e = ( uint32_t* ) ( nc ); + // auto data = &e [ 0x54 ]; + // + // auto fragment = data [ 0x43 ]; + // + // last_fragment = fragment; + // last_time = GetTickCount( ) * 0.001f; + // } + //} return old_fn( ecx_, 0 ); } \ No newline at end of file diff --git a/cheat/internal_rewrite/packet_start.cpp b/cheat/internal_rewrite/packet_start.cpp index c24e722..ecc35f8 100644 --- a/cheat/internal_rewrite/packet_start.cpp +++ b/cheat/internal_rewrite/packet_start.cpp @@ -7,21 +7,21 @@ void __fastcall hooks::packet_start( void* ecx, void* edx, int in_seq, int out_a *( int* )( uintptr_t( ecx ) + 0x114 ) = in_seq; *( int* )( uintptr_t( ecx ) + 0x4cb4 ) = out_ack; } - + // okay now this is epic - //printf("%08x -> %08x\n", &hooks::packet_start, hooks::packet_start_o); - + // printf("%08x -> %08x\n", &hooks::packet_start, hooks::packet_start_o); + for( auto cmd_number = g_ctx.m_cmd_numbers.begin( ); cmd_number != g_ctx.m_cmd_numbers.end( ); ) { if( *cmd_number == out_ack ) { auto cl = ( uintptr_t )( ecx ); - + *( int* )( cl + 0x114 ) = in_seq; *( int* )( cl + 0x4cb4 ) = out_ack; - + g_ctx.m_cmd_numbers.erase( cmd_number ); return; } - + cmd_number++; } } \ No newline at end of file diff --git a/cheat/internal_rewrite/process_packet.cpp b/cheat/internal_rewrite/process_packet.cpp new file mode 100644 index 0000000..5188f4d --- /dev/null +++ b/cheat/internal_rewrite/process_packet.cpp @@ -0,0 +1,39 @@ +#include "hooks.hpp" + +bool __fastcall hooks::process_packet(void *ecx, void *, void *packet, bool has_header) { + bool result = process_packet_o(ecx, nullptr, packet, has_header); + + auto *cl = g_csgo.m_global_state->get_client_state(); + + if (!g_csgo.m_engine()->IsInGame() || !cl) + return result; + + // new events could be coming in + uint32_t v3 = *(uint32_t*)cl + 19948; + + if (!v3) + return result; + + for (; !!v3; ) { + float &v8 = *(float *)((uint32_t)v3 + 4); + + if (v8 > 0.0f) + v8 = 0.0f; + + uint32_t v11 = *(uint32_t *)((uint32_t)v3 + 56); + v3 = v11; + } + + printf("yea\n"); + + // CL_FireEvents will make sure the events are triggered instantly + // i honestly can't wait for you to call me a retard for this :DDDDDDDDDDDDD + // 55 8B EC 83 EC 08 53 8B 1D ? ? ? ? 56 57 83 BB ? ? ? ? ? 74 12 8D 8B ? ? ? ? E8 + static auto fire_events = pattern::first_code_match< void(*)() >( + g_csgo.m_engine.dll(), + xors("55 8B EC 83 EC 08 53 8B 1D ? ? ? ? 56 57 83 BB ? ? ? ? ? 74 12 8D 8B ? ? ? ? E8") + ); + fire_events(); + + return result; +} \ No newline at end of file diff --git a/cheat/internal_rewrite/send_datagram.cpp b/cheat/internal_rewrite/send_datagram.cpp index 7a86842..35053bc 100644 --- a/cheat/internal_rewrite/send_datagram.cpp +++ b/cheat/internal_rewrite/send_datagram.cpp @@ -4,6 +4,12 @@ #include "hooks.hpp" uintptr_t cl_sendmove = 0; + +// loopback:reliable state invalid (0). +// loopback:reliable state invalid (0). +// loopback:reliable state invalid (0). +// fucks up here: +// 68 ? ? ? ? FF 15 ? ? ? ? 83 C4 0C 83 C8 FF 5F 5E 5B 8B E5 5D C2 04 00 int __fastcall hooks::send_datagram( INetChannel* channel, void* edx_, void* datagram ) { if( g_csgo.m_panic || !g_settings.misc.net_fakelag || datagram ) { @@ -15,18 +21,15 @@ int __fastcall hooks::send_datagram( INetChannel* channel, void* edx_, void* dat return send_datagram_o( channel, 0, datagram ); } - // There is no need to restore the reliable state sequence since - // we are not fucking with reliable state with 'proper' fake latency. - int backup_sequence = channel->m_nInSequenceNr; + int backup_reliable = channel->m_nInReliableState; - g_cheat.m_extra.add_latency( channel ); - - auto nci = g_csgo.m_engine( )->GetNetChannelInfo( ); + //g_cheat.m_extra.add_latency( channel ); int ret = send_datagram_o( channel, 0, datagram ); channel->m_nInSequenceNr = backup_sequence; + channel->m_nInReliableState = backup_reliable; return ret; } \ No newline at end of file diff --git a/cheat/internal_rewrite/ui.h b/cheat/internal_rewrite/ui.h index 4232ef0..9a32603 100644 --- a/cheat/internal_rewrite/ui.h +++ b/cheat/internal_rewrite/ui.h @@ -37,7 +37,7 @@ namespace ui menu.reset( ); #ifndef _DEBUG - //date_str = g_header.username; + date_str = g_header.username; const auto username_hash = hash::fnv1a(g_header.username); -- cgit v1.2.3