diff options
| author | JustSomePwner <crotchyalt@gmail.com> | 2018-08-30 14:01:54 +0200 |
|---|---|---|
| committer | JustSomePwner <crotchyalt@gmail.com> | 2018-08-30 14:01:54 +0200 |
| commit | 7ccb819f867493f8ec202ea3b39c94c198c64584 (patch) | |
| tree | 94622e61af0ff359e3d6689cf274d74f60b2492a /internal_rewrite/net_showfragments.cpp | |
| parent | 564d979b79e8a5aaa5014eba0ecd36c61575934f (diff) | |
first
Diffstat (limited to 'internal_rewrite/net_showfragments.cpp')
| -rw-r--r-- | internal_rewrite/net_showfragments.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/internal_rewrite/net_showfragments.cpp b/internal_rewrite/net_showfragments.cpp new file mode 100644 index 0000000..60ddbc9 --- /dev/null +++ b/internal_rewrite/net_showfragments.cpp @@ -0,0 +1,50 @@ +#include "hooks.hpp"
+#include "mem.hpp"
+#include "context.hpp"
+
+// Index 13 is GetBool, GetInt and GetFloat are inlined by default.
+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 && ( ( g_settings.misc.net_fakeping_amount( ) && g_settings.misc.net_fakeping_active ) || 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 |
